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

Abstract class for spatially explicit models, parent of FMTSesModel and FMTSaModel. More...

#include <FMTSeModel.h>

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

Public Member Functions

 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

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).
 

Protected Attributes

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.
 

Friends

class boost::serialization::access
 Serialize the FMTSeModel through its base FMTModel 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.
 
- 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

Abstract class for spatially explicit models, parent of FMTSesModel and FMTSaModel.

Contains a spatial schedule holding the best solution in optimization or the latest solution in simulation.

Constructor & Destructor Documentation

◆ FMTSeModel() [1/4]

Models::FMTSeModel::FMTSeModel ( )

Default constructor for FMTSeModel.

◆ ~FMTSeModel()

virtual Models::FMTSeModel::~FMTSeModel ( )
virtualdefault

Default virtual destructor for FMTSeModel.

◆ FMTSeModel() [2/4]

Models::FMTSeModel::FMTSeModel ( const FMTSeModel rhs)

Copy constructor for FMTSeModel.

Parameters
[in]rhsthe FMTSeModel to copy.

◆ FMTSeModel() [3/4]

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

Construct a FMTSeModel from a model and a forest.

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

◆ FMTSeModel() [4/4]

Models::FMTSeModel::FMTSeModel ( const FMTModel rhs)

Construct a FMTSeModel from a model.

Parameters
[in]rhsthe model.

Member Function Documentation

◆ _doRefactorization()

void Models::FMTSeModel::_doRefactorization ( Spatial::FMTSpatialSchedule p_SpatialSchedule) const
protected

Refactorize a spatial schedule.

Parameters
[in,out]p_SpatialSchedulethe spatial schedule.

◆ _getConstraintFactor()

double Models::FMTSeModel::_getConstraintFactor ( size_t  p_constraint,
double  p_GrossValue 
) const
protected

Return the factor of a constraint for a gross value.

Parameters
[in]p_constraintthe constraint index.
[in]p_GrossValuethe gross value.
Returns
the constraint factor.

◆ _getConstraintsValues()

std::vector< double > Models::FMTSeModel::_getConstraintsValues ( const Spatial::FMTSpatialSchedule p_SpatialSchedule) const
protected

Return the constraint values of a spatial schedule.

Parameters
[in]p_SpatialSchedulethe spatial schedule.
Returns
the constraint values.

◆ _getGlobalObjective()

double Models::FMTSeModel::_getGlobalObjective ( const Spatial::FMTSpatialSchedule p_Schedule) const
protected

Return the global objective of a spatial schedule.

Parameters
[in]p_Schedulethe spatial schedule.
Returns
the global objective.

◆ _getNewSolution()

Spatial::FMTSpatialSchedule Models::FMTSeModel::_getNewSolution ( const Spatial::FMTSpatialSchedule p_FromSolution) const
protected

Return a new solution from an existing one.

Parameters
[in]p_FromSolutionthe solution to start from.
Returns
the new solution.

◆ _isValidFactor()

bool Models::FMTSeModel::_isValidFactor ( double  p_GrossValue) const
protected

Return true if a gross value is a valid factor.

Parameters
[in]p_GrossValuethe gross value.
Returns
true if the factor is valid else false.

◆ clone()

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

Get a clone of the FMTSeModel.

Returns
a unique pointer to the cloned model.

Reimplemented from Models::FMTModel.

Reimplemented in Models::FMTSesModel, and Models::FMTSaModel.

◆ getArea()

virtual std::vector< Core::FMTActualDevelopment > Models::FMTSeModel::getArea ( int  period = 0,
bool  beforegrowanddeath = false 
) const
virtual

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.

Reimplemented from Models::FMTModel.

◆ getConstraintEvaluation()

double Models::FMTSeModel::getConstraintEvaluation ( size_t  p_Constraint) const

Evaluate a constraint with the actual solution.

Parameters
[in]p_Constraintthe constraint index.
Returns
the evaluation value.

◆ getCopy()

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

Return a copy of the model for a period, cleaning the constraints and keeping the objective.

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

Reimplemented from Models::FMTModel.

Reimplemented in Models::FMTSaModel, and Models::FMTSesModel.

◆ getDisturbanceStats()

std::string Models::FMTSeModel::getDisturbanceStats ( ) const

Return a string of patch statistics (area, perimeter) of the disturbances stack.

Returns
the disturbance statistics.

◆ getMapping()

Spatial::FMTForest Models::FMTSeModel::getMapping ( ) const

