#include <InsectInfestation.h>
Public Member Functions | |
clInsectInfestation (clSimManager *p_oSimManager) | |
Constructor. | |
~clInsectInfestation () | |
Destructor. | |
void | GetData (xercesc::DOMDocument *p_oDoc) |
Does behavior setup. | |
void | Action () |
Does insect infestation each timestep. | |
void | RegisterTreeDataMembers () |
Registers the "YearsInfested" int data member. | |
Protected Member Functions | |
void | ReadParFile (xercesc::DOMDocument *p_oDoc, clTreePopulation *p_oPop) |
Reads in parameters from the parameter file. | |
void | FormatQueryString (clTreePopulation *p_oPop) |
Formats the string in m_cQuery. | |
void | GetInfestationRate (long *p_iTotalTrees, long *p_iInfTrees) |
Gets the current rate of infestation in the tree population. | |
Protected Attributes | |
short int ** | mp_iDataCodes |
Return codes for the "YearsInfested" int tree data member. | |
float * | mp_fIntercept |
Intercept parameter - rate of infestation at time 1. | |
float * | mp_fMax |
Maximum infestation rate for each species. | |
float * | mp_fX0 |
The "X0" parameter for each species. | |
float * | mp_fXb |
The "Xb" parameter for each species. | |
float * | mp_fMinDBH |
Minimum DBH for trees to be infested. | |
char * | m_cQuery |
String to pass to clTreePopulation::Find() in order to get the trees to apply damage to. | |
int | m_iFirstTimestep |
Timestep to begin infestation. | |
int | m_iYearsOfInfestation |
Years since infestation began - 0 if there is no current infestation. | |
int | m_iTotalNumSpecies |
Total number of species. |
This behavior simulates a spreading insect infestation throughout the tree population.
The proportion of trees infested as a lognormal function of time is as follows:
P = I +((MAX-I)/(1+(T/X0)^Xb))
where:
Infestation begins at a time step chosen by the user. Infestation continues until there are no more infested trees in the plot.
The proportion of trees infested at time T does not depend on additions to or subtractions from the tree population. The number of trees of a species at that time is counted and the number of trees that are newly infested is the number required to cause the appropriate proportion to be infested. If for some reason there are more trees infested than there should be at that time, no additional trees are infested.
There is no spatial component to the selection of trees for infestation. It is assumed that all trees have an equal chance of becoming infested no matter where they are in the plot. The number of trees that should be infested for a given time step minus the number that actually are gives the probability that an uninfested tree will become infested this time step. A random number is used against this probability for each uninfested tree to determine whether or not it will become infested.
An integer data member is added to trees that tracks the number of years that they have been infested. This data member is called "YearsInfested".
This behavior will not infest trees below a minimum DBH set by the user. Because of the need for DBH, obviously seedlings are ignored.
This behavior's call string and name string are both "Insect Infestation".
Copyright 2010 Charles D. Canham
clInsectInfestation::clInsectInfestation | ( | clSimManager * | p_oSimManager | ) |
Constructor.
p_oSimManager | Sim Manager object. |
clInsectInfestation::~clInsectInfestation | ( | ) |
Destructor.
Frees memory.
void clInsectInfestation::GetData | ( | xercesc::DOMDocument * | p_oDoc | ) | [virtual] |
Does behavior setup.
Calls the following functions:
p_oDoc | DOM tree of parsed input file. |
Implements clWorkerBase.
void clInsectInfestation::Action | ( | ) | [virtual] |
Does insect infestation each timestep.
If the timestep has not yet reached the value in m_iFirstTimestep, or if the value in m_iYearsOfInfestation is 0 (indicating an infestation is over), then nothing happens.
The counter in m_iYearsOfInfestation is incremented and the target level of infestation is calculated for each species according to the function above. GetInfestationRate() calculates the actual current rate. The difference between the target and actual rates gives the probability of an uninfested tree becoming infested. Then for each tree to which this behavior is applied, if the tree is not infested, a random number compared to the infestation probability determines if it will become infested. If so, a value of 1 is entered into the "YearsInfested" data member. If the tree was already infested, the data member value is incremented.
Reimplemented from clBehaviorBase.
void clInsectInfestation::RegisterTreeDataMembers | ( | ) | [virtual] |
Registers the "YearsInfested" int data member.
The return codes are captured in the mp_iDataCodes array.
Reimplemented from clBehaviorBase.
void clInsectInfestation::ReadParFile | ( | xercesc::DOMDocument * | p_oDoc, | |
clTreePopulation * | p_oPop | |||
) | [protected] |
Reads in parameters from the parameter file.
p_oDoc | DOM tree of parsed input file. | |
p_oPop | Tree population object. |
modelErr | if:
|
void clInsectInfestation::FormatQueryString | ( | clTreePopulation * | p_oPop | ) | [protected] |
Formats the string in m_cQuery.
This value will be used in Action() to pass to clTreePopulation::Find() in order to get the trees to act on.
p_oPop | Tree population object. |
void clInsectInfestation::GetInfestationRate | ( | long * | p_iTotalTrees, | |
long * | p_iInfTrees | |||
) | [protected] |
Gets the current rate of infestation in the tree population.
This counts the total number of trees of each species eligible for infestation, and the number of those that are currently infested.
p_iTotalTrees | Pointer to an array, sized m_iTotalNumSpecies, into which to put the total number of trees found of each species. | |
p_iInfTrees | Pointer to an array, sized m_iTotalNumSpecies, into which to put the infested number of trees found of each species. |
short int** clInsectInfestation::mp_iDataCodes [protected] |
Return codes for the "YearsInfested" int tree data member.
Array index one is sized m_iTotalNumSpecies; array index two is sized number of total types.
float* clInsectInfestation::mp_fIntercept [protected] |
Intercept parameter - rate of infestation at time 1.
Array size is total # species.
float* clInsectInfestation::mp_fMax [protected] |
Maximum infestation rate for each species.
Array size is total # species.
float* clInsectInfestation::mp_fX0 [protected] |
The "X0" parameter for each species.
Array size is total # species.
float* clInsectInfestation::mp_fXb [protected] |
The "Xb" parameter for each species.
Array size is total # species.
float* clInsectInfestation::mp_fMinDBH [protected] |
Minimum DBH for trees to be infested.
Array size is total # species.
char* clInsectInfestation::m_cQuery [protected] |
String to pass to clTreePopulation::Find() in order to get the trees to apply damage to.
This will instigate a species/type search for all the species and types to which this behavior applies.
int clInsectInfestation::m_iFirstTimestep [protected] |
Timestep to begin infestation.
int clInsectInfestation::m_iYearsOfInfestation [protected] |
Years since infestation began - 0 if there is no current infestation.
int clInsectInfestation::m_iTotalNumSpecies [protected] |
Total number of species.
Primarily for the destructor.