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 setEyeCapsFraction(double f) { m_eyeCapsFraction = f; }
22 
23  int getInitialMen() const { return m_initialMen; }
24  int getInitialWomen() const { return m_initialWomen; }
25  double getEyeCapsFraction() const { return m_eyeCapsFraction; }
26 private:
27  int m_initialMen, m_initialWomen;
28  double m_eyeCapsFraction;
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  Person **getDeceasedPeople() { return reinterpret_cast<Person**>(Population::getDeceasedPeople()); }
43 
44  int getInitialPopulationSize() const { return m_initialPopulationSize; }
45  double getEyeCapsFraction() const { return m_eyeCapsFraction; }
46 protected:
47  bool createInitialPopulation(const SimpactPopulationConfig &config, const PopulationDistribution &popDist);
48  bool scheduleInitialEvents();
49 private:
50  void onAboutToFire(EventBase *pEvt);
51 
52  int m_initialPopulationSize;
53  double m_eyeCapsFraction;
54 
55  bool m_init;
56 };
57 
58 inline SimpactPopulation &SIMPACTPOPULATION(State *pState)
59 {
60  assert(pState != 0);
61  return static_cast<SimpactPopulation &>(*pState);
62 }
63 
64 inline const SimpactPopulation &SIMPACTPOPULATION(const State *pState)
65 {
66  assert(pState != 0);
67  return static_cast<const SimpactPopulation &>(*pState);
68 }
69 
70 #endif // SIMPACTPOPULATION_H
71 
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
PersonBase ** getDeceasedPeople()
Returns the people who were part of the simulation but who are now deceased (intended for result anal...
Definition: population.h:122
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:83
This class allows you to generate random numbers, and uses the GNU Scientific Library for this...
Definition: gslrandomnumbergenerator.h:16
PersonBase ** getMen()
Same as Population::getAllPeople, but only the men are returned.
Definition: population.cpp:505
PersonBase ** getWomen()
Same as Population::getAllPeople, but only the women are returned.
Definition: population.cpp:518
This is the base class for events in the mNRM algorithm.
Definition: eventbase.h:62
PersonBase ** getAllPeople()
Returns a list to the current living members in the population, introduced into the simulation using ...
Definition: population.h:112