Simpact Cyan
Population based event driven simulation using mNRM
populationinterfaces.h
Go to the documentation of this file.
1 #ifndef POPULATIONINTERFACES_H
2 
3 #define POPULATIONINTERFACES_H
4 
9 #include "algorithm.h"
10 #include "booltype.h"
11 
12 class PersonBase;
13 class PopulationEvent;
14 
18 {
19 public:
21  virtual ~PopulationStateExtra() { }
22 };
23 
27 {
28 public:
29  PopulationStateInterface() { m_pExtraState = 0; }
31 
34  virtual PersonBase **getAllPeople() = 0;
35 
37  virtual PersonBase **getMen() = 0;
38 
40  virtual PersonBase **getWomen() = 0;
41 
44  virtual PersonBase **getDeceasedPeople() = 0;
45 
47  virtual int getNumberOfPeople() const = 0;
48 
50  virtual int getNumberOfMen() const = 0;
51 
53  virtual int getNumberOfWomen() const = 0;
54 
56  virtual int getNumberOfDeceasedPeople() const = 0;
57 
62  virtual void addNewPerson(PersonBase *pPerson) = 0;
63 
68  virtual void setPersonDied(PersonBase *pPerson) = 0;
69 
73  virtual void markAffectedPerson(PersonBase *pPerson) const = 0;
74 
78  void setExtraStateInfo(PopulationStateExtra *pExtra) { m_pExtraState = pExtra; }
79 
82  PopulationStateExtra *getExtraStateInfo() const { return m_pExtraState; }
83 private:
84  PopulationStateExtra *m_pExtraState;
85 };
86 
90 {
91 public:
94 
97  virtual void onAboutToFire(PopulationEvent *pEvt) = 0;
98 };
99 
102 {
103 public:
105  virtual ~PopulationAlgorithmInterface() { }
106 
108  virtual bool_t init() = 0;
109 
121  virtual bool_t run(double &tMax, int64_t &maxEvents, double startTime = 0) = 0;
122 
130 
133  virtual void onNewEvent(PopulationEvent *pEvt) = 0;
134 
136  virtual double getTime() const = 0;
137 
140 };
141 
145 {
146 public:
147  PersonAlgorithmInfo() { }
148  virtual ~PersonAlgorithmInfo() { }
149 };
150 
151 #endif // POPULATIONINTERFACES_H
This class allows you to generate random numbers, and uses the GNU Scientific Library for this.
Definition: gslrandomnumbergenerator.h:17
Base class to be able to store algorithm-specific information in the PersonBase object for a person i...
Definition: populationinterfaces.h:145
This is the base class for a person in a population-based simulation.
Definition: personbase.h:24
An interface to allow a member function PopulationAlgorithmAboutToFireInterface::onAboutToFire to be ...
Definition: populationinterfaces.h:90
virtual void onAboutToFire(PopulationEvent *pEvt)=0
If set using PopulationAlgorithmInterface::setAboutToFireAction, this function will be called right b...
An interface for a population based mNRM algorithm.
Definition: populationinterfaces.h:102
virtual bool_t run(double &tMax, int64_t &maxEvents, double startTime=0)=0
This should be called to actually start the simulation, do not call Algorithm::evolve for this.
virtual void onNewEvent(PopulationEvent *pEvt)=0
When a new event has been created, it must be injected into the simulation using this function.
virtual double getTime() const =0
Must return the simulation tilme of the algorithm.
virtual GslRandomNumberGenerator * getRandomNumberGenerator() const =0
Must return the random number generator used by the algorithm.
virtual void setAboutToFireAction(PopulationAlgorithmAboutToFireInterface *pAction)=0
Allows you to set the action that needs to be performed before firing an event dynamically.
virtual bool_t init()=0
Abstract function to initialize the implementation used.
This is the base class for events in population-based simulations.
Definition: populationevent.h:64
Base class to allow some extra information to be stored in each state that implements PopulationState...
Definition: populationinterfaces.h:18
Interface for a simulation state for the population-based algorithm, specifying member functions that...
Definition: populationinterfaces.h:27
virtual int getNumberOfDeceasedPeople() const =0
Returns the number of people in the array returned by PopulationStateInterface::getDeceasedPeople.
virtual int getNumberOfPeople() const =0
Returns the number of people in the array returned by PopulationStateInterface::getAllPeople.
virtual void addNewPerson(PersonBase *pPerson)=0
When a new person is introduced into the population, this function must be used to tell the simulatio...
virtual PersonBase ** getAllPeople()=0
Returns a list to the current living members in the population, introduced into the simulation using ...
void setExtraStateInfo(PopulationStateExtra *pExtra)
This allows you to store additional information for a state that implements this PopulationStateInter...
Definition: populationinterfaces.h:78
virtual void setPersonDied(PersonBase *pPerson)=0
When a person has died, this function must be called to inform the simulation about this.
virtual PersonBase ** getMen()=0
Same as PopulationStateInterface::getAllPeople, but only the men are returned.
virtual void markAffectedPerson(PersonBase *pPerson) const =0
This should only be called from within the PopulationEvent::markOtherAffectedPeople function,...
virtual PersonBase ** getWomen()=0
Same as PopulationStateInterface::getAllPeople, but only the women are returned.
virtual int getNumberOfWomen() const =0
Returns the number of people in the array returned by PopulationStateInterface::getWomen.
PopulationStateExtra * getExtraStateInfo() const
Retrieves the PopulationStateExtra instance that was stored using PopulationStateInterface::setExtraS...
Definition: populationinterfaces.h:82
virtual PersonBase ** getDeceasedPeople()=0
Returns the people who were part of the simulation but who are now deceased (intended for result anal...
virtual int getNumberOfMen() const =0
Returns the number of people in the array returned by PopulationStateInterface::getMen.
This is a base class describing the simulation state of an mNRM algorithm.
Definition: algorithm.h:24
Type to return true/false with error description.
Definition: booltype.h:26