FMT 1.2.0
Forest management tools for forest planning
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Friends | List of all members
Graph::FMTLineGraph Class Reference

Simple graph where each action generates a single new vertex (0-—0-—0-—0), used with FMTLayer to simulate the growth and harvest of a single forest stand. More...

#include <FMTLineGraph.h>

Inheritance diagram for Graph::FMTLineGraph:
[legend]
Collaboration diagram for Graph::FMTLineGraph:
[legend]

Public Member Functions

 FMTLineGraph ()
 Default constructor for FMTLineGraph.
 
 ~FMTLineGraph ()=default
 Default destructor for FMTLineGraph.
 
 FMTLineGraph (size_t p_LengthReserve)
 Construct a FMTLineGraph reserving memory for a given length.
 
 FMTLineGraph (size_t p_LengthReserve, const Core::FMTActualDevelopment &p_dev)
 Construct a FMTLineGraph from a base development, reserving memory for a given length.
 
 FMTLineGraph (const FMTLineGraph &rhs)
 Copy constructor for FMTLineGraph.
 
 FMTLineGraph (const FMTGraph< FMTBaseVertexProperties, FMTBaseEdgeProperties > &rhs)
 Construct a FMTLineGraph from its parent FMTGraph.
 
FMTLineGraphoperator= (const FMTLineGraph &rhs)
 Copy assignment operator for FMTLineGraph.
 
FMTLineGraphoperator= (const FMTGraph< FMTBaseVertexProperties, FMTBaseEdgeProperties > &rhs)
 Copy assignment operator from the parent FMTGraph.
 
void setAction (FMTvertex_descriptor active, const int &actionID, const std::vector< Core::FMTDevelopmentPath > &paths)
 Generate a new period container at the end of the line graph.
 
size_t operate (const Core::FMTAction &action, const int &action_id, const Core::FMTTransition &transition, const Core::FMTYields &ylds, const std::vector< Core::FMTTheme > &themes)
 Operate the last active vertex and return the length of the generated development path.
 
void grow (int p_Length=1)
 Grow the last active vertex of the line graph, generating a new edge and vertex.
 
FMTvertex_descriptor getActiveVertex () const
 Return the last active vertex of the graph.
 
int getLastActionId (const int &period) const
 Return the action id of the last edge of a period.
 
std::vector< int > getPeriodActionIds (const int &period, bool p_ordered=true) const
 Return the action ids of every action done in a period, in order.
 
std::vector< FMTPredictorgetPeriodPredictors (const int &period, const Models::FMTModel &model, const std::vector< std::string > &yieldnames, bool periodonevalues=false, bool withGCBMid=true) const
 Return the predictors of a period.
 
int getInEdgeActionId (const FMTvertex_descriptor &vdesc) const
 Return the in edge action id of a vertex.
 
const Core::FMTDevelopmentgetPeriodStartDev (const int &period) const
 Return a reference to the first development (vertex) of a period.
 
const Core::FMTDevelopmentgetPeriodStopDev (const int &period) const
 Return a reference to the last development (vertex) of a period.
 
std::vector< int > randomBuildPeriod (const Models::FMTModel &model, std::default_random_engine &generator, boost::unordered_map< Core::FMTDevelopment, std::vector< int > > &operability, bool dontchoosegrow=false)
 Randomly operate the active vertex to completely build the active period of the graph.
 
std::vector< std::vector< bool > > getActions (const Models::FMTModel &model, const int &fromperiod, std::map< Core::FMTDevelopment, std::vector< bool > > &operability) const
 Return, starting from a period, a vector of booleans per period indicating whether each action is operable.
 
const Core::FMTDevelopmentgetBaseDevelopment () const
 Return a reference to the first development of the graph.
 
size_t getBaseHash (const Core::FMTMask &dynamicmask) const
 Return a hash of the starting development of the line graph based on a dynamic mask filter.
 
std::string getBaseStr (const Core::FMTMask &dynamicmask) const
 Return a string of the starting development of the line graph based on a dynamic mask filter.
 
