![]() |
FMT 1.2.0
Forest management tools for forest planning
|
Map containing a line graph for each cell, representing the stand, the action and the transition at each period for the cell. More...
#include <FMTSpatialSchedule.h>
Classes | |
| struct | EventSpread |
| Helper holding the input iterator, output iterator and event of an event spread move. More... | |
Public Types | |
| typedef std::vector< std::vector< Spatial::FMTBindingSpatialAction > > | actionbindings |
Public Member Functions | |
| FMTSpatialSchedule ()=default | |
| Default constructor for FMTSpatialSchedule. | |
| virtual | ~FMTSpatialSchedule ()=default |
| Default destructor for FMTSpatialSchedule. | |
| FMTSpatialSchedule & | operator= (const FMTSpatialSchedule &rhs)=default |
| Copy assignment operator for FMTSpatialSchedule. | |
| FMTSpatialSchedule (const FMTSpatialSchedule &other)=default | |
| Copy constructor for FMTSpatialSchedule. | |
| FMTSpatialSchedule (const FMTForest &p_InitialMap, size_t p_LengthReserve, FMTSpatialGraphs &p_SpatialGraph) | |
| Construct a FMTSpatialSchedule from a forest, initializing every graph in the map based on the development types of each cell. | |
| FMTSpatialSchedule (const FMTSpatialSchedule &other, const std::vector< FMTCoordinate >::const_iterator &firstcoord, const std::vector< FMTCoordinate >::const_iterator &endcoord) | |
| Create a partial copy of the complete solution based on coordinates. | |
| bool | operator== (const FMTSpatialSchedule &rhs) const |
| Comparison operator for FMTSpatialSchedule. | |
| bool | operator!= (const FMTSpatialSchedule &rhs) const |
| Comparison operator for FMTSpatialSchedule. | |
| bool | empty () const |
| Test whether the map is empty. | |
| int | actPeriod () const |
| Return the last period in the graph, which is the active one. | |
| FMTForest | getForestPeriod (const int &period, bool periodStart=false) const |
| Return the forest corresponding to a period. | |
| bool | allowAction (const int &targetaction, const std::vector< Spatial::FMTBindingSpatialAction > &bindingactions, const FMTCoordinate &location, const int &period) const |
| Check the events around a location during the green up delay periods to see if a neighboring action is within the adjacency limit. | |
| std::vector< std::set< Spatial::FMTCoordinate > > | getUpdatedScheduling (const Models::FMTModel &model, const std::vector< int > &actiontargets, boost::unordered_map< Core::FMTDevelopment, std::vector< bool > > &cachedaction, const std::vector< boost::unordered_set< Core::FMTDevelopment > > &scheduleoperabilities, bool schedule_only=true, std::vector< std::set< Spatial::FMTCoordinate > > original=std::vector< std::set< Spatial::FMTCoordinate > >(), std::vector< FMTCoordinate > updatedcoordinate=std::vector< FMTCoordinate >()) const |
| Return, for all actions, the coordinates with operable developments at the end of the graph. | |
| double | evaluateSpatialConstraint (const Core::FMTConstraint &p_SpatialConstraint, const FMTSpatialGraphs &p_SpatialGraph) const |
| Return the evaluation value of a spatial constraint. | |
| std::set< FMTCoordinate > | verifySpatialFeasibility (const int &targetaction, const std::vector< Spatial::FMTBindingSpatialAction > &bindingactions, const int &period, const std::set< FMTCoordinate > &operables) const |
| Return the evaluation value of a distance spatial constraint. | |
| FMTEventContainer | buildHarvest (const double &target, const Spatial::FMTBindingSpatialAction &targetaction, std::default_random_engine &generator, std::set< FMTCoordinate > mapping_pass, const int &previousperiod, const int &actionid, std::vector< FMTCoordinate > &operated) const |
| Build a container of harvest events for a target action until the area target is reached. | |
| double | operateEvents (const FMTEventContainer &cuts, const Core::FMTAction &action, const int &action_id, const Core::FMTTransition &Transition, const Core::FMTYields &ylds, const std::vector< Core::FMTTheme > &themes) |
| Operate a container of events for an action and return the operated area. | |
| void | operateCoord (const FMTCoordinate &coord, const Core::FMTAction &action, const int &action_id, const FMTBindingSpatialAction &bindingspaction, const Core::FMTTransition &Transition, const Core::FMTYields &ylds, const std::vector< Core::FMTTheme > &themes) |
| Operate a coordinate and add it to the events. | |
| void | grow () |
| Grow every graph of the schedule by one period. | |
| std::vector< Core::FMTSchedule > | getSchedules (const FMTSpatialGraphs p_Graphs, bool withlock=false) const |
| Set a new period in the schedule. | |
| std::vector< int > | isBetterThan (const FMTSpatialSchedule &newsolution, const Spatial::FMTSpatialGraphs &p_Graphs) const |
| Compare two spatial schedules and return, for each constraint group, true if this solution has a better value than the compared one. | |
| double | getConstraintEvaluation (const FMTSpatialGraphs &p_Graphs, size_t p_ConstraintId) const |
| Return the evaluated value of a solution constraint. | |
| std::vector< double > | getConstraintsValues (const Spatial::FMTSpatialGraphs &p_Graphs) const |
| Return the values of each constraint, used for normalization. | |
| std::vector< double > | getWeightedFactors (const Spatial::FMTSpatialGraphs &p_Graphs) const |
| Generate the constraint factors based on the actual solution. | |
| double | getPrimalInfeasibility (const std::vector< const Core::FMTConstraint * > &constraints, const Spatial::FMTSpatialGraphs &p_Graphs, bool withfactorization=false) const |
| Return the primal infeasibility of a set of constraints. | |
| void | logSolutionStatus (const size_t &iteration, const double &objective, const double &primalinfeasibility) const |
| Log the status of the solution. | |
| void | getSolutionStatus (double &objective, double &primalinfeasibility, const FMTSpatialGraphs &p_Graphs, bool withsense=true, bool withfactorization=false, bool withspatial=true) const |
| Get the objective value and the primal infeasibility of the solution. | |
| double | getGlobalObjective (const FMTSpatialGraphs &p_Graphs) const |
| Return the global objective, mixing the objective and the infeasibility, where a lower value is a better solution. | |
| double | getObjectiveValue (const FMTSpatialGraphs &p_Graphs, bool withsense=true) const |
| Return the objective value of the spatial schedule. | |
| std::string | getPatchStats (const std::vector< Core::FMTAction > &actions) const |
| Return the patch statistics (area, perimeter) of the events for a set of actions. | |
| FMTLayer< std::string > | lastDistLayer (const std::vector< Core::FMTAction > &modelactions, const int &period) const |
| Return a layer with the sum of all the graph outputs related to a constraint for a period. | |
| std::vector< Core::FMTGCBMTransition > | getGCBMtransitions (FMTLayer< std::string > &stackedactions, const std::vector< Core::FMTAction > &modelactions, const std::vector< Core::FMTTheme > &classifiers, const int &period) const |
| Return the GCBM transitions of the solution and fill a layer with the stacked actions. | |
| std::vector< std::vector< Graph::FMTPredictor > > | getPredictors (FMTLayer< int > &predictorids, const Models::FMTModel &model, const std::vector< std::string > &yieldnames, const int &period, bool periodonevalues=false, bool withGCBMid=true) const |
| Get the predictors for the whole solution and write the predictor ids into a layer. | |
| void | eraseLastPeriod () |
| Erase the last period of the FMTSpatialSchedule. | |
| std::vector< Spatial::FMTBindingSpatialAction > | getBindingActions (const Models::FMTModel &model, const int &period) const |
| Get the binding actions based on the model constraints for a period. | |
| actionbindings | getBindingActionsByPeriod (const Models::FMTModel &model) const |
| Get the binding actions based on the model constraints in a vector by period. | |
| std::map< std::string, double > | referenceBuild (const Core::FMTSchedule &schedule, const Models::FMTModel &model, const std::vector< boost::unordered_set< Core::FMTDevelopment > > &scheduleoperabilities, std::default_random_engine &p_randomEngine, bool schedule_only=true, bool scheduleatfirstpass=true) |
| Simulate a schedule of actions on the actual spatially explicit forest. | |
| std::map< std::string, double > | greedyReferenceBuild (const Core::FMTSchedule &schedule, const FMTSpatialGraphs &p_Graphs, const size_t &randomiterations, unsigned int seed=0, double tolerance=FMT_DBL_TOLERANCE, bool log=true) |
| Call the simulate function multiple times to find the best possible spatialization for a schedule using random draws. | |
| Graph::FMTGraphStats | randomBuild (const Models::FMTModel &model, std::default_random_engine &generator) |
| Randomly create a solution for one period using a generator. | |
| void | setGrow (const std::vector< FMTCoordinate > &p_coordinates, const Models::FMTModel &p_model) |
| Set natural growth on coordinates, removing every action. | |
| void | perturbGraph (const FMTCoordinate &coordinate, const int &period, const Models::FMTModel &model, std::default_random_engine &generator, const actionbindings &bindings) |
| Change one graph in the solution, removing its contribution to the objective and adding the contribution of the newly generated one. | |
| bool | isBetterByGroup (const FMTSpatialSchedule &rhs, const FMTSpatialGraphs &p_Graphs) const |
| Compare this solution to another one by constraint group. | |
| void | swap (FMTSpatialSchedule &rhs) |
| Swap this FMTSpatialSchedule with another one. | |
| std::vector< Spatial::FMTCoordinate > | getMovableCoordinates (const Models::FMTModel &model, const int &period) const |
| Return the coordinates where something can be operated for a period. | |
| int | getPeriodWithMaximalEvents (const std::vector< bool > &actions) const |
| Return the period with the maximal number of events for a set of actions. | |
| std::vector< std::vector< Spatial::FMTCoordinate > > | getAreaConflictCoordinates (const actionbindings &bindingactions, const int &period, bool conflictonly=true) const |
| Return the coordinates of the events that do not have the right area in the worst period. | |
| std::vector< std::vector< Spatial::FMTCoordinate > > | getAdjacencyConflictCoordinates (const actionbindings &bindingactions, const int &period, bool conflictonly=true) const |
| Return the adjacency conflict coordinates that need to be destroyed. | |
| bool | isPartial () const |
| Return true if the solution is partial. | |
| bool | emptyEvents () const |
| Return true if there are no events. | |
| void | copyFromPartial (const FMTSpatialSchedule &rhs) |
| Copy the elements from a partial solution. | |
| void | copyFromPartial (FMTSpatialSchedule &rhs) |
| Copy the elements from a partial solution, also allowing a swap. | |
| void | setConstraintsFactor (const Models::FMTModel &model, const std::vector< double > &factors) |
| Set the constraint factors for normalization. | |
| bool | needsRefactorization (const FMTSpatialGraphs &p_Graphs) const |
| Return true if the solution looks unscaled and needs new factors. | |
| const std::vector< double > & | getConstraintsFactor () const |
| Get the constraint factors for normalization. | |
| std::map< std::string, double > | getOutput (const FMTSpatialGraphs &p_Graphs, const Core::FMTOutput &p_output, int p_period, Core::FMToutputlevel level=Core::FMToutputlevel::totalonly) const |
| Get the output value for a period using the solution. | |
| FMTLayer< double > | getSpatialOutput (const Models::FMTModel &model, const Core::FMTOutput &output, const int &period) const |
| Get the output value for the whole layer for a period and an output. | |
| std::vector< std::pair< FMTCoordinate, double > > | getOutputByCoordinate (const Models::FMTModel &model, const Core::FMTOutput &output, const int &period) const |
| Return the output value by coordinate for an output, a model and a period. | |
| void | postSolve (const Core::FMTMaskFilter &p_Filter, const std::vector< Core::FMTAction > &p_PresolveActions, Spatial::FMTSpatialGraphs &p_Graphs) |
| Postsolve the spatial solution. | |
| FMTSpatialSchedule | preSolve (const Core::FMTMaskFilter &p_filter, FMTSpatialGraphs &p_Graphs, size_t p_ReserveSize) const |
| Return a presolved solution of the original solution. | |
| std::vector< Core::FMTActualDevelopment > | getArea (int period=0, bool beforegrowanddeath=false) const |
| Get the area of a period based on the solution. | |
| FMTSpatialSchedule | getBaseSchedule (const FMTSpatialGraphs &p_SpatialGraph) const |
| Return the base schedule of the spatial graphs. | |
| void | setSpatialGraphs (const Spatial::FMTSpatialSchedule &p_ToCopy, FMTSpatialGraphs &p_SpatialGraph) |
| Set the spatial graphs from another schedule. | |
| std::vector< FMTCoordinate > | getGroupsConflict (const Core::FMTConstraint &p_SpatialConstraint, const FMTSpatialGraphs &p_SpatialGraph) const |
| Return the coordinates in conflict with a group spatial constraint. | |
| std::vector< EventSpread > | getPotentialSpread (int p_period) |
| Return the potential event spreads for a period. | |
| bool | canDoEventSpread (int p_period) const |
| Return true if an event spread can be done for a period. | |
| void | setSpread (std::vector< EventSpread >::const_iterator p_first, std::vector< EventSpread >::const_iterator p_end) |
| Apply a range of event spreads to the solution. | |
| void | setStaticsMovableCoordinates (const Models::FMTModel &p_model) |
| Set the static movable coordinates from a model. | |
| void | enableSolutionTracker (const FMTSpatialGraphs &p_SpatialGraph) |
| Enable the non spatial solution tracker using the spatial graphs. | |
| void | disableSolutionTracker () |
| Disable the non spatial solution tracker. | |
Protected Member Functions | |
| std::vector< const Graph::FMTLineGraph * > | _getFromEvents (const Core::FMTConstraint &constraint, const std::vector< Core::FMTAction > &actions, const int &start, const int &stop) const |
| Return the line graphs of the events for a constraint, actions and a period range. | |
| std::vector< FMTCoordinate > | _getFromEvents (const Core::FMTOutputNode &node, const std::vector< Core::FMTAction > &actions, const int &period) const |
| Return the coordinates present in the events for an output node, actions and a period. | |
| std::map< std::string, double > | _getOutputFromGraph (const Graph::FMTLineGraph &linegraph, const Models::FMTModel &model, const Core::FMTOutputNode &node, const double *solution, const int &period, const Core::FMTMask &nodemask, boost::unordered_map< Core::FMTMask, double > &nodecache, const Core::FMTTheme *p_theme, Core::FMToutputlevel level=Core::FMToutputlevel::totalonly) const |
| Get the requested output from a line graph into the period values. | |
| bool | _inScheduleOperabilities (const std::vector< boost::unordered_set< Core::FMTDevelopment > > &scheduleoperabilities, Core::FMTDevelopment const *dev, const int &actionid, const Core::FMTAction &action) const |
| Return the maximal patch size of a vector of spatial actions. | |
Map containing a line graph for each cell, representing the stand, the action and the transition at each period for the cell.
It can be built randomly or with a schedule.
| typedef std::vector<std::vector<Spatial::FMTBindingSpatialAction> > Spatial::FMTSpatialSchedule::actionbindings |
|
default |
Default constructor for FMTSpatialSchedule.
|
virtualdefault |
Default destructor for FMTSpatialSchedule.
|
default |
Copy constructor for FMTSpatialSchedule.
| [in] | other | the FMTSpatialSchedule to copy. |
| Spatial::FMTSpatialSchedule::FMTSpatialSchedule | ( | const FMTForest & | p_InitialMap, |
| size_t | p_LengthReserve, | ||
| FMTSpatialGraphs & | p_SpatialGraph | ||
| ) |
Construct a FMTSpatialSchedule from a forest, initializing every graph in the map based on the development types of each cell.
| [in] | p_InitialMap | the initial map of the schedule. |
| [in] | p_LengthReserve | the amount of memory to reserve for each line graph. |
| [in,out] | p_SpatialGraph | the spatial graphs. |
| Spatial::FMTSpatialSchedule::FMTSpatialSchedule | ( | const FMTSpatialSchedule & | other, |
| const std::vector< FMTCoordinate >::const_iterator & | firstcoord, | ||
| const std::vector< FMTCoordinate >::const_iterator & | endcoord | ||
| ) |
Create a partial copy of the complete solution based on coordinates.
| [in] | other | the complete solution. |
| [in] | firstcoord | the first coordinate. |
| [in] | endcoord | the end coordinate. |
|
protected |
Return the line graphs of the events for a constraint, actions and a period range.
| [in] | constraint | the constraint. |
| [in] | actions | the actions. |
| [in] | start | the start period. |
| [in] | stop | the stop period. |
|
protected |
Return the coordinates present in the events for an output node, actions and a period.
| [in] | node | the output node. |
| [in] | actions | the actions. |
| [in] | period | the period. |
|
protected |
Get the requested output from a line graph into the period values.
| [in] | linegraph | the line graph. |
| [in] | model | the model. |
| [in] | node | the output node. |
| [in] | solution | the solution. |
| [in] | period | the period. |
| [in] | nodemask | the node mask. |
| [in,out] | nodecache | the node cache. |
| [in] | p_theme | the theme. |
| [in] | level | the output level. |
|
protected |
Return the maximal patch size of a vector of spatial actions.
Return true if a development is operable for an action in the schedule operabilities.
| [in] | scheduleoperabilities | the schedule operabilities. |
| [in] | dev | the development. |
| [in] | actionid | the action id. |
| [in] | action | the action. |
| int Spatial::FMTSpatialSchedule::actPeriod | ( | ) | const |
Return the last period in the graph, which is the active one.
| bool Spatial::FMTSpatialSchedule::allowAction | ( | const int & | targetaction, |
| const std::vector< Spatial::FMTBindingSpatialAction > & | bindingactions, | ||
| const FMTCoordinate & | location, | ||
| const int & | period | ||
| ) | const |
Check the events around a location during the green up delay periods to see if a neighboring action is within the adjacency limit.
| [in] | targetaction | the target action. |
| [in] | bindingactions | the binding actions. |
| [in] | location | the location. |
| [in] | period | the period. |
| FMTEventContainer Spatial::FMTSpatialSchedule::buildHarvest | ( | const double & | target, |
| const Spatial::FMTBindingSpatialAction & | targetaction, | ||
| std::default_random_engine & | generator, | ||
| std::set< FMTCoordinate > | mapping_pass, | ||
| const int & | previousperiod, | ||
| const int & | actionid, | ||
| std::vector< FMTCoordinate > & | operated | ||
| ) | const |
Build a container of harvest events for a target action until the area target is reached.
| [in] | target | the area target. |
| [in] | targetaction | the target binding action. |
| [in,out] | generator | the random generator. |
| [in] | mapping_pass | the candidate coordinates. |
| [in] | previousperiod | the previous period. |
| [in] | actionid | the action id. |
| [in,out] | operated | the operated coordinates. |
| bool Spatial::FMTSpatialSchedule::canDoEventSpread | ( | int | p_period | ) | const |
Return true if an event spread can be done for a period.
| [in] | p_period | the period. |
| void Spatial::FMTSpatialSchedule::copyFromPartial | ( | const FMTSpatialSchedule & | rhs | ) |
Copy the elements from a partial solution.
| [in] | rhs | the partial solution to copy. |
| void Spatial::FMTSpatialSchedule::copyFromPartial | ( | FMTSpatialSchedule & | rhs | ) |
Copy the elements from a partial solution, also allowing a swap.
| [in,out] | rhs | the partial solution to copy. |
| void Spatial::FMTSpatialSchedule::disableSolutionTracker | ( | ) |
Disable the non spatial solution tracker.
|
inline |
Test whether the map is empty.
| bool Spatial::FMTSpatialSchedule::emptyEvents | ( | ) | const |
Return true if there are no events.
| void Spatial::FMTSpatialSchedule::enableSolutionTracker | ( | const FMTSpatialGraphs & | p_SpatialGraph | ) |
Enable the non spatial solution tracker using the spatial graphs.
| [in] | p_SpatialGraph | the spatial graphs. |
| void Spatial::FMTSpatialSchedule::eraseLastPeriod | ( | ) |
Erase the last period of the FMTSpatialSchedule.
| double Spatial::FMTSpatialSchedule::evaluateSpatialConstraint | ( | const Core::FMTConstraint & | p_SpatialConstraint, |
| const FMTSpatialGraphs & | p_SpatialGraph | ||
| ) | const |
Return the evaluation value of a spatial constraint.
| [in] | p_SpatialConstraint | the spatial constraint. |
| [in] | p_SpatialGraph | the spatial graphs. |
| std::vector< std::vector< Spatial::FMTCoordinate > > Spatial::FMTSpatialSchedule::getAdjacencyConflictCoordinates | ( | const actionbindings & | bindingactions, |
| const int & | period, | ||
| bool | conflictonly = true |
||
| ) | const |
Return the adjacency conflict coordinates that need to be destroyed.
| [in] | bindingactions | the binding actions. |
| [in] | period | the period. |
| [in] | conflictonly | if true returns only the conflicting coordinates. |
| std::vector< Core::FMTActualDevelopment > Spatial::FMTSpatialSchedule::getArea | ( | int | period = 0, |
| bool | beforegrowanddeath = false |
||
| ) | const |
Get the area of a period based on the solution.
| [in] | period | the period. |
| [in] | beforegrowanddeath | if true returns before growth and death. |
| std::vector< std::vector< Spatial::FMTCoordinate > > Spatial::FMTSpatialSchedule::getAreaConflictCoordinates | ( | const actionbindings & | bindingactions, |
| const int & | period, | ||
| bool | conflictonly = true |
||
| ) | const |
Return the coordinates of the events that do not have the right area in the worst period.
| [in] | bindingactions | the binding actions. |
| [in] | period | the period. |
| [in] | conflictonly | if true returns only the conflicting coordinates. |
| FMTSpatialSchedule Spatial::FMTSpatialSchedule::getBaseSchedule | ( | const FMTSpatialGraphs & | p_SpatialGraph | ) | const |
Return the base schedule of the spatial graphs.
| [in] | p_SpatialGraph | the spatial graphs. |
| std::vector< Spatial::FMTBindingSpatialAction > Spatial::FMTSpatialSchedule::getBindingActions | ( | const Models::FMTModel & | model, |
| const int & | period | ||
| ) | const |
Get the binding actions based on the model constraints for a period.
| [in] | model | the model. |
| [in] | period | the period. |
| actionbindings Spatial::FMTSpatialSchedule::getBindingActionsByPeriod | ( | const Models::FMTModel & | model | ) | const |
Get the binding actions based on the model constraints in a vector by period.
| [in] | model | the model. |
| double Spatial::FMTSpatialSchedule::getConstraintEvaluation | ( | const FMTSpatialGraphs & | p_Graphs, |
| size_t | p_ConstraintId | ||
| ) | const |
Return the evaluated value of a solution constraint.
| [in] | p_Graphs | the spatial graphs. |
| [in] | p_ConstraintId | the constraint id. |
| const std::vector< double > & Spatial::FMTSpatialSchedule::getConstraintsFactor | ( | ) | const |
Get the constraint factors for normalization.
| std::vector< double > Spatial::FMTSpatialSchedule::getConstraintsValues | ( | const Spatial::FMTSpatialGraphs & | p_Graphs | ) | const |
Return the values of each constraint, used for normalization.
| [in] | p_Graphs | the spatial graphs. |
| FMTForest Spatial::FMTSpatialSchedule::getForestPeriod | ( | const int & | period, |
| bool | periodStart = false |
||
| ) | const |
Return the forest corresponding to a period.
If periodStart is true the forest is the one before the actions were set, otherwise the one after.
| [in] | period | the period. |
| [in] | periodStart | if true returns the forest before the actions. |
| std::vector< Core::FMTGCBMTransition > Spatial::FMTSpatialSchedule::getGCBMtransitions | ( | FMTLayer< std::string > & | stackedactions, |
| const std::vector< Core::FMTAction > & | modelactions, | ||
| const std::vector< Core::FMTTheme > & | classifiers, | ||
| const int & | period | ||
| ) | const |
Return the GCBM transitions of the solution and fill a layer with the stacked actions.
| [in,out] | stackedactions | the stacked actions layer. |
| [in] | modelactions | the model actions. |
| [in] | classifiers | the classifiers. |
| [in] | period | the period. |
| double Spatial::FMTSpatialSchedule::getGlobalObjective | ( | const FMTSpatialGraphs & | p_Graphs | ) | const |
Return the global objective, mixing the objective and the infeasibility, where a lower value is a better solution.
The returned value can be negative.
| [in] | p_Graphs | the spatial graphs. |
| std::vector< FMTCoordinate > Spatial::FMTSpatialSchedule::getGroupsConflict | ( | const Core::FMTConstraint & | p_SpatialConstraint, |
| const FMTSpatialGraphs & | p_SpatialGraph | ||
| ) | const |
Return the coordinates in conflict with a group spatial constraint.
| [in] | p_SpatialConstraint | the spatial constraint. |
| [in] | p_SpatialGraph | the spatial graphs. |
| std::vector< Spatial::FMTCoordinate > Spatial::FMTSpatialSchedule::getMovableCoordinates | ( | const Models::FMTModel & | model, |
| const int & | period | ||
| ) | const |
Return the coordinates where something can be operated for a period.
| [in] | model | the model. |
| [in] | period | the period. |
| double Spatial::FMTSpatialSchedule::getObjectiveValue | ( | const FMTSpatialGraphs & | p_Graphs, |
| bool | withsense = true |
||
| ) | const |
Return the objective value of the spatial schedule.
| [in] | p_Graphs | the spatial graphs. |
| [in] | withsense | if true applies the sense. |
| std::map< std::string, double > Spatial::FMTSpatialSchedule::getOutput | ( | const FMTSpatialGraphs & | p_Graphs, |
| const Core::FMTOutput & | p_output, | ||
| int | p_period, | ||
| Core::FMToutputlevel | level = Core::FMToutputlevel::totalonly |
||
| ) | const |
Get the output value for a period using the solution.
The map key is the output name when level is standard or totalonly, or the development name when level is developpement.
| [in] | p_Graphs | the spatial graphs. |
| [in] | p_output | the output. |
| [in] | p_period | the period. |
| [in] | level | the output level. |
| std::vector< std::pair< FMTCoordinate, double > > Spatial::FMTSpatialSchedule::getOutputByCoordinate | ( | const Models::FMTModel & | model, |
| const Core::FMTOutput & | output, | ||
| const int & | period | ||
| ) | const |
Return the output value by coordinate for an output, a model and a period.
| [in] | model | the model. |
| [in] | output | the output. |
| [in] | period | the period. |
| std::string Spatial::FMTSpatialSchedule::getPatchStats | ( | const std::vector< Core::FMTAction > & | actions | ) | const |
Return the patch statistics (area, perimeter) of the events for a set of actions.
| [in] | actions | the actions. |
| int Spatial::FMTSpatialSchedule::getPeriodWithMaximalEvents | ( | const std::vector< bool > & | actions | ) | const |
Return the period with the maximal number of events for a set of actions.
| [in] | actions | the actions. |
| std::vector< EventSpread > Spatial::FMTSpatialSchedule::getPotentialSpread | ( | int | p_period | ) |
Return the potential event spreads for a period.
| [in] | p_period | the period. |
| std::vector< std::vector< Graph::FMTPredictor > > Spatial::FMTSpatialSchedule::getPredictors | ( | FMTLayer< int > & | predictorids, |
| const Models::FMTModel & | model, | ||
| const std::vector< std::string > & | yieldnames, | ||
| const int & | period, | ||
| bool | periodonevalues = false, |
||
| bool | withGCBMid = true |
||
| ) | const |
Get the predictors for the whole solution and write the predictor ids into a layer.
| [in,out] | predictorids | the predictor ids layer. |
| [in] | model | the model. |
| [in] | yieldnames | the yield names. |
| [in] | period | the period. |
| [in] | periodonevalues | if true uses the period one values. |
| [in] | withGCBMid | if true uses the GCBM id. |
| double Spatial::FMTSpatialSchedule::getPrimalInfeasibility | ( | const std::vector< const Core::FMTConstraint * > & | constraints, |
| const Spatial::FMTSpatialGraphs & | p_Graphs, | ||
| bool | withfactorization = false |
||
| ) | const |
Return the primal infeasibility of a set of constraints.
| [in] | constraints | the constraints. |
| [in] | p_Graphs | the spatial graphs. |
| [in] | withfactorization | if true applies the factorization. |
| std::vector< Core::FMTSchedule > Spatial::FMTSpatialSchedule::getSchedules | ( | const FMTSpatialGraphs | p_Graphs, |
| bool | withlock = false |
||
| ) | const |
Set a new period in the schedule.
Return the operated schedules from the line graphs.
| [in] | p_Graphs | the spatial graphs. |
| [in] | withlock | if true includes the locked developments. |
| void Spatial::FMTSpatialSchedule::getSolutionStatus | ( | double & | objective, |
| double & | primalinfeasibility, | ||
| const FMTSpatialGraphs & | p_Graphs, | ||
| bool | withsense = true, |
||
| bool | withfactorization = false, |
||
| bool | withspatial = true |
||
| ) | const |
Get the objective value and the primal infeasibility of the solution.
| [out] | objective | the objective value. |
| [out] | primalinfeasibility | the primal infeasibility. |
| [in] | p_Graphs | the spatial graphs. |
| [in] | withsense | if true applies the sense. |
| [in] | withfactorization | if true applies the factorization. |
| [in] | withspatial | if true includes the spatial part. |
| FMTLayer< double > Spatial::FMTSpatialSchedule::getSpatialOutput | ( | const Models::FMTModel & | model, |
| const Core::FMTOutput & | output, | ||
| const int & | period | ||
| ) | const |
Get the output value for the whole layer for a period and an output.
| [in] | model | the model. |
| [in] | output | the output. |
| [in] | period | the period. |
| std::vector< std::set< Spatial::FMTCoordinate > > Spatial::FMTSpatialSchedule::getUpdatedScheduling | ( | const Models::FMTModel & | model, |
| const std::vector< int > & | actiontargets, | ||
| boost::unordered_map< Core::FMTDevelopment, std::vector< bool > > & | cachedaction, | ||
| const std::vector< boost::unordered_set< Core::FMTDevelopment > > & | scheduleoperabilities, | ||
| bool | schedule_only = true, |
||
| std::vector< std::set< Spatial::FMTCoordinate > > | original = std::vector< std::set< Spatial::FMTCoordinate > >(), |
||
| std::vector< FMTCoordinate > | updatedcoordinate = std::vector< FMTCoordinate >() |
||
| ) | const |
Return, for all actions, the coordinates with operable developments at the end of the graph.
| [in] | model | the model. |
| [in] | actiontargets | the action targets. |
| [in,out] | cachedaction | the operability cache per development. |
| [in] | scheduleoperabilities | the schedule operabilities. |
| [in] | schedule_only | if true only considers the developments of the schedule. |
| [in] | original | the original scheduling. |
| [in] | updatedcoordinate | the updated coordinates. |
| std::vector< double > Spatial::FMTSpatialSchedule::getWeightedFactors | ( | const Spatial::FMTSpatialGraphs & | p_Graphs | ) | const |
Generate the constraint factors based on the actual solution.
| [in] | p_Graphs | the spatial graphs. |
| std::map< std::string, double > Spatial::FMTSpatialSchedule::greedyReferenceBuild | ( | const Core::FMTSchedule & | schedule, |
| const FMTSpatialGraphs & | p_Graphs, | ||
| const size_t & | randomiterations, | ||
| unsigned int | seed = 0, |
||
| double | tolerance = FMT_DBL_TOLERANCE, |
||
| bool | log = true |
||
| ) |
Call the simulate function multiple times to find the best possible spatialization for a schedule using random draws.
| [in] | schedule | the schedule. |
| [in] | p_Graphs | the spatial graphs. |
| [in] | randomiterations | the number of random iterations. |
| [in] | seed | the seed. |
| [in] | tolerance | the tolerance. |
| [in] | log | if true logs the process. |
| void Spatial::FMTSpatialSchedule::grow | ( | ) |
Grow every graph of the schedule by one period.
| bool Spatial::FMTSpatialSchedule::isBetterByGroup | ( | const FMTSpatialSchedule & | rhs, |
| const FMTSpatialGraphs & | p_Graphs | ||
| ) | const |
Compare this solution to another one by constraint group.
| [in] | rhs | the solution to compare to. |
| [in] | p_Graphs | the spatial graphs. |
| std::vector< int > Spatial::FMTSpatialSchedule::isBetterThan | ( | const FMTSpatialSchedule & | newsolution, |
| const Spatial::FMTSpatialGraphs & | p_Graphs | ||
| ) | const |
Compare two spatial schedules and return, for each constraint group, true if this solution has a better value than the compared one.
| [in] | newsolution | the solution to compare to. |
| [in] | p_Graphs | the spatial graphs. |
| bool Spatial::FMTSpatialSchedule::isPartial | ( | ) | const |
Return true if the solution is partial.
| FMTLayer< std::string > Spatial::FMTSpatialSchedule::lastDistLayer | ( | const std::vector< Core::FMTAction > & | modelactions, |
| const int & | period | ||
| ) | const |
Return a layer with the sum of all the graph outputs related to a constraint for a period.
| [in] | modelactions | the model actions. |
| [in] | period | the period. |
| void Spatial::FMTSpatialSchedule::logSolutionStatus | ( | const size_t & | iteration, |
| const double & | objective, | ||
| const double & | primalinfeasibility | ||
| ) | const |
Log the status of the solution.
| [in] | iteration | the iteration. |
| [in] | objective | the objective value. |
| [in] | primalinfeasibility | the primal infeasibility. |
| bool Spatial::FMTSpatialSchedule::needsRefactorization | ( | const FMTSpatialGraphs & | p_Graphs | ) | const |
Return true if the solution looks unscaled and needs new factors.
| [in] | p_Graphs | the spatial graphs. |
| void Spatial::FMTSpatialSchedule::operateCoord | ( | const FMTCoordinate & | coord, |
| const Core::FMTAction & | action, | ||
| const int & | action_id, | ||
| const FMTBindingSpatialAction & | bindingspaction, | ||
| const Core::FMTTransition & | Transition, | ||
| const Core::FMTYields & | ylds, | ||
| const std::vector< Core::FMTTheme > & | themes | ||
| ) |
Operate a coordinate and add it to the events.
| [in] | coord | the coordinate. |
| [in] | action | the action. |
| [in] | action_id | the action id. |
| [in] | bindingspaction | the binding spatial action. |
| [in] | Transition | the transition. |
| [in] | ylds | the yields. |
| [in] | themes | the themes. |
| double Spatial::FMTSpatialSchedule::operateEvents | ( | const FMTEventContainer & | cuts, |
| const Core::FMTAction & | action, | ||
| const int & | action_id, | ||
| const Core::FMTTransition & | Transition, | ||
| const Core::FMTYields & | ylds, | ||
| const std::vector< Core::FMTTheme > & | themes | ||
| ) |
Operate a container of events for an action and return the operated area.
| [in] | cuts | the events to operate. |
| [in] | action | the action. |
| [in] | action_id | the action id. |
| [in] | Transition | the transition. |
| [in] | ylds | the yields. |
| [in] | themes | the themes. |
| bool Spatial::FMTSpatialSchedule::operator!= | ( | const FMTSpatialSchedule & | rhs | ) | const |
Comparison operator for FMTSpatialSchedule.
| [in] | rhs | the FMTSpatialSchedule to compare to. |
|
default |
Copy assignment operator for FMTSpatialSchedule.
| [in] | rhs | the FMTSpatialSchedule to copy. |
| bool Spatial::FMTSpatialSchedule::operator== | ( | const FMTSpatialSchedule & | rhs | ) | const |
Comparison operator for FMTSpatialSchedule.
| [in] | rhs | the FMTSpatialSchedule to compare to. |
| void Spatial::FMTSpatialSchedule::perturbGraph | ( | const FMTCoordinate & | coordinate, |
| const int & | period, | ||
| const Models::FMTModel & | model, | ||
| std::default_random_engine & | generator, | ||
| const actionbindings & | bindings | ||
| ) |
Change one graph in the solution, removing its contribution to the objective and adding the contribution of the newly generated one.
| [in] | coordinate | the coordinate. |
| [in] | period | the period. |
| [in] | model | the model. |
| [in,out] | generator | the random generator. |
| [in] | bindings | the action bindings. |
| void Spatial::FMTSpatialSchedule::postSolve | ( | const Core::FMTMaskFilter & | p_Filter, |
| const std::vector< Core::FMTAction > & | p_PresolveActions, | ||
| Spatial::FMTSpatialGraphs & | p_Graphs | ||
| ) |
Postsolve the spatial solution.
| [in] | p_Filter | the filter used for the preSolve. |
| [in] | p_PresolveActions | the presolved actions. |
| [in,out] | p_Graphs | the spatial graphs. |
| FMTSpatialSchedule Spatial::FMTSpatialSchedule::preSolve | ( | const Core::FMTMaskFilter & | p_filter, |
| FMTSpatialGraphs & | p_Graphs, | ||
| size_t | p_ReserveSize | ||
| ) | const |
Return a presolved solution of the original solution.
| [in] | p_filter | the filter used to keep the mask. |
| [in,out] | p_Graphs | the spatial graphs. |
| [in] | p_ReserveSize | the number of vertices to reserve per line graph. |
| Graph::FMTGraphStats Spatial::FMTSpatialSchedule::randomBuild | ( | const Models::FMTModel & | model, |
| std::default_random_engine & | generator | ||
| ) |
Randomly create a solution for one period using a generator.
| [in] | model | the model. |
| [in,out] | generator | the random generator. |
| std::map< std::string, double > Spatial::FMTSpatialSchedule::referenceBuild | ( | const Core::FMTSchedule & | schedule, |
| const Models::FMTModel & | model, | ||
| const std::vector< boost::unordered_set< Core::FMTDevelopment > > & | scheduleoperabilities, | ||
| std::default_random_engine & | p_randomEngine, | ||
| bool | schedule_only = true, |
||
| bool | scheduleatfirstpass = true |
||
| ) |
Simulate a schedule of actions on the actual spatially explicit forest.
If schedule_only is on, the simulator does not try to find operable developments outside the potential schedule even if the harvested area target is not reached.
| [in] | schedule | the schedule. |
| [in] | model | the model. |
| [in] | scheduleoperabilities | the schedule operabilities. |
| [in,out] | p_randomEngine | the random engine. |
| [in] | schedule_only | if true only considers the developments of the schedule. |
| [in] | scheduleatfirstpass | if true uses the schedule at the first pass. |
| void Spatial::FMTSpatialSchedule::setConstraintsFactor | ( | const Models::FMTModel & | model, |
| const std::vector< double > & | factors | ||
| ) |
Set the constraint factors for normalization.
| [in] | model | the model. |
| [in] | factors | the factors. |
| void Spatial::FMTSpatialSchedule::setGrow | ( | const std::vector< FMTCoordinate > & | p_coordinates, |
| const Models::FMTModel & | p_model | ||
| ) |
Set natural growth on coordinates, removing every action.
| [in] | p_coordinates | the coordinates to set to growth. |
| [in] | p_model | the model to use. |
| void Spatial::FMTSpatialSchedule::setSpatialGraphs | ( | const Spatial::FMTSpatialSchedule & | p_ToCopy, |
| FMTSpatialGraphs & | p_SpatialGraph | ||
| ) |
Set the spatial graphs from another schedule.
| [in] | p_ToCopy | the schedule to copy. |
| [in,out] | p_SpatialGraph | the spatial graphs. |
| void Spatial::FMTSpatialSchedule::setSpread | ( | std::vector< EventSpread >::const_iterator | p_first, |
| std::vector< EventSpread >::const_iterator | p_end | ||
| ) |
Apply a range of event spreads to the solution.
| [in] | p_first | the first event spread. |
| [in] | p_end | the end of the event spreads. |
| void Spatial::FMTSpatialSchedule::setStaticsMovableCoordinates | ( | const Models::FMTModel & | p_model | ) |
Set the static movable coordinates from a model.
| [in] | p_model | the model. |
| void Spatial::FMTSpatialSchedule::swap | ( | FMTSpatialSchedule & | rhs | ) |
Swap this FMTSpatialSchedule with another one.
| [in,out] | rhs | the FMTSpatialSchedule to swap with. |
| std::set< FMTCoordinate > Spatial::FMTSpatialSchedule::verifySpatialFeasibility | ( | const int & | targetaction, |
| const std::vector< Spatial::FMTBindingSpatialAction > & | bindingactions, | ||
| const int & | period, | ||
| const std::set< FMTCoordinate > & | operables | ||
| ) | const |
Return the evaluation value of a distance spatial constraint.
Return the cells that are spatially allowable for a target action from operable coordinates, mainly checking the green up constraint.
| [in] | targetaction | the target action. |
| [in] | bindingactions | the binding actions. |
| [in] | period | the period. |
| [in] | operables | the operable coordinates. |