FMT 1.2.0
Forest management tools for forest planning
Loading...
Searching...
No Matches
PYexportCore.h
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 PYEXPORTCORE_H_INCLUDED
9#define PYEXPORTCORE_H_INCLUDED
10
11#include "FMTGCBMTransition.h"
12#include "FMTObject.h"
13#include "FMTMask.h"
14#include "FMTTheme.h"
15#include "FMTBounds.hpp"
16#include "FMTDevelopment.h"
18#include "FMTFuturDevelopment.h"
19#include "FMTAction.h"
20#include "FMTTransition.h"
21#include "FMTOutput.h"
22#include "FMTConstraint.h"
23#include "FMTSchedule.h"
24#include "FMTYields.h"
25#include "FMTConstants.h"
26#include "boost/python.hpp"
27//#include "FMTData.h"
28#include "FMTTimeYieldHandler.h"
29#include "FMTAgeYieldHandler.h"
30#include "FMTMaskFilter.h"
31#include "FMTTransitionMask.h"
32#include "FMTDevelopmentPath.h"
33#include "FMTSerie.h"
34
35namespace Python
36{
37
38BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(getattributes_overloads, getAttributes, 1, 2)
39//BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(getnodes_overloads, getNodes, 3, 4)
40BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(getnodes_overloads, getNodes, 1, 4)
41BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(getyieldrequest_overloads, getYieldRequest, 0, 0)
42BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(operable_overloads, operable, 2, 3)
43
45 {
46 namespace bp = boost::python;
47 bp::object CoreModule(bp::handle<>(bp::borrowed(PyImport_AddModule("FMT.Core"))));
48 bp::scope().attr("Core") = CoreModule;
49 bp::scope Core_scope = CoreModule;
50 bp::scope().attr("__doc__") = ".. module:: Core\n"
51 "\n"
52 " :platform: Unix, Windows\n"
53 " :synopsis: Core class for generating Forest Models.\n"
54 "\n";
55
56 bp::enum_<Core::FMTsection>("FMTsection")
57 .value("Control", Core::FMTsection::Control)
58 .value("Landscape", Core::FMTsection::Landscape)
59 .value("Area", Core::FMTsection::Area)
60 .value("Action", Core::FMTsection::Action)
61 .value("Transition", Core::FMTsection::Transition)
62 .value("Yield", Core::FMTsection::Yield)
63 .value("Outputs", Core::FMTsection::Outputs)
64 .value("Optimize", Core::FMTsection::Optimize)
65 .value("Constants", Core::FMTsection::Constants)
66 .value("Schedule", Core::FMTsection::Schedule)
67 .value("Empty", Core::FMTsection::Empty)
68 .export_values();
69
70 bp::enum_<Core::FMToutputlevel>("FMToutputlevel")
71 .value("standard", Core::FMToutputlevel::standard)
72 .value("totalonly", Core::FMToutputlevel::totalonly)
73 .value("developpement", Core::FMToutputlevel::developpement)
74 .export_values();
75
76 bp::enum_<Core::FMTconstrainttype>("FMTconstrainttype")
77 .value("FMTMAXobjective", Core::FMTconstrainttype::FMTMAXobjective)
78 .value("FMTMINobjective", Core::FMTconstrainttype::FMTMINobjective)
79 .value("FMTMAXMINobjective", Core::FMTconstrainttype::FMTMAXMINobjective)
80 .value("FMTMINMAXobjective", Core::FMTconstrainttype::FMTMINMAXobjective)
81 .value("FMTevenflow", Core::FMTconstrainttype::FMTevenflow)
82 .value("FMTnondeclining", Core::FMTconstrainttype::FMTnondeclining)
83 .value("FMTsequence", Core::FMTconstrainttype::FMTsequence)
84 .value("FMTstandard", Core::FMTconstrainttype::FMTstandard)
85 .value("FMTspatialsize", Core::FMTconstrainttype::FMTspatialsize)
86 .value("FMTspatialadjacency", Core::FMTconstrainttype::FMTspatialadjacency)
87 .value("FMTspatialgreenup", Core::FMTconstrainttype::FMTspatialgreenup)
88 .export_values();
89
90 bp::class_<Core::FMTObject>("FMTobject", "@DocString(FMTObject)")
91 .def("setdefaultexceptionhandler", &Core::FMTObject::setDefaultExceptionHandler,
92 "@DocString(FMTObject::setdefaultexceptionhandler)")
93 .def("setquietexceptionhandler", &Core::FMTObject::setQuietExceptionHandler,
94 "@DocString(FMTObject::setquietexceptionhandler)")
95 .def("setdebugexceptionhandler", &Core::FMTObject::setDebugExceptionHandler,
96 "@DocString(FMTObject::setdebugexceptionhandler)")
97 .def("setfreeexceptionhandler", &Core::FMTObject::setFreeExceptionHandler,
98 "@DocString(FMTObject::setfreeexceptionhandler)")
99 .def("enablenestedexceptions", &Core::FMTObject::enableNestedExceptions,
100 "@DocString(FMTObject::enablenestedexceptions)")
101 .def("disablenestedexceptions", &Core::FMTObject::disableNestedExceptions,
102 "@DocString(FMTObject::disablenestedexceptions)")
103 .def("setdefaultlogger", &Core::FMTObject::setDefaultLogger,
104 "@DocString(FMTObject::setdefaultlogger)")
105 .def("setdebuglogger", &Core::FMTObject::setDebugLogger,
106 "@DocString(FMTObject::setdebuglogger)")
107 .def("setquietlogger", &Core::FMTObject::setQuietLogger,
108 "@DocString(FMTObject::setquietlogger)")
109 .def("settasklogger", &Core::FMTObject::setTaskLogger,
110 "@DocString(FMTObject::settasklogger")
111 .def("redirectlogtofile", &Core::FMTObject::redirectLogToFile,
112 "@DocString(FMTObject::redirectlogtofile)")
113 .def("seterrorstowarnings", &Core::FMTObject::setErrorsToWarnings,
114 "@DocString(FMTObject::seterrorstowarnings)");
115
116 bp::class_<Core::FMTMaskFilter>("FMTmaskfilter", "@DocString(FMTMaskFilter)");
117
118 definePyList<Core::FMTDevelopmentPath>();
119 definePySet<Core::FMTSerie>();
120 definePyList<Core::FMTSerie>();
121 definePyList<Core::FMTMaskFilter>();
122 definePyList<Core::FMTMask>();
123 definePyList<Core::FMTDevelopment>();
124 definePyList<Core::FMTFuturDevelopment>();
125 definePyList<Core::FMTActualDevelopment>();
126 definePyDict<std::string, std::vector<Core::FMTDevelopment>>();
127
128 definePyList<Core::FMTTheme>();
129 definePyList<Core::FMTAction>();
130 definePyList<Core::FMTTransition>();
131 definePyList<Core::FMTOutput>();
132 definePyList<Core::FMTSchedule>();
133 definePyList<std::vector<Core::FMTSchedule>>();
134 definePyList<Core::FMTYieldHandler>();
135 definePyList<Core::FMTOutputSource>();
136 definePyList<Core::FMTOperator>();
137
138 definePyDict<Core::FMTDevelopment, std::vector<double>>();
139 definePyDict<Core::FMTAction,std::map<Core::FMTDevelopment, std::vector<double>>>();
140 py_pair<Core::FMTAction, std::map<Core::FMTDevelopment, std::vector<double>>>();
141 py_pair<Core::FMTAction const, std::map<Core::FMTDevelopment, std::vector<double>>>();
142
143 define_FMTlist<Core::FMTSpec>();
144 definePyList<std::vector<std::string>>();
145
146 bool (Core::FMTMask::*issubsetof)(const Core::FMTMask&) const = &Core::FMTMask::isSubsetOf;
147
148 bp::class_<Core::FMTMask>("FMTmask", "@DocString(FMTMask)")
149 .def(bp::init<Core::FMTMask>())
150 .def_pickle(FMT_pickle_suite<Core::FMTMask>())
151 .def(bp::init<const std::vector<std::string>&,const std::vector<Core::FMTTheme>&>())
152 .def(bp::init<const std::string&, const std::vector<Core::FMTTheme>&>())
153 .def("__len__", &Core::FMTMask::operator bool,
154 "@DocString(FMTMask::operator bool)")
155 .def("__str__",&Core::FMTMask::operator std::string,
156 "@DocString(FMTMask::operator std::string)")
157 .def("__eq__", &Core::FMTMask::operator ==,
158 "@DocString(FMTMask::operator==)")
159 .def("__ne__", &Core::FMTMask::operator !=,
160 "@DocString(FMTMask::operator!=)")
161 .def("__lt__", &Core::FMTMask::operator <,
162 "@DocString(FMTMask::operator<)")
163 .def("__hash__",&boost::pyHash<Core::FMTMask>)
164 .def("decompose", &Core::FMTMask::decompose,
165 "@DocString(FMTMask::decompose)")
166 .def("issubsetof",issubsetof,
167 "@DocString(FMTMask::issubsetof)")
168 .def("presolve",&Core::FMTMask::preSolve,
169 "@DocString(FMTMask::preSolve)")
170 .def("postsolve",&Core::FMTMask::postSolve,
171 "@DocString(FMTMask::postsolve)");
172
173 bp::class_<Core::FMTDevelopmentPath>("FMTdevelopmentpath", "@DocString(FMTDevelopmentPath)")
174 .def(bp::init<Core::FMTDevelopmentPath>())
175 .def("getDevelopment", &Core::FMTDevelopmentPath::getDevelopment,
176 bp::return_value_policy<bp::return_by_value>(),
177 "@DocString(FMTDevelopmentPath::getDevelopment)")
178 .def("getProportion", &Core::FMTDevelopmentPath::getProportion,
179 bp::return_value_policy<bp::return_by_value>(),
180 "@DocString(FMTDevelopmentPath::getProportion)");
181
182 bp::class_<Core::FMTSerie>("FMTSerie", "@DocString(FMTSerie)")
183 .def(bp::init<Core::FMTSerie>())
184 .def("getLength", &Core::FMTSerie::getLength,
185 bp::return_value_policy<bp::return_by_value>(),
186 "@DocString(FMTSerie::getLength)")
187 .def("getSerie", &Core::FMTSerie::getSerie,
188 bp::return_value_policy<bp::return_by_value>(),
189 "@DocString(FMTSerie::getSerie)");
190
191
192
193 bp::class_<Core::FMTDevelopment>("FMTdevelopment", "@DocString(FMTDevelopment)")
194 .def_pickle(FMT_pickle_suite<Core::FMTDevelopment>())
195 .def(bp::init<Core::FMTDevelopment>())
196 .def("getage", &Core::FMTDevelopment::getAge,
197 "@DocString(FMTDevelopment::getage)")
198 .def("getlock", &Core::FMTDevelopment::getLock,
199 "@DocString(FMTDevelopment::getlock)")
200 .def("getperiod", &Core::FMTDevelopment::getPeriod,
201 "@DocString(FMTDevelopment::getperiod)")
202 .def("getmask", &Core::FMTDevelopment::getMaskCopy,
203 "@DocString(FMTDevelopment::getmask)")
204 .def("setage", &Core::FMTDevelopment::setAge,
205 "@DocString(FMTDevelopment::setage)")
206 .def("setlock", &Core::FMTDevelopment::setLock,
207 "@DocString(FMTDevelopment::setlock)")
208 .def("setperiod", &Core::FMTDevelopment::setPeriod,
209 "@DocString(FMTDevelopment::setperiod)")
210 .def("setmask", &Core::FMTDevelopment::setMask,
211 "@DocString(FMTDevelopment::setmask)")
212 .def("__eq__", &Core::FMTDevelopment::operator ==,
213 "@DocString(FMTDevelopment::operator==)")
214 .def("__ne__", &Core::FMTDevelopment::operator !=,
215 "@DocString(FMTDevelopment::operator!=)")
216 .def("__lt__",&Core::FMTDevelopment::operator <,
217 "@DocString(FMTDevelopment::operator<")
218 .def("grow",&Core::FMTDevelopment::grow,
219 "@DocString(FMTDevelopment::grow)")
220 .def("operable",&Core::FMTDevelopment::operable,operable_overloads(bp::args("action,yields,yieldrequest"),"@DocString(FMTDevelopment::operable)"))
221 .def("operate",&Core::FMTDevelopment::operate,
222 "@DocString(FMTDevelopment::operate)")
223 .def("getyieldrequest",&Core::FMTDevelopment::getYieldRequest,getyieldrequest_overloads("@DocString(FMTDevelopment::getyieldrequest)"))
224 .def("__str__", &Core::FMTDevelopment::operator std::string,
225 "@DocString(FMTDevelopment::operator std::string)")
226 .setattr("__hash__",&boost::pyHash<Core::FMTDevelopment>);
227
228
229
230 bp::class_<Core::FMTAgeBounds>("FMTagebounds", "@DocString(FMTAgeBounds)")
231 .def(bp::init<Core::FMTAgeBounds>())
232 .def(bp::init<Core::FMTsection, int, int>());
233
234 bp::class_<Core::FMTPerBounds>("FMTperbounds", "@DocString(FMTPerBounds)")
235 .def(bp::init<Core::FMTPerBounds>())
236 .def(bp::init<Core::FMTsection, int, int>());
237
238 bp::class_<Core::FMTYldBounds>("FMTyldbounds", "@DocString(FMTYldBounds)")
239 .def(bp::init<Core::FMTYldBounds>())
240 .def(bp::init<Core::FMTsection, std::string, double, double>());
241
242 bp::class_<Core::FMTLockBounds>("FMTlockbounds", "@DocString(FMTLockBounds)")
243 .def(bp::init<Core::FMTLockBounds>())
244 .def(bp::init<Core::FMTsection, int, int>());
245
246 bp::class_<Core::FMTSpec>("FMTspec", "@DocString(FMTSpec)")
247 .def(bp::init<Core::FMTSpec>())
248 .def("getperiodlowerbound", &Core::FMTSpec::getPeriodLowerBound,
249 "@DocString(FMTSpec::getperiodlowerbound)")
250 .def("getperiodupperbound", &Core::FMTSpec::getPeriodUpperBound,
251 "@DocString(FMTSpec::getperiodupperbound)")
252 .def("setbounds", &Core::FMTSpec::setBounds, "@DocString(Core::FMTSpec::setbounds())")
253 .def<bool(Core::FMTSpec::*)(const Core::FMTAgeBounds&)>("addbounds", &Core::FMTSpec::addBounds,
254 "@DocString(Core::FMTSpec::addbounds(const FMTAgeBounds&))")
255 .def<bool(Core::FMTSpec::*)(const Core::FMTYldBounds&)>("addbounds",&Core::FMTSpec::addBounds,
256 "@DocString(Core::FMTSpec::addbounds(const FMTYldBounds&))")
257 .def<bool(Core::FMTSpec::*)(const Core::FMTLockBounds&)>("addbounds",&Core::FMTSpec::addBounds,
258 "@DocString(Core::FMTSpec::addbounds(const FMTLockBounds&))");
259
260 bp::class_<Core::FMTTransitionMask>("FMTtransitionmask", "@DocString(FMTTransitionMask)")
261 .def(bp::init<const std::string&, const std::vector<Core::FMTTheme>&, const double&>())
262 .def(bp::init<Core::FMTTransitionMask>());
263
264 bp::class_<Core::FMTFork, bp::bases<Core::FMTList<Core::FMTSpec>>>("FMTfork", "@DocString(FMTFork)")
265 .def(bp::init<Core::FMTFork>())
266 .def("add", &Core::FMTFork::add,
267 "@DocString(FMTFork::add)");
268
269
270
271
272 bp::class_<Core::FMTActualDevelopment, bp::bases<Core::FMTDevelopment>>("FMTactualdevelopment", "@DocString(FMTActualDevelopment)")
273 .def(bp::init<const Core::FMTMask&, const int&, const int&, const double&>())
274 .def(bp::init<Core::FMTActualDevelopment>())
276 "@DocString(FMTActualDevelopment::getarea)")
278 "@DocString(FMTActualDevelopment::setarea)")
279 .def("__eq__", &Core::FMTActualDevelopment::operator ==,
280 "@DocString(FMTActualDevelopment::operator==)")
281 .def("__ne__", &Core::FMTActualDevelopment::operator !=,
282 "@DocString(FMTActualDevelopment::operator!=)")
283 .def("__lt__", &Core::FMTActualDevelopment::operator <,
284 "@DocString(FMTActualDevelopment::operator<)");
285
286 bp::class_<Core::FMTFuturDevelopment, bp::bases<Core::FMTDevelopment>>("FMTfuturdevelopment", "@DocString(FMTFuturDevelopment)");
287
288 //Need preprocessor here
289
290
291 define_FMTlist<int>();
292 //definePyList<string>();
293 //define_FMTlist<std::unique_ptr<Core::FMTYieldHandler>>();
294 define_FMTlist<Core::FMTFork>();
295
296
297
298 bp::class_<Core::FMTAction, bp::bases<Core::FMTList<Core::FMTSpec>>>("FMTaction", "@DocString(FMTAction)")
299 .def_pickle(FMT_pickle_suite<Core::FMTAction>())
300 .def(bp::init<Core::FMTAction>())
301 .def(bp::init<const std::string&,const bool&,const bool&>())
302 .def("__eq__",&Core::FMTAction::operator ==,
303 "@DocString(FMTAction::operator==)")
304 .def("__ne__",&Core::FMTAction::operator !=,
305 "@DocString(FMTAction::operator!=)")
306 .def("__lt__",&Core::FMTAction::operator <,
307 "@DocString(FMTAction::operator<)")
308 .def("__str__", &Core::FMTAction::operator std::string,
309 "@DocString(FMTAction::operator std::string)")
310 .def("getname",&Core::FMTAction::getName,
311 "@DocString(FMTAction::getname)")
312 .def("dorespectlock",&Core::FMTAction::doRespectLock,
313 "@DocString(FMTAction::dorespectlock)")
314 .def("useyield", &Core::FMTAction::useYield,
315 "@DocString(FMTAction::useyield)")
316 .def("push_aggregate", &Core::FMTAction::pushAggregate,
317 "@DocString(FMTAction::push_aggregate)")
318 .def("getaggregates", &Core::FMTAction::getAggregates,
319 "@DocString(FMTAction::getaggregates)")
320 .def("update", &Core::FMTAction::update,
321 "@DocString(FMTAction::update)")
322 .def_readwrite("isresetage",&Core::FMTAction::isResetAge,
323 "@DocString(FMTAction::isresetage)")
324 .setattr("__hash__",&boost::pyHash<Core::FMTAction>);
325
326 bp::class_<Core::FMTLifespans, bp::bases<Core::FMTList<int>>>("FMTlifespans", "@DocString(FMTLifespans)")
327 .def(bp::init<Core::FMTLifespans>());
328
329
330 bp::enum_<Core::FMTyldtype>("FMTyldtype")
331 .value("FMTageyld", Core::FMTyldtype::FMTageyld)
332 .value("FMTtimeyld", Core::FMTyldtype::FMTtimeyld)
333 .value("FMTcomplexyld", Core::FMTyldtype::FMTcomplexyld)
334 .export_values();
335
336 definePyDict<std::string, std::map<std::string,std::vector<double>>>();
337
338 definePyDict<std::string, std::vector<double>>();
339
340 bp::class_<Core::FMTYieldHandler>("FMTyieldhandler", "@DocString(FMTYieldHandler)")
341 .def(bp::init<Core::FMTYieldHandler>())
342 .def<bool (Core::FMTYieldHandler::*)(const std::string& yld, const double& value)>("push_data",&Core::FMTYieldHandler::pushData,
343 "@DocString(FMTYieldHandler::push_data(const std::string&,const double&))")
344 .def("push_base", &Core::FMTYieldHandler::pushBase,
345 "@DocString(FMTYieldHandler::push_base)");
346
347
348 bp::class_<Core::FMTAgeYieldHandler,bp::bases<Core::FMTYieldHandler>>("FMTageyieldhandler", "@DocString(FMTAgeYieldHandler)")
349 .def(bp::init<const Core::FMTMask&>())
350 .def_pickle(FMT_pickle_suite<Core::FMTAgeYieldHandler>())
351 .def("__str__", &Core::FMTAgeYieldHandler::operator std::string,
352 "@DocString(FMTAgeYieldHandler::operator std::string)")
353 .def("setyieldvalues", &Core::FMTAgeYieldHandler::setYieldValues,
354 "@DocString(FMTAgeYieldHandler::setyieldvalues)");
355
356 definePyList<Core::FMTAgeYieldHandler>();
357
358 bp::class_<Core::FMTTimeYieldHandler,bp::bases<Core::FMTYieldHandler>>("FMTtimeyieldhandler", "@DocString(FMTTimeYieldHandler)")
359 .def(bp::init<const Core::FMTMask&>())
360 .def_pickle(FMT_pickle_suite<Core::FMTTimeYieldHandler>())
361 .def("__str__", &Core::FMTTimeYieldHandler::operator std::string,
362 "@DocString(FMTTimeYieldHandler::operator std::string)")
363 .def("setyieldvalues", &Core::FMTTimeYieldHandler::setYieldValues,
364 "@DocString(FMTTimeYieldHandler::setyieldvalues)");
365
366 definePyList<Core::FMTTimeYieldHandler>();
367
368 bp::class_<Core::FMTYields/*, bp::bases<Core::FMTList<std::unique_ptr<Core::FMTYieldHandler>>>*/>("FMTyields", "@DocString(FMTYields)")
369 .def(bp::init<Core::FMTYields>())
370 .def_pickle(FMT_pickle_suite<Core::FMTYields>())
371 .def("getallyields", &Core::FMTYields::getAllYields,
372 "@DocString(FMTYields::getallyields)")
373 .def("get", &Core::FMTYields::get,
374 "@DocString(FMTYields::get)")
375 .def("push_back", &Core::FMTYields::pushBackAgeHandler,
376 "@DocString(FMTYields::push_backagehandler)")
377 .def("push_back", &Core::FMTYields::pushBackTimeHandler,
378 "@DocString(FMTYields::push_backtimehandler)")
379 .def("getallyieldnames", &Core::FMTYields::getAllYieldNames,
380 "@DocString(FMTYields::getallyieldnames)")
381 .def("getfromfactor",&Core::FMTYields::getFromFactor,
382 "@DocString(FMTYields::getfromfactor)")
383 .def("update", &Core::FMTYields::update,
384 "@DocString(FMTYields::update)");
385
386
387
388 bp::class_<Core::FMTTransition, bp::bases<Core::FMTList<Core::FMTFork>>>("FMTtransition", "@DocString(FMTTransition)")
389 .def_pickle(FMT_pickle_suite<Core::FMTTransition>())
390 .def(bp::init<Core::FMTTransition>())
391 .def(bp::init<const std::string&>())
392 .def("single",&Core::FMTTransition::single,
393 "@DocString(FMTTransition::single)")
394 .def("main_target", &Core::FMTTransition::mainTarget,
395 "@DocString(FMTTransition::main_target)")
396 .def("age_after", &Core::FMTTransition::ageAfter,
397 "@DocString(FMTTransition::age_after)")
398 .def("attribute_targets", &Core::FMTTransition::attributeTargets,
399 "@DocString(FMTTransition::attribute_targets)")
400 .def("__str__", &Core::FMTTransition::operator std::string,
401 "@DocString(FMTTransition::operator std::string)")
402 .def("__eq__",&Core::FMTTransition::operator ==,
403 "@DocString(FMTTransition::operator==)")
404 .def("__ne__",&Core::FMTTransition::operator !=,
405 "@DocString(FMTTransition::operator!=)")
406 .def("__lt__",&Core::FMTTransition::operator <,
407 "@DocString(FMTTransition::operator<)")
408 .def("getname",&Core::FMTTransition::getName,
409 "@DocString(FMTTransition::getname)");
410
411
412 bp::enum_<Core::FMTotar>("FMTotar")
413 .value("inventory", Core::FMTotar::inventory)
414 .value("actual", Core::FMTotar::actual)
415 .value("val", Core::FMTotar::val)
416 .value("timeyld", Core::FMTotar::timeyld)
417 .value("level", Core::FMTotar::level)
418 .export_values();
419
420 bp::class_<Core::FMTOutputSource>("FMToutputsource", "@DocString(FMTOutputSource)")
421 .def(bp::init<const Core::FMTSpec&, const Core::FMTMask&,
422 Core::FMTotar, const std::string&,
423 const std::string&, const int&, const int&>())
424 .def(bp::init<Core::FMTOutputSource>());
425
426 bp::class_<Core::FMTOperator>("FMToperator", "@DocString(FMTOperator)")
427 .def(bp::init<Core::FMTOperator>());
428
429
430 bp::class_<Core::FMTOutputNode>("FMToutputnode", "@DocString(FMTOutputNode)")
431 .def(bp::init<const Core::FMTMask&,const std::string&>())
432 .def("__str__", &Core::FMTOutputNode::operator std::string,
433 "@DocString(FMTOutputNode::operator std::string)");
434
435 define_FMTlist<Core::FMTOutputNode>();
436
437 bp::class_<Core::FMTOutput>("FMToutput", "@DocString(FMTOutput)")
438 .def(bp::init<Core::FMTOutput>())
439 .def(bp::init<const std::string&, const std::string&, const std::string&,
440 const std::vector<Core::FMTOutputSource>&,
441 const std::vector<Core::FMTOperator>&>())
442 .def_pickle(FMT_pickle_suite<Core::FMTTransition>())
443 .def("getname",&Core::FMTOutput::getName,
444 "@DocString(FMTOutput::getname)")
445 .def("getdescription",&Core::FMTOutput::getDescription,
446 "@DocString(FMTOutput::getdescription)")
447 .def("empty", &Core::FMTOutput::empty,
448 "@DocString(FMTOutput::empty)")
449 .def("containslevel",&Core::FMTOutput::containsLevel,
450 "@DocString(FMTOutput::containslevel)")
451 .def("islevel", &Core::FMTOutput::isLevel,
452 "@DocString(FMTOutput::islevel)")
453 .def("isonlylevel", &Core::FMTOutput::isOnlyLevel,
454 "@DocString(FMTOutput::isonlylevel)")
455 .def("getnodes",&Core::FMTOutput::getNodes, getnodes_overloads(bp::args("multiplier"), "@DocString(FMTOutput::getnodes)"))
456 .def("__str__", &Core::FMTOutput::operator std::string,
457 "@DocString(FMTOutput::operator std::string)")
458 .def("__eq__",&Core::FMTOutput::operator ==,
459 "@DocString(FMTOutput::operator==)")
460 .def("__ne__",&Core::FMTOutput::operator !=,
461 "@DocString(FMTOutput::operator!=)");
462
463 bp::class_<Core::FMTTheme>("FMTtheme", "@DocString(FMTTheme)")
464 .def_pickle(FMT_pickle_suite<Core::FMTTheme>())
465 .def(bp::init<const std::vector<std::string>&,const std::vector<std::string>&,const std::vector<std::string>&,const std::vector<std::vector<std::string>>&,const size_t&,const size_t&, const std::string&>())
466 .def(bp::init<Core::FMTTheme>())
467 .def("__str__", &Core::FMTTheme::operator std::string,
468 "@DocString(FMTTheme::operator std::string)")
469 .def("__eq__", &Core::FMTTheme::operator ==,
470 "@DocString(FMTTheme::operator==)")
471 .def("getaggregates", &Core::FMTTheme::getAggregates,
472 "@DocString(Core::FMTTheme::getaggregates)")
473 .def("getstart", &Core::FMTTheme::getStart,
474 bp::return_value_policy<bp::return_by_value>(),
475 "@DocString(Core::FMTTheme::getaggregates)")
476 .def("getid", &Core::FMTTheme::getId,
477 bp::return_value_policy<bp::return_by_value>(),
478 "@DocString(Core::FMTTheme::getid)")
479 .def("getattributenames", &Core::FMTTheme::getAttributeNames,
480 bp::return_value_policy<bp::return_by_value>(),
481 "@DocString(Core::FMTTheme::getattributenames)")
482 .def("getattributes", &Core::FMTTheme::getAttributes, getattributes_overloads(bp::args("value","aggregate_source"), "@DocString(FMTTheme::getattributes)"))
483 .def("getname", &Core::FMTTheme::getName,
484 "@DocString(FMTTheme::getname)");
485
486 bp::class_<Core::FMTConstants>("FMTconstants","@DocString(FMTConstants)");
487
488 bp::class_<Core::FMTSchedule>("FMTschedule", "@DocString(FMTSchedule)")
489 .def_pickle(FMT_pickle_suite<Core::FMTSchedule>())
490 .def(bp::init<Core::FMTSchedule>())
491 .def(bp::init<int, std::map<Core::FMTAction, std::map<Core::FMTDevelopment, std::vector<double>>>>())
492 .def("__str__", &Core::FMTSchedule::operator std::string,
493 "@DocString(FMTSchedule::operator std::string)")
494 .def("__add__", &Core::FMTSchedule::operator +,
495 "@DocString(FMTSchedule::operator+)")
496 .def("actionarea", &Core::FMTSchedule::actionArea,
497 "@DocString(FMTSchedule::actionarea)")
498 .def("getperiod", &Core::FMTSchedule::getPeriod,
499 "@DocString(FMTSchedule::getperiod)")
500 .def("setperiod", &Core::FMTSchedule::setPeriod,
501 "@DocString(FMTSchedule::setperiod)")
502 .def("__eq__", &Core::FMTSchedule::operator ==,
503 "@DocString(FMTSchedule::operator==)")
504 .def("__ne__", &Core::FMTSchedule::operator !=,
505 "@DocString(FMTSchedule::operator!=)")
506 .def("__iter__", boost::python::iterator<Core::FMTSchedule>())
507 .def("empty",&Core::FMTSchedule::empty,
508 "@DocString(FMTSchedule::empty)");
509
510 bp::class_<Core::FMTGCBMTransition>("FMTGCBMtransition", "@DocString(FMTGCBMTransition)")
511 .def_readwrite("name", &Core::FMTGCBMTransition::name,
512 "@DocString(FMTGCBMTransition::name)")
513 .def_readwrite("ageafter", &Core::FMTGCBMTransition::ageafter,
514 "@DocString(FMTGCBMTransition::ageafter)")
515 .add_property("themes", bp::make_getter(&Core::FMTGCBMTransition::themes, bp::return_value_policy<bp::return_by_value>()),
516 bp::make_setter(&Core::FMTGCBMTransition::themes, bp::return_value_policy<bp::return_by_value>()));
517
518 bp::class_<Core::FMTConstraint, bp::bases<Core::FMTOutput,Core::FMTSpec>>("FMTconstraint", "@DocString(FMTConstraint)")
519 .def(bp::init<Core::FMTConstraint>())
520 .def(bp::init<Core::FMTconstrainttype,const Core::FMTOutput&>())
521 .def("__str__", &Core::FMTConstraint::operator std::string,
522 "@DocString(FMTConstraint::operator std::string)")
523 .def("__eq__", &Core::FMTConstraint::operator ==,
524 "@DocString(FMTConstraint::operator==)")
525 .def("isspatial",&Core::FMTConstraint::isSpatial,
526 "@DocString(FMTConstraint::isspatial)")
527 .def("setlength", &Core::FMTConstraint::setLength,
528 "@DocString(FMTConstraint::setlength)")
529 .def("issetfrom", &Core::FMTConstraint::isSetFrom,
530 "@DocString(FMTConstraint::issetfrom)")
531 .def("setfrom", &Core::FMTConstraint::setFrom,
532 "@DocString(FMTConstraint::setfrom)")
533 .def("sense",&Core::FMTConstraint::sense,
534 "@DocString(FMTConstraint::sense)")
535 .def("setrhs", &Core::FMTConstraint::setRhs,
536 "@DocString(FMTConstraint::setrhs)")
537 .def("getconstrainttype", &Core::FMTConstraint::getConstraintType,
538 "@DocString(FMTConstraint::getconstrainttype)")
539 .def("getfromreplicate", &Core::FMTConstraint::getFromReplicate,
540 "@DocString(FMTConstraint::getfromreplicate)")
541 .def("getscheduleweight", &Core::FMTConstraint::getScheduleWeight,
542 "@DocString(FMTConstraint::getscheduleweight)")
543 .def("setpenalties", &Core::FMTConstraint::setPenalties,
544 "@DocString(FMTConstraint::setpenalties)");
545
546 define_FMTlist<Core::FMTConstraint>();
547 define_FMTlist<Core::FMTGCBMTransition>();
548
549 bp::class_<Core::FMTYieldRequest>("FMTyieldrequest", "@DocString(FMTYieldRequest)");
550
551 define_FMTlist<Core::FMTYieldRequest>();
552
553
554 }
555}
556
557#endif // PYEXPORTCORE_H_INCLUDED
List of specifications dictating the operability of a subset of developments to this action.
Definition: FMTAction.h:43
bool isResetAge() const
Return true if the development age is reset to 0 when operated by this action.
Definition: FMTAction.h:198
bool useYield(const std::string &yldname) const
Return true if the yield is used by the action to set operability.
void pushAggregate(const std::string &aggregate)
Push an aggregate to the aggregates of the action.
std::vector< std::string > getAggregates() const
Return the names of the aggregates the action is part of.
bool doRespectLock() const
Return true if the action needs to respect the lock state of the development.
Definition: FMTAction.h:189
void update() override
Update the action by setting the bounds and shrinking the list, for optimization.
std::string getName() const
Get the name of the action.
Definition: FMTAction.h:180
void setArea(const double &newarea)
Set the area of the actual development.
double getArea() const override
Return the area of the actual development.
virtual void setYieldValues(const std::string &yldname, const std::vector< int > &baseages, const std::vector< double > &values)
Set the values for a given yield name.
FMTconstrainttype getConstraintType() const
Return the type of the constraint.
double sense() const
Return the sense of the objective, 1 for minimisation and -1 for maximisation.
double getScheduleWeight() const
Return the global schedule weight of the objective for a local model.
Core::FMTConstraint getFromReplicate(const size_t &replicate, const int &period) const
Return a new constraint with the replicate value, if the constraint is built with a replicate table....
void setPenalties(const std::string &penaltyoperator, const std::vector< std::string > &variables)
Set the penalties if the constraint is an objective.
bool isSpatial() const
Return true if the constraint is a spatial constraint.
bool isSetFrom(const std::string &modeltype) const
Return true if the constraint needs to be set from a specific model.
void setRhs(double lower, double upper)
Set the RHS of the constraint with a lower and upper bound.
Core::FMTConstraint setFrom(const std::string &modeltype, const double &value) const
Return a new constraint set with the value of the given model type.
void setLength(int firstPeriod=1, int lastPeriod=std::numeric_limits< int >::max())
Set the length of the constraint.
const FMTDevelopment & getDevelopment() const
Get the new development.
double getProportion() const
Get the proportion of area going to this dev.
Base class of FMTActualDevelopment and FMTFuturDevelopment representing a forest stand.
Definition: FMTDevelopment.h:44
void setMask(const Core::FMTMask &p_mask)
Set the mask of the development.
void setLock(const int &llock)
Set the lock of the development.
FMTFuturDevelopment grow() const
Return a grown copy of this development, increasing the age and period and decreasing the lock level ...
int getLock() const
Get the lock of the development.
Definition: FMTDevelopment.h:82
void setPeriod(const int &lperiod)
Set the period of the development.
void setAge(const int &lage)
Set the age of the development.
int getPeriod() const
Get the period of the development.
Definition: FMTDevelopment.h:91
bool operable(const FMTAction &action, const Core::FMTYields &ylds, const Graph::FMTGraphVertexToYield *graphyieldrequest=nullptr) const
Check if this development is operable to an action based on multiple yields.
Core::FMTMask getMaskCopy() const
Get a copy of the mask of the development.
Definition: FMTDevelopment.h:109
std::vector< FMTDevelopmentPath > operate(const FMTAction &action, const FMTTransition &Transition, const Core::FMTYields &ylds, const std::vector< FMTTheme > &themes) const
Return the development paths resulting from operating this development with an action and a transitio...
int getAge() const
Get the age of the development.
Definition: FMTDevelopment.h:64
FMTYieldRequest getYieldRequest(const Graph::FMTGraphVertexToYield *graphyieldrequest=nullptr) const
Get a yield request for this development, without reference to a graph unless one is provided.
void add(const FMTTransitionMask &transition)
Add a transition mask to the fork.
std::string name
The name of the GCBM transition.
Definition: FMTGCBMTransition.h:52
std::map< std::string, std::string > themes
Map where's the key is the theme name and the element is the new attribute set after the transition.
Definition: FMTGCBMTransition.h:49
int ageafter
Describe the age set on the strata after the disturbance.
Definition: FMTGCBMTransition.h:46
Core class holding, as a boost dynamic bitset, which theme attributes are part of a mask.
Definition: FMTMask.h:96
FMTMask preSolve(const FMTMaskFilter &filter, const std::vector< FMTTheme > &presolvedthemes) const
Return a presolved mask with potentially less data using a filter and a subset of the original themes...
FMTMask postSolve(const FMTMaskFilter &filter, const std::vector< FMTTheme > &basethemes) const
Return a postsolved mask using a filter and the original themes.
bool isSubsetOf(const FMTMask &p_mask, const std::vector< size_t > &p_subset) const
Check if this mask is a subset of another mask by looking at a block subset.
std::vector< FMTMask > decompose(const FMTTheme &theme) const
Disaggregate the attribute of a theme from the mask into a vector of masks, one per possible attribut...
void setQuietExceptionHandler()
Create and set a quiet exception handler to the FMTObject.
virtual void setDebugLogger()
Create and set a debug logger to the FMTObject.
void setFreeExceptionHandler()
Create and set a free exception handler to the FMTObject.
void enableNestedExceptions()
Enable the nested exception throw of the exception handler.
virtual void setDefaultLogger()
Create and set a default logger to the FMTObject.
void redirectLogToFile(const std::string &location)
Redirect the log to a specific file, appending to it.
virtual void setTaskLogger()
Create and set a task logger to the FMTObject.
void setDefaultExceptionHandler()
Create and set a default exception handler to the FMTObject.
void setErrorsToWarnings(const std::vector< Exception::FMTexc > &errors)
Set a list of errors to be cast to warnings on the exception handler.
virtual void setQuietLogger()
Create and set a quiet logger to the FMTObject.
void disableNestedExceptions()
Disable the nested exception throw of the exception handler.
void setDebugExceptionHandler()
Create and set a debug exception handler to the FMTObject.
bool containsLevel() const
Return true if the output contains any level.
std::string getDescription() const
Return the description of the output.
Definition: FMTOutput.h:143
std::string getName() const
Return the name of the output.
Definition: FMTOutput.h:134
std::vector< FMTOutputNode > getNodes(std::vector< std::string > &equation, double multiplier=1, bool orderbyoutputid=false, int period=1) const
Return the output nodes generated from the output sources and operators, optionally multiplied by a f...
bool isLevel() const
Return true if one output source of the output is a level.
bool isOnlyLevel() const
Return true if all output sources of the output are levels.
bool empty() const
Return true if the output has no output source.
double actionArea(const FMTAction &action) const
Return the total harvested area of an action in the schedule.
void setPeriod(const int &newPeriod)
Set the period of the schedule and of its developments.
bool empty() const
Return true if the schedule is empty.
int getPeriod() const
Return the period of the schedule.
Definition: FMTSchedule.h:122
const std::string getSerie() const
Return the string of the serie.
int getLength() const
Return the length of the serie.
const std::vector< std::string > & getAttributeNames() const
Return the names of the attributes.
Definition: FMTTheme.h:269
const size_t & getStart() const
Return the bit location of the mask at which the theme starts.
Definition: FMTTheme.h:216
std::vector< std::string > getAttributes(const std::string &p_value, bool p_aggregate_source=false) const
Get the attributes of an aggregate for the theme.
std::vector< std::string > getAggregates() const
Return the aggregates of the theme.
std::string getName() const
Return the name of the theme.
Definition: FMTTheme.h:234
const size_t & getId() const
Return the id of the theme.
Definition: FMTTheme.h:225
virtual void setYieldValues(const std::string &yldname, const int &startingperiod, const std::vector< double > &values)
Set the values for a given yield name.
unsigned int ageAfter(const std::vector< FMTDevelopment > &devs, const FMTAction &action, const FMTYields &ylds, const std::vector< FMTTheme > &themes) const
Return the average age after disturbance across the developments, for GCBM.
std::string getName() const
Get the name of the transition.
Definition: FMTTransition.h:90
FMTTransition single() const
Return a transition that leads to a single development path, selecting the one with the highest area ...
FMTMask mainTarget(const std::vector< FMTDevelopment > &devs, const FMTYields &ylds) const
Return the most targeted mask across the developments based on the yields, for GCBM.
std::map< std::string, std::vector< FMTDevelopment > > attributeTargets(const std::vector< FMTDevelopment > &devs, const FMTYields &ylds, const std::vector< FMTTheme > &themes) const
Classify the developments by mask key based on the yields.
Base class for yield handlers, holding a mask and the base ages of the yields.
Definition: FMTYieldHandler.h:80
bool pushBase(const int &base)
Push a base age to the handler.
virtual bool pushData(const std::string &yld, const double &value)
Push a value for a yield.
FMTList containing multiple yield handlers as seen in the yield section, holding the information rela...
Definition: FMTYields.h:44
void update() override
Update the yield names and null yield names caching, as required by FMTList.
void pushBackTimeHandler(const FMTMask &mask, const FMTTimeYieldHandler &value)
Push back a time yield handler, for R.
void pushBackAgeHandler(const FMTMask &mask, const FMTAgeYieldHandler &value)
Push back an age yield handler, for R.
FMTYields getFromFactor(const double &factor, std::vector< std::string >yieldnames=std::vector< std::string >()) const
Multiply the yields section by a factor and return a new yields section.
double get(const FMTYieldRequest &request, const std::string &yld) const
Get the yield value for a development from a yield request.
std::map< std::string, std::map< std::string, std::vector< double > > > getAllYields(const FMTTheme &target, FMTyldtype type) const
Return a map of all the yield values for a given yield handler type, used for generating a text file ...
std::vector< std::string > getAllYieldNames() const
Return all the yield names from the list.
@ Control
Definition: FMTutility.h:33
@ Constants
Definition: FMTutility.h:41
@ Area
Definition: FMTutility.h:35
@ Outputs
Definition: FMTutility.h:39
@ Optimize
Definition: FMTutility.h:40
@ Landscape
Definition: FMTutility.h:34
@ Schedule
Definition: FMTutility.h:42
@ Action
Definition: FMTutility.h:36
@ Transition
Definition: FMTutility.h:37
@ Empty
Definition: FMTutility.h:44
@ Yield
Definition: FMTutility.h:38
@ FMTsequence
Definition: FMTConstraint.h:38
@ FMTspatialadjacency
Definition: FMTConstraint.h:41
@ FMTstandard
Definition: FMTConstraint.h:39
@ FMTMINMAXobjective
Definition: FMTConstraint.h:35
@ FMTnondeclining
Definition: FMTConstraint.h:37
@ FMTMAXMINobjective
Definition: FMTConstraint.h:34
@ FMTspatialsize
Regular constraint m_type like output = 1...
Definition: FMTConstraint.h:40
@ FMTMAXobjective
Definition: FMTConstraint.h:32
@ FMTMINobjective
Definition: FMTConstraint.h:33
@ FMTevenflow
Definition: FMTConstraint.h:36
@ FMTspatialgreenup
Definition: FMTConstraint.h:42
@ FMTcomplexyld
Definition: FMTutility.h:65
@ FMTageyld
Definition: FMTutility.h:63
@ FMTtimeyld
Definition: FMTutility.h:64
@ developpement
Definition: FMTutility.h:25
@ totalonly
Definition: FMTutility.h:24
@ standard
Definition: FMTutility.h:23
FMTotar
Enumerator describing the target of an output (inventory, actual, value, time yield,...
Definition: FMTutility.h:101
@ actual
Definition: FMTutility.h:103
@ val
Definition: FMTutility.h:104
@ level
Definition: FMTutility.h:106
@ timeyld
Definition: FMTutility.h:105
@ inventory
Definition: FMTutility.h:102
Definition: PYdefinitions.h:14
void exportCore()
Definition: PYexportCore.h:44