1 #ifndef POPULATIONALGORITHMADVANCED_H
3 #define POPULATIONALGORITHMADVANCED_H
14 #include "personaleventlist.h"
93 bool isParallel()
const {
return m_parallel; }
94 bool_t run(
double &tMax, int64_t &maxEvents,
double startTime = 0);
108 bool_t initEventTimes()
const;
110 void advanceEventTimes(
EventBase *pScheduledEvent,
double dt);
111 void onAboutToFire(
EventBase *pEvt) {
if (m_pOnAboutToFire) m_pOnAboutToFire->
onAboutToFire(static_cast<PopulationEvent *>(pEvt)); }
112 PopulationEvent *getEarliestEvent(
const std::vector<PersonBase *> &people);
113 PersonalEventList *personalEventList(
PersonBase *pPerson);
118 #ifdef ALGORITHM_SHOW_EVENTS
120 #endif // ALGORITHM_SHOW_EVENTS
121 void onAlgorithmLoop(
bool finished);
123 int64_t getNextEventID();
125 #ifndef DISABLEOPENMP
126 Mutex m_eventsToRemoveMutex;
127 #endif // !DISABLEOPENMP
128 std::vector<EventBase *> m_eventsToRemove;
133 int64_t m_nextEventID;
134 #ifndef DISABLEOPENMP
135 Mutex m_nextEventIDMutex;
136 #endif // !DISABLEOPENMP
138 std::vector<PopulationEvent *> m_tmpEarliestEvents;
139 std::vector<double> m_tmpEarliestTimes;
141 #ifndef DISABLEOPENMP
142 mutable std::vector<Mutex> m_eventMutexes;
143 #endif // !DISABLEOPENMP
148 inline int64_t PopulationAlgorithmAdvanced::getNextEventID()
150 #ifndef DISABLEOPENMP
152 m_nextEventIDMutex.lock();
153 #endif // !DISABLEOPENMP
155 int64_t
id = m_nextEventID++;
157 #ifndef DISABLEOPENMP
159 m_nextEventIDMutex.unlock();
160 #endif // !DISABLEOPENMP
165 inline PersonalEventList *PopulationAlgorithmAdvanced::personalEventList(
PersonBase *pPerson)
168 PersonalEventList *pEvtList =
static_cast<PersonalEventList *
>(pPerson->
getAlgorithmInfo());
173 #endif // POPULATIONALGORITHMADVANCED_H
Type to return true/false with error description.
Definition: booltype.h:25
virtual void onAboutToFire(PopulationEvent *pEvt)=0
If set using PopulationAlgorithmInterface::setAboutToFireAction, this function will be called right b...
This class provides functions for a population-based simulation using the modified Next Reaction Meth...
Definition: populationalgorithmadvanced.h:82
void setAboutToFireAction(PopulationAlgorithmAboutToFireInterface *pAction)
Allows you to set the action that needs to be performed before firing an event dynamically.
Definition: populationalgorithmadvanced.h:106
PopulationAlgorithmAdvanced(PopulationStateAdvanced &state, GslRandomNumberGenerator &rng, bool parallel)
Constructor of the class, indicating if a parallel version should be used, which random number genera...
Definition: populationalgorithmadvanced.cpp:28
double getTime() const
Must return the simulation tilme of the algorithm.
Definition: populationalgorithmadvanced.h:103
bool_t init()
Abstract function to initialize the implementation used.
Definition: populationalgorithmadvanced.cpp:41
GslRandomNumberGenerator * getRandomNumberGenerator() const
Must return the random number generator used by the algorithm.
Definition: populationalgorithmadvanced.h:104
This class allows you to generate random numbers, and uses the GNU Scientific Library for this...
Definition: gslrandomnumbergenerator.h:16
double getTime() const
This function returns the current time of the simulation.
Definition: algorithm.h:142
GslRandomNumberGenerator * getRandomNumberGenerator() const
Returns the random number generator that was specified in the constructor.
Definition: algorithm.h:145
This class contains the core algorithm (as shown on the main page of the documentation) to execute th...
Definition: algorithm.h:68
This is the base class for events in population-based simulations.
Definition: populationevent.h:63
An interface to allow a member function PopulationAlgorithmAboutToFireInterface::onAboutToFire to be ...
Definition: populationinterfaces.h:89
This is the base class for a person in a population-based simulation.
Definition: personbase.h:23
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...
Definition: populationalgorithmadvanced.cpp:83
Population state to be used when simulating with the population based algorithm in PopulationAlgorith...
Definition: populationstateadvanced.h:22
void onNewEvent(PopulationEvent *pEvt)
When a new event has been created, it must be injected into the simulation using this function...
Definition: populationalgorithmadvanced.cpp:416
This is the base class for events in the mNRM algorithm.
Definition: eventbase.h:55
PersonAlgorithmInfo * getAlgorithmInfo() const
Returns what was stored using PersonBase::PersonAlgorithmInfo.
Definition: personbase.h:77
An interface for a population based mNRM algorithm.
Definition: populationinterfaces.h:101