ATanDeath

The class ATanDeath is derived from Action and serves as an age cut-off (probability-based deaths such as in LinearDeath make it possible that lucky agents can be hundreds of years old). To calculate a death-probability for a given age we use a function \(d_p\) defined as foolowse;

\(d_p(a) = 0 \;\;\; \forall a \in [-\infty, a_c - w]\),

\(d_p(a) = 0.5 + h \cdot tan^{-1}(r \cdot (a - a_{c}))/\pi \; \forall a \in [a_c - w, a_c + w]\),

\(d_p(a) = 1 \;\;\; \forall a \in [a_c + w, \infty]\),

where \(w\) is a positive real number, and \(r\) is the slope at the inflection point, and the scaling factor

\(h = ( \frac{\pi}{2} - \varepsilon)/tan^{-1}(s \cdot w)\)

../../images/atan.png

The translation brings the inflection point of the curve to the ccordinates \((a_c, 0.5)\), and the scaling is set to a value such that function \(d_p(a_c+w) = 1\).

This definition ensures that agents older than \(a_c+w\) will certainly die.

Code:

Attributes

ATTR_ATANDEATH_NAME

“ATanDeath”

action name

ATTR_ATANDEATH_MAXAGE_NAME

“ATanDeath_max_age”

average maximum age (\(a_c\))

ATTR_ATANDEATH_RANGE_NAME

“ATanDeath_range”

half width of variable interval (\(w\))

ATTR_ATANDEATH_SLOPE_NAME

“ATanDeath_slope”

slope at inflection point (\(r\))

Public Methods

constructor

ATanDeath(SPopulation<T> *pPop, SCellGrid *pCG, std::string sID, WELL512 **apWELL);,
pPop

A pointer to the SPopulation object performing this action.

pCG

A pointer to the SCellGrid object on which the simulation runs.

sID

An ID for this action.

apWELL

A pointer to an array of WELL512 random number generators (one for each thread).

Creates a NPPCalc objects (in case temoerature and precipitation nee to be converted to NPP.

destructor

virtual ~ATanDeath();

The destructor does nothing,

preLoop

virtual int preLoop();

Calculates the scale using the attribute values.

execute

virtual int execute(int iAgentIndex, float fT);
iAgentIndex

Current agent’s index.

fT

Current simulation step

Calculates the deathprobability for the agent, draws a random number \(r\), and kills the agent if \(r\) is less than the death probability.

extractAttributesQDF

virtual int extractAttributesQDF(hid_t hSpeciesGroup);
hSpeciesGroup

HDF handle for the species group to read from.

This method reads the atttributes of this action from a QDF.

writeAttributesQDF

virtual int writeAttributesQDF(hid_t hSpeciesGroup);
hSpeciesGroup

HDF handle for the species group to write to.

This method writes the attributes of this action to the specified group in a QDF file.

tryGetAttributes

virtual int tryGetAttributes(const ModuleComplex *pMC);
pMC

A ModuleComplex object.

Extracts the action’s attributes from the ModuleComplex object.

isEqual

virtual bool isEqual(Action<T> *pAction, bool bStrict);
pAction

Pointer to an action object to compare with this.

bStrict

Strictness of comparisons (ignored here).

pAction is equal to this, if it is a ATanDeath object whose attributes match those of this.