Simpact Cyan
Population based event driven simulation using mNRM
Public Member Functions | Protected Member Functions | List of all members
PopulationEvent Class Reference

This is the base class for events in population-based simulations which use the Population class. More...

#include <populationevent.h>

Inheritance diagram for PopulationEvent:
Inheritance graph
[legend]
Collaboration diagram for PopulationEvent:
Collaboration graph
[legend]

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...
 
PersonBasegetPerson (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 PersonBasegetNextOtherAffectedPerson ()
 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 $ {\rm Tdiff} $. More...
 

Detailed Description

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:

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.

Constructor & Destructor Documentation

PopulationEvent::PopulationEvent ( PersonBase pPerson)

Constructs an event relevant to one person.

PopulationEvent::PopulationEvent ( PersonBase pPerson1,
PersonBase pPerson2 
)

Constructs an event relevant to two persons.

Member Function Documentation

virtual std::string PopulationEvent::getDescription ( double  tNow) const
inlinevirtual

Returns a short description of the event, can be useful for logging/debugging purposes.

virtual PersonBase* PopulationEvent::getNextOtherAffectedPerson ( )
inlinevirtual

Retrieves an affected person and advaces the iteration (should return 0 if no more persons are affected).

virtual int PopulationEvent::getNumberOfOtherAffectedPersons ( ) const
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).

int PopulationEvent::getNumberOfPersons ( ) const
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.

virtual bool PopulationEvent::isUseless ( )
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.

virtual void PopulationEvent::startOtherAffectedPersonIteration ( )
inlinevirtual

Starts the iteration of the other affected persons.


The documentation for this class was generated from the following files: