SORTIE Core C++ Documentation
|
SelectionHarvest - Version 1.0. More...
#include <SelectionHarvest.h>
Public Types | |
enum | cutType { partial, gap, clear } |
Types of harvest cuts. More... | |
enum | amtType { percentBA, absBA, percentDen, absDen } |
Clear cut. More... | |
Public Member Functions | |
clSelectionHarvest (clSimManager *p_oSimManager) | |
Constructor. More... | |
~clSelectionHarvest () | |
Destructor. More... | |
void | Action () |
Performs the selection cut setup for a timestep. More... | |
void | GetTimeSinceHarvest () |
Determines the time that has elapsed since the last harvest for each cell in the harvest results grid. 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 | RegisterTreeDataMembers () |
Registers tree data members. 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 Member Functions | |
void | GetData (xercesc::DOMDocument *p_oDoc) |
Reads all the harvest events from the parameter file. More... | |
void | GetBasalArea (clTreePopulation *p_oTreePop, double *p_fTotalBasalArea, double *p_fLoDbh, double *p_fHiDbh) |
Gets the basal area in a cut area for all species. More... | |
void | GetBasalArea (clTreePopulation *p_oTreePop, int iSpecies, double *p_fTotalBasalArea, double *p_fLoDbh, double *p_fHiDbh) |
Gets the basal area in a cut area for a single species. More... | |
int | CalculateBasalAreaDifference (double *p_fCurrentBasalArea) |
Determines the dbh to cut in each grid cell by calculating the difference between the target basal area and the actual current basal area. More... | |
void | CreateMasterCutPackage (int iSpecies) |
This function will use the values extracted from the parameter file in order to create a package which will be inserted into the master cut events grid. More... | |
void | EditCutEventsGrid () |
This function will edit the cut events grid so that it holds ID and timestep values for the selection harvest created in the behaviour. More... | |
void | GetHarvestGrids () |
Obtains a pointer to the harvest grids and gets all the return codes. More... | |
void | ValidatePackages () |
Makes sure that the data in the event harvest packages makes sense. 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 | |
double * | mp_fLowDBH |
The lower bound for each DBH size class. More... | |
double * | mp_fHighDBH |
The upper bound for each DBH size class. More... | |
double * | mp_fTargetBA |
To hold the target basal area for each size class, in m2/ha. More... | |
double * | mp_fLandscapeBasalArea |
Holds the basal area for each size class for all species across the landscape. More... | |
double * | mp_fBasalArea |
Holds the basal area of 1 species for each size class. More... | |
double * | mp_fTempTargetBA |
Used to ensure that TargetBA does not get overwritten in the CalculateBasalAreaDifference function. More... | |
float | m_fPlotArea |
Plot area, in hectares. More... | |
float | m_fTotalBasalArea [][NUM_SIZE_CLASSES] |
The array into which GetBasalArea will store the Basal area values for each size class. More... | |
float | m_fBasalAreaDifference [][NUM_SIZE_CLASSES] |
The array into which CalculateBasalAreaDifference will place the absolute basal area to remove from each size class. More... | |
clPackage * | mp_oOldPackage |
For finding where to place a new package. More... | |
clPackage * | mp_oNewPackage |
A newly created package in the grids. More... | |
clTreePopulation * | mp_oPop |
Stashed pointer to tree population. More... | |
clGrid * | mp_oMasterCutsGrid |
HARVEST MASTER CUTS. More... | |
clGrid * | mp_oCutEventsGrid |
HARVEST CUT EVENTS. More... | |
clGrid * | mp_oResultsGrid |
RESULTS GRID. More... | |
clGrid * | mp_oTimeSinceHarvestGrid |
TIME SINCE HARVEST. More... | |
int | m_iInitialAge |
Initial age. More... | |
short int | m_iMasterTimestepCode |
timestep data member code in "harvestmastercuts" grid More... | |
short int | m_iMasterIDCode |
id data member code in "harvestmastercuts" grid More... | |
short int | m_iTallestFirstCode |
tallestfirst data member code in "harvestmastercuts" grid More... | |
short int * | mp_iSpeciesCodes |
Species data member code in "harvestmastercuts" grid. More... | |
short int | m_iCutTypeCode |
cuttype data member code in "harvestmastercuts" grid More... | |
short int | m_iAmountTypeCode |
amttype data member code in "harvestmastercuts" grid More... | |
short int * | mp_iRangeMinCodes |
rangeminx data member codes in "harvestmastercuts" grid. More... | |
short int * | mp_iRangeMaxCodes |
rangemaxx data member codes in "harvestmastercuts" grid. More... | |
short int * | mp_iRangeAmountCodes |
rangeamtx data member codes in "harvestmastercuts" grid. More... | |
short int | m_iCutTimestepCode |
timestep data member code in "harvestcutevents" grid More... | |
short int | m_iCutIDCode |
id data member code in "harvestcutevents" grid More... | |
short int | m_iHarvestTypeCode |
Harvest Type data member code in "Harvest Results" grid. More... | |
short int ** | mp_iDenCutCodes |
dencut data member codes in "Harvest Results" grid. More... | |
short int ** | mp_iBaCutCodes |
bacut data member codes in "Harvest Results" grid. More... | |
short int | m_iTime |
Data member return code for "time" data member of "timesinceharvest" grid. More... | |
short int | m_iNumAllowedCutRanges |
Number of cut ranges allowed. More... | |
short int | m_iNumSpecies |
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... | |
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... | |
SelectionHarvest - Version 1.0.
In the case that the parameter file specifies a target basal area, rather than an absolute value or percentage value, this behaviour will calculate the basal area to be removed based as the difference betweent the target basal area the actual basal area (the amount present prior to harvest).(JM)
This behaviour will be able to set a target basal area for each of the 4 size classes. The behaviour will determine the target basal areas in one of two ways. First, if the user specifies their target basal area in all four size classes, the behaviour will calculate the difference, for each size class, between the actual basal area and the target basal area. That delta will be the basal area to remove from each size class. The second option is for the user to provide a 'Q-ratio' and a total target basal area for the 4 size classes combined. These values will be set in the parameter file. The combination of these two values is used to determine the target basal area in each size class based on the exponential distribution. So, regardless of the method, this behaviour will calculate an absolute amount of basal area to remove from each size class, based on the current basal area in each grid cell.(JM)
Prior to each harvest event, this behaviour will compute the actual basal in each grid cell prior to harvest. Then, based on the user input target BA values, or the Q-ratio method, the behaviour will determine how much basal area must be removed from each size class in order to meet the target basal area.(JM)
If by chance, the current basal area of the system in a size class is less than the target basal area, no trees will be harvested from that size class. Furthermore, the shortage will not be made up for by overharvesting another size class.(JM)
This behaviour will then create a set of packages for the harvest grids. Once the packages are created, the behaviour will insert them into the proper place in the harvest grids.(JM)
The namestring and parameter file call string for this behavior are both "SelectionHarvest". (LEM)
Copyright 2011 Charles D. Canham.
Edit history:
--------------—
October 20, 2011 - Wiped the slate clean for SORTIE 7.0 (LEM)
May 5, 2017 - Updated to work correctly with the new tallest-first cut flag in harvest (LEM)
clSelectionHarvest::clSelectionHarvest | ( | clSimManager * | p_oSimManager | ) |
Constructor.
p_oSimManager | Sim Manager object. |
clSelectionHarvest::~clSelectionHarvest | ( | ) |
Destructor.
|
virtual |
Performs the selection cut setup for a timestep.
For a timestep, this function will call CalculateBasalAreaDifference() and TellHarvestToCutTrees() for each selection cut for this timestep.
Reimplemented from clBehaviorBase.
|
protected |
Determines the dbh to cut in each grid cell by calculating the difference between the target basal area and the actual current basal area.
The difference is stored in an array whose pointer is passed to the function.
mp_fLanscapeBasalArea[] will contain the amount of basal area to remove from each size class. this value is not per hectare, but for the whole plot.
p_fCurrentBasalArea | Pointer to array containing the basal area in each size class |
|
protected |
This function will use the values extracted from the parameter file in order to create a package which will be inserted into the master cut events grid.
|
protected |
This function will edit the cut events grid so that it holds ID and timestep values for the selection harvest created in the behaviour.
The function will traverse through every cell in the cut event grid and create a package containing the selection harvest ID and a timestep.
|
protected |
Gets the basal area in a cut area for all species.
This gets the basal area in each cut range and puts it in an array whose pointer was passed.
p_oTreePop | Pointer to the tree population that will have the selection cut applied to it. |
p_fTotalBasalArea | Array (size m_iNumAllowedCutRanges) in which to put the total basal area calculation. |
p_fLoDbh | Array (size m_iNumAllowedCutRanges) of lower-limit dbhs for the cut ranges that have been defined. |
p_fHiDbh | Array (size m_iNumAllowedCutRanges) of upper-limit dbhs for the cut ranges that have been defined. |
|
protected |
Gets the basal area in a cut area for a single species.
The cut area is defined by a linked list of grid cells. This gets the basal area in each cut range and puts it in an array whose pointer was passed.
p_oTreePop | Tree population |
iSpecies | Species of tree for which to calculate basal area. |
p_fTotalBasalArea | Array (size m_iNumAllowedCutRanges) in which to put the total basal area calculation. |
p_fLoDbh | Array (size m_iNumAllowedCutRanges) of lower-limit dbhs for the cut ranges that have been defined. |
p_fHiDbh | Array (size m_iNumAllowedCutRanges) of upper-limit dbhs for the cut ranges that have been defined. |
|
protectedvirtual |
Reads all the harvest events from the parameter file.
It doesn't perform validation on them other than basic data types - more in-depth logical validation is left to ValidatePackages().
p_oDoc | DOM tree of parsed input file. |
Implements clWorkerBase.
|
protected |
Obtains a pointer to the harvest grids and gets all the return codes.
void clSelectionHarvest::GetTimeSinceHarvest | ( | ) |
Determines the time that has elapsed since the last harvest for each cell in the harvest results grid.
|
protected |
Makes sure that the data in the event harvest packages makes sense.
For each cut event (each package) - this checks the following:
|
protected |
The array into which CalculateBasalAreaDifference will place the absolute basal area to remove from each size class.
|
protected |
Plot area, in hectares.
|
protected |
The array into which GetBasalArea will store the Basal area values for each size class.
|
protected |
amttype data member code in "harvestmastercuts" grid
|
protected |
id data member code in "harvestcutevents" grid
|
protected |
timestep data member code in "harvestcutevents" grid
|
protected |
cuttype data member code in "harvestmastercuts" grid
|
protected |
Harvest Type data member code in "Harvest Results" grid.
|
protected |
Initial age.
|
protected |
id data member code in "harvestmastercuts" grid
|
protected |
timestep data member code in "harvestmastercuts" grid
|
protected |
Number of cut ranges allowed.
|
protected |
Total number of species.
|
protected |
tallestfirst data member code in "harvestmastercuts" grid
|
protected |
Data member return code for "time" data member of "timesinceharvest" grid.
|
protected |
Holds the basal area of 1 species for each size class.
|
protected |
The upper bound for each DBH size class.
|
protected |
Holds the basal area for each size class for all species across the landscape.
|
protected |
The lower bound for each DBH size class.
|
protected |
To hold the target basal area for each size class, in m2/ha.
|
protected |
Used to ensure that TargetBA does not get overwritten in the CalculateBasalAreaDifference function.
|
protected |
bacut data member codes in "Harvest Results" grid.
Array size is number cut ranges by number of species
|
protected |
dencut data member codes in "Harvest Results" grid.
Array size is number cut ranges by number of species
|
protected |
rangeamtx data member codes in "harvestmastercuts" grid.
Array size is number cut ranges
|
protected |
rangemaxx data member codes in "harvestmastercuts" grid.
Array size is number cut ranges
|
protected |
rangeminx data member codes in "harvestmastercuts" grid.
Array size is number cut ranges
|
protected |
Species data member code in "harvestmastercuts" grid.
Array size is number species. Array index matches species number
|
protected |
HARVEST CUT EVENTS.
The grid called "harvestcutevents" will have a cell resolution that matches the tree population. This is where data about harvest cutting events is stored.
The need to cut a grid cell is signaled by the presence of a package. The package has an ID number which matches a package in the "harvestmastercuts" grid, which contains the information about how the cut is actually to be performed. Packages are in timestep order, earliest first.
It is possible that a grid map will have been read in for this grid; it will be ignored, and any grid created with such a map will be overwritten.
Data members - all for packages:
Data member | Data | Description |
---|---|---|
id | int | ID number matching master package in "harvestmastercuts" |
timestep | int | Timestep at which to apply the cut |
|
protected |
HARVEST MASTER CUTS.
The grid called "harvestmastercuts" will have a single cell. This is where the cut events are defined.
Each cut event is one package and is applied to a list of species. It has a timestep, cut amount, cut type, and number of cut ranges defined. It also has a unique ID number. The grid cells to which it is applied are in the "harvestcutevents" grid.
For the cut ranges, four dbh ranges can be defined to which the cuts will be applied. The ranges are ordered as 1 is the smallest minimum dbh. Ranges cannot overlap.
The packages are in timestep order, earliest first.
It is possible that a grid map will have been read in for this grid; it will be ignored, and any grid created with such a map will be overwritten.
Data members - all for packages:
Data member | Data | Description |
---|---|---|
id | int | ID number of cut |
timestep | int | Timestep at which to apply the cut |
cuttype | int | Matches a value of the enum "cutType" |
amttype | int | Matches a value of the enum "amtType" |
species(x) | bool | One of each of these for each species. If true, this species is being cut. |
rangeamt(x) | float | Range amount to cut. There are one of each of the following for m_iNumAllowedCutRanges, where x is the index, starting at 0 (thus "rangemin0" and "rangeamt2"). |
rangemin(x) | float | Range minimum dbh value. There are one of each of the following for m_iNumAllowedCutRanges, where x is the index, starting at 0. |
rangemax(x) | float | Range maximum dbh value. There are one of each of the following for m_iNumAllowedCutRanges, where x is the index, starting at 0. |
|
protected |
A newly created package in the grids.
|
protected |
For finding where to place a new package.
|
protected |
Stashed pointer to tree population.
|
protected |
RESULTS GRID.
If this behavior is harvesting, the grid is called "Harvest Results"; if it is episodic mortality, the grid is called "Mortality Episode Results". The grid has a cell resolution matching that of "harvestcutevents/ mortepisodecutevents". This is where data on actual cut/kill results is stored. The data is stored raw - no conversion to per-hectare amounts.
It is possible that a grid map will have been read in for this grid; it will be ignored, and any grid created with such a map will be overwritten.
Data member | Data type | Description |
---|---|---|
Harvest Type | int | Type of harvest that occurred in the current timestep - -1 if none has occurred. |
Cut Density_x_sp | int | Number of trees cut in the current timestep. There are one of each of the following for m_iNumAllowedCutRanges times number of species, where x is the cut range index, starting at 0, and sp is the species number. |
Cut Basal Area_x_sp | float | Total basal area cut in the current timestep. There are one of each of the following for m_iNumAllowedCutRanges times number of species, where x is the cut range index, starting at 0, and sp is the species number. |
|
protected |
TIME SINCE HARVEST.
The grid called "timesinceharvest" will have a cell resolution that matches the harvest results grid. This is where the time since the last harvest is stored.
Data members - all for packages:
Data member | Data type | Description |
---|---|---|
Time | int | Time since last harvest |