tut_SexualPop

The class tut_SexualPop is derived from SPopulation.

Apart from aging, dyining and moving, the agents can sexually reproduce.

For this the actions

are required.

(The class tut_SexualPop is described in detail in the fifth 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 action Verhulst requires an int member m_iMateIndex.

struct tut_Sexual : Agent {

    float m_fAge;

    float m_fLastBirth;
    int m_iMateIndex;
};

Public Methods

constructor

tut_SexualPop(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, RandomMove, Fertility, Verhulst, and RandomPair, and registers them with the Prioritizer.

destructor

~tut_SexualPop();

The destructor deletes the action objects created in the constructor.

addPopSpecificAgentData

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

Index of agent whose data is being read.

ppData

pointer to a string containing textual representation of data (see DAT-files).

This method expects the next two words to be the age of the agent, and the step of its last birth.
The next two words are converted to float (this may of course fail) and assigned to the corresponding agent variables, and ppData is modified to point to the following word.

addPopSpecificAgentDataTypeQDF

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.

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 a negative value denoting unpaired state.