Core::FMTMask getBaseMask (const Core::FMTMask &dynamicmask) const
 Return a filtered mask of the starting development mask of the line graph based on a dynamic mask filter.
 
void setBaseMask (Core::FMTMask &p_dynamicmask, const int &p_period) const
 Set the base mask to the dynamic mask by intersection for a period.
 
size_t getEdgesHash (const int &maximalperiod, bool &gotthewhole) const
 Return a hash of the edges of the line graph from period 0 to a maximal period.
 
std::string getEdgesStr (const int &maximalperiod, bool &gotthewhole) const
 Return a string representing the edges of the line graph from period 0 to a maximal period.
 
void fillEdgesMask (Core::FMTMask &mask, const int &maximalperiod) const
 Fill a unique mask based on the edges from period 0 to a maximal period.
 
bool stringForConstraint (std::string &value, const int &stop, const Core::FMTMask &dynamicmask) const
 Fill a string used for the uniqueness of the line graph.
 
bool hashForConstraint (size_t &hashvalue, const int &stop, const Core::FMTMask &dynamicmask) const
 Fill a hash used for the uniqueness of the line graph.
 
bool isOnlyGrow (int period=0) const
 Return true if the graph is never operated by any action.
 
bool isMovable (const Models::FMTModel &p_model, const int &period, boost::unordered_map< Core::FMTDevelopment, std::vector< int > > &p_operability) const
 Add actions (edges) and vertices to the graph based on an event.
 
bool operator== (const FMTLineGraph &rhs) const
 Comparison operator for FMTLineGraph.
 
bool operator< (const FMTLineGraph &rhs) const
 Less than operator for FMTLineGraph.
 
bool isLessPeriod (const FMTLineGraph &rhs) const
 Return true if the other graph is the same graph with one less period.
 
bool isSameBase (const FMTLineGraph &rhs) const
 Return true if the other graph has the same base development.
 
bool isNotDead (FMTvertex_descriptor p_Descriptor, int8_t p_DeathId) const
 Return true if a vertex descriptor did not get the death action.
 
void clearNodeCache ()
 Clear the node cache used when getting outputs of the line graph.
 
std::vector< int > anyUsageOf (Core::FMTOutputNode output_node, const Models::FMTModel &model, const int &startingperiod) const
 Return the periods at which the vertices fall within an output node description.
 

Static Public Member Functions

static const std::vector< int > & getSetOperability (const Core::FMTDevelopment &p_development, const Models::FMTModel &p_model, boost::unordered_map< Core::FMTDevelopment, std::vector< int > > &p_Cache)
 Return the operable action ids of a development, computing and caching them if needed.
 

Friends

class boost::serialization::access
 

Detailed Description

Simple graph where each action generates a single new vertex (0-—0-—0-—0), used with FMTLayer to simulate the growth and harvest of a single forest stand.

Heavily used in FMTSesModel and FMTSaModel and normally used with spatially explicit models.

Constructor & Destructor Documentation

◆ FMTLineGraph() [1/5]

Graph::FMTLineGraph::FMTLineGraph ( )

Default constructor for FMTLineGraph.

◆ ~FMTLineGraph()

Graph::FMTLineGraph::~FMTLineGraph ( )
default

Default destructor for FMTLineGraph.

◆ FMTLineGraph() [2/5]

Graph::FMTLineGraph::FMTLineGraph ( size_t  p_LengthReserve)

Construct a FMTLineGraph reserving memory for a given length.

Parameters
[in]p_LengthReservethe size to reserve.

◆ FMTLineGraph() [3/5]

Graph::FMTLineGraph::FMTLineGraph ( size_t  p_LengthReserve,
const Core::FMTActualDevelopment p_dev 
)

Construct a FMTLineGraph from a base development, reserving memory for a given length.

Parameters
[in]p_LengthReservethe size to reserve.
[in]p_devthe base development.

◆ FMTLineGraph() [4/5]

