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 ()
 Constructs a 'global' event. More...
 
 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 (will be one for global events since these are registered with the 'dummy' person mentioned above).
 
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 bool isEveryoneAffected () const
 If the entire population is affected by this event (should be avoided!), this function can be overridden to indicate this. More...
 
virtual void markOtherAffectedPeople (const Population &population)
 If other people than the one(s) mentioned in the constructor are also affected by this event, it should be indicated in this function. More...
 
virtual bool areGlobalEventsAffected () const
 If global events (not referring to a particular person) are affected, this function can be overridden to indicate this. 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...
 
bool willBeRemoved () const
 Check if the event has been marked for deletion, can avoid a call to the random number generator to create a new random number. More...
 
void setWillBeRemoved (bool f)
 When an event has fired, by default a new internal fire time will be calculated; setting this flag avoids this which can be useful if the event isn't going to be used again. 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. It's also possible to specify global events, for example to trigger the start of an infection by marking specific persons as infected. In this case, the no persons will be specified in the constructor, but internally the event will be stored using a 'dummy' person for global events.

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 mortality 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 included in the PopulationEvent::markOtherAffectedPeople function, 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 ( )

Constructs a 'global' event.

Note that while no people are specified here, internally the algorithm will store the event in the list of a 'dummy' person, which is neither labelled as a 'Man' nor as a 'Woman'.

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 bool PopulationEvent::areGlobalEventsAffected ( ) const
inlinevirtual

If global events (not referring to a particular person) are affected, this function can be overridden to indicate this.

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

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

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::isEveryoneAffected ( ) const
inlinevirtual

If the entire population is affected by this event (should be avoided!), this function can be overridden to indicate this.

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::markOtherAffectedPeople ( const Population population)
inlinevirtual

If other people than the one(s) mentioned in the constructor are also affected by this event, it should be indicated in this function.


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