FMT 1.2.0
Forest management tools for forest planning
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Member Functions | Friends | List of all members
Models::FMTSaModel Class Referencefinal

Area restricted model (ARM) using the simulated annealing meta-heuristic to solve the spatial optimization problem. More...

#include <FMTSaModel.h>

Inheritance diagram for Models::FMTSaModel:
[legend]
Collaboration diagram for Models::FMTSaModel:
[legend]

Public Member Functions

void logMovesReport () const
 Log the moves report.
 
bool isProvenOptimal () const
 Return true if the solution is optimal based on the termination criteria.
 
bool initialSolve ()
 Try to solve the model from a cold start.
 
virtual bool build (std::vector< Core::FMTSchedule > schedules=std::vector< Core::FMTSchedule >())
 Try to build the spatial schedule from a schedule if one is provided, otherwise randomly build the model to be ready to solve.
 
virtual bool solve ()
 Call initialSolve on the solver.
 
virtual std::unique_ptr< FMTModelpreSolve (std::vector< Core::FMTActualDevelopment > optionaldevelopments=std::vector< Core::FMTActualDevelopment >()) const
 Return a presolved copy of the model using a vector of developments and the actual transitions, reducing the model data if it is badly formulated.
 
virtual std::unique_ptr< FMTModelgetCopy (int period=0) const
 Return a copy of the FMTModel for the selected period.
 
 FMTSaModel ()=default
 Default constructor for FMTSaModel.
 
 ~FMTSaModel ()
 Destructor for FMTSaModel.
 
 FMTSaModel (const FMTSaModel &rhs)
 Copy constructor for FMTSaModel.
 
 FMTSaModel (const FMTModel &rhs)
 Construct a FMTSaModel from a FMTModel, using the parent as argument.
 
 FMTSaModel (const FMTModel &rhs, const Spatial::FMTForest &forest)
 Construct a FMTSaModel from a FMTModel and a forest.
 
FMTSaModeloperator= (const FMTSaModel &rhs)
 Copy assignment operator for FMTSaModel.
 
virtual std::unique_ptr< FMTModelclone () const final
 Get a clone of the FMTSaModel.
 
Graph::FMTGraphStats buildPeriod ()
 Build a period of the model.
 
- Public Member Functions inherited from Models::FMTSeModel
 FMTSeModel ()
 Default constructor for FMTSeModel.
 
virtual ~FMTSeModel ()=default
 Default virtual destructor for FMTSeModel.
 
 FMTSeModel (const FMTSeModel &rhs)
 Copy constructor for FMTSeModel.
 
 FMTSeModel (const FMTModel &rhs, const Spatial::FMTForest &forest)
 Construct a FMTSeModel from a model and a forest.
 
 FMTSeModel (const FMTModel &rhs)
 Construct a FMTSeModel from a model.
 
FMTSeModeloperator= (const FMTSeModel &rhs)
 Copy assignment operator for FMTSeModel.
 
Spatial::FMTForest getMapping () const
 Return a copy of the actual spatial forest state of each development.
 
Spatial::FMTSpatialSchedule getSpSchedule () const
 Return a copy of the spatially explicit solution.
 
std::string getDisturbanceStats () const
 Return a string of patch statistics (area, perimeter) of the disturbances stack.
 
std::vector< Core::FMTSchedulegetSchedule (bool withlock=false) const
 Return a copy of the operated schedules of the model, which can differ from the potential schedule.
 
bool setInitialMapping (const Spatial::FMTForest &forest)
 Set the initial forest state, to be set before greedyReferenceBuild is called.
 
void logConstraintsInfeasibilities () const
 Log the constraint infeasibilities, spatial or not.
 
void logConstraintsFactors () const
 Log the constraint factors.
 
virtual std::unique_ptr< FMTModelpreSolve (std::vector< Core::FMTActualDevelopment > optionaldevelopments=std::vector< Core::FMTActualDevelopment >()) const
 Return a presolved copy of the model, presolving the forest map and the spatial actions.
 
virtual void postSolve (const FMTModel &originalbasemodel)
 Postsolve the model back into a complete model using the original model.
 
virtual std::map< std::string, double > getOutput (const Core::FMTOutput &output, int period, Core::FMToutputlevel level=Core::FMToutputlevel::standard) const
 Get the output value for a period using the spatial solution.
 
