SORTIE Core C++ Documentation
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
clInsectInfestation Class Reference

Insect Infestation version 1.0. More...

#include <InsectInfestation.h>

Inheritance diagram for clInsectInfestation:
clBehaviorBase clWorkerBase

Public Member Functions

 clInsectInfestation (clSimManager *p_oSimManager)
 Constructor. More...
 
 ~clInsectInfestation ()
 Destructor. More...
 
void GetData (xercesc::DOMDocument *p_oDoc)
 Does behavior setup. More...
 
void Action ()
 Does insect infestation each timestep. More...
 
void RegisterTreeDataMembers ()
 Registers the "YearsInfested" int data member. More...
 
- Public Member Functions inherited from clBehaviorBase
virtual float GetBehaviorVersion ()
 Gets the behavior version number. More...
 
 clBehaviorBase (clSimManager *p_oSimManager)
 Constructor. More...
 
virtual ~clBehaviorBase ()
 Destructor. More...
 
virtual short int ValidateVersionNumber (float fTestVersion)
 Makes sure that the version number of a file passed is between the minimum and current version numbers. More...
 
virtual void SetSpeciesTypeCombos (short int iNumCombos, stcSpeciesTypeCombo *p_whatCombos)
 Sets the species/type combos for a behavior. More...
 
virtual void SetNameData (std::string sNameString)
 Sets the string for the parameter file behavior. More...
 
virtual short int GetNewTreeInts ()
 Gets the number of new tree integer data members this behavior wants to register. More...
 
virtual short int GetNewTreeFloats ()
 Gets the number of new tree float data members this behavior wants to register. More...
 
virtual short int GetNewTreeChars ()
 Gets the number of new tree character data members this behavior wants to register. More...
 
virtual short int GetNewTreeBools ()
 Gets the number of new tree bool data members this behavior wants to register. More...
 
virtual short int GetNumSpeciesTypeCombos ()
 Gets the number of species/type combos to which this behavior applies. More...
 
virtual short int GetNumBehaviorSpecies ()
 Gets the number of unique tree species to which this behavior applies. More...
 
struct stcSpeciesTypeCombo GetSpeciesTypeCombo (short int iIndex)
 Gets one of this behavior's type/species combos. More...
 
virtual short int GetBehaviorSpecies (short int iIndex)
 Gets one of the behavior's species. More...
 
short int GetBehaviorListNumber ()
 Gets the behavior list number for this behavior, which differentiates between multiple copies of the behavior in the behavior list. More...
 
void SetBehaviorListNumber (short int iNumber)
 Sets the behavior list number for this behavior, which differentiates between multiple copies of the behavior in the behavior list. More...
 
std::string FormatSpeciesTypeQueryString ()
 Formats the string for species/types query. More...
 
virtual DOMElement * GetParentParametersElement (xercesc::DOMDocument *p_oDoc)
 This will get the correct set of parameters for this behavior based on the behavior list position number. More...
 
- Public Member Functions inherited from clWorkerBase
 clWorkerBase (clSimManager *p_oSimManager)
 Constructor. More...
 
virtual ~clWorkerBase ()
 Destructor. More...
 
std::string GetName ()
 Gets the object's namestring. More...
 
clSimManagerGetSimManager ()
 
void DoObjectSetup (xercesc::DOMDocument *p_oDoc, fileType iFileType)
 Triggers the setup process. More...
 
virtual void TimestepCleanup ()
 Performs any necessary cleanup operations at the end of a timestep. More...
 
virtual void EndOfRunCleanup ()
 Performs any necessary cleanup operations at the end of a run. More...
 

Protected Member Functions

void ReadParFile (xercesc::DOMDocument *p_oDoc, clTreePopulation *p_oPop)
 Reads in parameters from the parameter file. More...
 
void FormatQueryString (clTreePopulation *p_oPop)
 Formats the string in m_cQuery. More...
 
void GetInfestationRate (long *p_iTotalTrees, long *p_iInfTrees)
 Gets the current rate of infestation in the tree population. More...
 
void EndInfestation ()
 Ends infestation. More...
 
- Protected Member Functions inherited from clWorkerBase
void AssembleFileCode (int iFileType, int iFileVersion, char *cCode)
 Creates the proper identifying filecode for an XML file. More...
 

Protected Attributes

short int ** mp_iDataCodes
 Return codes for the "YearsInfested" int tree data member. More...
 
double * mp_fIntercept
 Intercept parameter - rate of infestation at time 1. More...
 
double * mp_fMax
 Maximum infestation rate for each species. More...
 
double * mp_fX0
 The "X0" parameter for each species. More...
 
double * mp_fXb
 The "Xb" parameter for each species. More...
 
double * mp_fMinDBH
 Minimum DBH for trees to be infested. More...
 
char * m_cQuery
 String to pass to clTreePopulation::Find() in order to get the trees to apply damage to. More...
 
int m_iFirstTimestep
 Timestep to begin infestation. More...
 
int m_iLastTimestep
 Timestep to end infestation. More...
 
int m_iYearsOfInfestation
 Years since infestation began - 0 if there is no current infestation. More...
 
int m_iTotalNumSpecies
 Total number of species. More...
 
- Protected Attributes inherited from clBehaviorBase
short int m_iNumSpeciesTypeCombos
 How many type/species combos a behavior will act on. More...
 
short int m_iNumBehaviorSpecies
 How many distinct species are in the combo list - important for filling species-specific values from parameter file. More...
 
