tut_EnvironAltPop

The class tut_EnvironAltPop is derived from SPopulation.

Apart from aging, dyining, moving, sexually reproducing, the agents react ot the envrionment. In particular the agents “sense” the altitude, and try to move to locations with altitudes they prefer. This preference is expressed by means of a poly line.

For this the actions

are required.

(The class tut_SexualPop ` is described in detail in the sixth part of the tutorial).

Code:

Data types

The actions GetOld and OldAgeDeath expect the agents to have a float member m_fAge, the action Fertility additionally requires a float member m_fLastBirth, and the actions Verhulst and RandomPair require an int member m_iMateIndex.

struct tut_EnvironAltAgent : Agent {

    float m_fAge;
    float m_fLastBirth;
    int   m_iMateIndex;
};

Public Methods

constructor

tut_EnvironAltPop(SCellGrid *pCG, PopFinder *pPopFinder, int iLayerSize, IDGen **apIDG, uint32_t *aulState, uint *aiSeeds);
pCG

Pointer to the cell grid the simulation runs on.

pPopFinder

A pointer to an instance of a PopFinder population container.

iLayerSize

The layer size used by the agent management system.

apIDG

An array of pointers to the ID generators, one for each thread.

aulState

An array of uint used to initalize the WELL512 random number generators.

aiSeeds

Seeds for other WELL512 instances not used for moving and breeding, e.g. for genetics.

This creates an instance each of GetOld, OldAgeDeath, WeightedMove, Fertility, Verhulst, and SingleEvaluator, and registers them with the Prioritizer.

destructor

~tut_EnvironAltPop();

The destructor deletes the action objects created in the constructor.

makePopSpecificOffspring

int makePopSpecificOffspring(int iAgent, int iMother, int iFather);
iAgent

Index of new born agent.

iMother

Index of the baby’s mother.

iFather

Index of the baby’s father.

Initializes the members of the new agent. In particular, the mate index is set to the agent’s own index and the gender set to 0 (female) - this enable asexual reproduction.

addPopSpecificAgentData

int addPopSpecificAgentData(int iAgentIndex, char **ppData);

addPopSpecificAgentDataTypeQDF

void addPopSpecificAgentDataTypeQDF(hid_t *hAgentDataType);
hAgentDataType

HDF5 handle for a existin HDF data type.

This method extends the existing HDF data type, by entriues for the agent’s age member, and the last birth.

updateEvent

virtual int updateEvent(int EventID, char *pData, float fT);
EventID

The ID of an event.

pData

Optional strin for the event.

‘’fT’’

Current simulation step.

This method only handles events related to changes in geography. In particular, it kills agents who suddenly finde them selves under water or under ice.

flushEvents

virtual void flushEvents(float fT);
‘’fT’’

Current simulation step.

This method is called when no more events are scheduled for this time step.