virtual Spatial::FMTLayer< double > getSpatialOutput (const Core::FMTOutput &output, int period) const
 Get the spatial output value based on the spatial solution.
 
virtual Core::FMTSchedule getSolution (int period, bool withlock=false) const
 Get the standard solution for a period, without the natural growth solution.
 
virtual std::unique_ptr< FMTModelclone () const
 Get a clone of the FMTSeModel.
 
virtual std::vector< Core::FMTActualDevelopmentgetArea (int period=0, bool beforegrowanddeath=false) const
 Get the area of a period based on the solution.
 
virtual std::unique_ptr< FMTModelgetCopy (int period=0) const
 Return a copy of the model for a period, cleaning the constraints and keeping the objective.
 
virtual double getObjectiveValue () const
 Return the global objective value of the actual solution.
 
std::vector< Core::FMTSchedulegetSchedules (const Spatial::FMTSpatialSchedule &p_SpatialSchedule, bool withlock=false) const
 Get the schedules of a spatial solution.
 
void getSolutionStatus (const Spatial::FMTSpatialSchedule &p_SpatialSchedule, double &p_Objective, double &p_PrimalInFeasibility, bool withsense=true, bool withfactorization=false, bool withspatial=true) const
 Get the status of a spatial solution.
 
double getConstraintEvaluation (size_t p_Constraint) const
 Evaluate a constraint with the actual solution.
 
- Public Member Functions inherited from Models::FMTModel
double getYieldValue (const std::string &p_mask, const std::string &p_yield, int p_age, int p_period) const
 Get yield value.
 
void setReplicate (size_t p_replicate, int p_ReplanningPeriod)
 Set the constraints to the specified Replanning Period.
 
bool gotReIgnore (const int &p_replanningPeriod) const
 Check if setReIgnore needs to be called.
 
bool gotReplicate (const int &p_replanningPeriod) const
 Check if setReplicate needs to be called.
 
FMTModel buildAction (const std::string &p_actionName, const std::string &p_Targetyield) const
 Build an action based on the positive value of a yield.
 
std::vector< Core::FMTSchedulebuildSchedule (const Core::FMTAction &p_action, const FMTModel &p_BaseModel, const std::string &p_Targetyield, const std::vector< Core::FMTSchedule > &p_schedules) const
 Build a schedule by looking at operability of the actual developments.
 
void pushTheme (const std::string &p_themeName, const std::string &p_yieldName, const std::vector< std::string > &p_attributes)
 Push a new theme and update the whole model with it.
 
Models::FMTModel aggregateAllActions (const std::vector< std::string > &p_Aggregates, std::vector< std::string > p_ActionOrdering) const
 Aggregate actions together and create a new model with new actions, transitions, outputs, constraints, yields and lifespan.
 
Models::FMTModel splitActions (const std::vector< std::string > &p_Actions, const std::vector< std::string > &p_masks) const
 Split actions using the provided masks, new actions are named action_mask and aggregated into the original action name.
 
std::vector< std::string > getSchedulesPriorities (const std::vector< Core::FMTSchedule > &p_schedules) const
 Return the action names in priority of area scheduled.
 
std::vector< Core::FMTScheduleaggregateSchedules (const std::vector< Core::FMTSchedule > &p_schedules) const
 Build a new schedule based on p_schedules with the corresponding aggregated actions.
 
std::vector< Core::FMTSchedulesplitSchedules (const std::vector< Core::FMTSchedule > &p_schedules) const
 Using the actions of the model change the actions of the schedule.
 
virtual void setParallelLogger (Logging::FMTLogger &logger)
 Set a thread owned logger so the solver does not work in concurrency.
 
virtual void clearCache ()
 Clear caching elements to reduce memory usage.
 
 FMTModel (const std::vector< Core::FMTActualDevelopment > &larea, const std::vector< Core::FMTTheme > &lthemes, const std::vector< Core::FMTAction > &lactions, const std::vector< Core::FMTTransition > &ltransitions, const Core::FMTYields &lyields, const Core::FMTLifespans &llifespan, const std::string &lname, const std::vector< Core::FMTOutput > &loutputs, std::vector< Core::FMTConstraint > lconstraints=std::vector< Core::FMTConstraint >(), FMTModelParameters lparameters=FMTModelParameters())
 Main constructor for FMTModel used in Parser::FMTModelParser, constraints and parameters are optional.
 
 FMTModel ()
 Default constructor of FMTModel.
 
