Simpact Cyan
Population based event driven simulation using mNRM
state.h
Go to the documentation of this file.
1 #ifndef STATE_H
2 
3 #define STATE_H
4 
9 #include "errut/errorbase.h"
10 #include <stdint.h>
11 #include <vector>
12 
13 //#define STATE_SHOW_EVENTS
14 
16 class EventBase;
17 
40 class State : public errut::ErrorBase
41 {
42 public:
46  ~State();
47 
111  bool evolve(double &tMax, int64_t &maxEvents, double startTime = 0, bool initEvents = true);
112 
114  double getTime() const { return m_time; }
115 
117  GslRandomNumberGenerator *getRandomNumberGenerator() const { return m_pRndGen; }
118 protected:
121  virtual bool initEventTimes() const;
122 
125  virtual EventBase *getNextScheduledEvent(double &dt);
126 
129  virtual void advanceEventTimes(EventBase *pScheduledEvent, double dt);
130 
132  virtual void onAboutToFire(EventBase *pEvt) { }
133 
135  virtual void onFiredEvent(EventBase *pEvt) { }
136 
139  virtual void onAlgorithmLoop(bool finished) { }
140 private:
141  mutable GslRandomNumberGenerator *m_pRndGen;
142  double m_time;
143 };
144 
145 #endif // STATE_H
146 
GslRandomNumberGenerator * getRandomNumberGenerator() const
Returns the random number generator that was specified in the constructor.
Definition: state.h:117
This class both describes the simulation state and contains the core algorithm (as shown on the main ...
Definition: state.h:40
virtual void onFiredEvent(EventBase *pEvt)
Called after pEvt is fired.
Definition: state.h:135
Base class which allows an error message to be set.
Definition: errorbase.h:49
virtual bool initEventTimes() const
Generate the internal times for the events present in the algorithm (called by State::evolve dependin...
Definition: state.cpp:87
virtual void onAboutToFire(EventBase *pEvt)
Called right before pEvt is fired.
Definition: state.h:132
double getTime() const
This function returns the current time of the simulation.
Definition: state.h:114
virtual EventBase * getNextScheduledEvent(double &dt)
Return the next event to be fired and store the real world time that will have passed until it fires ...
Definition: state.cpp:93
This class allows you to generate random numbers, and uses the GNU Scientific Library for this...
Definition: gslrandomnumbergenerator.h:16
virtual void onAlgorithmLoop(bool finished)
Called at the end of each algorithm loop, with finished set to true if the loop will be exited...
Definition: state.h:139
State(GslRandomNumberGenerator *pRng)
Constructor of the class, to which the random number generator to be used internally must be specifie...
Definition: state.cpp:9
virtual void advanceEventTimes(EventBase *pScheduledEvent, double dt)
Advance the times of the necessary events to the time when dt has passed, ignoring pScheduledEvent si...
Definition: state.cpp:99
This is the base class for events in the mNRM algorithm.
Definition: eventbase.h:62
bool evolve(double &tMax, int64_t &maxEvents, double startTime=0, bool initEvents=true)
This advances the simulation state using the core mNRM.
Definition: state.cpp:23