ShareEvaluator¶
This page describes the class ShareEvaluator
ShareEvaluator
is derived from Evaluator
and is used to assign values to the cells calculated from a shared array (obtained via ArrayShare.
Usually this calculation is done by means of a poly line function providing the “preference” values for the data in the array.
While the input array usually has a size of m_iNumCells
, the output array has a size of (m+1)*m_iNumCells
where m is the maximum number of neighbors of a cell.
In its raw form the element i*(m+1) + k
is the value of the (k-1)
-th neighbor of cell i
(for k > 1
), whereas the element i*(m+1)
is the value of the cell itself..
Often, however, the output data is used to make weighted random numbers so within a cells “subarray” we accumulate the numbers:

A raw subarray and its cumulation.¶
- Given a subarray
\((s_i)_{0 \leq i \leq i+1}\),
- where
\(s_i = outputarray[k \cdot m + i]\),
with \(m\) being the maximum number of integers, and \(k\) an integer,
- the cumulated array is
\((c_i)_{0 \leq i \leq i+1}\)
- where
\(c_0 = s_0\), and \(c_i = s_i + c_{i-1}\) for \(i > 0\)
- Code:
Attributes
|
ShareEvaluator” |
action name |
|
ShareEvaluator_%s_arrayname” |
template for array name |
|
ShareEvaluator_%s_polyname” |
template for poly name |
The attribute names of the array and the PolyLine in the input files must have the form “ShareEvaluator_<id>_arrayname” and “ShareEvaluator_<id>_polyname”, respectively, where <id> is an arbitrary string (which must be passed to the constructor.
Public Methods¶
constructor
¶
ShareEvaluator(SPopulation<T> *pPop, SCellGrid *pCG, std::string sID, double *adOutputWeights, bool bCumulate, intset &sTriggerIDs);
ShareEvaluator(SPopulation<T> *pPop, SCellGrid *pCG, std::string sID, double *adOutputWeights, bool bCumulate, int iTriggerID);
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 (used to construct the names of the shared array and the poly line) .
adOutputWeights
Array to hold the output weights. The size of this array is (m+1)*NumCells, where m is the maximum number of neighbors of a cell.
adInputData
Array containing the input data with size equal to the number of cells (often one of the environment arrays).
bCumulate
Already cumulate the values for every cell in the output array.
iTriggerID
ID of event which should trigger a recalculation (for an altitude evaluator everything stays the same until a new geography is loaded. when the avaluation has to be redone).
sTriggerIDs
A set if event IDs which should trigger to a recalculation.
destructor
¶
virtual ~SingleEvaluator();
The destructor deletes the PolyLine
object if one has been created.
preLoop
¶
virtual int preLoop();
Creates the array name and tries to get it from ArrayShare
.
initialize
¶
virtual int initialize(float fT);
Recalculates the output data if required.
finalize
¶
virtual int finalize(float fT);
Reset the update flags.
extractAttributesQDF
¶
virtual int extractAttributesQDF(hid_t hSpeciesGroup);
Creates the attribute names for the poly line and the shared array and reads the array name and the poly name, then tries to read and construct the poly line.
writeAttributesQDF
¶
virtual int writeAttributesQDF(hid_t hSpeciesGroup);
Creates the attributes names for the poly line and the shared array and writes them, then writes the poly line to file.
tryGetAttributes
¶
virtual int tryGetAttributes(const ModuleComplex *pMC);
pMC
A
ModuleComplex
object.
Creates the attribute names for the poly line and the shared array and reads the array name and the poly name from the``ModuleComplex`` object, then tries to read and construct the poly line.
setOutputWeights
¶
void setOutputWeights(double *adOutput);
adOutput
An array containing values destined for output.
The variable m_adOutputWeights
is set to a pointer to the previously filled array adOutput
.
notify
¶
void notify(Observable *pObs, int iEvent, const void *pData);
pObs
The observable which sends the event.
iEvent
ID of the event.
pData
Pointer to data pertaining to the event. It must be cast to the correct type.
Observer
interface)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 ShareEvaluator
and their ID’s match.
showAttributes
¶
void showAttributes();
Displays the poly line data.
Protected Methods¶
void calcValues();
The elements at position iCellIndex*(m_iMaxNeighbors+1)
are set to the poly line evaluation of m_adInput[iCellIndex]
if there is aa poly line. Otherwise it is set to m_adInput[iCellINdex]
.
constructor
¶
void exchangeAndCumulate();
The “free” positions in the output array (those corresponding to the neighbors) are set to the evaluation values of the neighbors.
If cumulation is required this is done here.