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

SelectionHarvest - Version 1.0. More...

#include <SelectionHarvest.h>

Inheritance diagram for clSelectionHarvest:
clBehaviorBase clWorkerBase

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...
 
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 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...
 
clPackagemp_oOldPackage
 For finding where to place a new package. More...
 
clPackagemp_oNewPackage
 A newly created package in the grids. More...
 
clTreePopulationmp_oPop
 Stashed pointer to tree population. More...
 
clGridmp_oMasterCutsGrid
 HARVEST MASTER CUTS. More...
 
clGridmp_oCutEventsGrid
 HARVEST CUT EVENTS. More...
 
clGridmp_oResultsGrid
 RESULTS GRID. More...
 
clGridmp_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...
 
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

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)

Member Enumeration Documentation

◆ amtType

Clear cut.

How amount to cut is defined.

Enumerator
percentBA 

As a percentage of total basal area in cut range.

absBA 

As an amount of BA in sq m in that cut range.

percentDen 

As a percentage of total density in that cut range.

absDen 

◆ cutType

Types of harvest cuts.

These are listed in increasing order of severity (that's important!)

Enumerator
partial 

Partial cut.

gap 

Gap cut.

clear 

Constructor & Destructor Documentation

◆ clSelectionHarvest()

clSelectionHarvest::clSelectionHarvest ( clSimManager p_oSimManager)

Constructor.

Parameters
p_oSimManagerSim Manager object.

◆ ~clSelectionHarvest()

clSelectionHarvest::~clSelectionHarvest ( )

Destructor.

Member Function Documentation

◆ Action()

void clSelectionHarvest::Action ( )
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.

◆ CalculateBasalAreaDifference()

int clSelectionHarvest::CalculateBasalAreaDifference ( double *  p_fCurrentBasalArea)
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.

Parameters
p_fCurrentBasalAreaPointer to array containing the basal area in each size class

◆ CreateMasterCutPackage()

void clSelectionHarvest::CreateMasterCutPackage ( int  iSpecies)
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.

◆ EditCutEventsGrid()

void clSelectionHarvest::EditCutEventsGrid ( )
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.

◆ GetBasalArea() [1/2]

void clSelectionHarvest::GetBasalArea ( clTreePopulation p_oTreePop,
double *  p_fTotalBasalArea,
double *  p_fLoDbh,
double *  p_fHiDbh 
)
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.

Parameters
p_oTreePopPointer to the tree population that will have the selection cut applied to it.
p_fTotalBasalAreaArray (size m_iNumAllowedCutRanges) in which to put the total basal area calculation.
p_fLoDbhArray (size m_iNumAllowedCutRanges) of lower-limit dbhs for the cut ranges that have been defined.
p_fHiDbhArray (size m_iNumAllowedCutRanges) of upper-limit dbhs for the cut ranges that have been defined.

◆ GetBasalArea() [2/2]

void clSelectionHarvest::GetBasalArea ( clTreePopulation p_oTreePop,
int  iSpecies,
double *  p_fTotalBasalArea,
double *  p_fLoDbh,
double *  p_fHiDbh 
)
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.

Parameters
p_oTreePopTree population
iSpeciesSpecies of tree for which to calculate basal area.
p_fTotalBasalAreaArray (size m_iNumAllowedCutRanges) in which to put the total basal area calculation.
p_fLoDbhArray (size m_iNumAllowedCutRanges) of lower-limit dbhs for the cut ranges that have been defined.
p_fHiDbhArray (size m_iNumAllowedCutRanges) of upper-limit dbhs for the cut ranges that have been defined.

◆ GetData()

void clSelectionHarvest::GetData ( xercesc::DOMDocument *  p_oDoc)
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().

Parameters
p_oDocDOM tree of parsed input file.

Implements clWorkerBase.

◆ GetHarvestGrids()

void clSelectionHarvest::GetHarvestGrids ( )
protected

Obtains a pointer to the harvest grids and gets all the return codes.

◆ GetTimeSinceHarvest()

void clSelectionHarvest::GetTimeSinceHarvest ( )

Determines the time that has elapsed since the last harvest for each cell in the harvest results grid.

◆ ValidatePackages()

void clSelectionHarvest::ValidatePackages ( )
protected

Makes sure that the data in the event harvest packages makes sense.

For each cut event (each package) - this checks the following:

  • No negative values in cut ranges
  • Cut ranges do not overlap

Member Data Documentation

◆ m_fBasalAreaDifference

float clSelectionHarvest::m_fBasalAreaDifference[][NUM_SIZE_CLASSES]
protected

The array into which CalculateBasalAreaDifference will place the absolute basal area to remove from each size class.

◆ m_fPlotArea

float clSelectionHarvest::m_fPlotArea
protected

Plot area, in hectares.

◆ m_fTotalBasalArea

float clSelectionHarvest::m_fTotalBasalArea[][NUM_SIZE_CLASSES]
protected

The array into which GetBasalArea will store the Basal area values for each size class.

◆ m_iAmountTypeCode

short int clSelectionHarvest::m_iAmountTypeCode
protected

amttype data member code in "harvestmastercuts" grid

◆ m_iCutIDCode

short int clSelectionHarvest::m_iCutIDCode
protected

id data member code in "harvestcutevents" grid

◆ m_iCutTimestepCode

short int clSelectionHarvest::m_iCutTimestepCode
protected

timestep data member code in "harvestcutevents" grid

◆ m_iCutTypeCode

short int clSelectionHarvest::m_iCutTypeCode
protected

cuttype data member code in "harvestmastercuts" grid

◆ m_iHarvestTypeCode

short int clSelectionHarvest::m_iHarvestTypeCode
protected

Harvest Type data member code in "Harvest Results" grid.

◆ m_iInitialAge

int clSelectionHarvest::m_iInitialAge
protected

Initial age.

◆ m_iMasterIDCode

short int clSelectionHarvest::m_iMasterIDCode
protected

id data member code in "harvestmastercuts" grid

◆ m_iMasterTimestepCode

short int clSelectionHarvest::m_iMasterTimestepCode
protected

timestep data member code in "harvestmastercuts" grid

◆ m_iNumAllowedCutRanges

short int clSelectionHarvest::m_iNumAllowedCutRanges
protected

Number of cut ranges allowed.

◆ m_iNumSpecies

short int clSelectionHarvest::m_iNumSpecies
protected

Total number of species.

◆ m_iTallestFirstCode

short int clSelectionHarvest::m_iTallestFirstCode
protected

tallestfirst data member code in "harvestmastercuts" grid

◆ m_iTime

short int clSelectionHarvest::m_iTime
protected

Data member return code for "time" data member of "timesinceharvest" grid.

◆ mp_fBasalArea

double* clSelectionHarvest::mp_fBasalArea
protected

Holds the basal area of 1 species for each size class.

◆ mp_fHighDBH

double* clSelectionHarvest::mp_fHighDBH
protected

The upper bound for each DBH size class.

◆ mp_fLandscapeBasalArea

double* clSelectionHarvest::mp_fLandscapeBasalArea
protected

Holds the basal area for each size class for all species across the landscape.

◆ mp_fLowDBH

double* clSelectionHarvest::mp_fLowDBH
protected

The lower bound for each DBH size class.

◆ mp_fTargetBA

double* clSelectionHarvest::mp_fTargetBA
protected

To hold the target basal area for each size class, in m2/ha.

◆ mp_fTempTargetBA

double* clSelectionHarvest::mp_fTempTargetBA
protected

Used to ensure that TargetBA does not get overwritten in the CalculateBasalAreaDifference function.

◆ mp_iBaCutCodes

short int** clSelectionHarvest::mp_iBaCutCodes
protected

bacut data member codes in "Harvest Results" grid.

Array size is number cut ranges by number of species

◆ mp_iDenCutCodes

short int** clSelectionHarvest::mp_iDenCutCodes
protected

dencut data member codes in "Harvest Results" grid.

Array size is number cut ranges by number of species

◆ mp_iRangeAmountCodes

short int* clSelectionHarvest::mp_iRangeAmountCodes
protected

rangeamtx data member codes in "harvestmastercuts" grid.

Array size is number cut ranges

◆ mp_iRangeMaxCodes

short int* clSelectionHarvest::mp_iRangeMaxCodes
protected

rangemaxx data member codes in "harvestmastercuts" grid.

Array size is number cut ranges

◆ mp_iRangeMinCodes

short int* clSelectionHarvest::mp_iRangeMinCodes
protected

rangeminx data member codes in "harvestmastercuts" grid.

Array size is number cut ranges

◆ mp_iSpeciesCodes

short int* clSelectionHarvest::mp_iSpeciesCodes
protected

Species data member code in "harvestmastercuts" grid.

Array size is number species. Array index matches species number

◆ mp_oCutEventsGrid

clGrid* clSelectionHarvest::mp_oCutEventsGrid
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

◆ mp_oMasterCutsGrid

clGrid* clSelectionHarvest::mp_oMasterCutsGrid
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) floatRange 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) floatRange minimum dbh value. There are one of each of the following for m_iNumAllowedCutRanges, where x is the index, starting at 0.
rangemax(x) floatRange maximum dbh value. There are one of each of the following for m_iNumAllowedCutRanges, where x is the index, starting at 0.

◆ mp_oNewPackage

clPackage * clSelectionHarvest::mp_oNewPackage
protected

A newly created package in the grids.

◆ mp_oOldPackage

clPackage* clSelectionHarvest::mp_oOldPackage
protected

For finding where to place a new package.

◆ mp_oPop

clTreePopulation* clSelectionHarvest::mp_oPop
protected

Stashed pointer to tree population.

◆ mp_oResultsGrid

clGrid* clSelectionHarvest::mp_oResultsGrid
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_spint 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_spfloat 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.

◆ mp_oTimeSinceHarvestGrid

clGrid* clSelectionHarvest::mp_oTimeSinceHarvestGrid
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 memberData type Description
Time int Time since last harvest

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