Health-GPS 3.0.0.0
Global Health Policy Simulation model (Health-GPS)
Loading...
Searching...
No Matches
hgps::Simulation Class Reference

Defines the simulation engine data type class. More...

#include <simulation.h>

Inheritance diagram for hgps::Simulation:
[legend]
Collaboration diagram for hgps::Simulation:
[legend]

Public Member Functions

 Simulation ()=delete
 
 Simulation (SimulationModuleFactory &factory, std::shared_ptr< const EventAggregator > bus, std::shared_ptr< const ModelInput > inputs, std::unique_ptr< Scenario > scenario)
 Initialises a new instance of the Simulation class.
 
virtual ~Simulation ()=default
 Destroys a simulation instance.
 
adevs::Time init (adevs::SimEnv< int > *env) override
 Called when the model is added to the simulation executive.
 
adevs::Time update (adevs::SimEnv< int > *env) override
 Called to assign a new state to the model at current time.
 
adevs::Time update (adevs::SimEnv< int > *env, std::vector< int > &x) override
 Called to assign a new state to the model at current time, when input is present.
 
void fini (adevs::Time clock) override
 Called after the model has been removed from the simulation executive.
 
void setup_run (unsigned int run_number, unsigned int seed) noexcept
 Set up a new simulation run.
 
ScenarioType type () noexcept
 Gets the simulation type.
 
std::string name () override
 Gets the simulation name.
 

Detailed Description

Defines the simulation engine data type class.

The simulation engine holds the modules instances and run-time context, manages the simulation clock and core algorithm sequencing.

Health-GPS uses a simpler version of adevs (A Discrete EVent System simulator) library (https://sourceforge.net/projects/bdevs), which contain only four header files, but provides an intuitive modelling interface for agent-based models, without requiring familiarity with the full aspects of the DEVS formalism.

Constructor & Destructor Documentation

◆ Simulation() [1/2]

hgps::Simulation::Simulation ( )
delete

◆ Simulation() [2/2]

hgps::Simulation::Simulation ( SimulationModuleFactory factory,
std::shared_ptr< const EventAggregator bus,
std::shared_ptr< const ModelInput inputs,
std::unique_ptr< Scenario scenario 
)
explicit

Initialises a new instance of the Simulation class.

Parameters
factoryThe simulation modules factory instance
busThe message bus instance to use
inputsThe simulation model inputs
scenarioThe scenario to simulate
Here is the call graph for this function:

◆ ~Simulation()

virtual hgps::Simulation::~Simulation ( )
virtualdefault

Destroys a simulation instance.

Member Function Documentation

◆ fini()

void hgps::Simulation::fini ( adevs::Time  clock)
override

Called after the model has been removed from the simulation executive.

Parameters
clockThe time at which the model no longer exists.
Here is the call graph for this function:

◆ init()

adevs::Time hgps::Simulation::init ( adevs::SimEnv< int > *  env)
override

Called when the model is added to the simulation executive.

Parameters
envThe simulation executive environment
Returns
The time of the next event
Here is the call graph for this function:

◆ name()

std::string hgps::Simulation::name ( )
inlineoverride

Gets the simulation name.

Returns
The intervention scenario name
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setup_run()

void hgps::Simulation::setup_run ( unsigned int  run_number,
unsigned int  seed 
)
noexcept

Set up a new simulation run.

Parameters
run_numberThe run number
run_seedThe custom seed for random number generation

◆ type()

ScenarioType hgps::Simulation::type ( )
inlinenoexcept

Gets the simulation type.

Returns
The intervention scenario type enumeration
Here is the call graph for this function:

◆ update() [1/2]

adevs::Time hgps::Simulation::update ( adevs::SimEnv< int > *  env)
override

Called to assign a new state to the model at current time.

Parameters
envThe simulation executive environment
Returns
The time of the next call to update.
Here is the call graph for this function:

◆ update() [2/2]

adevs::Time hgps::Simulation::update ( adevs::SimEnv< int > *  env,
std::vector< int > &  x 
)
override

Called to assign a new state to the model at current time, when input is present.

This is not used with Health-GPS, the individuals are independent and nobody sends messages. If needed by future scenarios, e.g., agent-based models, the input was generated in the previous simulation instant and so this calculates the new state using state information from the previous instant.

Parameters
envThe simulation executive environment
xMessages sent to the model.
Returns
The time of the next call to update.

The documentation for this class was generated from the following files: