FMT 0.9.8
Forest management tools for forest planning
Loading...
Searching...
No Matches
RexportModel.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#ifndef REXPORTMODEL_H_INCLUDED
9#define REXPORTMODEL_H_INCLUDED
10
11#include "FMTmodel.hpp"
12#include "FMTsrmodel.hpp"
13#include "FMTlpmodel.hpp"
14#include "FMTsemodel.hpp"
15#include "FMTsesmodel.hpp"
16#include "FMTnssmodel.hpp"
17#include "FMTsamodel.hpp"
18#include "FMTlpsolver.hpp"
19#include "Rdefinitions.hpp"
21#include <Rcpp.h>
22#include <string>
23
27RCPP_DEFINEMAP(std::string,double);//For map<string,double>
34#ifdef FMTWITHOSI
48#endif
49
53
57
58namespace R
59{
60
62{
63 Rcpp::class_<Models::FMTmodel>("FMTmodel", "@DocString(FMTmodel)")
64 .derives<Core::FMTobject>("FMTobject")
65 .constructor<Models::FMTmodel>("@DocString(FMTmodel(Models::FMTmodel))")
66 .constructor("@DocString(FMTmodel())")
67 .method("getname",&Models::FMTmodel::getname,
68 "@DocString(FMTmodel::getname)")
69 .method("getyields",&Models::FMTmodel::getyields,
70 "@DocString(FMTmodel::getyields)")
71 .method("setyields", &Models::FMTmodel::setyields,
72 "@DocString(FMTmodel::setyields)")
73 .method("getarea",&Models::FMTmodel::getarea,
74 "@DocString(FMTmodel::getarea)")
75 .method("setarea", &Models::FMTmodel::setarea,
76 "@DocString(FMTmodel::setarea)")
77 .method("getthemes",&Models::FMTmodel::getthemes,
78 "@DocString(FMTmodel::getthemes)")
79 .method("setthemes", &Models::FMTmodel::setthemes,
80 "@DocString(FMTmodel::setthemes)")
81 .method("getactions",&Models::FMTmodel::getactions,
82 "@DocString(FMTmodel::getactions)")
83 .method("setactions", &Models::FMTmodel::setactions,
84 "@DocString(FMTmodel::setactions)")
85 .method("getoutputs", &Models::FMTmodel::getoutputs,
86 "@DocString(FMTmodel::getoutputs)")
87 .method("setoutputs", &Models::FMTmodel::setoutputs,
88 "@DocString(FMTmodel::setoutputs)")
89 .method("getconstraints", &Models::FMTmodel::getconstraints,
90 "@DocString(FMTmodel::getconstraints)")
91 .method("setconstraints", &Models::FMTmodel::setconstraints,
92 "@DocString(FMTmodel::setconstraints)")
93 .method("gettransitions",&Models::FMTmodel::gettransitions,
94 "@DocString(FMTmodel::gettransitions)")
95 .method("settransitions",&Models::FMTmodel::settransitions,
96 "@DocString(FMTmodel::settransitions)")
97 .method("setname", &Models::FMTmodel::setname,
98 "@DocString(FMTmodel::setname)")
99 .method("setareaperiod", &Models::FMTmodel::setareaperiod,
100 "@DocString(FMTmodel::setareaperiod)")
101 .method("getlifespan",&Models::FMTmodel::getlifespan,
102 "@DocString(FMTmodel::getlifespan)")
103 .method("setlifespan", &Models::FMTmodel::setlifespan,
104 "@DocString(FMTmodel::setlifespan)")
105 .method("isvalid",&Models::FMTmodel::isvalid,
106 "@DocString(FMTmodel::isvalid)")
107 .method("getpostsolvefilter", &Models::FMTmodel::getpostsolvefilter,
108 "@DocString(FMTmodel::getpostsolvefilter)")
109 .method("isoptimal", &Models::FMTmodel::isoptimal,
110 "@DocString(FMTmodel::isoptimal)")
111 .method("getobjectivevalue", &Models::FMTmodel::getobjectivevalue,
112 "@DocString(FMTmodel::getobjectivevalue)")
113 .method("setboolparameter",
114 static_cast<bool(Models::FMTmodel::*)(const Models::FMTboolmodelparameters&, const bool&)>(&Models::FMTmodel::setparameter),
115 "@DocString(Models::FMTmodel::setparameter(const FMTboolmodelparameters,const bool))")
116 .method("setintparameter",
117 static_cast<bool(Models::FMTmodel::*)(const Models::FMTintmodelparameters&, const int&)>(&Models::FMTmodel::setparameter),
118 "@DocString(Models::FMTmodel::setparameter(const FMTintmodelparameters,const int))")
119 .method("setdblparameter",
120 static_cast<bool(Models::FMTmodel::*)(const Models::FMTdblmodelparameters&, const double&)>(&Models::FMTmodel::setparameter),
121 "@DocString(Models::FMTmodel::setparameter(const FMTdblmodelparameters,const int))")
122 .method("showparameters",&Models::FMTmodel::showparameters,
123 "@DocString(FMTmodel::showparameters)")
124 .method("doplanning",&Models::FMTmodel::doplanning,
125 "@DocString(FMTmodel::doplanning)");
126
127 Rcpp::class_<Models::FMTsemodel>("FMTsemodel", "@DocString(FMTsemodel)")
128 .derives<Models::FMTmodel>("FMTmodel")
129 .constructor("@DocString(FMTsemodel())")
130 .constructor<Models::FMTmodel>("@DocString(FMTsemodel(Models::FMTmodel))")
131 .method("getmapping", &Models::FMTsemodel::getmapping,
132 "@DocString(FMTsemodel::getmapping)")
133 .method("getschedule", &Models::FMTsemodel::getschedule,
134 "@DocString(FMTsemodel::getschedule)")
135 .method("getspschedule", &Models::FMTsemodel::getspschedule,
136 "@DocString(FMTsemodel::getdisturbances)")
137 .method("setinitialmapping", &Models::FMTsemodel::setinitialmapping,
138 "@DocString(FMTsemodel::setinitialmapping)")
139 .method("getspatialoutput", &Models::FMTsemodel::getspatialoutput,
140 "@DocString(FMTsemodel::getschedule)")
141 .method("getdisturbancestats", &Models::FMTsemodel::getdisturbancestats,
142 "@DocString(FMTsemodel::getdisturbancestats)");
143
144
145 Rcpp::class_<Models::FMTsesmodel>("FMTsesmodel", "@DocString(FMTsesmodel)")
146 .derives<Models::FMTsemodel>("FMTsemodel")
147 .constructor("@DocString(FMTsesmodel())")
148 .constructor<Models::FMTmodel>("@DocString(FMTsesmodel(Models::FMTmodel))")
149 .method("greedyreferencebuild", &Models::FMTsesmodel::greedyreferencebuild,
150 "@DocString(FMTsesmodel:::greedyreferencebuild)");
151
152 #ifdef FMTWITHOSI
153 Rcpp::class_<Models::FMTlpsolver>("FMTlpsolver", "@DocString(FMTlpsolver)")
154 .constructor("@DocString(FMTlpsolver())")
155 .method("isProvenOptimal", &Models::FMTlpsolver::isProvenOptimal,
156 "@DocString(FMTlpsolver::isProvenOptimal)")
157 .method("getObjValue", &Models::FMTlpsolver::getObjValue,
158 "@DocString(FMTlpsolver::getObjValue)")
159 .method("writeLP", &Models::FMTlpsolver::writeLP,
160 "@DocString(FMTlpsolver::writeLP)")
161 .method("writeMPS", &Models::FMTlpsolver::writeMPS,
162 "@DocString(FMTlpsolver::writeMPS)");
163
164
165 Rcpp::class_<Models::FMTsrmodel>("FMTsrmodel", "@DocString(FMTsrmodel)")
166 .derives<Models::FMTmodel>("FMTmodel")
167 .constructor("@DocString(FMTsrmodel())")
168 .method("buildperiod", &Models::FMTsrmodel::buildperiod,
169 "@DocString(FMTsrmodel::buildperiod)")
170 .method("boundsolution", &Models::FMTsrmodel::boundsolution,
171 "@DocString(FMTsrmodel::boundsolution)")
172 .method("getsolution", &Models::FMTsrmodel::getsolution,
173 "@DocString(FMTsrmodel::getsolution)")
174 .method("setsolution", &Models::FMTsrmodel::setsolution,
175 "@DocString(FMTsrmodel::setsolution)")
176 .method("setsolutionbylp", &Models::FMTsrmodel::setsolutionbylp,
177 "@DocString(FMTsrmodel::setsolutionbylp)")
178 .method("getoutputsdataframe", &Models::FMTsrmodel::getoutputsdataframe,
179 "@DocString(FMTsrmodel::getoutputsdataframe)")
180 .method("getoutput", &Models::FMTsrmodel::getoutput,
181 "@DocString(FMTsrmodel::getoutput)")
182 .method("getstats", &Models::FMTsrmodel::getstats,
183 "@DocString(FMTsrmodel::getstats)");
184
185 Rcpp::class_<Models::FMTnssmodel>("FMTnssmodel", "@DocString(FMTnssmodel)")
186 .derives<Models::FMTsrmodel>("FMTsrmodel")
187 .constructor("@DocString(FMTnssmodel())")
188 .constructor<Models::FMTmodel, unsigned int>("@DocString(FMTnssmodel(Models::FMTmodel,unsigned int))")
189 .method("simulate", &Models::FMTnssmodel::simulate,
190 "@DocString(FMTnssmodel::simulate)");
191
192
193
194 Rcpp::class_<Models::FMTlpmodel>("FMTlpmodel", "@DocString(FMTlpmodel)")
195 .derives<Models::FMTsrmodel>("FMTsrmodel")
196 .constructor<Models::FMTmodel, Models::FMTsolverinterface>("@DocString(FMTlpmodel(Models::FMTmodel,Models::FMTsolverinterface))")
197 .constructor("@DocString(FMTlpmodel())")
198 .constructor<Models::FMTlpmodel>("@DocString(FMTlpmodel(const FMTlpmodel&))")
199 .method("setobjective", &Models::FMTlpmodel::setobjective,
200 "@DocString(FMTlpmodel::setobjective)")
201 .method("setconstraint", &Models::FMTlpmodel::setconstraint,
202 "@DocString(FMTlpmodel::setconstraint)")
203 .method("eraseconstraint", &Models::FMTlpmodel::eraseconstraint,
204 "@DocString(FMTlpmodel::eraseconstraint)")
205 .method("eraseperiod", &Models::FMTlpmodel::eraseperiod,
206 "@DocString(FMTlpmodel::eraseperiod)")
207 .method("resolve", &Models::FMTlpmodel::resolve,
208 "@DocString(FMTlpmodel::resolve)")
209 .method("initialsolve", &Models::FMTlpmodel::initialsolve,
210 "@DocString(FMTlpmodel::initialsolve)")
211 .method("eq", &Models::FMTlpmodel::operator ==,
212 "@DocString(FMTlpmodel::operator==)")
213 .method("ne", &Models::FMTlpmodel::operator !=,
214 "@DocString(FMTlpmodel::operator!=)")
215 .method("getoperatingareaschedulerheuristics", &Models::FMTlpmodel::getoperatingareaschedulerheuristics,
216 "@DocString(FMTlpmodel::getoperatingareaschedulerheuristics)")
217 .method("getvariabilities", &Models::FMTlpmodel::getvariabilities,
218 "@DocString(FMTlpmodel::getvariabilities)")
219 .method("getareavariabilities", &Models::FMTlpmodel::getareavariabilities,
220 "@DocString(FMTlpmodel::getareavariabilities)")
221 .method("writeLP", &Models::FMTlpmodel::writeLP,
222 "@DocString(FMTlpmodel::writeLP)")
223 .method("setstrictlypositivesoutputsmatrix", &Models::FMTlpmodel::setstrictlypositivesoutputsmatrix,
224 "@DocString(FMTlpmodel::setstrictlypositivesoutputsmatrix)")
225 .method("getObjValue", &Models::FMTlpmodel::getObjValue,
226 "@DocString(FMTlpmodel::getObjValue)")
227 .method("writeMPS", &Models::FMTlpmodel::writeMPS,
228 "@DocString(FMTlpmodel::writeMPS)");;
229
230
231 #endif
232
233
234 Rcpp::class_<Models::FMTsamodel>("FMTsamodel", "@DocString(FMTsamodel)")
235 .derives<Models::FMTsemodel>("FMTmodel")
236 .constructor<Models::FMTmodel>("@DocString(FMTsamodel(FMTmodel))")
237 .constructor("@DocString(FMTsamodel())")
238 .method("initialsolve", &Models::FMTsamodel::initialsolve,
239 "@DocString(FMTsamodel::initialsolve)");
240
241 }
242}
243#endif // PYEXPORTMODEL_H_INCLUDED
RCPP_EXPOSED_WRAP(Models::FMTmodel)
RCPP_EXPOSED_AS(Models::FMTmodel)
RCPP_DEFINEVECTOR(Models::FMTmodel)
RCPP_DEFINEMAP(std::string, double)
RCPP_EXPOSED_ENUM_NODECL(Models::FMTsolverinterface)
Definition: FMTobject.hpp:50
Definition: FMTlpmodel.hpp:57
void writeMPS(const std::string &location)
Graph::FMTgraphstats eraseconstraint(const Core::FMTconstraint &constraint, int period=-1)
Graph::FMTgraphstats eraseperiod(bool constraintsonly=false)
Graph::FMTgraphstats setconstraint(const Core::FMTconstraint &constraint)
void writeLP(const std::string &location)
Graph::FMTgraphstats setobjective(const Core::FMTconstraint &objective)
void setstrictlypositivesoutputsmatrix()
std::map< std::string, std::vector< double > > getvariabilities(const std::vector< Core::FMToutput > &outputs, const int &periodstart, const int &periodstop)
double getObjValue() const
std::vector< Heuristics::FMToperatingareascheduler > getoperatingareaschedulerheuristics(const std::vector< Heuristics::FMToperatingareascheme > &opareas, const Core::FMToutputnode &node, size_t numberofheuristics=1, bool copysolver=true)
std::map< std::string, std::vector< double > > getareavariabilities(const std::vector< Core::FMToutput > &localoutputs, const std::vector< Core::FMTmask > &globalmasks, std::vector< double > tolerances=std::vector< double >()) const
Definition: FMTlpsolver.hpp:39
bool isProvenOptimal() const
double getObjValue() const
void writeLP(const std::string &location) const
void writeMPS(const std::string &location) const
Definition: FMTmodel.hpp:60
void setname(const std::string &newname)
void setyields(const Core::FMTyields &lylds)
Core::FMTlifespans getlifespan() const
Definition: FMTmodel.hpp:233
virtual bool setparameter(const FMTintmodelparameters &key, const int &value)
void setconstraints(const std::vector< Core::FMTconstraint > &lconstraint)
std::string getname() const
Definition: FMTmodel.hpp:193
void setarea(const std::vector< Core::FMTactualdevelopment > &ldevs)
std::vector< Core::FMToutput > getoutputs() const
Definition: FMTmodel.hpp:241
Core::FMTyields getyields() const
Definition: FMTmodel.hpp:225
virtual bool isoptimal() const
std::vector< Core::FMTtransition > gettransitions() const
Definition: FMTmodel.hpp:217
virtual void showparameters(const bool &showhelp=false) const
Core::FMTmaskfilter getpostsolvefilter(const std::vector< Core::FMTtheme > &originalthemes, const Core::FMTmask &devmask) const
std::vector< Core::FMTaction > getactions() const
Definition: FMTmodel.hpp:209
std::vector< Core::FMTtheme > getthemes() const
Definition: FMTmodel.hpp:201
virtual std::vector< Core::FMTactualdevelopment > getarea(int period=0, bool beforegrowanddeath=false) const
void setareaperiod(const int &period)
void setlifespan(const Core::FMTlifespans &llifespan)
void settransitions(const std::vector< Core::FMTtransition > &ltransitions)
void setoutputs(const std::vector< Core::FMToutput > &newoutputs)
void setactions(const std::vector< Core::FMTaction > &lactions)
virtual bool doplanning(const bool &solve, std::vector< Core::FMTschedule > schedules=std::vector< Core::FMTschedule >())
virtual double getobjectivevalue() const
void setthemes(const std::vector< Core::FMTtheme > &lthemes)
std::vector< Core::FMTconstraint > getconstraints() const
Definition: FMTmodel.hpp:249
Definition: FMTnssmodel.hpp:31
Definition: FMTsamodel.hpp:44
Definition: FMTsemodel.hpp:33
virtual Spatial::FMTlayer< double > getspatialoutput(const Core::FMToutput &output, int period) const
std::string getdisturbancestats() const
std::vector< Core::FMTschedule > getschedule(bool withlock=false) const
Spatial::FMTspatialschedule getspschedule() const
Definition: FMTsemodel.hpp:100
Spatial::FMTforest getmapping() const
bool setinitialmapping(Spatial::FMTforest forest)
Definition: FMTsesmodel.hpp:28
std::map< std::string, double > greedyreferencebuild(const Core::FMTschedule &schedule, const size_t &randomiterations, unsigned int seed=0, double tolerance=FMT_DBL_TOLERANCE)
Definition: FMTsrmodel.hpp:44
bool setsolutionbylp(int period, const Core::FMTschedule &schedule, double tolerance=FMT_DBL_TOLERANCE)
Graph::FMTgraphstats buildperiod(Core::FMTschedule schedule=Core::FMTschedule(), bool forcepartialbuild=false, int compressageclassoperability=1)
Graph::FMTgraphstats getstats() const
bool boundsolution(int period, double tolerance=FMT_DBL_TOLERANCE)
virtual std::map< std::string, double > getoutput(const Core::FMToutput &output, int period, Core::FMToutputlevel level=Core::FMToutputlevel::standard) const
bool setsolution(int period, const Core::FMTschedule &schedule, double tolerance=FMT_DBL_TOLERANCE)
Core::FMTschedule getsolution(int period, bool withlock=false) const final
FMTdblmodelparameters
Definition: FMTmodelparameters.hpp:37
FMTsolverinterface
Definition: FMTsolverinterface.hpp:21
FMTintmodelparameters
Definition: FMTmodelparameters.hpp:24
FMTboolmodelparameters
Definition: FMTmodelparameters.hpp:45
Definition: RexportCore.hpp:153
void exportModel()
Definition: RexportModel.hpp:61