Description Public fields Methods Examples
Simulation object to run the model and store data across multiple simulations.
envCurrent environment
(Environment R6 class object)
agentCurrent agent
(Agent R6 class object)
current_stateCurrent environment state.
current_actionCurrent action from agent.
simulation_numberSimulation Number.
end_timeTime when the simulation should end.
resultsResults of current simulation (list of vectors).
results_all_simulationsResults of all simulations (list of list of vectors).
verboseLog verbosity.
timestepCurrent time step.
sim_startedTRUE is the simulation has started,
FALSE otherwise.
new()Environment subclass representing a COVID19 outbreak as defined in the COVID19-IBM model
Simulation$new(env, agent = Agent$new(), end_time = NULL, verbose = FALSE)
envInstance of Environment R6Class
agentInstance of Agent R6Class
end_timeEnd time for the simulation
verboseLog verbosity.
start_simulation()Initialisation of the simulation; reset the model
Simulation$start_simulation()
end_simulation()End the simulation
Simulation$end_simulation()
steps()Run the model for a specific number of steps, starting from the current state, save data as model progresses.
Simulation$steps(n_steps)
n_stepsNumber of steps for which to call
self$model.one_time_step()
collect_results()Collect model results at each step; fixme action is not currently stored
Simulation$collect_results(state, action)
stateThe state to collect results from.
actionCurrently unused.
is_terminal_state()Get terminal state.
Simulation$is_terminal_state()
Is the current state the terminal state
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # Create a model using the baseline parameters included in the package.
# Note: This initialisation can take a few seconds.
model <- Model.new( params = list( n_total = 10000 ) )
if (!is.null(model)) {
# Begin simulation:
env <- COVID19IBM$new( model )
sim <- Simulation$new( env )
sim$start_simulation()
sim$steps(1) # Note: slow operation (takes a few seconds).
# Make changes to the model (environment)
model$seed_infect_by_idx(0)
# Resume simulation
sim$steps(1) # Note: slow operation (takes a few seconds).
# Get results
sim$results
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.