FMT 1.2.0
Forest management tools for forest planning
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Protected Member Functions | List of all members
Spatial::FMTSpatialSchedule Class Reference

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>

Inheritance diagram for Spatial::FMTSpatialSchedule:
[legend]
Collaboration diagram for Spatial::FMTSpatialSchedule:
[legend]

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.
 
FMTSpatialScheduleoperator= (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< FMTCoordinateverifySpatialFeasibility (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::FMTSchedulegetSchedules (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::FMTGCBMTransitiongetGCBMtransitions (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::FMTBindingSpatialActiongetBindingActions (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::FMTCoordinategetMovableCoordinates (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::FMTActualDevelopmentgetArea (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< FMTCoordinategetGroupsConflict (const Core::FMTConstraint &p_SpatialConstraint, const FMTSpatialGraphs &p_SpatialGraph) const
 Return the coordinates in conflict with a group spatial constraint.
 
std::vector< EventSpreadgetPotentialSpread (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.
 

Detailed Description

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.

Member Typedef Documentation

◆ actionbindings

Constructor & Destructor Documentation

◆ FMTSpatialSchedule() [1/4]

Spatial::FMTSpatialSchedule::FMTSpatialSchedule ( )
default

Default constructor for FMTSpatialSchedule.

◆ ~FMTSpatialSchedule()

virtual Spatial::FMTSpatialSchedule::~FMTSpatialSchedule ( )
virtualdefault

Default destructor for FMTSpatialSchedule.

◆ FMTSpatialSchedule() [2/4]

Spatial::FMTSpatialSchedule::FMTSpatialSchedule ( const FMTSpatialSchedule other)
default

Copy constructor for FMTSpatialSchedule.

Parameters
[in]otherthe FMTSpatialSchedule to copy.

◆ FMTSpatialSchedule() [3/4]

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.

Parameters
[in]p_InitialMapthe initial map of the schedule.
[in]p_LengthReservethe amount of memory to reserve for each line graph.
[in,out]p_SpatialGraphthe spatial graphs.

◆ FMTSpatialSchedule() [4/4]

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.

Parameters
[in]otherthe complete solution.
[in]firstcoordthe first coordinate.
[in]endcoordthe end coordinate.

Member Function Documentation

◆ _getFromEvents() [1/2]

std::vector< const Graph::FMTLineGraph * > Spatial::FMTSpatialSchedule::_getFromEvents ( const Core::FMTConstraint constraint,
const std::vector< Core::FMTAction > &  actions,
const int &  start,
const int &  stop 
) const
protected

Return the line graphs of the events for a constraint, actions and a period range.

Parameters
[in]constraintthe constraint.
[in]actionsthe actions.
[in]startthe start period.
[in]stopthe stop period.
Returns
the line graphs.

◆ _getFromEvents() [2/2]

std::vector< FMTCoordinate > Spatial::FMTSpatialSchedule::_getFromEvents ( const Core::FMTOutputNode node,
const std::vector< Core::FMTAction > &  actions,
const int &  period 
) const
protected

Return the coordinates present in the events for an output node, actions and a period.

Parameters
[in]nodethe output node.
[in]actionsthe actions.
[in]periodthe period.
Returns
the coordinates.

◆ _getOutputFromGraph()

std::map< std::string, double > Spatial::FMTSpatialSchedule::_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
protected

Get the requested output from a line graph into the period values.

Parameters
[in]linegraphthe line graph.
[in]modelthe model.
[in]nodethe output node.
[in]solutionthe solution.
[in]periodthe period.
[in]nodemaskthe node mask.
[in,out]nodecachethe node cache.
[in]p_themethe theme.
[in]levelthe output level.
Returns
a map of names to values.

◆ _inScheduleOperabilities()

bool Spatial::FMTSpatialSchedule::_inScheduleOperabilities ( const std::vector< boost::unordered_set< Core::FMTDevelopment > > &  scheduleoperabilities,
Core::FMTDevelopment const *  dev,
const int &  actionid,
const Core::FMTAction action 
) const
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.

Parameters
[in]scheduleoperabilitiesthe schedule operabilities.
[in]devthe development.
[in]actionidthe action id.
[in]actionthe action.
Returns
true if the development is operable else false.

◆ actPeriod()

int Spatial::FMTSpatialSchedule::actPeriod ( ) const

Return the last period in the graph, which is the active one.

Returns
the active period.

◆ allowAction()

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.

Parameters
[in]targetactionthe target action.
[in]bindingactionsthe binding actions.
[in]locationthe location.
[in]periodthe period.
Returns
true if the action is allowed else false.

◆ buildHarvest()

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.

Parameters
[in]targetthe area target.
[in]targetactionthe target binding action.
[in,out]generatorthe random generator.
[in]mapping_passthe candidate coordinates.
[in]previousperiodthe previous period.
[in]actionidthe action id.
[in,out]operatedthe operated coordinates.
Returns
the harvest events.

◆ canDoEventSpread()

bool Spatial::FMTSpatialSchedule::canDoEventSpread ( int  p_period) const

Return true if an event spread can be done for a period.

Parameters
[in]p_periodthe period.
Returns
true if an event spread can be done else false.

◆ copyFromPartial() [1/2]

void Spatial::FMTSpatialSchedule::copyFromPartial ( const FMTSpatialSchedule rhs)

Copy the elements from a partial solution.

Parameters
[in]rhsthe partial solution to copy.

◆ copyFromPartial() [2/2]

void Spatial::FMTSpatialSchedule::copyFromPartial ( FMTSpatialSchedule rhs)

Copy the elements from a partial solution, also allowing a swap.

Parameters
[in,out]rhsthe partial solution to copy.

◆ disableSolutionTracker()

void Spatial::FMTSpatialSchedule::disableSolutionTracker ( )

Disable the non spatial solution tracker.

◆ empty()

bool Spatial::FMTSpatialSchedule::empty ( ) const
inline

Test whether the map is empty.

Returns
true if the map is empty else false.

◆ emptyEvents()

bool Spatial::FMTSpatialSchedule::emptyEvents ( ) const

Return true if there are no events.

Returns
true if there are no events else false.

◆ enableSolutionTracker()

void Spatial::FMTSpatialSchedule::enableSolutionTracker ( const FMTSpatialGraphs p_SpatialGraph)

Enable the non spatial solution tracker using the spatial graphs.

Parameters
[in]p_SpatialGraphthe spatial graphs.

◆ eraseLastPeriod()

void Spatial::FMTSpatialSchedule::eraseLastPeriod ( )

Erase the last period of the FMTSpatialSchedule.

◆ evaluateSpatialConstraint()

double Spatial::FMTSpatialSchedule::evaluateSpatialConstraint ( const Core::FMTConstraint p_SpatialConstraint,
const FMTSpatialGraphs p_SpatialGraph 
) const

Return the evaluation value of a spatial constraint.

Parameters
[in]p_SpatialConstraintthe spatial constraint.
[in]p_SpatialGraphthe spatial graphs.
Returns
the constraint evaluation value.

◆ getAdjacencyConflictCoordinates()

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.

Parameters
[in]bindingactionsthe binding actions.
[in]periodthe period.
[in]conflictonlyif true returns only the conflicting coordinates.
Returns
the adjacency conflict coordinates.

◆ getArea()

std::vector< Core::FMTActualDevelopment > Spatial::FMTSpatialSchedule::getArea ( int  period = 0,
bool  beforegrowanddeath = false 
) const

Get the area of a period based on the solution.

Parameters
[in]periodthe period.
[in]beforegrowanddeathif true returns before growth and death.
Returns
the actual developments.

◆ getAreaConflictCoordinates()

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.

Parameters
[in]bindingactionsthe binding actions.
[in]periodthe period.
[in]conflictonlyif true returns only the conflicting coordinates.
Returns
the area conflict coordinates.

◆ getBaseSchedule()

FMTSpatialSchedule Spatial::FMTSpatialSchedule::getBaseSchedule ( const FMTSpatialGraphs p_SpatialGraph) const

Return the base schedule of the spatial graphs.

Parameters
[in]p_SpatialGraphthe spatial graphs.
Returns
the base schedule.

◆ getBindingActions()

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.

Parameters
[in]modelthe model.
[in]periodthe period.
Returns
the binding actions.

◆ getBindingActionsByPeriod()

actionbindings Spatial::FMTSpatialSchedule::getBindingActionsByPeriod ( const Models::FMTModel model) const

Get the binding actions based on the model constraints in a vector by period.

Parameters
[in]modelthe model.
Returns
the binding actions by period.

◆ getConstraintEvaluation()

double Spatial::FMTSpatialSchedule::getConstraintEvaluation ( const FMTSpatialGraphs p_Graphs,
size_t  p_ConstraintId 
) const

Return the evaluated value of a solution constraint.

Parameters
[in]p_Graphsthe spatial graphs.
[in]p_ConstraintIdthe constraint id.
Returns
the constraint evaluation value.

◆ getConstraintsFactor()

const std::vector< double > & Spatial::FMTSpatialSchedule::getConstraintsFactor ( ) const

Get the constraint factors for normalization.

Returns
the constraint factors.

◆ getConstraintsValues()

std::vector< double > Spatial::FMTSpatialSchedule::getConstraintsValues ( const Spatial::FMTSpatialGraphs p_Graphs) const

Return the values of each constraint, used for normalization.

Parameters
[in]p_Graphsthe spatial graphs.
Returns
the constraint values.

◆ getForestPeriod()

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.

Parameters
[in]periodthe period.
[in]periodStartif true returns the forest before the actions.
Returns
the forest.

◆ getGCBMtransitions()

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.

Parameters
[in,out]stackedactionsthe stacked actions layer.
[in]modelactionsthe model actions.
[in]classifiersthe classifiers.
[in]periodthe period.
Returns
the GCBM transitions.

◆ getGlobalObjective()

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.

Parameters
[in]p_Graphsthe spatial graphs.
Returns
the global objective.

◆ getGroupsConflict()

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.

Parameters
[in]p_SpatialConstraintthe spatial constraint.
[in]p_SpatialGraphthe spatial graphs.
Returns
the group conflict coordinates.

◆ getMovableCoordinates()

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.

Parameters
[in]modelthe model.
[in]periodthe period.
Returns
the movable coordinates.

◆ getObjectiveValue()

double Spatial::FMTSpatialSchedule::getObjectiveValue ( const FMTSpatialGraphs p_Graphs,
bool  withsense = true 
) const

Return the objective value of the spatial schedule.

Parameters
[in]p_Graphsthe spatial graphs.
[in]withsenseif true applies the sense.
Returns
the objective value.

◆ getOutput()

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.

Parameters
[in]p_Graphsthe spatial graphs.
[in]p_outputthe output.
[in]p_periodthe period.
[in]levelthe output level.
Returns
a map of names to values.

◆ getOutputByCoordinate()

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.

Parameters
[in]modelthe model.
[in]outputthe output.
[in]periodthe period.
Returns
the output value per coordinate.

◆ getPatchStats()

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.

Parameters
[in]actionsthe actions.
Returns
the patch statistics.

◆ getPeriodWithMaximalEvents()

int Spatial::FMTSpatialSchedule::getPeriodWithMaximalEvents ( const std::vector< bool > &  actions) const

Return the period with the maximal number of events for a set of actions.

Parameters
[in]actionsthe actions.
Returns
the period with the maximal number of events.

◆ getPotentialSpread()

std::vector< EventSpread > Spatial::FMTSpatialSchedule::getPotentialSpread ( int  p_period)

Return the potential event spreads for a period.

Parameters
[in]p_periodthe period.
Returns
the potential event spreads.

◆ getPredictors()

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.

Parameters
[in,out]predictoridsthe predictor ids layer.
[in]modelthe model.
[in]yieldnamesthe yield names.
[in]periodthe period.
[in]periodonevaluesif true uses the period one values.
[in]withGCBMidif true uses the GCBM id.
Returns
the predictors.

◆ getPrimalInfeasibility()

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.

Parameters
[in]constraintsthe constraints.
[in]p_Graphsthe spatial graphs.
[in]withfactorizationif true applies the factorization.
Returns
the primal infeasibility.

◆ getSchedules()

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.

Parameters
[in]p_Graphsthe spatial graphs.
[in]withlockif true includes the locked developments.
Returns
the schedules.

◆ getSolutionStatus()

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.

Parameters
[out]objectivethe objective value.
[out]primalinfeasibilitythe primal infeasibility.
[in]p_Graphsthe spatial graphs.
[in]withsenseif true applies the sense.
[in]withfactorizationif true applies the factorization.
[in]withspatialif true includes the spatial part.

◆ getSpatialOutput()

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.

Parameters
[in]modelthe model.
[in]outputthe output.
[in]periodthe period.
Returns
the spatial output layer.

◆ getUpdatedScheduling()

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.

Parameters
[in]modelthe model.
[in]actiontargetsthe action targets.
[in,out]cachedactionthe operability cache per development.
[in]scheduleoperabilitiesthe schedule operabilities.
[in]schedule_onlyif true only considers the developments of the schedule.
[in]originalthe original scheduling.
[in]updatedcoordinatethe updated coordinates.
Returns
the operable coordinates per action.

◆ getWeightedFactors()

std::vector< double > Spatial::FMTSpatialSchedule::getWeightedFactors ( const Spatial::FMTSpatialGraphs p_Graphs) const

Generate the constraint factors based on the actual solution.

Parameters
[in]p_Graphsthe spatial graphs.
Returns
the weighted factors.

◆ greedyReferenceBuild()

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.

Parameters
[in]schedulethe schedule.
[in]p_Graphsthe spatial graphs.
[in]randomiterationsthe number of random iterations.
[in]seedthe seed.
[in]tolerancethe tolerance.
[in]logif true logs the process.
Returns
a map of statistics.

◆ grow()

void Spatial::FMTSpatialSchedule::grow ( )

Grow every graph of the schedule by one period.

◆ isBetterByGroup()

bool Spatial::FMTSpatialSchedule::isBetterByGroup ( const FMTSpatialSchedule rhs,
const FMTSpatialGraphs p_Graphs 
) const

Compare this solution to another one by constraint group.

Parameters
[in]rhsthe solution to compare to.
[in]p_Graphsthe spatial graphs.
Returns
true if this solution is better by group else false.

◆ isBetterThan()

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.

Parameters
[in]newsolutionthe solution to compare to.
[in]p_Graphsthe spatial graphs.
Returns
a vector of booleans per constraint group.

◆ isPartial()

bool Spatial::FMTSpatialSchedule::isPartial ( ) const

Return true if the solution is partial.

Returns
true if the solution is partial else false.

◆ lastDistLayer()

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.

Parameters
[in]modelactionsthe model actions.
[in]periodthe period.
Returns
the disturbance layer.

◆ logSolutionStatus()

void Spatial::FMTSpatialSchedule::logSolutionStatus ( const size_t &  iteration,
const double &  objective,
const double &  primalinfeasibility 
) const

Log the status of the solution.

Parameters
[in]iterationthe iteration.
[in]objectivethe objective value.
[in]primalinfeasibilitythe primal infeasibility.

◆ needsRefactorization()

bool Spatial::FMTSpatialSchedule::needsRefactorization ( const FMTSpatialGraphs p_Graphs) const

Return true if the solution looks unscaled and needs new factors.

Parameters
[in]p_Graphsthe spatial graphs.
Returns
true if the solution needs refactorization else false.

◆ operateCoord()

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.

Parameters
[in]coordthe coordinate.
[in]actionthe action.
[in]action_idthe action id.
[in]bindingspactionthe binding spatial action.
[in]Transitionthe transition.
[in]yldsthe yields.
[in]themesthe themes.

◆ operateEvents()

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.

Parameters
[in]cutsthe events to operate.
[in]actionthe action.
[in]action_idthe action id.
[in]Transitionthe transition.
[in]yldsthe yields.
[in]themesthe themes.
Returns
the operated area.

◆ operator!=()

bool Spatial::FMTSpatialSchedule::operator!= ( const FMTSpatialSchedule rhs) const

Comparison operator for FMTSpatialSchedule.

Parameters
[in]rhsthe FMTSpatialSchedule to compare to.
Returns
true if both schedules are different else false.

◆ operator=()

FMTSpatialSchedule & Spatial::FMTSpatialSchedule::operator= ( const FMTSpatialSchedule rhs)
default

Copy assignment operator for FMTSpatialSchedule.

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

◆ operator==()

bool Spatial::FMTSpatialSchedule::operator== ( const FMTSpatialSchedule rhs) const

Comparison operator for FMTSpatialSchedule.

Parameters
[in]rhsthe FMTSpatialSchedule to compare to.
Returns
true if both schedules are equal else false.

◆ perturbGraph()

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.

Parameters
[in]coordinatethe coordinate.
[in]periodthe period.
[in]modelthe model.
[in,out]generatorthe random generator.
[in]bindingsthe action bindings.

◆ postSolve()

void Spatial::FMTSpatialSchedule::postSolve ( const Core::FMTMaskFilter p_Filter,
const std::vector< Core::FMTAction > &  p_PresolveActions,
Spatial::FMTSpatialGraphs p_Graphs 
)

Postsolve the spatial solution.

Parameters
[in]p_Filterthe filter used for the preSolve.
[in]p_PresolveActionsthe presolved actions.
[in,out]p_Graphsthe spatial graphs.

◆ preSolve()

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.

Parameters
[in]p_filterthe filter used to keep the mask.
[in,out]p_Graphsthe spatial graphs.
[in]p_ReserveSizethe number of vertices to reserve per line graph.
Returns
the presolved schedule.

◆ randomBuild()

Graph::FMTGraphStats Spatial::FMTSpatialSchedule::randomBuild ( const Models::FMTModel model,
std::default_random_engine &  generator 
)

Randomly create a solution for one period using a generator.

Parameters
[in]modelthe model.
[in,out]generatorthe random generator.
Returns
the graph stats.

◆ referenceBuild()

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.

Parameters
[in]schedulethe schedule.
[in]modelthe model.
[in]scheduleoperabilitiesthe schedule operabilities.
[in,out]p_randomEnginethe random engine.
[in]schedule_onlyif true only considers the developments of the schedule.
[in]scheduleatfirstpassif true uses the schedule at the first pass.
Returns
a map of statistics.

◆ setConstraintsFactor()

void Spatial::FMTSpatialSchedule::setConstraintsFactor ( const Models::FMTModel model,
const std::vector< double > &  factors 
)

Set the constraint factors for normalization.

Parameters
[in]modelthe model.
[in]factorsthe factors.

◆ setGrow()

void Spatial::FMTSpatialSchedule::setGrow ( const std::vector< FMTCoordinate > &  p_coordinates,
const Models::FMTModel p_model 
)

Set natural growth on coordinates, removing every action.

Parameters
[in]p_coordinatesthe coordinates to set to growth.
[in]p_modelthe model to use.

◆ setSpatialGraphs()

void Spatial::FMTSpatialSchedule::setSpatialGraphs ( const Spatial::FMTSpatialSchedule p_ToCopy,
FMTSpatialGraphs p_SpatialGraph 
)

Set the spatial graphs from another schedule.

Parameters
[in]p_ToCopythe schedule to copy.
[in,out]p_SpatialGraphthe spatial graphs.

◆ setSpread()

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.

Parameters
[in]p_firstthe first event spread.
[in]p_endthe end of the event spreads.

◆ setStaticsMovableCoordinates()

void Spatial::FMTSpatialSchedule::setStaticsMovableCoordinates ( const Models::FMTModel p_model)

Set the static movable coordinates from a model.

Parameters
[in]p_modelthe model.

◆ swap()

void Spatial::FMTSpatialSchedule::swap ( FMTSpatialSchedule rhs)

Swap this FMTSpatialSchedule with another one.

Parameters
[in,out]rhsthe FMTSpatialSchedule to swap with.

◆ verifySpatialFeasibility()

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.

Parameters
[in]targetactionthe target action.
[in]bindingactionsthe binding actions.
[in]periodthe period.
[in]operablesthe operable coordinates.
Returns
the spatially feasible coordinates.

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