Simpact Cyan
Population based event driven simulation using mNRM
simpactpopulation.h
1 #ifndef SIMPACTPOPULATION_H
2 
3 #define SIMPACTPOPULATION_H
4 
5 #include "population.h"
6 #include <assert.h>
7 
9 class Person;
10 class Man;
11 class Woman;
12 
13 class SimpactPopulationConfig : public errut::ErrorBase
14 {
15 public:
16  SimpactPopulationConfig();
17  ~SimpactPopulationConfig();
18 
19  void setInitialMen(int number) { m_initialMen = number; }
20  void setInitialWomen(int number) { m_initialWomen = number; }
21  void setInitialInfectionFraction(double f) { m_initialInfectionFraction = f; }
22 
23  int getInitialMen() const { return m_initialMen; }
24  int getInitialWomen() const { return m_initialWomen; }
25  double getInitialInfectionFraction() const { return m_initialInfectionFraction; }
26 private:
27  int m_initialMen, m_initialWomen;
28  double m_initialInfectionFraction;
29 };
30 
31 class SimpactPopulation : public Population
32 {
33 public:
34  SimpactPopulation(bool parallel, GslRandomNumberGenerator *pRng);
35  ~SimpactPopulation();
36 
37  bool init(const SimpactPopulationConfig &popConfig, const PopulationDistribution &popDist);
38 
39  Person **getAllPeople() { return reinterpret_cast<Person**>(Population::getAllPeople()); }
40  Man **getMen() { return reinterpret_cast<Man**>(Population::getMen()); }
41  Woman **getWomen() { return reinterpret_cast<Woman**>(Population::getWomen()); }
42 
43  int getInitialPopulationSize() const { return m_initialPopulationSize; }
44  double getDebutAge() const { return 15.0; }
45  double getAcuteStageTime() const { return 3.0/12.0; } // three months
46 protected:
47  virtual void onScheduleInitialEvents();
48 private:
49  void onAboutToFire(EventBase *pEvt);
50 
51  int m_initialPopulationSize;
52 
53  bool m_init;
54 };
55 
56 inline SimpactPopulation &SIMPACTPOPULATION(State *pState)
57 {
58  assert(pState != 0);
59  return static_cast<SimpactPopulation &>(*pState);
60 }
61 
62 inline const SimpactPopulation &SIMPACTPOPULATION(const State *pState)
63 {
64  assert(pState != 0);
65  return static_cast<const SimpactPopulation &>(*pState);
66 }
67 
68 #endif // SIMPACTPOPULATION_H
69 
This class both describes the simulation state and contains the core algorithm (as shown on the main ...
Definition: state.h:40
Base class which allows an error message to be set.
Definition: errorbase.h:49
virtual void onAboutToFire(EventBase *pEvt)
Called right before pEvt is fired.
Definition: state.h:132
Base class for picking random numbers according to some kind of age distribution. ...
Definition: populationdistribution.h:15
This class provides functions for a population-based simulation using the modified Next Reaction Meth...
Definition: population.h:77
This class allows you to generate random numbers, and uses the GNU Scientific Library for this...
Definition: gslrandomnumbergenerator.h:15
PersonBase ** getMen()
Same as Population::getAllPeople, but only the men are returned.
Definition: population.cpp:429
PersonBase ** getWomen()
Same as Population::getAllPeople, but only the women are returned.
Definition: population.cpp:442
This is the base class for events in the mNRM algorithm.
Definition: eventbase.h:60
PersonBase ** getAllPeople()
Returns a list to the current living members in the population, introduced into the simulation using ...
Definition: population.h:106