virtual ~FMTModel ()=default
 Default virtual destructor of FMTModel.
 
 FMTModel (FMTModel &&rhs)
 Default move constructor for FMTModel.
 
FMTModeloperator= (FMTModel &&rhs)
 Default move assignment for FMTModel.
 
virtual std::vector< Core::FMTActualDevelopmentgetArea (int period=0, bool beforegrowanddeath=false) const
 Get the area of a given period as actual developments.
 
virtual std::unique_ptr< FMTModelgetCopy (int period=0) const
 Return a copy of the FMTModel for the selected period, cleaning the constraints and keeping the objective.
 
FMTModel basePreSolve () const
 Presolve the model using the existing area.
 
Core::FMTMaskFilter getPreSolveFilter (const std::vector< Core::FMTTheme > &originalthemes) const
 Get the preSolve filter.
 
Core::FMTMaskFilter getPostSolveFilter (const std::vector< Core::FMTTheme > &originalthemes, const Core::FMTMask &devmask) const
 Get the postsolve filter used by the preSolve, to turn a presolved mask into a postsolve mask.
 
Core::FMTMask getSelectedMask (const std::vector< Core::FMTTheme > &originalthemes) const
 Get the selection mask needed to preSolve a FMTMask when the model is presolved.
 
virtual std::unique_ptr< FMTModelpreSolve (std::vector< Core::FMTActualDevelopment > optionaldevelopments=std::vector< Core::FMTActualDevelopment >()) const
 Return a new presolved FMTModel using developments and the actual transitions of the model.
 
virtual void postSolve (const FMTModel &originalbasemodel)
 Postsolve the presolved model into the original model.
 
Core::FMTSchedule preSolveSchedule (const Core::FMTSchedule &originalbaseschedule, const FMTModel &originalbasemodel) const
 Return a new schedule with presolved development masks and actions.
 
FMTModelStats getModelStats () const
 Return the statistics of the model such as the number of themes, yields, actions and transitions.
 
void cleanActionsNTransitions ()
 Delete actions that have no defined transition and transitions that have no defined action, then sort them.
 
std::string getName () const
 Return the name of the FMTModel.
 
std::vector< Core::FMTThemegetThemes () const
 Return a copy of the themes of the model.
 
std::vector< Core::FMTActiongetActions () const
 Return a copy of the actions of the model.
 
std::vector< Core::FMTTransitiongetTransitions () const
 Return a copy of the transitions of the model.
 
Core::FMTYields getYields () const
 Return a copy of the yields of the model.
 
Core::FMTLifespans getLifespan () const
 Return a copy of the lifespan of the model.
 
std::vector< Core::FMTOutputgetOutputs () const
 Return a copy of the outputs of the model.
 
std::vector< Core::FMTConstraintgetConstraints () const
 Return a copy of the constraints of the model.
 
void addOutput (const std::string &name, const std::string &maskstring, Core::FMTotar outputtarget, std::string action=std::string(), std::string yield=std::string(), std::string description=std::string(), int targetTheme=-1)
 Add one output to the model based only on strings.
 
template<typename T >
void addYieldHandlers (const std::vector< T > &yieldhandlers)
 Add FMTYieldHandler from a vector to the yields.
 
void addYieldHandlersFromPtr (const std::vector< std::unique_ptr< Core::FMTYieldHandler > > &yieldhandlers)
 Add unique pointers of FMTYieldHandler from a vector to the yields.
 
bool operator== (const FMTModel &rhs) const
 Equality comparison operator of FMTModel.
 
bool operator< (const FMTModel &rhs) const
 Less than comparison operator of FMTModel.
 
void setArea (const std::vector< Core::FMTActualDevelopment > &ldevs)
 Setter for the initial actual developments (area section), replacing the originals.
 
void setThemes (const std::vector< Core::FMTTheme > &lthemes)
 Setter for the themes of the model, replacing the originals.
 
void setActions (const std::vector< Core::FMTAction > &lactions)
 Setter for the actions of the model, replacing the originals.
 
