SORTIE Core C++ Documentation
|
Competition Based Harvest - Version 1.0. More...
#include <CompetitionHarvest.h>
Public Member Functions | |
clCompetitionHarvest (clSimManager *p_oSimManager) | |
Constructor. More... | |
~clCompetitionHarvest () | |
Destructor. More... | |
void | Action () |
Performs the harvesting. More... | |
void | RegisterTreeDataMembers () |
Registers the "COE" tree float 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... | |
clSimManager * | GetSimManager () |
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 Types | |
enum | cutType { interval, ba_amt, ba_prop } |
Type of harvest. More... | |
Protected Member Functions | |
void | ResetResultsGrid () |
Resets all the values in the "Competition Harvest Results" grid. More... | |
void | GetData (xercesc::DOMDocument *p_oDoc) |
Performs setup. More... | |
void | ReadParameterFileData (xercesc::DOMDocument *p_oDoc, clTreePopulation *p_oPop) |
Reads harvest data from the parameter file. More... | |
void | SetupGrids () |
Sets up the "Competition Harvest Results" grid and gets all the return codes. More... | |
void | SetupCOEGrids (clTreePopulation *p_oPop) |
Sets up the mp_oHighestCOE and mp_fCOE arrays. More... | |
void | CutTreesSpeciesSpecific (const float &fPlotBA) |
Performs species-specific harvests. More... | |
void | CutTreesNotSpeciesSpecific (const float &fPlotBA) |
Performs non-species-specific harvests. More... | |
void | CalculateAllCOEsSpeciesSpecific (clTreePopulation *p_oPop) |
Calculates competitive effects for those trees that are eligible for harvest. More... | |
void | CalculateAllCOEsNotSpeciesSpecific (clTreePopulation *p_oPop) |
Calculates competitive effects for those trees that are eligible for harvest. More... | |
void | RecalculateCOESpeciesSpecific (clTreePopulation *p_oPop, const float &fX, const float &fY) |
Recalculates COEs in the neighborhood of a recently cut tree. More... | |
void | RecalculateCOENotSpeciesSpecific (clTreePopulation *p_oPop, const float &fX, const float &fY) |
Recalculates COEs in the neighborhood of a recently cut tree. More... | |
float | GetBasalArea () |
Gets the basal area across the plot for those trees that are eligible for harvest. More... | |
float | CalculateOneCOE (clPlot *p_oPlot, clTreePopulation *p_oPop, clTree *p_oTree) |
Calculates the competitive effect for one tree. 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 | |
clGrid * | mp_oResultsGrid |
RESULTS GRID This grid is called "Competition Harvest Results". More... | |
clTree *** | mp_oHighestCOE |
Which tree in each grid cell (matching the cells of the clTreePopulation class) has the highest COE. More... | |
float ** | mp_fCOE |
The value for the COE of each tree in mp_oHighestCOE. More... | |
double ** | mp_fLambda |
Lambda for NCI. More... | |
short int ** | mp_iCOECodes |
Data member codes for the "COE" tree float data member. More... | |
double * | mp_fAlpha |
Target DBH effect on each neighbor species. More... | |
double * | mp_fBeta |
Target distance effect. More... | |
double * | mp_fC |
Crowding effect slope. More... | |
double * | mp_fD |
Crowding effect steepness. More... | |
double * | mp_fGamma |
Size sensitivity to competition parameter. More... | |
double * | mp_fMaxCrowdingRadius |
Maximum radius, in meters, for which a target has a crowding effect on neighbors. More... | |
double * | mp_fTargetToCut |
Holds the target left to cut for each species. More... | |
double * | mp_fAlreadyCut |
The amount cut this timestep for each species. More... | |
double * | mp_fPropToCut |
Proportion of each species to cut as a value between 0 and 1. More... | |
short int * | mp_iDenCutCodes |
Data member codes for the "Cut Density_sp" data member of the "Competition
Harvest Results" grid. More... | |
short int * | mp_iBaCutCodes |
Data member codes for the "Cut Basal Area_sp" data member of the "Competition Harvest Results" grid. More... | |
std::string | m_sHarvestListFilename |
The filename to which to write the list of all trees harvested each timestep. More... | |
double | m_fMaxMaxCrowdingRadius |
Maximum crowding radius across all species - used when recalculating COEs after a tree has been cut. More... | |
double | m_fQ |
Target DBH divisor. More... | |
double | m_fMinHarvestDBH |
Mininum DBH for harvesting. More... | |
double | m_fMaxHarvestDBH |
Maxinum DBH for harvesting. More... | |
double | m_fAmtToCut |
Cut amount - if this is a fixed interval harvest, this is the amount to which the plot is cut back, in m2 of basal area; if this is a fixed BA threshold harvest with fixed amount to cut, this is that amount to cut, in m2 of basal area; if this is a fixed BA threshold harvest with proportion to cut, this is the proportion to cut between 0 and 1. More... | |
double | m_fBAThreshold |
For fixed BA threshold harvests, the BA threshold that triggers a harvest. More... | |
float | m_fMinSaplingHeight |
Minimum sapling height. More... | |
int | m_iInterval |
For fixed BA threshold harvests, the minimum interval between harvests. More... | |
deadCode | m_iReasonCode |
Reason code to pass to the tree population when trees are killed. More... | |
short int | m_iTimeSinceLastHarvest |
How many timesteps it's been since the last harvest. More... | |
short int | m_iNumX |
Number of cells in the X direction for the mp_oHighestCOE and mp_fCOE arrays. More... | |
short int | m_iNumY |
Number of cells in the Y direction for the mp_oHighestCOE and mp_fCOE arrays. More... | |
short int | m_iNumSpecies |
Number of species. More... | |
enum clCompetitionHarvest::cutType | harvest |
What kind of harvest is being used for this run. More... | |
bool | m_bIsSpeciesSpecific |
Whether or not this is a species-specific harvest. 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... | |
stcSpeciesTypeCombo * | mp_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... | |
clSimManager * | mp_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... | |
Competition Based Harvest - Version 1.0.
This is a behavior which performs harvests by preferentially removing those trees that exert the most competitive pressure on their neighbors. This behavior is also more autonomous - it decides for itself when harvests occur and how much cutting to do based on criteria provided by the user.
There are two ways to specify when harvests occur.
1) Fixed basal area threshold. A harvest occurs every time the total plot basal area exceeds a threshold set by the user. There is a minimum interval between harvests which can be used to make sure they do not occur too frequently. The harvests cut either an absolute amount of basal area or a percentage of the total.
2) Fixed interval. The user specifies how often harvests occur. The harvests cut the plot back to a set total basal area.
Either way, the user can specify a minimum and maximum DBH for trees to harvest.
Harvests may be species-specific or non-species-specific. If they are species-specific, the user specifies the relative amounts to remove of each species (including 0 for non-participating species). 100% participation for all species indicates that all species can be treated as a single group. Only participating species and size ranges are used to establish basal area criteria for initiating a harvest.
The harvest preferentially removes the most competitive trees. The competitive effect (COE) of a tree i on neighbors j within a given radius is calculated as follows:
summed over all neighbors. The values of C, gamma, alpha, beta, and D are specific to the neighbor's species. Lambda is for the effect of the target species i on the neighbor species j. DBH is the neighbor's DBH, and distance is the distance in meters between the target and neighbor. Optionally, DBH can be divided by a divisor term if there needs to be a units correction.
Trees in the plot are ranked by COE. The harvest behavior works its way down the list, removing trees in order, until the amount to harvest requirements have been met. After each tree is removed, the COE of all trees in its immediate vicinity are recalculated and the COE list will be resorted.
If removing a tree will cause the harvest to overshoot its cutting target, a random number will be compared to the amount of overshoot to determine if the tree will be removed. Harvesting ends with this tree.
If the cut is species-specific, a tree high on the competitiveness list will be skipped if a sufficient amount of that species has already been removed.
The behavior uses a grid to report on actual harvest amounts removed across the plot, and optionally can provide a list of all individuals removed each timestep, along with their basal area, biomass and bole volume.
Seedlings, snags, and dead trees have neither competitive effect on neighbors or have competitive effects put on them by other trees. In other words, they are always ignored.
This adds one float data member to trees to which it is applied to hold their competitive effect. This member is called "COE". It has limited usefulness outside of this behavior.
This behavior's namestring and parameter file call string are both "CompetitionHarvest".
Copyright 2011 Charles D. Canham.
Edit history:
--------------—
October 20, 2011 - Wiped the slate clean for SORTIE 7.0 (LEM)
|
protected |
clCompetitionHarvest::clCompetitionHarvest | ( | clSimManager * | p_oSimManager | ) |
Constructor.
p_oSimManager | Sim Manager object. |
clCompetitionHarvest::~clCompetitionHarvest | ( | ) |
Destructor.
|
virtual |
Performs the harvesting.
First this calls ResetResultsGrid(). Then this decides whether a harvest will occur. If this is a fixed interval harvest, it checks the amount of time that has passed. If this is a fixed BA harvest, this calls GetBasalArea() to find out whether the basal area is over the threshold. If a harvest is to occur, this calls CutTreesSpeciesSpecific() or CutTreesNotSpeciesSpecific().
Reimplemented from clBehaviorBase.
|
protected |
Calculates competitive effects for those trees that are eligible for harvest.
After calculating the COE, this finds the tree with the highest COE in each grid cell and populates the mp_oHighestCOE and mp_fCOE arrays. Eligible trees are those that have a COE tree data member.
|
protected |
Calculates competitive effects for those trees that are eligible for harvest.
After calculating the COE, this finds the tree with the highest COE in each grid cell and populates the mp_oHighestCOE and mp_fCOE arrays. Eligible trees are those that have a COE tree data member, and whose species has a positive difference between mp_fTargetToCut and mp_fAlreadyCut.
|
protected |
Calculates the competitive effect for one tree.
If the tree is dead, the answer is zero. All dead trees are also excluded as neighbors.
p_oPlot | Plot object. |
p_oPop | Tree population object. |
p_oTree | Tree for which to calculate competitive effect. |
|
protected |
Performs non-species-specific harvests.
This calculates basal area cut targets, depending on the type of harvest being performed. Then this calls CalculateCOENotSpeciesSpecific() to get tree competitive effects. The most competitive tree across the entire plot is cut, and then RecalculateCOENotSpeciesSpecific() is called. This process is repeated until cut targets have been reached. If cutting a tree would cause an overshoot of the target BA, then a random number is compared to the amount of difference between the target and the overshoot to decide whether that tree is cut.
fPlotBA | Basal area of the plot. |
|
protected |
Performs species-specific harvests.
This calculates basal area cut targets, depending on the type of harvest being performed. Then this calls CalculateCOESpeciesSpecific() to get tree competitive effects. The most competitive tree across the entire plot is cut, and then RecalculateCOESpeciesSpecific() is called. This process is repeated until cut targets have been reached. Only the highest-COE trees of species that are left are put in the mp_oHighestCOE and mp_fCOE arrays. If cutting a tree would cause an overshoot of that species' target BA, then a random number is compared to the amount of difference between the target and the overshoot to decide whether that tree is cut.
fPlotBA | Basal area of the plot. |
|
protected |
Gets the basal area across the plot for those trees that are eligible for harvest.
Eligible trees are those that are of a species participating in harvests (those to which this behavior is applied) whose DBHs are between the minimum and the maximum.
|
protectedvirtual |
Performs setup.
p_oDoc | DOM tree of parsed input file. |
Implements clWorkerBase.
|
protected |
Reads harvest data from the parameter file.
p_oDoc | DOM tree of parsed input file. |
p_oPop | Tree population object. |
modelErr | if:
|
|
protected |
Recalculates COEs in the neighborhood of a recently cut tree.
All trees within a distance of m_fMaxMaxCrowdingRadius from the point fX, fY have their COEs recalculated. Any applicable updates are made to mp_oHighestCOE and mp_fCOE.
p_oPop | Tree population object. |
fX | X coordinate of tree that was removed. |
fY | Y coordinate of tree that was removed. |
|
protected |
Recalculates COEs in the neighborhood of a recently cut tree.
All trees within a distance of m_fMaxMaxCrowdingRadius from the point fX, fY have their COEs recalculated. Any applicable updates are made to mp_oHighestCOE and mp_fCOE. Only trees whose species still have a positive difference between mp_fTargetToCut and mp_fAlreadyCut are recalculated and considered for a spot on mp_oHighestCOE.
p_oPop | Tree population object. |
fX | X coordinate of tree that was removed. |
fY | Y coordinate of tree that was removed. |
|
virtual |
Registers the "COE" tree float data member.
The return codes are captured in the mp_iCOECodes array.
modelErr | if this behavior is being applied to any tree type except saplings and adults. |
Reimplemented from clBehaviorBase.
|
protected |
Resets all the values in the "Competition Harvest Results" grid.
All values are set to 0.
|
protected |
Sets up the mp_oHighestCOE and mp_fCOE arrays.
p_oPop | Tree population object. |
|
protected |
Sets up the "Competition Harvest Results" grid and gets all the return codes.
|
protected |
What kind of harvest is being used for this run.
|
protected |
Whether or not this is a species-specific harvest.
|
protected |
Cut amount - if this is a fixed interval harvest, this is the amount to which the plot is cut back, in m2 of basal area; if this is a fixed BA threshold harvest with fixed amount to cut, this is that amount to cut, in m2 of basal area; if this is a fixed BA threshold harvest with proportion to cut, this is the proportion to cut between 0 and 1.
BA amounts are read as per ha from the parameter file, but they are stored as a total amount here to avoid having to convert back and forth.
|
protected |
For fixed BA threshold harvests, the BA threshold that triggers a harvest.
This is read in from the parameter file as m2/ha, but stored as total m2 of basal area.
|
protected |
Maxinum DBH for harvesting.
|
protected |
Maximum crowding radius across all species - used when recalculating COEs after a tree has been cut.
|
protected |
Mininum DBH for harvesting.
|
protected |
Minimum sapling height.
For doing neighbor searches.
|
protected |
Target DBH divisor.
The target's DBH is divided by this term before being used in the COE equation. This is in case any units corrections need to be made.
|
protected |
For fixed BA threshold harvests, the minimum interval between harvests.
For fixed interval harvests, the interval between harvests. This is read from the parameter file in years but is stored as timesteps.
|
protected |
Number of species.
For destructor.
|
protected |
Number of cells in the X direction for the mp_oHighestCOE and mp_fCOE arrays.
|
protected |
Number of cells in the Y direction for the mp_oHighestCOE and mp_fCOE arrays.
|
protected |
Reason code to pass to the tree population when trees are killed.
|
protected |
How many timesteps it's been since the last harvest.
|
protected |
The filename to which to write the list of all trees harvested each timestep.
This is optional. If the file is to be written, it is a tab-delimited text file. The columns are X, Y, Species, DBH, and Timestep cut.
|
protected |
Target DBH effect on each neighbor species.
α variable in COE equation above. Array is sized number of species and is required for all species.
|
protected |
The amount cut this timestep for each species.
Ignored unless m_bIsSpeciesSpecific is true. This can be compared against the mp_fTargetToCut array to decide whether an individual of a certain species is eligible for cutting. Array size is number of species.
|
protected |
Target distance effect.
β variable in COE equation above. Array is sized number of species and is required for all species.
|
protected |
Crowding effect slope.
C in COE equation above. Array is sized number of species and is required for all species.
|
protected |
The value for the COE of each tree in mp_oHighestCOE.
Array size is number of X cells (in variable m_iNumX) by number of Y cells (held in variable m_iNumY).
|
protected |
Crowding effect steepness.
D in COE equation above. Array is sized number of species and is required for all species.
|
protected |
Size sensitivity to competition parameter.
γ in COE equation above. Array is sized number of species and is required for all species.
|
protected |
Lambda for NCI.
Array is sized number of species by number of species. The first index is for targets, the second for neighbors. Thus mp_fLambda[2][3] is the effect of target species 2 on species 3 neighbors.
|
protected |
Maximum radius, in meters, for which a target has a crowding effect on neighbors.
Array is sized number of species but is only required for those species to which this behavior applies.
|
protected |
Proportion of each species to cut as a value between 0 and 1.
All 1s mean treat the species as a common pool (and m_bSpeciesSpecific = false). Array is sized number of species but is only required for those species to which this behavior applies.
|
protected |
Holds the target left to cut for each species.
Ignored unless m_bIsSpeciesSpecific is true. CutTrees() manages this array to properly direct the behavior of the other functions. Array size is number of species.
|
protected |
Data member codes for the "Cut Basal Area_sp" data member of the "Competition Harvest Results" grid.
Array size is number species.
|
protected |
Data member codes for the "COE" tree float data member.
Array size is number of species by 2 (saplings and adults).
|
protected |
Data member codes for the "Cut Density_sp" data member of the "Competition Harvest Results" grid.
Array size is number species.
|
protected |
Which tree in each grid cell (matching the cells of the clTreePopulation class) has the highest COE.
Array size is number of X cells (in variable m_iNumX) by number of Y cells (held in variable m_iNumY).
|
protected |
RESULTS GRID This grid is called "Competition Harvest Results".
It holds the actual amount cut for the current timestep. The grid's cell resolution is up to the user, but defaults to one grid cell covering the whole plot. The data is stored raw - no conversion to per-hectare amounts.
Any parameter file grid map for this grid it will be ignored.
Data member name | Type | Description |
---|---|---|
Cut Density_sp | int | Number of trees cut. There is one for each species; sp is the species number. |
Cut Basal Area_sp | float | Total basal area cut. There is one for each species; sp is the species number. |