![]() |
FMT 1.2.0
Forest management tools for forest planning
|
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>
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. | |
| FMTLineGraph & | operator= (const FMTLineGraph &rhs) |
| Copy assignment operator for FMTLineGraph. | |
| FMTLineGraph & | operator= (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< FMTPredictor > | 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. | |
| int | getInEdgeActionId (const FMTvertex_descriptor &vdesc) const |
| Return the in edge action id of a vertex. | |
| const Core::FMTDevelopment & | getPeriodStartDev (const int &period) const |
| Return a reference to the first development (vertex) of a period. | |
| const Core::FMTDevelopment & | getPeriodStopDev (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::FMTDevelopment & | getBaseDevelopment () 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 |
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.
| Graph::FMTLineGraph::FMTLineGraph | ( | ) |
Default constructor for FMTLineGraph.
|
default |
Default destructor for FMTLineGraph.
| Graph::FMTLineGraph::FMTLineGraph | ( | size_t | p_LengthReserve | ) |
Construct a FMTLineGraph reserving memory for a given length.
| [in] | p_LengthReserve | the size to reserve. |
| 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.
| [in] | p_LengthReserve | the size to reserve. |
| [in] | p_dev | the base development. |
| Graph::FMTLineGraph::FMTLineGraph | ( | const FMTLineGraph & | rhs | ) |
Copy constructor for FMTLineGraph.
| [in] | rhs | the FMTLineGraph to copy. |
| Graph::FMTLineGraph::FMTLineGraph | ( | const FMTGraph< FMTBaseVertexProperties, FMTBaseEdgeProperties > & | rhs | ) |
Construct a FMTLineGraph from its parent FMTGraph.
| [in] | rhs | the parent graph. |
| 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.
| [in] | output_node | the output node. |
| [in] | model | the model. |
| [in] | startingperiod | the starting period. |
| void Graph::FMTLineGraph::clearNodeCache | ( | ) |
Clear the node cache used when getting outputs of the line graph.
| 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.
| [in,out] | mask | the mask to fill. |
| [in] | maximalperiod | the maximal period. |
| 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.
| [in] | model | the model. |
| [in] | fromperiod | the first period. |
| [in,out] | operability | the operability cache. |
| FMTvertex_descriptor Graph::FMTLineGraph::getActiveVertex | ( | ) | const |
Return the last active vertex of the graph.
| const Core::FMTDevelopment & Graph::FMTLineGraph::getBaseDevelopment | ( | ) | const |
Return a reference to the first development of the graph.
| 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.
| [in] | dynamicmask | the dynamic mask. |
| 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.
| [in] | dynamicmask | the dynamic mask. |
| 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.
| [in] | dynamicmask | the dynamic mask. |
| 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.
| [in] | maximalperiod | the maximal period. |
| [out] | gotthewhole | true if the whole graph was hashed. |
| 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.
| [in] | maximalperiod | the maximal period. |
| [out] | gotthewhole | true if the whole graph was represented. |
| int Graph::FMTLineGraph::getInEdgeActionId | ( | const FMTvertex_descriptor & | vdesc | ) | const |
Return the in edge action id of a vertex.
| [in] | vdesc | the vertex descriptor. |
| int Graph::FMTLineGraph::getLastActionId | ( | const int & | period | ) | const |
Return the action id of the last edge of a period.
| [in] | period | the period. |
| 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.
| [in] | period | the period. |
| [in] | p_ordered | if true returns them ordered. |
| 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.
| [in] | period | the period. |
| [in] | model | the model. |
| [in] | yieldnames | the yield names. |
| [in] | periodonevalues | if true uses the period one values. |
| [in] | withGCBMid | if true uses the GCBM id. |
| const Core::FMTDevelopment & Graph::FMTLineGraph::getPeriodStartDev | ( | const int & | period | ) | const |
Return a reference to the first development (vertex) of a period.
| [in] | period | the period. |
| const Core::FMTDevelopment & Graph::FMTLineGraph::getPeriodStopDev | ( | const int & | period | ) | const |
Return a reference to the last development (vertex) of a period.
| [in] | period | the period. |
|
static |
Return the operable action ids of a development, computing and caching them if needed.
| [in] | p_development | the development. |
| [in] | p_model | the model. |
| [in,out] | p_Cache | the operability cache. |
| void Graph::FMTLineGraph::grow | ( | int | p_Length = 1 | ) |
Grow the last active vertex of the line graph, generating a new edge and vertex.
| [in] | p_Length | the number of periods to grow. |
| 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.
| [in,out] | hashvalue | the hash to fill. |
| [in] | stop | the stop period. |
| [in] | dynamicmask | the dynamic mask. |
| bool Graph::FMTLineGraph::isLessPeriod | ( | const FMTLineGraph & | rhs | ) | const |
Return true if the other graph is the same graph with one less period.
| [in] | rhs | the other graph. |
| 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.
| [in] | p_model | the model. |
| [in] | period | the period. |
| [in,out] | p_operability | the operability cache. |
| 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.
| [in] | p_Descriptor | the vertex descriptor. |
| [in] | p_DeathId | the death action id. |
| bool Graph::FMTLineGraph::isOnlyGrow | ( | int | period = 0 | ) | const |
Return true if the graph is never operated by any action.
| [in] | period | the period. |
| bool Graph::FMTLineGraph::isSameBase | ( | const FMTLineGraph & | rhs | ) | const |
Return true if the other graph has the same base development.
| [in] | rhs | the other graph. |
| 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.
| [in] | action | the action. |
| [in] | action_id | the action id. |
| [in] | transition | the transition. |
| [in] | ylds | the yields. |
| [in] | themes | the themes. |
| bool Graph::FMTLineGraph::operator< | ( | const FMTLineGraph & | rhs | ) | const |
Less than operator for FMTLineGraph.
| [in] | rhs | the FMTLineGraph to compare to. |
| FMTLineGraph & Graph::FMTLineGraph::operator= | ( | const FMTGraph< FMTBaseVertexProperties, FMTBaseEdgeProperties > & | rhs | ) |
Copy assignment operator from the parent FMTGraph.
| [in] | rhs | the parent graph. |
| FMTLineGraph & Graph::FMTLineGraph::operator= | ( | const FMTLineGraph & | rhs | ) |
Copy assignment operator for FMTLineGraph.
| [in] | rhs | the FMTLineGraph to copy. |
| bool Graph::FMTLineGraph::operator== | ( | const FMTLineGraph & | rhs | ) | const |
Comparison operator for FMTLineGraph.
| [in] | rhs | the FMTLineGraph to compare to. |
| 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.
| [in] | model | the model. |
| [in,out] | generator | the random generator. |
| [in,out] | operability | the operability cache. |
| [in] | dontchoosegrow | if true does not choose the grow action. |
| 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.
| [in] | active | the active vertex. |
| [in] | actionID | the action id. |
| [in] | paths | the development paths. |
| 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.
| [in,out] | p_dynamicmask | the dynamic mask to intersect. |
| [in] | p_period | the period. |
| 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.
| [in,out] | value | the string to fill. |
| [in] | stop | the stop period. |
| [in] | dynamicmask | the dynamic mask. |
|
friend |