void setTransitions (const std::vector< Core::FMTTransition > &ltransitions)
 Setter for the transitions of the model, replacing the originals.
 
void setConstraints (const std::vector< Core::FMTConstraint > &lconstraint)
 Setter for the constraints of the model, replacing the original.
 
void setYields (const Core::FMTYields &lylds)
 Setter for the yields of the model, replacing the original.
 
void setLifespan (const Core::FMTLifespans &llifespan)
 Setter for the lifespan of the model, replacing the original.
 
void setName (const std::string &newname)
 Set the name of the FMTModel.
 
void setOutputs (const std::vector< Core::FMTOutput > &newoutputs)
 Setter for the outputs of the model.
 
bool isValid ()
 Validate the whole FMTModel through themes, actual developments, yields, actions, transitions, outputs and constraints.
 
std::vector< const Core::FMTTheme * > locateStaticThemes (const Core::FMTOutput &output, bool ignoreoutputvariables=false) const
 Return the themes that are not used in the transitions and in a given output (static themes).
 
std::vector< const Core::FMTTheme * > locateStaticThemes (const Core::FMTOutputNode &output, bool ignoreoutputvariables=false) const
 Return the themes that are not used in the transitions and in a given output node (static themes).
 
std::vector< const Core::FMTTheme * > locateDynamicThemes (const Core::FMTOutput &outpu, bool ignoreoutputvariables=false) const
 Return the themes used in the transition scheme.
 
Core::FMTMask getDynamicMask (const Core::FMTOutput &output, bool ignoreoutputvariables=false) const
 Return a mask where static attributes have a value of 0 and dynamic attributes a value of 1.
 
Core::FMTMask getDynamicMask (const Core::FMTOutputNode &node, bool ignoreoutputvariables=false) const
 Return a mask where static attributes have a value of 0 and dynamic attributes a value of 1.
 
virtual Core::FMTMask getStaticMask (const Core::FMTOutputNode &node, bool ignoreoutputvariables=false) const
 Return a mask where static attributes have a value of 1 and dynamic attributes a value of 0.
 
bool isStaticNode (const Core::FMTOutputNode &node, double ratioofset=0.1) const
 Return true if the node can be used in static mask functions.
 
std::vector< const Core::FMTTheme * > locateStaticTransitionsThemes () const
 Return the static themes based on the model transitions.
 
std::vector< const Core::FMTTheme * > locateNodeStaticThemes (const Core::FMTOutputNode &node, bool ignoreoutputvariables=false, std::vector< const Core::FMTTheme * > basethemes=std::vector< const Core::FMTTheme * >()) const
 Return the static themes of a node based on the model transitions.
 
 FMTModel (const FMTModel &rhs)
 Copy constructor of FMTModel.
 
FMTModeloperator= (const FMTModel &rhs)
 Copy assignment of FMTModel.
 
bool empty () const
 Return true if the FMTModel is empty.
 
void push_back (const FMTModel &rhs)
 Append a FMTModel to this FMTModel without overriding the objective of the base model.
 
double getInitialArea () const
 Return the sum of the area of the area vector.
 
void setAreaPeriod (const int &period)
 Change the initial area period to the targeted period.
 
int getAreaPeriod () const
 get the period of the area section.
 
Core::FMTSchedule getPotentialSchedule (std::vector< Core::FMTActualDevelopment > toRemove, std::vector< Core::FMTActualDevelopment > selection, bool withlock=true) const
 Test operability of a selection minus the developments to remove and return a schedule with an area of 1.0 for each operable development.
 
virtual std::vector< Core::FMTConstraintgetReplanningConstraints (const std::string &modeltype, const std::vector< Core::FMTConstraint > &localconstraints, const int &period) const
 Adjust the constraints that need to be set to a value of the global or local model and return all constraints.
 
virtual bool doPlanning (const bool &solve, std::vector< Core::FMTSchedule > schedules=std::vector< Core::FMTSchedule >())
 Build the model and do the initial solve or simulate, using the build and solve overridden functions of the different model types.
 
virtual std::map< std::string, double > getOutput (const Core::FMTOutput &output, int period, Core::FMToutputlevel level=Core::FMToutputlevel::standard) const
 Get the output value of an output for a given period using the spatial solution.
 
