Simpact Cyan
Population based event driven simulation using mNRM
|
This class provides functions for a population-based simulation using the modified Next Reaction Method (mNRM). More...
#include <populationalgorithmsimple.h>
Public Member Functions | |
PopulationAlgorithmSimple (PopulationStateSimple &state, GslRandomNumberGenerator &rng, bool parallel) | |
Constructor of the class, indicating if a parallel version should be used, which random number generator should be used and which simulation state. More... | |
bool_t | init () |
Abstract function to initialize the implementation used. More... | |
bool_t | run (double &tMax, int64_t &maxEvents, double startTime=0) |
This should be called to actually start the simulation, do not call Algorithm::evolve for this. More... | |
void | onNewEvent (PopulationEvent *pEvt) |
When a new event has been created, it must be injected into the simulation using this function. More... | |
double | getTime () const |
Must return the simulation tilme of the algorithm. More... | |
void | setAboutToFireAction (PopulationAlgorithmAboutToFireInterface *pAction) |
Allows you to set the action that needs to be performed before firing an event dynamically. More... | |
GslRandomNumberGenerator * | getRandomNumberGenerator () const |
Must return the random number generator used by the algorithm. More... | |
Public Member Functions inherited from SimpleAlgorithm | |
SimpleAlgorithm (State &state, GslRandomNumberGenerator &rng, bool parallel) | |
Constructor of this class, specifying whether a parallel version should be used to speed things up a bit, specifying the random number generator as well as the simulation state to use. More... | |
Public Member Functions inherited from Algorithm | |
Algorithm (State &state, GslRandomNumberGenerator &rng) | |
Constructor of the class, to which the simulation state must be specified as well as the random number generator to be used internally. More... | |
bool_t | evolve (double &tMax, int64_t &maxEvents, double startTime=0, bool initEvents=true) |
This advances the simulation state specified in the constructor using the core mNRM. More... | |
double | getTime () const |
This function returns the current time of the simulation. More... | |
GslRandomNumberGenerator * | getRandomNumberGenerator () const |
Returns the random number generator that was specified in the constructor. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from Algorithm | |
State * | getState () const |
Returns the simulation state instance that was specified in the constructor. More... | |
This class provides functions for a population-based simulation using the modified Next Reaction Method (mNRM).
Being population-based, the state of the simulation mostly consists of the (living) people.
In this implementation, the very straightforward algorithm provided by the SimpleState class is used, making sure that all event times are recalculated after an event got fired. While being a slow algorithm, it can be useful to compare the results from PopulationAlgorithmAdvanced to, to make sure the advanced implementation yields the correct results.
Before calling PopulationAlgorithmInterface::run, you'll need to introduce initial events (see PopulationAlgorithmInterface::onNewEvent) and most likely also an initial set of persons in the simulation state you're using (see PopulationStateInterface::addNewPerson). The actual state that needs to be used in this implementation, is defined in PopulationStateSimple.
Events for this type of simulation should derive from the PopulationEvent class instead of using the EventBase base class directly.
PopulationAlgorithmSimple::PopulationAlgorithmSimple | ( | PopulationStateSimple & | state, |
GslRandomNumberGenerator & | rng, | ||
bool | parallel | ||
) |
Constructor of the class, indicating if a parallel version should be used, which random number generator should be used and which simulation state.
|
inlinevirtual |
Must return the random number generator used by the algorithm.
Implements PopulationAlgorithmInterface.
|
inlinevirtual |
Must return the simulation tilme of the algorithm.
Implements PopulationAlgorithmInterface.
|
virtual |
Abstract function to initialize the implementation used.
Implements PopulationAlgorithmInterface.
|
virtual |
When a new event has been created, it must be injected into the simulation using this function.
Implements PopulationAlgorithmInterface.
|
virtual |
This should be called to actually start the simulation, do not call Algorithm::evolve for this.
tMax | Stop the simulation if the simulation time exceeds the specified time. Upon completion of the function, this variable will contain the actual simulation time stopped. |
maxEvents | If positive, the simulation will stop if this many events have been executed. Set to a negative value to disable this limit. At the end of the simulation, this variable will contain the number of events executed. |
startTime | The start time of the simulation, can be used to continue where a previous call to this function left off. |
Implements PopulationAlgorithmInterface.
|
inlinevirtual |
Allows you to set the action that needs to be performed before firing an event dynamically.
When implementing a new population based algorithm you must make sure that this way the action performed by Algorithm::onAboutToFire can be changed at run time.
Implements PopulationAlgorithmInterface.