FMT 0.9.8
Forest management tools for forest planning
Loading...
Searching...
No Matches
FMToutput.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 FMToutput_H_INCLUDED
9#define FMToutput_H_INCLUDED
10
11#include <vector>
12#include <string>
13#include <stack>
14#include <set>
15#include "FMToutputsource.hpp"
16#include "FMToperator.hpp"
17#include "FMTbounds.hpp"
18#include "FMTobject.hpp"
19#include <boost/serialization/string.hpp>
20#include <boost/serialization/serialization.hpp>
21#include <boost/serialization/export.hpp>
22
23namespace Core {
24 class FMToutputnode;
25 class FMTtheme;
26}
27
28
29namespace Core
30{
31// DocString: FMToutput
39 {
40 public:
41 // DocString: FMToutput()
46 // DocString: ~FMToutput()
50 virtual ~FMToutput() = default;
51 // DocString: FMToutput(const std::string&,const std::string&,const int&,std::vector<FMToutputsource>&,std::vector<FMToperator>&)
56 FMToutput(const std::string& lname, const std::string& ldescription,
57 const std::string& lgroup,
58 const std::vector<FMToutputsource>& lsources,
59 const std::vector<FMToperator>& loperators);
60 // DocString: FMToutput(const std::string&)
64 FMToutput(const std::string& lname);
65 // DocString: FMToutput(const FMToutput&)
69 FMToutput(const FMToutput& rhs);
70 // DocString: FMToutput::operator=
74 FMToutput& operator = (const FMToutput& rhs);
75 // DocString: FMToutput::operator==
79 bool operator == (const FMToutput& rhs) const;
80 // DocString: FMToutput::operator!=
84 bool operator != (const FMToutput& rhs) const;
85 // DocString: FMToutput::operator+=
89 FMToutput& operator +=(const FMToutput& rhs);
90 // DocString: FMToutput::operator-=
94 FMToutput& operator -=(const FMToutput& rhs);
95 // DocString: FMToutput::operator*=
100 FMToutput& operator *=(const double& rhs);
101 // DocString: FMToutput::operator/=
106 FMToutput& operator /=(const double& rhs);
107 // DocString: FMToutput::operator std::string
111 operator std::string() const;
112 // DocString: FMToutput::getname
116 inline std::string getname() const
117 {
118 return name;
119 }
120 // DocString: FMToutput::getdescription
124 inline std::string getdescription() const
125 {
126 return description;
127 }
128 // DocString: FMToutput::getgroup
132 inline std::string getgroup() const
133 {
134 return group;
135 }
136 // DocString: FMToutput::empty
140 bool empty() const;
141 // DocString: FMToutput::size
145 size_t size() const;
146 // DocString: FMToutput::islinear
151 bool islinear() const;
152 // DocString: FMToutput::canbenodesonly
157 bool canbenodesonly() const;
158 // DocString: FMToutput::islevel
162 bool islevel() const;
163 // DocString: FMToutput::isonlylevel
167 bool isonlylevel() const;
168 // DocString: FMToutput::isconstantlevel
172 bool isconstantlevel() const;
173 // DocString: FMToutput::isconstant
177 bool isconstant() const;
178 // DocString: FMToutput::getconstantvalue
182 double getconstantvalue() const;
183 // DocString: FMToutput::containslevel
187 bool containslevel() const;
188
189 // DocString: FMToutput::shuntingyard
193 double shuntingyard(const std::vector<double>& sourcevalues, const std::vector<FMToperator>& simple_operators) const;
194 // DocString: FMToutput::boundto
199 FMToutput boundto(const std::vector<FMTtheme>& themes, const FMTperbounds& bound, const std::string& specialbound, std::string attribute = "") const;
200 // DocString: FMToutput::getnodes
205 std::vector<FMToutputnode> getnodes(std::vector<std::string>& equation,
206 double multiplier = 1,
207 bool orderbyoutputid = false,
208 int period = 1) const;
209 // DocString: FMToutput::issingleperiod
214 bool issingleperiod() const;
215 // DocString: FMToutput::hasaverage
219 bool hasaverage() const;
220 // DocString: FMToutput::gettargetperiod
224 int gettargetperiod() const;
225 // DocString: FMToutput::hash
229 size_t hash() const;
230 // DocString: FMToutput::setsources
235 void setsources(const std::vector<FMToutputsource>& p_sources);
236 // DocString: FMToutput::getsources
240 inline std::vector<FMToutputsource> getsources() const
241 {
242 return sources;
243 }
244 // DocString: FMToutput::getsourcesreference
248 inline const std::vector<FMToutputsource>& getsourcesreference() const
249 {
250 return sources;
251 }
252 // DocString: FMToutput::getopes
256 inline std::vector<FMToperator> getopes() const
257 {
258 return operators;
259 }
260 // DocString: FMToutput::targettheme
265 FMTtheme targettheme(const std::vector<FMTtheme>& themes) const;
266 // DocString: FMToutput::targetthemeid
270 inline int targetthemeid() const
271 {
272 return sources.begin()->getthemetarget();
273 }
274 // DocString: FMToutput::getdecomposition
278 std::vector<std::string>getthemedecomposition(const FMTtheme& theme) const;
279 // DocString: FMToutput::getdecomposition
284 std::vector<std::string>getdecomposition(const std::vector<FMTtheme>& themes) const;
285 // DocString: FMToutput::intersectwithmask
290 const std::vector<Core::FMTtheme>& themes) const;
291 // DocString: FMToutput::getvariableintersect
296 // DocString: FMToutput::getstaticthemes()
300 std::vector<Core::FMTtheme>getstaticthemes(const std::vector<Core::FMTtheme>& themes, const Core::FMTyields& yields, bool ignoreoutputvariables = false) const;
301 // DocString: FMToutput::presolve
308 const std::vector<FMTtheme>& originalthemes,
309 const std::vector<FMTtheme>& selectedthemes,
310 const std::vector<FMTtheme>& newthemes,
311 const std::vector<FMTaction>& actions, const FMTyields& yields) const;
312 // DocString: FMToutput::changeoutputsorigin
317 void changesourcesid(const std::set<int>& newoutputsorigin, const std::set<int>& newthemeid);
318 // DocString: FMToutput::changeoutputsorigin
322 void changesourcesid(const int& outid);
323 // DocString: FMToutput::extractRHSvalue
329 // DocString: FMToutput::getRHSvalue
333 void getRHSvalue(const int& period, double& lower, double& upper) const;
334
335 // DocString: FMToutput::setperiod
339 void setperiod(const int& newperiod);
340 // DocString: FMToutput::isactionbased
344 bool isactionbased() const;
345 // DocString: FMToutput::isvariablesizeof
350 bool isvariablesizeof(const size_t& masksize) const;
351 // DocString: FMToutput::isinventory
355 bool isinventory() const;
356 // DocString: FMToutput::fillfromshuntingyard
361 const std::vector<std::string>baseeq,
362 std::map<std::string, double>& results,
363 const std::vector<Core::FMToutputnode>& nodes,
364 std::map<std::string, std::vector<std::string>>& allequations) const;
365 protected:
366 // DocString: FMToutput::sources
368 std::vector<FMToutputsource>sources;
369 // DocString: FMToutput::operators
371 std::vector<FMToperator>operators;
372 // DocString: FMToutput::theme_target
374 //int theme_target;
375 // DocString: FMToutput::name
377 std::string name;
378 // DocString: FMToutput::description
380 std::string description;
381 // DocString: FMToutput::group
383 std::string group;
384 // DocString: FMToutput::setproportions
388 void setproportions(std::map<std::string, std::vector<std::string>>& allequations,
389 const std::vector<std::string>& baseequation) const;
390 // DocString: FMToutput::isdivision
394 bool isdivision() const;
395 // DocString: FMToutput::isdivision
399 void replacedivision(const double& bound);
400
401 // DocString: FMToutput::serialize
405 private:
406 friend class boost::serialization::access;
407 template<class Archive>
408 void serialize(Archive& ar, const unsigned int version)
409 {
410 try {
411 ar& boost::serialization::make_nvp("FMTobject", boost::serialization::base_object<FMTobject>(*this));
412 ar& BOOST_SERIALIZATION_NVP(sources);
413 ar& BOOST_SERIALIZATION_NVP(operators);
414 //ar & BOOST_SERIALIZATION_NVP(theme_target);
415 ar& BOOST_SERIALIZATION_NVP(name);
416 ar& BOOST_SERIALIZATION_NVP(description);
417 }
418 catch (...)
419 {
420 _exhandler->printexceptions("", "FMToutput::serialize", __LINE__, __FILE__);
421 }
422 }
423 };
424// DocString: FMToutputcomparator
429{
430 // DocString: FMToutputcomparator::output_name
432 std::string output_name;
433public:
434 // DocString: FMToutputcomparator()
438 FMToutputcomparator(std::string name);
439 // DocString: FMToutputcomparator::operator()(const FMToutput&)
443 bool operator()(const FMToutput& output) const;
444
445};
446
447}
448BOOST_CLASS_EXPORT_KEY(Core::FMToutput)
449#endif // FMToutput_H_INCLUDED
#define FMTEXPORT
Definition: FMTutility.hpp:92
Definition: FMTmask.hpp:96
Definition: FMTmaskfilter.hpp:27
Definition: FMTobject.hpp:50
Definition: FMToutput.hpp:39
void setproportions(std::map< std::string, std::vector< std::string > > &allequations, const std::vector< std::string > &baseequation) const
bool empty() const
std::string name
Sometime output can specify multiple attributes of a given themes.
Definition: FMToutput.hpp:377
void changesourcesid(const std::set< int > &newoutputsorigin, const std::set< int > &newthemeid)
bool containslevel() const
bool isdivision() const
double getconstantvalue() const
void replacedivision(const double &bound)
virtual ~FMToutput()=default
bool isvariablesizeof(const size_t &masksize) const
std::vector< FMToutputnode > getnodes(std::vector< std::string > &equation, double multiplier=1, bool orderbyoutputid=false, int period=1) const
bool isactionbased() const
FMTmask getvariableintersect() const
bool canbenodesonly() const
bool islinear() const
bool isconstantlevel() const
void setsources(const std::vector< FMToutputsource > &p_sources)
set new sources for this output
bool islevel() const
int gettargetperiod() const
void changesourcesid(const int &outid)
std::vector< std::string > getdecomposition(const std::vector< FMTtheme > &themes) const
double shuntingyard(const std::vector< double > &sourcevalues, const std::vector< FMToperator > &simple_operators) const
std::string getgroup() const
Definition: FMToutput.hpp:132
bool isconstant() const
FMToutput(const FMToutput &rhs)
std::vector< Core::FMTtheme > getstaticthemes(const std::vector< Core::FMTtheme > &themes, const Core::FMTyields &yields, bool ignoreoutputvariables=false) const
int targetthemeid() const
Definition: FMToutput.hpp:270
bool issingleperiod() const
size_t size() const
FMTtheme targettheme(const std::vector< FMTtheme > &themes) const
std::vector< FMToperator > operators
vector of simple operators like +-*â€/
Definition: FMToutput.hpp:371
std::string getname() const
Definition: FMToutput.hpp:116
std::vector< FMToutputsource > getsources() const
Definition: FMToutput.hpp:240
std::vector< FMToperator > getopes() const
Definition: FMToutput.hpp:256
FMToutput(const std::string &lname)
FMToutput boundto(const std::vector< FMTtheme > &themes, const FMTperbounds &bound, const std::string &specialbound, std::string attribute="") const
bool isinventory() const
void getRHSvalue(const int &period, double &lower, double &upper) const
FMToutput intersectwithmask(const Core::FMTmask &mask, const std::vector< Core::FMTtheme > &themes) const
bool hasaverage() const
bool isonlylevel() const
FMToutput(const std::string &lname, const std::string &ldescription, const std::string &lgroup, const std::vector< FMToutputsource > &lsources, const std::vector< FMToperator > &loperators)
Core::FMToutput removeRHSvalue() const
const std::vector< FMToutputsource > & getsourcesreference() const
Definition: FMToutput.hpp:248
void fillfromshuntingyard(const std::vector< std::string >baseeq, std::map< std::string, double > &results, const std::vector< Core::FMToutputnode > &nodes, std::map< std::string, std::vector< std::string > > &allequations) const
std::string group
This is the group of the output, if empty there's no group.
Definition: FMToutput.hpp:383
size_t hash() const
std::string getdescription() const
Definition: FMToutput.hpp:124
FMToutput presolve(const FMTmaskfilter &filter, const std::vector< FMTtheme > &originalthemes, const std::vector< FMTtheme > &selectedthemes, const std::vector< FMTtheme > &newthemes, const std::vector< FMTaction > &actions, const FMTyields &yields) const
std::vector< FMToutputsource > sources
outputsources data used to generate outputnodes
Definition: FMToutput.hpp:368
std::vector< std::string > getthemedecomposition(const FMTtheme &theme) const
std::string description
This is description of the FMToutput has seen in the output section.
Definition: FMToutput.hpp:380
void setperiod(const int &newperiod)
Definition: FMToutput.hpp:429
FMToutputcomparator(std::string name)
bool operator()(const FMToutput &output) const
Definition: FMTbounds.hpp:293
Definition: FMTtheme.hpp:47
Definition: FMTyields.hpp:40
The Core namespace provides classes for simulating stands/strata growth/harvest through time.
Definition: FMTaction.hpp:31