1 #ifndef POPULATIONEVENT_H
3 #define POPULATIONEVENT_H
15 #define POPULATIONEVENT_MAXPERSONS 2
82 void setGlobalEventPerson(
PersonBase *pDummyPerson);
83 void setEventID(int64_t
id);
84 int64_t getEventID()
const;
112 virtual std::string
getDescription(
double tNow)
const {
return std::string(
"No description given"); }
116 void setEventIndex(
PersonBase *pPerson,
int idx);
119 void setScheduledForRemoval() { m_scheduledForRemoval =
true; }
120 bool isScheduledForRemoval()
const {
return m_scheduledForRemoval; }
125 #if !defined(NDEBUG) && defined(POPULATIONEVENT_FAKEDELETE)
126 void setDeleted() { m_deleted =
true; }
127 bool isDeleted()
const {
return m_deleted; }
129 void setDeleted() { }
130 bool isDeleted()
const {
return false; }
132 PersonBase *getPersonWithoutChecking(
int idx)
const;
140 void commonConstructor();
142 PersonBase *m_pPersons[POPULATIONEVENT_MAXPERSONS];
143 int m_eventIndex[POPULATIONEVENT_MAXPERSONS];
146 bool m_scheduledForRemoval;
149 #ifdef POPULATIONEVENT_FAKEDELETE
154 inline void PopulationEvent::setEventIndex(
PersonBase *pPerson,
int idx)
156 assert(pPerson != 0);
157 int num = m_numPersons;
159 for (
int i = 0 ; i < num ; i++)
161 assert(m_pPersons[i] != 0);
163 if (pPerson == m_pPersons[i])
165 m_eventIndex[i] = idx;
170 std::cerr <<
"PopulationEvent::setEventIndex: Consistency error: invalid Person object in setEventIndex" << std::endl;
174 inline int PopulationEvent::getEventIndex(
PersonBase *pPerson)
const
176 assert(pPerson != 0);
177 int num = m_numPersons;
179 for (
int i = 0 ; i < num ; i++)
181 assert(m_pPersons[i] != 0);
183 if (pPerson == m_pPersons[i])
184 return m_eventIndex[i];
187 std::cerr <<
"PopulationEvent::getEventIndex: Consistency error: invalid Person object in getEventIndex" << std::endl;
194 return m_pPersons[idx];
198 inline PersonBase *PopulationEvent::getPersonWithoutChecking(
int idx)
const
200 return m_pPersons[idx];
203 inline void PopulationEvent::setEventID(int64_t
id)
205 #ifdef POPULATIONEVENT_FAKEDELETE
208 assert(m_eventID < 0);
213 inline int64_t PopulationEvent::getEventID()
const
215 #ifdef POPULATIONEVENT_FAKEDELETE
223 #ifdef POPULATIONEVENT_FAKEDELETE
226 assert(m_numPersons >= 0 && m_numPersons <= POPULATIONEVENT_MAXPERSONS);
227 return (
int)m_numPersons;
This is the base class for events in the mNRM algorithm.
Definition: eventbase.h:56
This is the base class for a person in a population-based simulation.
Definition: personbase.h:24
This is the base class for events in population-based simulations.
Definition: populationevent.h:64
PersonBase * getPerson(int idx) const
Returns a person that was specified when the event was constructed, where idx can range from 0 to Pop...
Definition: populationevent.cpp:93
virtual bool areGlobalEventsAffected() const
If global events (not referring to a particular person) are affected, this function can be overridden...
Definition: populationevent.h:106
virtual bool isEveryoneAffected() const
If the entire population is affected by this event (should be avoided!), this function can be overrid...
Definition: populationevent.h:98
virtual bool isUseless(const PopulationStateInterface &population)
This function can be used to inform the algorithm that an event is no longer of any use and should be...
Definition: populationevent.h:138
int getNumberOfPersons() const
Returns the number of people specified during the creation of the event (will be one for global event...
Definition: populationevent.h:221
PopulationEvent()
Constructs a 'global' event.
Definition: populationevent.cpp:30
virtual std::string getDescription(double tNow) const
Returns a short description of the event, can be useful for logging/debugging purposes.
Definition: populationevent.h:112
virtual void markOtherAffectedPeople(const PopulationStateInterface &population)
If other people than the one(s) mentioned in the constructor are also affected by this event,...
Definition: populationevent.h:102
Interface for a simulation state for the population-based algorithm, specifying member functions that...
Definition: populationinterfaces.h:27