Return a copy of the actual spatial forest state of each development.

Returns
the forest mapping.

◆ getObjectiveValue()

virtual double Models::FMTSeModel::getObjectiveValue ( ) const
virtual

Return the global objective value of the actual solution.

Returns
the objective value.

Reimplemented from Models::FMTModel.

◆ getOutput()

virtual std::map< std::string, double > Models::FMTSeModel::getOutput ( const Core::FMTOutput output,
int  period,
Core::FMToutputlevel  level = Core::FMToutputlevel::standard 
) const
virtual

Get the output value for a period using the spatial solution.

The map key is the output name when level is standard or totalonly, or the development name when level is developpement.

Parameters
[in]outputthe output.
[in]periodthe period.
[in]levelthe output level.
Returns
a map of names to values.

Reimplemented from Models::FMTModel.

◆ getSchedule()

std::vector< Core::FMTSchedule > Models::FMTSeModel::getSchedule ( bool  withlock = false) const

Return a copy of the operated schedules of the model, which can differ from the potential schedule.

Parameters
[in]withlockif true includes the locked developments.
Returns
the operated schedules.

◆ getSchedules()

std::vector< Core::FMTSchedule > Models::FMTSeModel::getSchedules ( const Spatial::FMTSpatialSchedule p_SpatialSchedule,
bool  withlock = false 
) const

Get the schedules of a spatial solution.

Parameters
[in]p_SpatialSchedulethe spatial schedule.
[in]withlockif true includes the locked developments.
Returns
the schedules.

◆ getSolution()

virtual Core::FMTSchedule Models::FMTSeModel::getSolution ( int  period,
bool  withlock = false 
) const
virtual

Get the standard solution for a period, without the natural growth solution.

Parameters
[in]periodthe period.
[in]withlockif true includes the locked developments.
Returns
the solution schedule.

Reimplemented from Models::FMTModel.

◆ getSolutionStatus()

void Models::FMTSeModel::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.

Parameters
[in]p_SpatialSchedulethe spatial schedule.
[out]p_Objectivethe objective value.
[out]p_PrimalInFeasibilitythe primal infeasibility.
[in]withsenseif true applies the sense.
[in]withfactorizationif true applies the factorization.
[in]withspatialif true includes the spatial part.

◆ getSpatialOutput()

virtual Spatial::FMTLayer< double > Models::FMTSeModel::getSpatialOutput ( const Core::FMTOutput output,
int  period 
) const
virtual

Get the spatial output value based on the spatial solution.

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

◆ getSpSchedule()

Spatial::FMTSpatialSchedule Models::FMTSeModel::getSpSchedule ( ) const
inline

Return a copy of the spatially explicit solution.

Returns
the spatial schedule.

◆ greedyReferenceBuild()

std::map< std::string, double > Models::FMTSeModel::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
protected

Find the best spatialization for a schedule using random draws.

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

◆ logConstraintsFactors()

void Models::FMTSeModel::logConstraintsFactors ( ) const

Log the constraint factors.

◆ logConstraintsInfeasibilities()

void Models::FMTSeModel::logConstraintsInfeasibilities ( ) const

Log the constraint infeasibilities, spatial or not.

◆ operator=()

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

Copy assignment operator for FMTSeModel.

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

◆ postSolve()

virtual void Models::FMTSeModel::postSolve ( const FMTModel originalbasemodel)
virtual

Postsolve the model back into a complete model using the original model.

Parameters
[in]originalbasemodelthe original base model.

Reimplemented from Models::FMTModel.

◆ preSolve()

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

Return a presolved copy of the model, presolving the forest map and the spatial actions.

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

Reimplemented from Models::FMTModel.

Reimplemented in Models::FMTSaModel, and Models::FMTSesModel.

◆ setInitialMapping()

bool Models::FMTSeModel::setInitialMapping ( const Spatial::FMTForest forest)

Set the initial forest state, to be set before greedyReferenceBuild is called.

Parameters
[in]forestthe initial forest.
Returns
true if the mapping is set else false.

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Serialize the FMTSeModel through its base FMTModel 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.

Member Data Documentation

◆ m_BestSolution

Spatial::FMTSpatialSchedule Models::FMTSeModel::m_BestSolution
protected

Contains the builded spatialsolution latest or best one.

◆ m_SpatialGraphs

Spatial::FMTSpatialGraphs Models::FMTSeModel::m_SpatialGraphs
protected

Contains all the SpatialGraphs.


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