virtual Core::FMTSchedule getSolution (int period, bool withlock=false) const
 Get the standard solution for a given period, without the natural growth solution.
 
virtual std::map< std::string, std::vector< std::vector< double > > > getOutputsFromPeriods (const std::vector< Core::FMTOutput > &theoutputs, const int &firstPeriod, const int &lastPeriod, Core::FMToutputlevel level=Core::FMToutputlevel::standard) const
 For each output get a vector of output values from the first period to the last period.
 
virtual std::unique_ptr< FMTModelclone () const
 Get a clone of the FMTModel.
 
virtual bool setParameter (const FMTintmodelparameters &p_key, const int &p_value)
 set int parameters to nss model.
 
virtual bool setParameter (const FMTdblmodelparameters &key, const double &value)
 Setter for double model parameters. See FMTModelParameters.h.
 
virtual bool setParameter (const FMTboolmodelparameters &key, const bool &value)
 Setter for bool model parameters. See FMTModelParameters.h.
 
virtual bool setParameter (const FMTstrmodelparameters &p_key, const std::string &p_value)
 Setter forstr model parameters. See FMTModelParameters.h.
 
int getParameter (const FMTintmodelparameters &key) const
 Getter for int model parameters. See FMTModelParameters.h.
 
double getParameter (const FMTdblmodelparameters &key) const
 Getter for double model parameters. See FMTModelParameters.h.
 
bool getParameter (const FMTboolmodelparameters &key) const
 Getter for bool model parameters. See FMTModelParameters.h.
 
const std::string & getParameter (const FMTstrmodelparameters &p_key) const
 Getter for str model parameters. See FMTModelParameters.h.
 
bool setCompressTime (const int &periodStart, const int &periodStop, const int &value)
 Set the compresstime value for a range of periods. See FMTModelParameters.h.
 
std::vector< int > getCompressTime () const
 Return a vector with the compresstime value for each period, the first period being index 0. See FMTModelParameters.h.
 
std::vector< Core::FMTConstraintgoalConstraints (double penalty=999999) const
 Return all constraints and the objective with goals and penalty.
 
std::vector< Core::FMTConstraintgetTacticalConstraints (double penalty=999999, double scheduleweight=999999, double objective=0, double objectivefactor=1.0) const
 Get the constraints adapted for a tactical model.
 
virtual void showParameters (const bool &showhelp=false) const
 Show the parameter values.
 
virtual bool build (std::vector< Core::FMTSchedule > schedules=std::vector< Core::FMTSchedule >())
 Build the elements needed to solve the model, overridden by each type of model.
 
virtual bool solve ()
 Solve the model, overridden by each type of model.
 
virtual bool isOptimal () const
 Return true if the FMTModel is optimal.
 
virtual double getObjectiveValue () const
 Return the value of the global objective.
 
std::default_random_engine * getGeneratorPtr () const
 Get a pointer to the generator.
 
std::vector< size_t > getStaticTransitionThemes () const
 Locate the static transition themes.
 
virtual bool SupportsMultiThreading () const
 Some solver dont support multithreading.
 
- Public Member Functions inherited from Core::FMTObject
 FMTObject ()
 Default constructor for FMTObject.
 
virtual ~FMTObject ()
 Default virtual destructor for FMTObject.
 
 FMTObject (const std::unique_ptr< Exception::FMTExceptionHandler > exhandler)
 Construct a FMTObject passing in the exception handler of another FMTObject.
 
 FMTObject (const FMTObject &rhs)
 Copy constructor for FMTObject.
 
FMTObjectoperator= (const FMTObject &rhs)
 Copy assignment operator for FMTObject.
 
virtual void passInLogger (const std::unique_ptr< Logging::FMTLogger > &logger)
 Pass in the logger of another FMTObject.
 
void passInExceptionHandler (const std::unique_ptr< Exception::FMTExceptionHandler > &exhandler)
 Pass in the exception handler of another FMTObject.
 
void redirectLogToFile (const std::string &location)
 Redirect the log to a specific file, appending to it.
 
virtual void setDefaultLogger ()
 Create and set a default logger to the FMTObject.
 
virtual void setQuietLogger ()
 Create and set a quiet logger to the FMTObject.
 