Graph::FMTLineGraph::FMTLineGraph ( const FMTLineGraph rhs)

Copy constructor for FMTLineGraph.

Parameters
[in]rhsthe FMTLineGraph to copy.

◆ FMTLineGraph() [5/5]

Graph::FMTLineGraph::FMTLineGraph ( const FMTGraph< FMTBaseVertexProperties, FMTBaseEdgeProperties > &  rhs)

Construct a FMTLineGraph from its parent FMTGraph.

Parameters
[in]rhsthe parent graph.

Member Function Documentation

◆ anyUsageOf()

std::vector< int > Graph::FMTLineGraph::anyUsageOf ( Core::FMTOutputNode  output_node,
const Models::FMTModel model,
const int &  startingperiod 
) const

Return the periods at which the vertices fall within an output node description.

Parameters
[in]output_nodethe output node.
[in]modelthe model.
[in]startingperiodthe starting period.
Returns
the periods of usage.

◆ clearNodeCache()

void Graph::FMTLineGraph::clearNodeCache ( )

Clear the node cache used when getting outputs of the line graph.

◆ fillEdgesMask()

void Graph::FMTLineGraph::fillEdgesMask ( Core::FMTMask mask,
const int &  maximalperiod 
) const

Fill a unique mask based on the edges from period 0 to a maximal period.

Parameters
[in,out]maskthe mask to fill.
[in]maximalperiodthe maximal period.

◆ getActions()

std::vector< std::vector< bool > > Graph::FMTLineGraph::getActions ( const Models::FMTModel model,
const int &  fromperiod,
std::map< Core::FMTDevelopment, std::vector< bool > > &  operability 
) const

Return, starting from a period, a vector of booleans per period indicating whether each action is operable.

Parameters
[in]modelthe model.
[in]fromperiodthe first period.
[in,out]operabilitythe operability cache.
Returns
the operable actions per period.

◆ getActiveVertex()

FMTvertex_descriptor Graph::FMTLineGraph::getActiveVertex ( ) const

Return the last active vertex of the graph.

Returns
the active vertex.

◆ getBaseDevelopment()

const Core::FMTDevelopment & Graph::FMTLineGraph::getBaseDevelopment ( ) const

Return a reference to the first development of the graph.

Returns
the base development.

◆ getBaseHash()

size_t Graph::FMTLineGraph::getBaseHash ( const Core::FMTMask dynamicmask) const

Return a hash of the starting development of the line graph based on a dynamic mask filter.

Parameters
[in]dynamicmaskthe dynamic mask.
Returns
the base hash.

◆ getBaseMask()

Core::FMTMask Graph::FMTLineGraph::getBaseMask ( const Core::FMTMask dynamicmask) const

Return a filtered mask of the starting development mask of the line graph based on a dynamic mask filter.

Parameters
[in]dynamicmaskthe dynamic mask.
Returns
the base mask.

◆ getBaseStr()

std::string Graph::FMTLineGraph::getBaseStr ( const Core::FMTMask dynamicmask) const

Return a string of the starting development of the line graph based on a dynamic mask filter.

Parameters
[in]dynamicmaskthe dynamic mask.
Returns
the base string.

◆ getEdgesHash()

size_t Graph::FMTLineGraph::getEdgesHash ( const int &  maximalperiod,
bool &  gotthewhole 
) const

Return a hash of the edges of the line graph from period 0 to a maximal period.

Parameters
[in]maximalperiodthe maximal period.
[out]gotthewholetrue if the whole graph was hashed.
Returns
the edges hash.

◆ getEdgesStr()

std::string Graph::FMTLineGraph::getEdgesStr ( const int &  maximalperiod,
bool &  gotthewhole 
) const

Return a string representing the edges of the line graph from period 0 to a maximal period.

Parameters
[in]maximalperiodthe maximal period.
[out]gotthewholetrue if the whole graph was represented.
Returns
the edges string.

◆ getInEdgeActionId()

int Graph::FMTLineGraph::getInEdgeActionId ( const FMTvertex_descriptor &  vdesc) const

