11#ifndef FMTsrmodel_Hm_included
12#define FMTsrmodel_Hm_included
15#include <boost/serialization/export.hpp>
16#include <boost/serialization/split_member.hpp>
20#include "FMTGraph.hpp"
35 class FMTGraphVertexToYield;
208 Core::FMTSchedule getScheduleProportions(
int period,
bool withlock) const;
214 Graph::FMTGraphStats getStats() const;
221 Graph::FMTGraphStats getGraphStats(const
Core::FMTMask& p_Subset) const;
239 virtual
std::map<
std::
string,
double> getOutput(const
Core::FMTOutput& output,
240 int period,
Core::FMToutputlevel level =
Core::FMToutputlevel::standard) const;
250 Rcpp::DataFrame getOutputsDataFrame(
const std::vector<Core::FMTOutput>& outputsdata,
int firstPeriod,
int lastPeriod)
const;
262 bool forcepartialbuild =
false,
int compressageclassoperability = 1);
278 virtual std::vector<Core::FMTActualDevelopment>
getArea(
int period = 0,
bool beforegrowanddeath =
false)
const override;
287 std::vector<Core::FMTActualDevelopment>
getPotentialArea(
int p_Period = 0,
bool p_BeforeGrowAndDeath =
false)
const;
307 virtual std::unique_ptr<FMTModel>
clone()
const override;
313 void passInLogger(
const std::unique_ptr<Logging::FMTLogger>& logger)
override;
320 virtual std::unique_ptr<FMTModel>
preSolve(std::vector<Core::FMTActualDevelopment> optionaldevelopments = std::vector<Core::FMTActualDevelopment>())
const override;
381 std::set<std::string>
getAllMasks(
const std::vector<Core::FMTTheme>& p_selectedThemes)
const;
391 std::unique_ptr<Graph::FMTGraph<Graph::FMTVertexProperties, Graph::FMTEdgeProperties>>
m_graph;
404 std::vector<int>& sumvariables, std::vector<double>& sumcoefficiants)
const;
438 std::queue<Graph::FMTGraph<Graph::FMTVertexProperties, Graph::FMTEdgeProperties>::FMTvertex_descriptor>
getActives();
447 friend class boost::serialization::access;
448 template<
class Archive>
449 void save(Archive& ar,
const unsigned int version)
const
451 ar& boost::serialization::make_nvp(
"model", boost::serialization::base_object<FMTModel>(*
this));
452 ar& BOOST_SERIALIZATION_NVP(solver);
453 ar& BOOST_SERIALIZATION_NVP(m_graph);
462 template<
class Archive>
463 void load(Archive& ar,
const unsigned int version)
465 ar& boost::serialization::make_nvp(
"model", boost::serialization::base_object<FMTModel>(*
this));
466 ar& BOOST_SERIALIZATION_NVP(solver);
467 ar& BOOST_SERIALIZATION_NVP(m_graph);
470 BOOST_SERIALIZATION_SPLIT_MEMBER()
#define FMT_DBL_TOLERANCE
Definition: FMTutility.h:11
#define FMTEXPORT
Definition: FMTutility.h:125
Core class holding, as a boost dynamic bitset, which theme attributes are part of a mask.
Definition: FMTMask.h:96
Spatially referenced schedule describing the area of developments for which an action can be operated...
Definition: FMTSchedule.h:29
Statistics about a FMTGraph and its FMTLpSolver: their size, elements and type of elements.
Definition: FMTGraphStats.h:28
Adapter pointing to a vertex of a line graph or a full graph and its model, used to answer a generic ...
Definition: FMTGraphVertexToYield.h:31
Definition: FMTGraphVertexToYield.h:20
Base class handling the level of information printed by FMT.
Definition: FMTLogger.h:37
Abstract class to ease the usage of the OsiSolverInterface in FMT for linear programming models.
Definition: FMTLpSolver.h:49
void passInMessageHandler(Logging::FMTLogger &logger)
Pass the FMTLogger to the solver interface.
Base class for the different models in FMT.
Definition: FMTModel.h:62
Base class holding the attributes and methods shared between the spatially referenced models (FMTLpMo...
Definition: FMTSrModel.h:46
virtual std::unique_ptr< FMTModel > preSolve(std::vector< Core::FMTActualDevelopment > optionaldevelopments=std::vector< Core::FMTActualDevelopment >()) const override
Return a presolved copy of the FMTSrModel.
std::unique_ptr< Graph::FMTGraph< Graph::FMTVertexProperties, Graph::FMTEdgeProperties > > m_graph
graph holding the FMTdevelopments for all the periods.
Definition: FMTSrModel.h:391
void passInLogger(const std::unique_ptr< Logging::FMTLogger > &logger) override
Pass in the logger, overridden for the osisolverinterface.
void clearGraphCache()
Clear the node caching in the graph.
bool SupportsMultiThreading() const override
Return true if the solver support multithreading.
FMTLpSolver * getSolverPtr()
Get a pointer to the solver behind the model.
void clearGraphDevelopments()
Clear the developments location by periods in the graph.
bool setParameter(const FMTboolmodelparameters &key, const bool &value) override
Override setter for bool model parameters.
virtual void postSolve(const FMTModel &originalbasemodel)
Postsolve the presolved model back into the original model, also postsolving the FMTGraph of the FMTS...
size_t getGraphSize() const
Return the size of the graph.
~FMTSrModel()=default
Default destructor for FMTSrModel.
std::set< std::string > getAllMasks(const std::vector< Core::FMTTheme > &p_selectedThemes) const
Get all masks in string format for a complete graph, only for the selected themes.
virtual std::vector< Core::FMTActualDevelopment > getArea(int period=0, bool beforegrowanddeath=false) const override
Return the area for a given period for a FMTSrModel.
virtual std::unique_ptr< FMTModel > clone() const override
Get a clone of the FMTSrModel.
bool boundSolution(int period, double tolerance=FMT_DBL_TOLERANCE)
Bound the primal variables to the primal solution present in the matrix for a given period and tolera...
const FMTLpSolver * getConstSolverPtr() const
Get a pointer to the const solver behind the model.
Graph::FMTGraphStats buildPeriod(Core::FMTSchedule schedule=Core::FMTSchedule(), bool forcepartialbuild=false, int compressageclassoperability=1)
Main function used to build the graph and the matrix, adding a period within the graph and the matrix...
std::vector< const Core::FMTDevelopment * > getNoChoice(const Core::FMTMask &base_mask) const
Return the period 0 developments of a base mask that have no actions assigned for the whole planning ...
std::set< Core::FMTSerie > getRotations(const Core::FMTMask &mask, const std::string &aggregate) const
Get all the unique rotations (in periods) taken to complete a serie of actions for a mask and an acti...
virtual double getObjectiveValue() const
Return the value of the solver objective.
FMTSrModel(const FMTModel &base, FMTSolverInterface lsolvertype)
Main constructor building a FMTSrModel from its base class and letting the user choose the solver typ...
Graph::FMTGraphStats initializeMatrix()
Initialize the solver interface, called once when the FMTGraph was empty after the first call of buil...
Core::FMTSchedule getSolution(int period, bool withlock=false) const final
Get the standard solution for a given period, without the natural growth solution.
bool setSolutionByLp(int period, const Core::FMTSchedule &schedule, double tolerance=FMT_DBL_TOLERANCE)
Set the solution on a partial graph using a schedule, changing the objective function,...
bool summarize(const std::map< int, double > &variables, std::vector< int > &sumvariables, std::vector< double > &sumcoefficiants) const
Summarize constraints stored in a map structure (key is the variable, element is the coefficient) int...
bool forceSolution(int period, const Core::FMTSchedule &proportionschedulewithlock)
Force a solution using a schedule based on proportions instead of area, placing only the parts of the...
FMTSrModel(const FMTSrModel &rhs)
Copy constructor for FMTSrModel.
std::vector< Core::FMTActualDevelopment > getPotentialArea(int p_Period=0, bool p_BeforeGrowAndDeath=false) const
Compute the potential (maximum) development area for a period by forcing all solver decision variable...
Graph::FMTGraphVertexToYield getGraphVertexToYield() const
Return a filled FMTGraphVertexToYield without a specific vertex selected.
bool unboundSolution(int period)
Unbound the primal bounds of a given period.
Graph::FMTGraphStats updateMatrix(const Graph::FMTGraph< Graph::FMTVertexProperties, Graph::FMTEdgeProperties >::FMTvertex_pair &targets, const Graph::FMTGraphStats &newstats)
Update the solver interface matrix after the graph has been updated with new development types during...
bool setParameter(const FMTintmodelparameters &key, const int &value) override
Override setter for int model parameters.
void setNodeCacheSize(const size_t &p_size)
Set the size of reserved memory used when caching output nodes during the build process and output re...
FMTSrModel(FMTSrModel &&rhs) noexcept
Default move constructor for FMTSrModel.
int getFirstActivePeriod() const
Return the first active period.
bool isPeriodBounded(int period) const
Check if the FMTDevelopment areas are bounded on their primal variables for a given period.
FMTSrModel(FMTModel &&base, const Graph::FMTGraph< Graph::FMTVertexProperties, Graph::FMTEdgeProperties > &lgraph, const FMTLpSolver &lsolver)
Constructor for FMTSrModel mainly used in postSolve.
FMTLpSolver solver
The lpsolver.
Definition: FMTSrModel.h:394
FMTSrModel()
Default constructor for FMTSrModel.
std::queue< Graph::FMTGraph< Graph::FMTVertexProperties, Graph::FMTEdgeProperties >::FMTvertex_descriptor > getActives()
Initialize the graph based on the area if it is not initialized, otherwise return the active vertices...
void postSolveGraph(const FMTModel &originalbasemodel)
Postsolve the graph, rebuilding each vertex and edge based on the original model.
virtual bool isOptimal() const
Return true if the solver considers the solution optimal.
bool setSolution(int period, const Core::FMTSchedule &schedule, double tolerance=FMT_DBL_TOLERANCE)
Set a solution for a given period to warmstart the model or to prepare to bound the model to that sol...
void setParallelLogger(Logging::FMTLogger &logger) override
Pass a logger owned by the thread to the solver so it does not work in concurrency.
The Core namespace provides classes for simulating stands/strata growth/harvest through time.
Definition: FMTAction.h:34
Definition: FMTAreaParser.h:35
Namespace containing all enumerator and classes used to construct or manipulate the different type of...
Definition: FMTAreaParser.h:54
FMTSolverInterface
Enumerator used to specify the solver to use when solving the FMTLpModel.
Definition: FMTsolverinterface.h:21
FMTintmodelparameters
Enumerator of the integer parameters of a FMTModel.
Definition: FMTModelParameters.h:28
FMTboolmodelparameters
Enumerator of the boolean parameters of a FMTModel.
Definition: FMTModelParameters.h:67