FMT 0.9.8
Forest management tools for forest planning
Loading...
Searching...
No Matches
FMTsrmodel.hpp
Go to the documentation of this file.
1/*
2Copyright (c) 2019 Gouvernement du Québec
3
4SPDX-License-Identifier: LiLiQ-R-1.1
5License-Filename: LICENSES/EN/LiLiQ-R11unicode.txt
6*/
7
8
9#ifdef FMTWITHOSI
10
11#ifndef FMTsrmodel_H_INCLUDED
12#define FMTsrmodel_H_INCLUDED
13
14#include "FMTmodel.hpp"
15#include <boost/serialization/export.hpp>
16#include <boost/serialization/split_member.hpp>
17#include "FMTlpsolver.hpp"
19#include "FMTedgeproperties.hpp"
20#include "FMTgraph.hpp"
21
22#if defined FMTWITHR
23 #include <Rcpp.h>
24#endif
25
26namespace Core
27{
28 class FMTSerie;
29}
30
31
32namespace Graph
33{
34 class FMTgraphvertextoyield;
35}
36
37namespace Models
38 {
39 // DocString: FMTsrmodel
44 {
45 public:
46 // DocString: FMTsrmodel::getGraphVertexToYield
47 /*
48 If you want to do a generic yieldrequest for the model you may need to have a graphvertextoyield to deal with yields
49 that depand on the full graph and model (like FMTyieldmodel).
50 the function return a filled Graphvertexyoyield without a specific vertex selected.
51 */
53 // DocString: FMTsrmodel::postsolve
54 /*
55 This function is for postsolving the presolved model into the original model. In this case, the FMTgraph of the FMTsrmodel is also postsolved.
56 */
57 virtual void postsolve(const FMTmodel& originalbasemodel);
58 // DocString: FMTsrmodel::setparallellogger
63 void setparallellogger(Logging::FMTlogger& logger) override;
64 // DocString: FMTsrmodel::getavailablesolverinterface
68 static std::vector<Models::FMTsolverinterface> getavailablesolverinterface();
69 // DocString: FMTsrmodel(const FMTmodel,FMTsolverinterface)
74 FMTsrmodel(const FMTmodel& base, FMTsolverinterface lsolvertype);
75 // DocString: FMTsrmodel()
80 // DocString: FMTsrmodel(const FMTsrmodel)
85 // DocString: FMTsrmodel(const FMTmodel, const Graph::FMTgraph<Graph::FMTvertexproperties,Graph::FMTedgeproperties>, const FMTlpsolver)
90 const FMTlpsolver& lsolver);
91 // DocString: FMTsrmodel::operator=
95 FMTsrmodel& operator = (const FMTsrmodel& rhs)=default;
96 // DocString: FMTsrmodel(FMTsrmodel&&)
100 FMTsrmodel(FMTsrmodel&& rhs)=default;
101 // DocString: FMTsrmodel::operator=(FMTsrmodel&& rhs)
105 FMTsrmodel& operator =(FMTsrmodel&& rhs) =default;
106 // DocString: ~FMTsrmodel()
110 ~FMTsrmodel() = default;
111 // DocString: FMTsrmodel::operator==
115 bool operator == (const FMTsrmodel& rhs) const;
116 // DocString: FMTsrmodel::operator!=
120 bool operator != (const FMTsrmodel& rhs) const;
121 // DocString: FMTsrmodel::unboundsolution
125 bool unboundsolution(int period);
126 // DocString: FMTsrmodel::isperiodbounded
130 bool isperiodbounded(int period) const;
131 // DocString: FMTsrmodel::cleargraphdevelopements
136 // DocString: FMTsrmodel::cleargraphcache
141 // DocString: FMTsrmodel::setsolution
146 bool setsolution(int period, const Core::FMTschedule& schedule, double tolerance = FMT_DBL_TOLERANCE);
147 // DocString: FMTsrmodel::setsolutionbylp
153 bool setsolutionbylp(int period, const Core::FMTschedule& schedule, double tolerance = FMT_DBL_TOLERANCE);
154 // DocString: FMTsrmodel::forcesolution
160 bool forcesolution(int period, const Core::FMTschedule& proportionschedulewithlock);
161 // DocString: FMTsrmodel::getsolution
166 Core::FMTschedule getsolution(int period, bool withlock = false) const final;
167 // DocString: FMTsrmodel::getscheduleproportions
171 Core::FMTschedule getscheduleproportions(int period, bool withlock) const;
172 // DocString: FMTsrmodel::getstats
176 Graph::FMTgraphstats getstats() const;
177 // DocString: FMTsrmodel::getcopy
184 virtual std::unique_ptr<FMTmodel> getcopy(int period = 0) const;
185 // DocString: FMTsrmodel::getoutput
192 virtual std::map<std::string, double> getoutput(const Core::FMToutput& output,
193 int period, Core::FMToutputlevel level = Core::FMToutputlevel::standard) const;
194 #if defined FMTWITHR
195 // DocString: FMTsrmodel::getoutputsdataframe
200 Rcpp::DataFrame getoutputsdataframe(const std::vector<Core::FMToutput>& outputsdata, int firstperiod, int lastperiod) const;
201 #endif
202 // DocString: FMTsrmodel::buildperiod
211 bool forcepartialbuild = false, int compressageclassoperability = 1);
212 // DocString: FMTsrmodel::getfirstactiveperiod
218 // DocString: FMTsrmodel::getarea
226 virtual std::vector<Core::FMTactualdevelopment>getarea(int period = 0, bool beforegrowanddeath = false) const override;
227 // DocString: FMTsrmodel::getsolverptr()
232 // DocString: FMTsrmodel::getconstsolverptr()
237 // DocString: FMTsrmodel::clone
241 virtual std::unique_ptr<FMTmodel>clone() const override;
242 // DocString: FMTsrmodel::passinlogger
246 void passinlogger(const std::shared_ptr<Logging::FMTlogger>& logger) override;
247 // DocString: FMTsrmodel::presolve
251 virtual std::unique_ptr<FMTmodel>presolve(std::vector<Core::FMTactualdevelopment> optionaldevelopments = std::vector<Core::FMTactualdevelopment>()) const override;
252 // DocString: FMTsrmodel::boundsolution
257 bool boundsolution(int period, double tolerance = FMT_DBL_TOLERANCE);
258 // DocString: FMTsrmodel::setparameter(const FMTintmodelparameters, const int)
262 bool setparameter(const FMTintmodelparameters& key, const int& value) override;
263 // DocString: FMTsrmodel::setparameter(const FMTboolmodelparameters, const bool)
267 bool setparameter(const FMTboolmodelparameters& key, const bool& value) override;
268 // DocString: FMTsrmodel::getgraphstats
273 // DocString: FMTsrmodel::getrorations
282 std::set<Core::FMTSerie>getrorations(const Core::FMTmask& mask, const std::string& aggregate) const;
283 // DocString: FMTsrmodel::isoptimal
287 virtual bool isoptimal() const;
288 // DocString: FMTsrmodel::getobjectivevalue
292 virtual double getobjectivevalue() const;
293 // DocString: FMTsrmodel::getnochoice
298 std::vector<const Core::FMTdevelopment*> getnochoice(const Core::FMTmask& base_mask) const;
299 protected:
300 // DocString: FMTsrmodel::graph
303 // DocString: FMTsrmodel::solver
306 // DocString: FMTsrmodel::summarize
311 bool summarize(const std::map<int, double>& variables,
312 std::vector<int>& sumvariables, std::vector<double>& sumcoefficiants) const;
313 // DocString: FMTsrmodel::initializematrix
318 // DocString: FMTsrmodel::updatematrix
325 const Graph::FMTgraphstats& newstats);
326 // DocString: FMTsrmodel::getgraphlength
330 size_t getgraphsize() const;
331 // DocString: FMTsrmodel::postsolvegraph
335 void postsolvegraph(const FMTmodel& originalbasemodel);
336 private:
337 // DocString: FMTsrmodel::save
341 friend class boost::serialization::access;
342 template<class Archive>
343 void save(Archive& ar, const unsigned int version) const
344 {
345 ar& boost::serialization::make_nvp("model", boost::serialization::base_object<FMTmodel>(*this));
346 ar& BOOST_SERIALIZATION_NVP(solver);
347 ar& BOOST_SERIALIZATION_NVP(graph);
348 }
349 // DocString: FMTsrmodel::load
353 template<class Archive>
354 void load(Archive& ar, const unsigned int version)
355 {
356 ar& boost::serialization::make_nvp("model", boost::serialization::base_object<FMTmodel>(*this));
357 ar& BOOST_SERIALIZATION_NVP(solver);
358 ar& BOOST_SERIALIZATION_NVP(graph);
359 solver.passinmessagehandler(*_logger);
360 }
361 BOOST_SERIALIZATION_SPLIT_MEMBER()
362
363 };
364
365}
366
367BOOST_CLASS_EXPORT_KEY(Models::FMTsrmodel)
368
369#endif
370#endif
#define FMT_DBL_TOLERANCE
Definition: FMTutility.hpp:11
#define FMTEXPORT
Definition: FMTutility.hpp:92
Definition: FMTmask.hpp:96
Definition: FMTschedule.hpp:31
Definition: FMTgraph.hpp:78
std::pair< FMTvertex_iterator, FMTvertex_iterator > FMTvertex_pair
Definition: FMTgraph.hpp:117
Definition: FMTgraphstats.hpp:28
Definition: FMTgraphvertextoyield.hpp:27
Definition: FMTlogger.hpp:37
Definition: FMTlpsolver.hpp:39
void passinmessagehandler(Logging::FMTlogger &logger)
Definition: FMTmodel.hpp:60
Definition: FMTsrmodel.hpp:44
bool setsolutionbylp(int period, const Core::FMTschedule &schedule, double tolerance=FMT_DBL_TOLERANCE)
void postsolvegraph(const FMTmodel &originalbasemodel)
Graph::FMTgraphstats buildperiod(Core::FMTschedule schedule=Core::FMTschedule(), bool forcepartialbuild=false, int compressageclassoperability=1)
bool setparameter(const FMTintmodelparameters &key, const int &value) override
Graph::FMTgraphstats initializematrix()
FMTlpsolver * getsolverptr()
FMTsrmodel(FMTsrmodel &&rhs)=default
int getfirstactiveperiod() const
virtual std::unique_ptr< FMTmodel > clone() const override
~FMTsrmodel()=default
bool summarize(const std::map< int, double > &variables, std::vector< int > &sumvariables, std::vector< double > &sumcoefficiants) const
Graph::FMTgraphvertextoyield getGraphVertexToYield() const
size_t getgraphsize() const
Graph::FMTgraphstats updatematrix(const Graph::FMTgraph< Graph::FMTvertexproperties, Graph::FMTedgeproperties >::FMTvertex_pair &targets, const Graph::FMTgraphstats &newstats)
FMTsrmodel(const FMTsrmodel &rhs)
static std::vector< Models::FMTsolverinterface > getavailablesolverinterface()
virtual std::unique_ptr< FMTmodel > presolve(std::vector< Core::FMTactualdevelopment > optionaldevelopments=std::vector< Core::FMTactualdevelopment >()) const override
bool boundsolution(int period, double tolerance=FMT_DBL_TOLERANCE)
virtual void postsolve(const FMTmodel &originalbasemodel)
Graph::FMTgraphstats getgraphstats() const
bool setparameter(const FMTboolmodelparameters &key, const bool &value) override
virtual double getobjectivevalue() const
bool isperiodbounded(int period) const
virtual bool isoptimal() const
virtual std::vector< Core::FMTactualdevelopment > getarea(int period=0, bool beforegrowanddeath=false) const override
FMTsrmodel(const FMTmodel &base, const Graph::FMTgraph< Graph::FMTvertexproperties, Graph::FMTedgeproperties > &lgraph, const FMTlpsolver &lsolver)
void passinlogger(const std::shared_ptr< Logging::FMTlogger > &logger) override
void setparallellogger(Logging::FMTlogger &logger) override
FMTsrmodel(const FMTmodel &base, FMTsolverinterface lsolvertype)
FMTlpsolver solver
The lpsolver.
Definition: FMTsrmodel.hpp:305
void cleargraphdevelopements()
bool unboundsolution(int period)
std::vector< const Core::FMTdevelopment * > getnochoice(const Core::FMTmask &base_mask) const
Graph::FMTgraph< Graph::FMTvertexproperties, Graph::FMTedgeproperties > graph
graph holding the FMTdevelopments for all the periods.
Definition: FMTsrmodel.hpp:302
std::set< Core::FMTSerie > getrorations(const Core::FMTmask &mask, const std::string &aggregate) const
bool forcesolution(int period, const Core::FMTschedule &proportionschedulewithlock)
bool setsolution(int period, const Core::FMTschedule &schedule, double tolerance=FMT_DBL_TOLERANCE)
Core::FMTschedule getsolution(int period, bool withlock=false) const final
const FMTlpsolver * getconstsolverptr() const
The Core namespace provides classes for simulating stands/strata growth/harvest through time.
Definition: FMTaction.hpp:31
Namespace for using/building unidirectional graphs in FMT.
Definition: FMTareaparser.hpp:31
Namespace containing all enumerator and classes used to construct or manipulate the different type of...
Definition: FMTareaparser.hpp:50
FMTsolverinterface
Definition: FMTsolverinterface.hpp:21
FMTintmodelparameters
Definition: FMTmodelparameters.hpp:24
FMTboolmodelparameters
Definition: FMTmodelparameters.hpp:45