Return the in edge action id of a vertex.

Parameters
[in]vdescthe vertex descriptor.
Returns
the in edge action id.

◆ getLastActionId()

int Graph::FMTLineGraph::getLastActionId ( const int &  period) const

Return the action id of the last edge of a period.

Parameters
[in]periodthe period.
Returns
the last action id.

◆ getPeriodActionIds()

std::vector< int > Graph::FMTLineGraph::getPeriodActionIds ( const int &  period,
bool  p_ordered = true 
) const

Return the action ids of every action done in a period, in order.

Parameters
[in]periodthe period.
[in]p_orderedif true returns them ordered.
Returns
the action ids.

◆ getPeriodPredictors()

std::vector< FMTPredictor > Graph::FMTLineGraph::getPeriodPredictors ( const int &  period,
const Models::FMTModel model,
const std::vector< std::string > &  yieldnames,
bool  periodonevalues = false,
bool  withGCBMid = true 
) const

Return the predictors of a period.

Parameters
[in]periodthe period.
[in]modelthe model.
[in]yieldnamesthe yield names.
[in]periodonevaluesif true uses the period one values.
[in]withGCBMidif true uses the GCBM id.
Returns
the predictors.

◆ getPeriodStartDev()

const Core::FMTDevelopment & Graph::FMTLineGraph::getPeriodStartDev ( const int &  period) const

Return a reference to the first development (vertex) of a period.

Parameters
[in]periodthe period.
Returns
the first development.

◆ getPeriodStopDev()

const Core::FMTDevelopment & Graph::FMTLineGraph::getPeriodStopDev ( const int &  period) const

Return a reference to the last development (vertex) of a period.

Parameters
[in]periodthe period.
Returns
the last development.

◆ getSetOperability()

static const std::vector< int > & Graph::FMTLineGraph::getSetOperability ( const Core::FMTDevelopment p_development,
const Models::FMTModel p_model,
boost::unordered_map< Core::FMTDevelopment, std::vector< int > > &  p_Cache 
)
static

Return the operable action ids of a development, computing and caching them if needed.

Parameters
[in]p_developmentthe development.
[in]p_modelthe model.
[in,out]p_Cachethe operability cache.
Returns
the operable action ids.

◆ grow()

void Graph::FMTLineGraph::grow ( int  p_Length = 1)

Grow the last active vertex of the line graph, generating a new edge and vertex.

Parameters
[in]p_Lengththe number of periods to grow.

◆ hashForConstraint()

bool Graph::FMTLineGraph::hashForConstraint ( size_t &  hashvalue,
const int &  stop,
const Core::FMTMask dynamicmask 
) const

Fill a hash used for the uniqueness of the line graph.

Parameters
[in,out]hashvaluethe hash to fill.
[in]stopthe stop period.
[in]dynamicmaskthe dynamic mask.
Returns
true if the whole graph was hashed else false.

◆ isLessPeriod()

bool Graph::FMTLineGraph::isLessPeriod ( const FMTLineGraph rhs) const

Return true if the other graph is the same graph with one less period.

Parameters
[in]rhsthe other graph.
Returns
true if it is the same graph with one less period else false.

◆ isMovable()

bool Graph::FMTLineGraph::isMovable ( const Models::FMTModel p_model,
const int &  period,
boost::unordered_map< Core::FMTDevelopment, std::vector< int > > &  p_operability 
) const

Add actions (edges) and vertices to the graph based on an event.

Return true if the graph can be modified at a period, operated by a different action or turned into natural growth.

Parameters
[in]p_modelthe model.
[in]periodthe period.
[in,out]p_operabilitythe operability cache.
Returns
true if the graph is movable else false.

◆ isNotDead()

bool Graph::FMTLineGraph::isNotDead ( FMTvertex_descriptor  p_Descriptor,
int8_t  p_DeathId 
) const

Return true if a vertex descriptor did not get the death action.

