SheepManager

The class SheepManager is derived from Action and is used to distribute the available grass mass in each cell among the local sheep. This class has been tailored for the use with SheepPop (see QHG Tutorial 08 - Simple Predator-Prey).

It uses the shared array of available grass mass and fills the shared array of consumed grass mass.

Code:

Attributes

ATTR_SHEEPMAN_NAME

“SheepManager”

action name

Public Methods

constructor

SheepManager(SPopulation<T> *pPop, SCellGrid *pCG, std::string sID,
             const std::string sNameGrassMassAvail, const std::string sNameGrassMassConsumed);
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.

sNameGrassMassAvail

Name of the shared array containing the per-cell available grass masses.

sNameGrassMassConsumed

Name of the shared array containing the per-cell consumed grass masses.

Creates some arrays

destructor

virtual ~SheepManager();

The destructor deletes the array created in the constructor.

preLoop

virtual int preLoop();

Loads the shared arrays and fills the shared array of available grass mass (m_sNameGrassMassAvail).

initialize

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

Index of the current agent.

fT

Current simulation step.

Calls feedSheep() and updates the per-cell sheep array.

finalize

virtual int finalize(float fT);
fT

Current simulation step.

Currently does nothing.

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 SheepManager object whose attributes match those of this.

Protected Methods

feedSheep

int feedSheep();

Determines the amount of grass mass each sheep in a cell will get, and writes the total comsumed mass per cell into the shared array of consumed masses (m_sNameGrassMassConsumed).

makeCellVecsSheep

int makeCellVecsSheep();

Fills an array with per-cell information about sheep’s ids and masses.