Simpact Cyan
Population based event driven simulation using mNRM
|
This is the base class for events in population-based simulations which use the Population class. More...
#include <populationevent.h>
Public Member Functions | |
PopulationEvent (PersonBase *pPerson) | |
Constructs an event relevant to one person. More... | |
PopulationEvent (PersonBase *pPerson1, PersonBase *pPerson2) | |
Constructs an event relevant to two persons. More... | |
int | getNumberOfPersons () const |
Returns the number of people specified during the creation of the event. More... | |
PersonBase * | getPerson (int idx) const |
Returns a person that was specified when the event was constructed, where idx can range from 0 to PopulationEvent::getNumberOfPersons() - 1. More... | |
virtual int | getNumberOfOtherAffectedPersons () const |
Returns the number of persons that are also affected by the firing of the event (see the detailed description of the class for more info). More... | |
virtual void | startOtherAffectedPersonIteration () |
Starts the iteration of the other affected persons. More... | |
virtual PersonBase * | getNextOtherAffectedPerson () |
Retrieves an affected person and advaces the iteration (should return 0 if no more persons are affected). More... | |
virtual std::string | getDescription (double tNow) const |
Returns a short description of the event, can be useful for logging/debugging purposes. More... | |
Public Member Functions inherited from EventBase | |
virtual void | fire (State *pState, double t) |
This function will be called when the event fires, so this should most likely be re-implemented in your own event. More... | |
Protected Member Functions | |
virtual bool | isUseless () |
This function can be used to inform the algorithm that an event is no longer of any use and should be discarded. More... | |
Protected Member Functions inherited from EventBase | |
virtual double | getNewInternalTimeDifference (GslRandomNumberGenerator *pRndGen, const State *pState) |
This function will be called to generate a new internal time difference. More... | |
virtual double | calculateInternalTimeInterval (const State *pState, double t0, double dt) |
This function should map the real world time interval onto an internal time interval and return it. More... | |
virtual double | solveForRealTimeInterval (const State *pState, double Tdiff, double t0) |
This function should calculate the real world time interval that corresponds to the value of . More... | |
This is the base class for events in population-based simulations which use the Population class.
Such an event should always specify at creation time which people are always involved in the event. For example, one person is always involved in a 'mortality' event, and two persons will be involved in an event for the formation of a relationship.
Of course, it is also possible that some people are affected because of an event, but that these people were not yet known at the time the event was created. For example, the hazard of a relationship formation event could depend on the number of relationships a person is in. When someone dies (i.e. a morality event), this ends all relationships that person was involved in, so all these people are affected by the event as well (they will need to recalculate event times since their number of relationships will have changed).
For this purpose, the following functions can be implemented, if not it means that no extra people are affected:
getNumberOfOtherAffectedPersons
times, and if it is called more than that (so no more persons are available), the function should return 0.The people specified in the constructor of the class should not be returned or counted by these functions, they are automatically taken into account. When one of the people specified in the constructor has died, the event will be considered useless in the rest of the simulation and will be discarded. Other conditions which can cause an event to become useless can be checked in the optional function PopulationEvent::isUseless.
PopulationEvent::PopulationEvent | ( | PersonBase * | pPerson | ) |
Constructs an event relevant to one person.
PopulationEvent::PopulationEvent | ( | PersonBase * | pPerson1, |
PersonBase * | pPerson2 | ||
) |
Constructs an event relevant to two persons.
|
inlinevirtual |
Returns a short description of the event, can be useful for logging/debugging purposes.
|
inlinevirtual |
Retrieves an affected person and advaces the iteration (should return 0 if no more persons are affected).
|
inlinevirtual |
Returns the number of persons that are also affected by the firing of the event (see the detailed description of the class for more info).
|
inline |
Returns the number of people specified during the creation of the event.
PersonBase * PopulationEvent::getPerson | ( | int | idx | ) | const |
Returns a person that was specified when the event was constructed, where idx
can range from 0 to PopulationEvent::getNumberOfPersons() - 1.
|
inlineprotectedvirtual |
This function can be used to inform the algorithm that an event is no longer of any use and should be discarded.
An event is automatically useless if one of the people specified at time of construction has died, so this function should not check for that again.
|
inlinevirtual |
Starts the iteration of the other affected persons.