Parameters
[in]p_Descriptorthe vertex descriptor.
[in]p_DeathIdthe death action id.
Returns
true if the vertex is not dead else false.

◆ isOnlyGrow()

bool Graph::FMTLineGraph::isOnlyGrow ( int  period = 0) const

Return true if the graph is never operated by any action.

Parameters
[in]periodthe period.
Returns
true if the graph only grows else false.

◆ isSameBase()

bool Graph::FMTLineGraph::isSameBase ( const FMTLineGraph rhs) const

Return true if the other graph has the same base development.

Parameters
[in]rhsthe other graph.
Returns
true if the base developments are the same else false.

◆ operate()

size_t Graph::FMTLineGraph::operate ( const Core::FMTAction action,
const int &  action_id,
const Core::FMTTransition transition,
const Core::FMTYields ylds,
const std::vector< Core::FMTTheme > &  themes 
)

Operate the last active vertex and return the length of the generated development path.

Parameters
[in]actionthe action.
[in]action_idthe action id.
[in]transitionthe transition.
[in]yldsthe yields.
[in]themesthe themes.
Returns
the length of the generated development path.

◆ operator<()

bool Graph::FMTLineGraph::operator< ( const FMTLineGraph rhs) const

Less than operator for FMTLineGraph.

Parameters
[in]rhsthe FMTLineGraph to compare to.
Returns
true if this line graph is less than the other else false.

◆ operator=() [1/2]

FMTLineGraph & Graph::FMTLineGraph::operator= ( const FMTGraph< FMTBaseVertexProperties, FMTBaseEdgeProperties > &  rhs)

Copy assignment operator from the parent FMTGraph.

Parameters
[in]rhsthe parent graph.
Returns
a reference to this FMTLineGraph.

◆ operator=() [2/2]

FMTLineGraph & Graph::FMTLineGraph::operator= ( const FMTLineGraph rhs)

Copy assignment operator for FMTLineGraph.

Parameters
[in]rhsthe FMTLineGraph to copy.
Returns
a reference to this FMTLineGraph.

◆ operator==()

bool Graph::FMTLineGraph::operator== ( const FMTLineGraph rhs) const

Comparison operator for FMTLineGraph.

Parameters
[in]rhsthe FMTLineGraph to compare to.
Returns
true if both line graphs are equal else false.

◆ randomBuildPeriod()

std::vector< int > Graph::FMTLineGraph::randomBuildPeriod ( const Models::FMTModel model,
std::default_random_engine &  generator,
boost::unordered_map< Core::FMTDevelopment, std::vector< int > > &  operability,
bool  dontchoosegrow = false 
)

Randomly operate the active vertex to completely build the active period of the graph.

Parameters
[in]modelthe model.
[in,out]generatorthe random generator.
[in,out]operabilitythe operability cache.
[in]dontchoosegrowif true does not choose the grow action.
Returns
the action ids of the new edges.

◆ setAction()

void Graph::FMTLineGraph::setAction ( FMTvertex_descriptor  active,
const int &  actionID,
const std::vector< Core::FMTDevelopmentPath > &  paths 
)

Generate a new period container at the end of the line graph.

Add an action edge based on paths on an active vertex.

Parameters
[in]activethe active vertex.
[in]actionIDthe action id.
[in]pathsthe development paths.

◆ setBaseMask()

void Graph::FMTLineGraph::setBaseMask ( Core::FMTMask p_dynamicmask,
const int &  p_period 
) const

Set the base mask to the dynamic mask by intersection for a period.

Parameters
[in,out]p_dynamicmaskthe dynamic mask to intersect.
[in]p_periodthe period.

◆ stringForConstraint()

bool Graph::FMTLineGraph::stringForConstraint ( std::string &  value,
const int &  stop,
const Core::FMTMask dynamicmask 
) const

Fill a string used for the uniqueness of the line graph.

Parameters
[in,out]valuethe string to fill.
[in]stopthe stop period.
[in]dynamicmaskthe dynamic mask.
Returns
true if the whole graph was represented else false.

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

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