virtual void setTaskLogger ()
 Create and set a task logger to the FMTObject.
 
virtual void setDebugLogger ()
 Create and set a debug logger to the FMTObject.
 
void setDefaultExceptionHandler ()
 Create and set a default exception handler to the FMTObject.
 
void setQuietExceptionHandler ()
 Create and set a quiet exception handler to the FMTObject.
 
void setDebugExceptionHandler ()
 Create and set a debug exception handler to the FMTObject.
 
void setFreeExceptionHandler ()
 Create and set a free exception handler to the FMTObject.
 
void disableNestedExceptions ()
 Disable the nested exception throw of the exception handler.
 
void enableNestedExceptions ()
 Enable the nested exception throw of the exception handler.
 
void setErrorsToWarnings (const std::vector< Exception::FMTexc > &errors)
 Set a list of errors to be cast to warnings on the exception handler.
 
void setMaxWarningsBeforeSilenced (const size_t &maxwarningcount)
 Set the number of warnings raised before being silenced.
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Protected Member Functions

virtual void swapPtr (std::unique_ptr< FMTModel > &rhs)
 Swap this model with an abstract FMTModel.
 
- Protected Member Functions inherited from Models::FMTSeModel
double _getGlobalObjective (const Spatial::FMTSpatialSchedule &p_Schedule) const
 Return the global objective of a spatial schedule.
 
std::vector< double > _getConstraintsValues (const Spatial::FMTSpatialSchedule &p_SpatialSchedule) const
 Return the constraint values of a spatial schedule.
 
void _doRefactorization (Spatial::FMTSpatialSchedule &p_SpatialSchedule) const
 Refactorize a spatial schedule.
 
Spatial::FMTSpatialSchedule _getNewSolution (const Spatial::FMTSpatialSchedule &p_FromSolution) const
 Return a new solution from an existing one.
 
std::map< std::string, double > greedyReferenceBuild (Spatial::FMTSpatialSchedule &p_SpatialSchedule, const Core::FMTSchedule &schedule, const size_t &randomiterations, unsigned int seed=0, double tolerance=FMT_DBL_TOLERANCE, bool log=true) const
 Find the best spatialization for a schedule using random draws.
 
double _getConstraintFactor (size_t p_constraint, double p_GrossValue) const
 Return the factor of a constraint for a gross value.
 
bool _isValidFactor (double p_GrossValue) const
 Return true if a gross value is a valid factor.
 
- Protected Member Functions inherited from Models::FMTModel
void setSeed (const int &p_seed)
 seed the random number generator
 
void setDefaultObjects ()
 Define the default _DEATH action and transition when they are not defined by the user.
 
Core::FMTMask getBaseMask (std::vector< Core::FMTActualDevelopment > optionaldevelopments) const
 Return a mask covering the actual bits used by the FMTModel and the optional developments.
 
std::vector< const Core::FMTTheme * > getStaticPreSolveThemes () const
 Return the themes that are not part of the model, using the transition themes, constraints, actions and yields.
 
void clearActionsCache ()
 Clear the cached actions data.
 
void clearYieldCache ()
 Clear the cached yields data.
 
void clearTransitionCache ()
 Clear the cached transitions data.
 
virtual void swapPtr (std::unique_ptr< FMTModel > &rhs)
 Swap this model for the element at the end of the rhs unique pointer.
 
std::vector< Core::FMTSchedulesetUpSchedulesForBuild (const std::vector< Core::FMTSchedule > &schedules) const
 Prepare the passed schedules for building based on FORCE_PARTIAL_BUILD, always returning a filled vector covering the whole length.
 
bool useActionSerie () const
 Return true if the model makes use of action series.
 
size_t getSeriesMaxSize () const
 Get the maximal serie size for the whole model.
 
- Protected Member Functions inherited from Core::FMTObject
template<class Archive >
void forceSave (Archive &ar, const unsigned int version) const
 Force the serialization to save useful information, which the default FMTObject serialization does not.
 
template<class Archive >
void forceLoad (Archive &ar, const unsigned int version)
 Force the serialization to load useful information, which the default FMTObject serialization does not.
 
void checkSignals () const
 Check if the user has sent a ctrl-c signal using boost::python to FMT.
 