short int * mp_iWhatSpecies
 List of distinct species - for filling species-specific values from parameter file. More...
 
stcSpeciesTypeCombomp_whatSpeciesTypeCombos
 Array of species/type combos that the behavior will act on. More...
 
short int m_iNewTreeInts
 The number of new tree integer data members this behavior wants to add. More...
 
short int m_iNewTreeFloats
 The number of new tree float data members this behavior wants to add. More...
 
short int m_iNewTreeChars
 The number of new tree character data members this behavior wants to add. More...
 
short int m_iNewTreeBools
 The number of new tree boolean data members this behavior wants to add. More...
 
short int m_iBehaviorListNumber
 The number of this behavior in the behavior list, to differentiate between possible multiple copies of this behavior. More...
 
float m_fVersionNumber
 Version number - this will be rounded to 2 digits after the decimal place. More...
 
std::string m_sXMLRoot
 XML root that encloses the parameters for this behavior. More...
 
float m_fMinimumVersionNumber
 Minimum version number - this behavior will run parameter data for a file marked between this number and the current version number, inclusive. More...
 
- Protected Attributes inherited from clWorkerBase
std::string m_sNameString
 If a behavior has registered a command line command with the sim manager, this allows it to be called. More...
 
clSimManagermp_oSimManager
 Pointer to the simulation manager object. More...
 
int * mp_iAllowedFileTypes
 List of the input file types this object can handle. More...
 
int m_iNumAllowedTypes
 Number of input file types this object can handle. More...
 

Detailed Description

Insect Infestation version 1.0.

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, or the ending timestep if the user indicates one.

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 "InsectInfestation".

Copyright 2011 Charles D. Canham

Author
Lora E. Murphy
Edit history:
--------------—
October 20, 2011 - Wiped the slate clean for SORTIE 7.0 (LEM)
July 24, 2015 - Added infection end date (LEM)

Constructor & Destructor Documentation

◆ clInsectInfestation()

clInsectInfestation::clInsectInfestation ( clSimManager p_oSimManager)

Constructor.

Parameters
p_oSimManagerSim Manager object.

◆ ~clInsectInfestation()

clInsectInfestation::~clInsectInfestation ( )

Destructor.

Frees memory.

Member Function Documentation

◆ Action()

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.

◆ EndInfestation()

void clInsectInfestation::EndInfestation ( )
protected

Ends infestation.

All flags are reset to 0 and m_iYearsOfInfestation is set to 0 which will make sure no trees are infected in the future.

◆ FormatQueryString()

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.

Parameters
p_oPopTree population object.

◆ GetData()

void clInsectInfestation::GetData ( xercesc::DOMDocument *  p_oDoc)
virtual

Does behavior setup.

Calls the following functions:

  1. ReadParFile()
  2. FormatQueryString()
Parameters
p_oDocDOM tree of parsed input file.

Implements clWorkerBase.

◆ GetInfestationRate()

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.

Parameters
p_iTotalTreesPointer to an array, sized m_iTotalNumSpecies, into which to put the total number of trees found of each species.
p_iInfTreesPointer to an array, sized m_iTotalNumSpecies, into which to put the infested number of trees found of each species.

◆ ReadParFile()

void clInsectInfestation::ReadParFile ( xercesc::DOMDocument *  p_oDoc,
clTreePopulation p_oPop 
)
protected

Reads in parameters from the parameter file.

Parameters
p_oDocDOM tree of parsed input file.
p_oPopTree population object.
Exceptions
modelErrif:
  • A value in the minimum DBH is less than 0
  • The timestep to start infestation is less than 0
  • The maximum infestation rate for any species is not between 0 and 1
  • The infestation intercept for any species is not between 0 and 1
  • The value for X0 for any species is 0

◆ RegisterTreeDataMembers()

void clInsectInfestation::RegisterTreeDataMembers ( )
virtual

Registers the "YearsInfested" int data member.

The return codes are captured in the mp_iDataCodes array.

Reimplemented from clBehaviorBase.

Member Data Documentation

◆ m_cQuery

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.

◆ m_iFirstTimestep

int clInsectInfestation::m_iFirstTimestep
protected

Timestep to begin infestation.

◆ m_iLastTimestep

int clInsectInfestation::m_iLastTimestep
protected

Timestep to end infestation.

◆ m_iTotalNumSpecies

int clInsectInfestation::m_iTotalNumSpecies
protected

Total number of species.

Primarily for the destructor.

◆ m_iYearsOfInfestation

int clInsectInfestation::m_iYearsOfInfestation
protected

Years since infestation began - 0 if there is no current infestation.

◆ mp_fIntercept

double* clInsectInfestation::mp_fIntercept
protected

Intercept parameter - rate of infestation at time 1.

Array size is total # species.

◆ mp_fMax

double* clInsectInfestation::mp_fMax
protected

Maximum infestation rate for each species.

Array size is total # species.

◆ mp_fMinDBH

double* clInsectInfestation::mp_fMinDBH
protected

Minimum DBH for trees to be infested.

Array size is total # species.

◆ mp_fX0

double* clInsectInfestation::mp_fX0
protected

The "X0" parameter for each species.

Array size is total # species.

◆ mp_fXb

double* clInsectInfestation::mp_fXb
protected

The "Xb" parameter for each species.

Array size is total # species.

◆ mp_iDataCodes

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.


The documentation for this class was generated from the following file: