![]() |
FMT 1.2.0
Forest management tools for forest planning
|
Base class for the different models in FMT. More...
#include <FMTModel.h>
Public Member Functions | |
| 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::FMTSchedule > | buildSchedule (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::FMTSchedule > | aggregateSchedules (const std::vector< Core::FMTSchedule > &p_schedules) const |
| Build a new schedule based on p_schedules with the corresponding aggregated actions. | |
| std::vector< Core::FMTSchedule > | splitSchedules (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 > <hemes, const std::vector< Core::FMTAction > &lactions, const std::vector< Core::FMTTransition > <ransitions, 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. | |
| FMTModel & | operator= (FMTModel &&rhs) |
| Default move assignment for FMTModel. | |
| virtual std::vector< Core::FMTActualDevelopment > | getArea (int period=0, bool beforegrowanddeath=false) const |
| Get the area of a given period as actual developments. | |
| virtual std::unique_ptr< FMTModel > | getCopy (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< FMTModel > | preSolve (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::FMTTheme > | getThemes () const |
| Return a copy of the themes of the model. | |
| std::vector< Core::FMTAction > | getActions () const |
| Return a copy of the actions of the model. | |
| std::vector< Core::FMTTransition > | getTransitions () 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::FMTOutput > | getOutputs () const |
| Return a copy of the outputs of the model. | |
| std::vector< Core::FMTConstraint > | getConstraints () 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 > <hemes) |
| 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 > <ransitions) |
| 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. | |
| FMTModel & | operator= (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::FMTConstraint > | getReplanningConstraints (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< FMTModel > | clone () 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::FMTConstraint > | goalConstraints (double penalty=999999) const |
| Return all constraints and the objective with goals and penalty. | |
| std::vector< Core::FMTConstraint > | getTacticalConstraints (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. | |
| FMTObject & | operator= (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) |
Static Public Member Functions | |
| static Core::FMTAction | defaultDeathAction (const Core::FMTLifespans &llifespan, const std::vector< Core::FMTTheme > <hemes) |
| 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 > <hemes) |
| 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::FMTLogger * | getLogger () |
| get a pointer to the actual logger. | |
| static Exception::FMTExceptionHandler * | getExceptionHandler () |
| 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. | |
Protected Member Functions | |
| 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::FMTSchedule > | setUpSchedulesForBuild (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 | |
| std::default_random_engine | m_generator |
| Random number generator. | |
| FMTModelParameters | parameters |
| std::vector< Core::FMTActualDevelopment > | area |
| Actualdevelopments for period 0, seen in the area section or the shapefile/raster. | |
| std::vector< Core::FMTTheme > | themes |
| Model themes of the landscape section file. | |
| std::vector< Core::FMTAction > | actions |
| Model actions from the action file and also the _death action. | |
| std::vector< Core::FMTTransition > | transitions |
| 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::FMTOutput > | outputs |
| Outputs comming from the ouput file. | |
| std::vector< Core::FMTConstraint > | constraints |
| 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 | |
| template<class T1 , class T2 > | |
| class | Graph::FMTGraph |
| class | Graph::FMTLineGraph |
| class | Spatial::FMTSpatialSchedule |
| class | Spatial::FMTSpatialNodesCache |
| class | Spatial::FMTSpatialGraphs |
| class | Parser::FMTModelParser |
| class | Graph::FMTGraphVertexToYield |
| class | boost::serialization::access |
| Save function used for serialization to do multiprocessing across multiple cpus (pickle in Python). | |
Additional Inherited Members | |
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. | |
Base class for the different models in FMT.
FMTModel is the formulation seen in the Woodstock files of a forest planning problem. FMTLpModel / FMTSaModel / FMTSesModel use the FMTModel protected members to generate the problem based on LP/SA or to simply simulate the FMTModel.
| Models::FMTModel::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.
| [in] | larea | the initial actual developments (area section). |
| [in] | lthemes | the model themes. |
| [in] | lactions | the model actions. |
| [in] | ltransitions | the model transitions. |
| [in] | lyields | the model yields. |
| [in] | llifespan | the model lifespans. |
| [in] | lname | the model name. |
| [in] | loutputs | the model outputs. |
| [in] | lconstraints | the model constraints, optional and not needed for FMTSesModel. |
| [in] | lparameters | the model parameters. |
| Models::FMTModel::FMTModel | ( | ) |
Default constructor of FMTModel.
|
virtualdefault |
Default virtual destructor of FMTModel.
| Models::FMTModel::FMTModel | ( | FMTModel && | rhs | ) |
| Models::FMTModel::FMTModel | ( | const FMTModel & | rhs | ) |
| void Models::FMTModel::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.
| [in] | name | the output name. |
| [in] | maskstring | the mask string (? ? ?). |
| [in] | outputtarget | the type of output created. |
| [in] | action | the targeted action string. |
| [in] | yield | the targeted yield string. |
| [in] | description | the description of the output. |
| [in] | targetTheme | the targeted theme index. |
|
inline |
Add FMTYieldHandler from a vector to the yields.
Can only be used for FMTAgeYieldHandler and FMTTimeYieldHandler. FMTModelYieldHandler or FMTcomplexyieldhandler must be added in the .yld file to parse with the model.
| T | the yield handler type. |
| [in] | yieldhandlers | the yield handlers to add. |
| void Models::FMTModel::addYieldHandlersFromPtr | ( | const std::vector< std::unique_ptr< Core::FMTYieldHandler > > & | yieldhandlers | ) |
Add unique pointers of FMTYieldHandler from a vector to the yields.
| [in] | yieldhandlers | the yield handlers to add. |
| Models::FMTModel 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.
| [in] | p_Aggregates | the action aggregates we want to merge together. |
| [in] | p_ActionOrdering | the order used for the hierarchy of actions, if empty uses the order of the actual actions. |
| std::vector< Core::FMTSchedule > Models::FMTModel::aggregateSchedules | ( | const std::vector< Core::FMTSchedule > & | p_schedules | ) | const |
Build a new schedule based on p_schedules with the corresponding aggregated actions.
| [in] | p_schedules | the schedules of the original model. |
| FMTModel Models::FMTModel::basePreSolve | ( | ) | const |
Presolve the model using the existing area.
Can reduce the number of global themes, actions, transitions, yields, lifespans, outputs and constraints if the model is badly formulated.
|
inlinevirtual |
Build the elements needed to solve the model, overridden by each type of model.
| [in] | schedules | the schedules used to build the model. |
Reimplemented in Models::FMTLpModel, Models::FMTNssModel, Models::FMTSaModel, and Models::FMTSesModel.
| FMTModel Models::FMTModel::buildAction | ( | const std::string & | p_actionName, |
| const std::string & | p_Targetyield | ||
| ) | const |
Build an action based on the positive value of a yield.
| [in] | p_actionName | the name of the action to create. |
| [in] | p_Targetyield | the yield to look for positive value. |
| std::vector< Core::FMTSchedule > Models::FMTModel::buildSchedule | ( | 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.
| [in] | p_action | the action we want to build a schedule for. |
| [in] | p_BaseModel | the base model. |
| [in] | p_Targetyield | the yield name to look for. |
| [in] | p_schedules | the non extended schedule we want to build on. |
| void Models::FMTModel::cleanActionsNTransitions | ( | ) |
Delete actions that have no defined transition and transitions that have no defined action, then sort them.
|
protected |
Clear the cached actions data.
|
virtual |
Clear caching elements to reduce memory usage.
Reimplemented in Models::FMTLpModel.
|
protected |
Clear the cached transitions data.
|
protected |
Clear the cached yields data.
|
virtual |
Get a clone of the FMTModel.
Reimplemented in Models::FMTLpModel, Models::FMTNssModel, Models::FMTSeModel, Models::FMTSesModel, Models::FMTSaModel, and Models::FMTSrModel.
|
static |
Return the default death action, based on the lifespan and themes, when not specified by the user.
| [in] | llifespan | the lifespan data. |
| [in] | lthemes | the model themes. |
|
static |
Return the default death transition, based on the lifespan and themes, when not specified by the user.
| [in] | llifespan | the lifespan data. |
| [in] | lthemes | the model themes. |
|
virtual |
Build the model and do the initial solve or simulate, using the build and solve overridden functions of the different model types.
| [in] | solve | if true solves the model, otherwise simulates it. |
| [in] | schedules | the schedules used to build the model. |
| bool Models::FMTModel::empty | ( | ) | const |
Return true if the FMTModel is empty.
|
inline |
Return a copy of the actions of the model.
|
virtual |
Get the area of a given period as actual developments.
| [in] | period | the period to get the area from. |
| [in] | beforegrowanddeath | if true returns the developments before growth and death to the next period. |
Reimplemented in Models::FMTSeModel, and Models::FMTSrModel.
| int Models::FMTModel::getAreaPeriod | ( | ) | const |
get the period of the area section.
|
protected |
Return a mask covering the actual bits used by the FMTModel and the optional developments.
| [in] | optionaldevelopments | the optional developments to cover. |
| std::vector< int > Models::FMTModel::getCompressTime | ( | ) | const |
Return a vector with the compresstime value for each period, the first period being index 0. See FMTModelParameters.h.
|
inline |
Return a copy of the constraints of the model.
|
virtual |
Return a copy of the FMTModel for the selected period, cleaning the constraints and keeping the objective.
| [in] | period | the period to copy. |
Reimplemented in Models::FMTLpModel, Models::FMTNssModel, Models::FMTSaModel, Models::FMTSeModel, Models::FMTSesModel, and Models::FMTSrModel.
| Core::FMTMask Models::FMTModel::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.
| [in] | output | the output to look into. |
| [in] | ignoreoutputvariables | if true ignores the output variables. |
| Core::FMTMask Models::FMTModel::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.
| [in] | node | the output node to look into. |
| [in] | ignoreoutputvariables | if true ignores the output variables. |
| std::default_random_engine * Models::FMTModel::getGeneratorPtr | ( | ) | const |
Get a pointer to the generator.
| double Models::FMTModel::getInitialArea | ( | ) | const |
Return the sum of the area of the area vector.
|
inline |
Return a copy of the lifespan of the model.
| FMTModelStats Models::FMTModel::getModelStats | ( | ) | const |
Return the statistics of the model such as the number of themes, yields, actions and transitions.
|
inline |
Return the name of the FMTModel.
|
virtual |
Return the value of the global objective.
Reimplemented in Models::FMTSeModel, and Models::FMTSrModel.
|
virtual |
Get the output value of an output for a given 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.
| [in] | output | the output to evaluate. |
| [in] | period | the period to evaluate. |
| [in] | level | the output level of detail. |
Reimplemented in Models::FMTLpModel, Models::FMTSeModel, and Models::FMTSrModel.
|
inline |
Return a copy of the outputs of the model.
|
virtual |
For each output get a vector of output values from the first period to the last period.
| [in] | theoutputs | the outputs to evaluate. |
| [in] | firstPeriod | the first period. |
| [in] | lastPeriod | the last period. |
| [in] | level | the output level of detail. |
| bool Models::FMTModel::getParameter | ( | const FMTboolmodelparameters & | key | ) | const |
Getter for bool model parameters. See FMTModelParameters.h.
| [in] | key | the parameter key. |
| double Models::FMTModel::getParameter | ( | const FMTdblmodelparameters & | key | ) | const |
Getter for double model parameters. See FMTModelParameters.h.
| [in] | key | the parameter key. |
| int Models::FMTModel::getParameter | ( | const FMTintmodelparameters & | key | ) | const |
Getter for int model parameters. See FMTModelParameters.h.
| [in] | key | the parameter key. |
| const std::string & Models::FMTModel::getParameter | ( | const FMTstrmodelparameters & | p_key | ) | const |
Getter for str model parameters. See FMTModelParameters.h.
| [in] | p_key | the parameter key. |
| Core::FMTMaskFilter Models::FMTModel::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.
| [in] | originalthemes | the original themes of the model. |
| [in] | devmask | the development mask. |
| Core::FMTSchedule Models::FMTModel::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.
| [in] | toRemove | the developments to remove from the selection. |
| [in] | selection | the developments to test. |
| [in] | withlock | if true keeps the locked developments. |
| Core::FMTMaskFilter Models::FMTModel::getPreSolveFilter | ( | const std::vector< Core::FMTTheme > & | originalthemes | ) | const |
Get the preSolve filter.
| [in] | originalthemes | the original themes of the model. |
|
virtual |
Adjust the constraints that need to be set to a value of the global or local model and return all constraints.
| [in] | modeltype | the type of the model. |
| [in] | localconstraints | the local constraints. |
| [in] | period | the replanning period. |
Reimplemented in Models::FMTLpModel.
| std::vector< std::string > Models::FMTModel::getSchedulesPriorities | ( | const std::vector< Core::FMTSchedule > & | p_schedules | ) | const |
Return the action names in priority of area scheduled.
| [in] | p_schedules | the schedules to look at. |
| Core::FMTMask Models::FMTModel::getSelectedMask | ( | const std::vector< Core::FMTTheme > & | originalthemes | ) | const |
Get the selection mask needed to preSolve a FMTMask when the model is presolved.
| [in] | originalthemes | the original themes of the model. |
|
protected |
Get the maximal serie size for the whole model.
|
virtual |
Get the standard solution for a given period, without the natural growth solution.
| [in] | period | the period to get the solution from. |
| [in] | withlock | if true the schedule contains the locked developments. |
Reimplemented in Models::FMTSeModel, and Models::FMTSrModel.
|
virtual |
Return a mask where static attributes have a value of 1 and dynamic attributes a value of 0.
| [in] | node | the output node to look into. |
| [in] | ignoreoutputvariables | if true ignores the output variables. |
|
protected |
Return the themes that are not part of the model, using the transition themes, constraints, actions and yields.
| std::vector< size_t > Models::FMTModel::getStaticTransitionThemes | ( | ) | const |
Locate the static transition themes.
| std::vector< Core::FMTConstraint > Models::FMTModel::getTacticalConstraints | ( | double | penalty = 999999, |
| double | scheduleweight = 999999, |
||
| double | objective = 0, |
||
| double | objectivefactor = 1.0 |
||
| ) | const |
Get the constraints adapted for a tactical model.
| [in] | penalty | the penalty applied to the goals. |
| [in] | scheduleweight | the weight of the schedule. |
| [in] | objective | the objective value. |
| [in] | objectivefactor | the objective factor. |
|
inline |
Return a copy of the themes of the model.
|
inline |
Return a copy of the transitions of the model.
|
inline |
Return a copy of the yields of the model.
| double Models::FMTModel::getYieldValue | ( | const std::string & | p_mask, |
| const std::string & | p_yield, | ||
| int | p_age, | ||
| int | p_period | ||
| ) | const |
Get yield value.
| [in] | p_mask | mask in string format |
| [in] | p_yield | the yield name. |
| [in] | p_age | Development age |
| [in] | p_period | Development period |
| std::vector< Core::FMTConstraint > Models::FMTModel::goalConstraints | ( | double | penalty = 999999 | ) | const |
Return all constraints and the objective with goals and penalty.
| [in] | penalty | the penalty applied to the goals. |
| bool Models::FMTModel::gotReIgnore | ( | const int & | p_replanningPeriod | ) | const |
Check if setReIgnore needs to be called.
| [in] | p_replanningPeriod | the replanning period to check. |
| bool Models::FMTModel::gotReplicate | ( | const int & | p_replanningPeriod | ) | const |
Check if setReplicate needs to be called.
| [in] | p_replanningPeriod | the replanning period to check. |
|
virtual |
Return true if the FMTModel is optimal.
Reimplemented in Models::FMTSrModel.
| bool Models::FMTModel::isStaticNode | ( | const Core::FMTOutputNode & | node, |
| double | ratioofset = 0.1 |
||
| ) | const |
Return true if the node can be used in static mask functions.
The higher the ratio of set the more likely this function returns true.
| [in] | node | the output node to check. |
| [in] | ratioofset | the ratio of set threshold. |
| bool Models::FMTModel::isValid | ( | ) |
Validate the whole FMTModel through themes, actual developments, yields, actions, transitions, outputs and constraints.
| std::vector< const Core::FMTTheme * > Models::FMTModel::locateDynamicThemes | ( | const Core::FMTOutput & | outpu, |
| bool | ignoreoutputvariables = false |
||
| ) | const |
Return the themes used in the transition scheme.
| [in] | outpu | the output to look into. |
| [in] | ignoreoutputvariables | if true ignores the output variables. |
| std::vector< const Core::FMTTheme * > Models::FMTModel::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.
| [in] | node | the output node to look into. |
| [in] | ignoreoutputvariables | if true ignores the output variables. |
| [in] | basethemes | optional base themes to start from. |
| std::vector< const Core::FMTTheme * > Models::FMTModel::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).
| [in] | output | the output to look into. |
| [in] | ignoreoutputvariables | if true ignores the output variables. |
| std::vector< const Core::FMTTheme * > Models::FMTModel::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).
| [in] | output | the output node to look into. |
| [in] | ignoreoutputvariables | if true ignores the output variables. |
| std::vector< const Core::FMTTheme * > Models::FMTModel::locateStaticTransitionsThemes | ( | ) | const |
Return the static themes based on the model transitions.
| bool Models::FMTModel::operator< | ( | const FMTModel & | rhs | ) | const |
| bool Models::FMTModel::operator== | ( | const FMTModel & | rhs | ) | const |
|
virtual |
Postsolve the presolved model into the original model.
| [in] | originalbasemodel | the original base model. |
Reimplemented in Models::FMTSeModel, and Models::FMTSrModel.
|
virtual |
Return a new presolved FMTModel using developments and the actual transitions of the model.
Can reduce the number of global themes, actions, transitions, yields, lifespans, outputs and constraints if the model is badly formulated.
| [in] | optionaldevelopments | optional developments to preSolve on. |
Reimplemented in Models::FMTLpModel, Models::FMTNssModel, Models::FMTSaModel, Models::FMTSeModel, Models::FMTSesModel, and Models::FMTSrModel.
| Core::FMTSchedule Models::FMTModel::preSolveSchedule | ( | const Core::FMTSchedule & | originalbaseschedule, |
| const FMTModel & | originalbasemodel | ||
| ) | const |
Return a new schedule with presolved development masks and actions.
| [in] | originalbaseschedule | the original (not presolved) schedule. |
| [in] | originalbasemodel | the original (not presolved) model. |
| void Models::FMTModel::push_back | ( | const FMTModel & | rhs | ) |
| void Models::FMTModel::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.
| [in] | p_themeName | the name of the theme to push. |
| [in] | p_yieldName | the yield used for SBW. |
| [in] | p_attributes | the attributes of the theme, will be the default of every mask. |
| void Models::FMTModel::setActions | ( | const std::vector< Core::FMTAction > & | lactions | ) |
Setter for the actions of the model, replacing the originals.
| [in] | lactions | the actions to set. |
| void Models::FMTModel::setArea | ( | const std::vector< Core::FMTActualDevelopment > & | ldevs | ) |
Setter for the initial actual developments (area section), replacing the originals.
Also checks if the actual development lifespan is shorter than the lock, raising FMTdeathwithlock, and reduces the locks accordingly if the error is set to warning.
| [in] | ldevs | the actual developments to set. |
| void Models::FMTModel::setAreaPeriod | ( | const int & | period | ) |
Change the initial area period to the targeted period.
| [in] | period | the new area period. |
| bool Models::FMTModel::setCompressTime | ( | const int & | periodStart, |
| const int & | periodStop, | ||
| const int & | value | ||
| ) |
Set the compresstime value for a range of periods. See FMTModelParameters.h.
| [in] | periodStart | the first period of the range. |
| [in] | periodStop | the last period of the range. |
| [in] | value | the compresstime value to set. |
| void Models::FMTModel::setConstraints | ( | const std::vector< Core::FMTConstraint > & | lconstraint | ) |
Setter for the constraints of the model, replacing the original.
| [in] | lconstraint | the constraints to set. |
|
protected |
Define the default _DEATH action and transition when they are not defined by the user.
| void Models::FMTModel::setLifespan | ( | const Core::FMTLifespans & | llifespan | ) |
Setter for the lifespan of the model, replacing the original.
| [in] | llifespan | the lifespan to set. |
| void Models::FMTModel::setName | ( | const std::string & | newname | ) |
Set the name of the FMTModel.
| [in] | newname | the new model name. |
| void Models::FMTModel::setOutputs | ( | const std::vector< Core::FMTOutput > & | newoutputs | ) |
Setter for the outputs of the model.
| [in] | newoutputs | the outputs to set. |
|
virtual |
Set a thread owned logger so the solver does not work in concurrency.
| [in,out] | logger | the logger owned by the thread to pass to the solver. |
Reimplemented in Models::FMTSrModel.
|
virtual |
Setter for bool model parameters. See FMTModelParameters.h.
| [in] | key | the parameter key. |
| [in] | value | the value to set. |
Reimplemented in Models::FMTNssModel, and Models::FMTSrModel.
|
virtual |
Setter for double model parameters. See FMTModelParameters.h.
| [in] | key | the parameter key. |
| [in] | value | the value to set. |
|
virtual |
set int parameters to nss model.
| [in] | p_key | the int key to change. |
| [in] | p_value | to set to the p_key. |
Reimplemented in Models::FMTSrModel, and Models::FMTNssModel.
|
virtual |
Setter forstr model parameters. See FMTModelParameters.h.
| [in] | p_key | the enum key of the parameter. |
| [in] | p_value | the value of the parameter. |
| void Models::FMTModel::setReplicate | ( | size_t | p_replicate, |
| int | p_ReplanningPeriod | ||
| ) |
Set the constraints to the specified Replanning Period.
| [in] | p_replicate | the replicate of the replanning task |
| [in] | p_ReplanningPeriod | the replanning period. |
|
protected |
seed the random number generator
| [in] | p_seed | the seed. |
| void Models::FMTModel::setThemes | ( | const std::vector< Core::FMTTheme > & | lthemes | ) |
Setter for the themes of the model, replacing the originals.
| [in] | lthemes | the themes to set. |
| void Models::FMTModel::setTransitions | ( | const std::vector< Core::FMTTransition > & | ltransitions | ) |
Setter for the transitions of the model, replacing the originals.
| [in] | ltransitions | the transitions to set. |
|
protected |
Prepare the passed schedules for building based on FORCE_PARTIAL_BUILD, always returning a filled vector covering the whole length.
| [in] | schedules | the schedules to prepare. |
| void Models::FMTModel::setYields | ( | const Core::FMTYields & | lylds | ) |
Setter for the yields of the model, replacing the original.
| [in] | lylds | the yields to set. |
|
virtual |
Show the parameter values.
| [in] | showhelp | if true shows a brief description of each parameter. |
|
inlinevirtual |
Solve the model, overridden by each type of model.
Reimplemented in Models::FMTLpModel, Models::FMTNssModel, Models::FMTSaModel, and Models::FMTSesModel.
| Models::FMTModel 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.
| [in] | p_Actions | the actions that you want to split. |
| [in] | p_masks | the masks you want to use to split the actions. |
| std::vector< Core::FMTSchedule > Models::FMTModel::splitSchedules | ( | const std::vector< Core::FMTSchedule > & | p_schedules | ) | const |
Using the actions of the model change the actions of the schedule.
| [in] | p_schedules | the schedules of the original model. |
|
virtual |
Some solver dont support multithreading.
Reimplemented in Models::FMTSrModel.
|
protectedvirtual |
Swap this model for the element at the end of the rhs unique pointer.
| [in,out] | rhs | the unique pointer to swap with. |
Reimplemented in Models::FMTSaModel.
|
protected |
Return true if the model makes use of action series.
|
friend |
Save function used for serialization to do multiprocessing across multiple cpus (pickle in Python).
| Archive | the archive type. |
| [in,out] | ar | the archive to save to. |
| [in] | version | the serialization version. |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
protected |
Model actions from the action file and also the _death action.
|
protected |
Actualdevelopments for period 0, seen in the area section or the shapefile/raster.
|
protected |
Outputs comming from the optimization file.
|
protected |
lifespan data comming from the lifespan file
|
mutableprotected |
Random number generator.
|
protected |
The name of the Model (name of the .pri file without extension)
|
protected |
Outputs comming from the ouput file.
|
protected |
Parameters needed for the function doPlanning by the different types of FMTModel. See FMTModelParameters for detail description or use FMTModel::showParameters(true) to see your parameters and a brief description.
|
protected |
The location of the themes static from transitions.
|
protected |
Model themes of the landscape section file.
|
protected |
Model transitions from the transition file and also the _death transition.
|
protected |
Yields data comming from the yield file.