void setCplHandler ()
 Pass the FMT exception handler to the GDAL exception handler (GDAL only).
 

Friends

class boost::serialization::access
 Serialize the FMTSaModel through its base FMTSeModel for multiprocessing across multiple cpus (pickle in Python).
 

Additional Inherited Members

- Static Public Member Functions inherited from Models::FMTModel
static Core::FMTAction defaultDeathAction (const Core::FMTLifespans &llifespan, const std::vector< Core::FMTTheme > &lthemes)
 Return the default death action, based on the lifespan and themes, when not specified by the user.
 
static Core::FMTTransition defaultDeathTransition (const Core::FMTLifespans &llifespan, const std::vector< Core::FMTTheme > &lthemes)
 Return the default death transition, based on the lifespan and themes, when not specified by the user.
 
- Static Public Member Functions inherited from Core::FMTObject
static Logging::FMTLoggergetLogger ()
 get a pointer to the actual logger.
 
static Exception::FMTExceptionHandlergetExceptionHandler ()
 get a pointer to the actual exception handler.
 
static std::string getRuntimeLocation ()
 Return the location of the FMT shared library.
 
static unsigned long long getAvailableMemory ()
 Return the available memory in bytes.
 
static void setTerminateStack ()
 will write the stack in the log when terminate called and raise a function failed.
 
static void setAbortStack ()
 will write the stack in the log when abort called with SIGABRT and raise a function failed.
 
- Static Protected Member Functions inherited from Core::FMTObject
static std::chrono::time_point< std::chrono::high_resolution_clock > getClock ()
 Return a clock of the current time.
 
template<class chrono >
static double getDuration (const std::chrono::time_point< std::chrono::high_resolution_clock > &startclock)
 Return the time elapsed since a start clock as a double.
 
static std::string getDurationInSeconds (const std::chrono::time_point< std::chrono::high_resolution_clock > &startclock)
 Return the time elapsed since a start clock in seconds as a string.
 
static void _logStack ()
 Log the stack trace...
 
static void _terminate ()
 Raise an error with the boost stacktrace.
 
static void _abort (int p_signal)
 Raise an error with the boost stacktrace on abort.
 
- Protected Attributes inherited from Models::FMTSeModel
Spatial::FMTSpatialSchedule m_BestSolution
 Contains the builded spatialsolution latest or best one.
 
Spatial::FMTSpatialGraphs m_SpatialGraphs
 Contains all the SpatialGraphs.
 
- Protected Attributes inherited from Models::FMTModel
std::default_random_engine m_generator
 Random number generator.
 
FMTModelParameters parameters
 
std::vector< Core::FMTActualDevelopmentarea
 Actualdevelopments for period 0, seen in the area section or the shapefile/raster.
 
std::vector< Core::FMTThemethemes
 Model themes of the landscape section file.
 
std::vector< Core::FMTActionactions
 Model actions from the action file and also the _death action.
 
std::vector< Core::FMTTransitiontransitions
 Model transitions from the transition file and also the _death transition.
 
Core::FMTYields yields
 Yields data comming from the yield file.
 
Core::FMTLifespans lifespan
 lifespan data comming from the lifespan file
 
std::vector< Core::FMTOutputoutputs
 Outputs comming from the ouput file.
 
std::vector< Core::FMTConstraintconstraints
 Outputs comming from the optimization file.
 
std::string name
 The name of the Model (name of the .pri file without extension)
 
std::vector< size_t > statictransitionthemes
 The location of the themes static from transitions.
 
- Static Protected Attributes inherited from Core::FMTObject
static std::unique_ptr< Exception::FMTExceptionHandler_exhandler
 A shared pointer to the exception handler.
 
static std::unique_ptr< Logging::FMTLogger_logger
 A shared pointer to the logger.
 

Detailed Description

Area restricted model (ARM) using the simulated annealing meta-heuristic to solve the spatial optimization problem.

Constraints must be goals with weight and the objective function must maximize or minimize those constraints. Only the functions needed to build a simulated annealing algorithm are implemented; the algorithm itself must be written by the user using the functions exposed in this class. An FMTForest is needed to set the initial map, an FMTSaSchedule is needed as cooling schedule and the FMTspatialaction must be set for the model.

Constructor & Destructor Documentation

◆ FMTSaModel() [1/4]

Models::FMTSaModel::FMTSaModel ( )
default

Default constructor for FMTSaModel.

◆ ~FMTSaModel()

Models::FMTSaModel::~FMTSaModel ( )

Destructor for FMTSaModel.

◆ FMTSaModel() [2/4]

Models::FMTSaModel::FMTSaModel ( const FMTSaModel rhs)

Copy constructor for FMTSaModel.

Parameters
[in]rhsthe FMTSaModel to copy.

◆ FMTSaModel() [3/4]

Models::FMTSaModel::FMTSaModel ( const FMTModel rhs)

Construct a FMTSaModel from a FMTModel, using the parent as argument.

Parameters
[in]rhsthe model.

◆ FMTSaModel() [4/4]

Models::FMTSaModel::FMTSaModel ( const FMTModel rhs,
const Spatial::FMTForest forest 
)

Construct a FMTSaModel from a FMTModel and a forest.

Parameters
[in]rhsthe model.
[in]forestthe forest.

Member Function Documentation

◆ build()

virtual bool Models::FMTSaModel::build ( std::vector< Core::FMTSchedule schedules = std::vector< Core::FMTSchedule >())
virtual

Try to build the spatial schedule from a schedule if one is provided, otherwise randomly build the model to be ready to solve.

Parameters
[in]schedulesthe schedules.
Returns
true if the build succeeded else false.

Reimplemented from Models::FMTModel.

◆ buildPeriod()

Graph::FMTGraphStats Models::FMTSaModel::buildPeriod ( )

Build a period of the model.

Returns
the graph stats.

◆ clone()

virtual std::unique_ptr< FMTModel > Models::FMTSaModel::clone ( ) const
finalvirtual

Get a clone of the FMTSaModel.

Returns
a unique pointer to the cloned model.

Reimplemented from Models::FMTSeModel.

◆ getCopy()

virtual std::unique_ptr< FMTModel > Models::FMTSaModel::getCopy ( int  period = 0) const
virtual

Return a copy of the FMTModel for the selected period.

For period 0 returns FMTModel::getCopy; for period greater than 0 returns a copy based on the developments of the FMTGraph. Needs a built graph with a solution.

Parameters
[in]periodthe period.
Returns
the copied model.

Reimplemented from Models::FMTSeModel.

◆ initialSolve()

bool Models::FMTSaModel::initialSolve ( )

Try to solve the model from a cold start.

Returns
true if the initial solve succeeded else false.

◆ isProvenOptimal()

bool Models::FMTSaModel::isProvenOptimal ( ) const

Return true if the solution is optimal based on the termination criteria.

Returns
true if the solution is proven optimal else false.

◆ logMovesReport()

void Models::FMTSaModel::logMovesReport ( ) const

Log the moves report.

◆ operator=()

FMTSaModel & Models::FMTSaModel::operator= ( const FMTSaModel rhs)

Copy assignment operator for FMTSaModel.

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

◆ preSolve()

virtual std::unique_ptr< FMTModel > Models::FMTSaModel::preSolve ( std::vector< Core::FMTActualDevelopment optionaldevelopments = std::vector< Core::FMTActualDevelopment >()) const
virtual

Return a presolved copy of the model using a vector of developments and the actual transitions, reducing the model data if it is badly formulated.

Parameters
[in]optionaldevelopmentsthe optional developments.
Returns
the presolved model.

Reimplemented from Models::FMTSeModel.

◆ solve()

virtual bool Models::FMTSaModel::solve ( )
virtual

Call initialSolve on the solver.

Returns
true if the solve succeeded else false.

Reimplemented from Models::FMTModel.

◆ swapPtr()

virtual void Models::FMTSaModel::swapPtr ( std::unique_ptr< FMTModel > &  rhs)
protectedvirtual

Swap this model with an abstract FMTModel.

Parameters
[in,out]rhsthe unique pointer to swap with.

Reimplemented from Models::FMTSeModel.

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Serialize the FMTSaModel through its base FMTSeModel for multiprocessing across multiple cpus (pickle in Python).

Template Parameters
Archivethe archive type.
Parameters
[in,out]arthe archive to serialize to or from.
[in]versionthe serialization version.

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