FMT 0.9.8
Forest management tools for forest planning
Loading...
Searching...
No Matches
FMToutputsource.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 FMTOSR_H_INCLUDED
9#define FMTOSR_H_INCLUDED
10
11#include "FMTbounds.hpp"
12#include "FMTmask.hpp"
13#include <vector>
14#include <boost/serialization/serialization.hpp>
15#include <string>
16#include "FMTutility.hpp"
17#include <unordered_set>
18#include "FMTdevelopment.hpp"
19
20
21namespace Graph
22{
23 class FMTgraphvertextoyield;
24}
25
26namespace Parser
27{
28 class FMToutputparser;
29}
30
31
32namespace Core
33{
34 class FMTaction;
35 class FMTyields;
36 class FMTactualdevelopment;
37 class FMTdevelopmentpath;
38 class FMToperator;
40 {
41 friend class boost::serialization::access;
43 template<class Archive>
44 void serialize(Archive& ar, const unsigned int version)
45 {
46 ar & boost::serialization::make_nvp("specification", boost::serialization::base_object<FMTspec>(*this));
47 ar & BOOST_SERIALIZATION_NVP(mask);
48 ar & BOOST_SERIALIZATION_NVP(target);
49 ar & BOOST_SERIALIZATION_NVP(action);
50 ar & BOOST_SERIALIZATION_NVP(yield);
51 ar & BOOST_SERIALIZATION_NVP(values);
52 ar & BOOST_SERIALIZATION_NVP(themetarget);
53 }
54 FMTmask mask;
55 FMTotar target;
56 std::string action,yield,levelname;//levelname is only for constant level...(for parsing)
57 std::vector<double>values;
58 bool average;
59 bool sum;
60 int outputorigin;
61 int themetarget;
62 //target =-1 or themetarget constructor
63 void pushvalues(const std::vector<double>& newvalues);
64 public:
66 ~FMToutputsource() = default;
67 FMToutputsource(const FMTotar ltarget,double lvalue = 0,
68 std::string lyield= "", std::string laction = "",int origin=-1, int ttarget=-1);
69 FMToutputsource(const FMTotar ltarget,
70 std::vector<double>lvalues, int origin = -1, int ttarget=-1, std::string llevelname = "");
71 FMToutputsource(const FMTspec& spec,const FMTmask& lmask,
72 const FMTotar ltarget, std::string lyield= "",
73 std::string laction = "", int origin = -1, int ttarget=-1);
75 FMToutputsource& operator = (const FMToutputsource& rhs);
76 operator std::string() const override;
77 bool operator == (const FMToutputsource& rhs) const;
78 bool operator != (const FMToutputsource& rhs) const;
79 bool operator < (const FMToutputsource& rhs) const;
80 inline int getoutputorigin() const
81 {
82 return outputorigin;
83 }
84 inline int getthemetarget() const
85 {
86 return themetarget;
87 }
88 bool isinaggregate(const FMToutputsource& rhs, const std::vector<Core::FMTaction>& actions) const;
89 bool issubsetof(const FMToutputsource& rhs, const std::vector<Core::FMTaction>& actions) const;
90 bool issubsetof(const FMToutputsource& rhs) const;
92 inline const FMTmask& getmask() const
93 {
94 return mask;
95 }
96 void setmask(const FMTmask& newmask);
97 void setaction(const std::string& actionname);
98 void settarget(const FMTotar& newtype);
99 void setthemetarget(const int& newttarget);
100 void setoutputorigin(const int& neworigin);
101 void resetvalues(const FMToperator& op,const FMToutputsource& other);
102 inline const std::string& getaction() const
103 {
104 return action;
105 }
106 inline const std::string& getyield() const
107 {
108 return yield;
109 }
110 inline const FMTotar& gettarget() const
111 {
112 return target;
113 }
114 double getvalue(int period = 0) const;
115 inline bool isvariable() const
116 {
117 return bool(mask);
118 }
119 inline bool islevel() const
120 {
121 return (target == FMTotar::level);
122 }
123 inline bool isconstant() const
124 {
125 return (target == FMTotar::val);
126 }
127 inline bool isvariablelevel() const
128 {
129 return (!action.empty() && islevel());
130 }
131 inline const std::string& getlevel() const
132 {
133 return yield;
134 }
135 inline const std::vector<double>& getvalues() const
136 {
137 return values;
138 }
139 bool isnull(const FMTyields& ylds) const;
140 inline bool istimeyield() const
141 {
142 return (target == FMTotar::timeyld);
143 }
144 std::vector<const FMTaction*>targets(const std::vector<FMTaction>& actions) const;
145 std::unordered_set<int>targetsset(const std::vector<FMTaction>& actions) const;
146 inline bool isinventory() const
147 {
148 return (target == FMTotar::inventory);
149 }
150 inline bool useinedges() const
151 {
152 return (target == FMTotar::inventory);
153 }
154 inline bool isnextperiod() const
155 {
156 return (target == FMTotar::inventory && action.empty());
157 }
158 inline bool useoutedges() const
159 {
160 return (target == FMTotar::actual);
161 }
162 double getcoef(const FMTdevelopment& development,
163 const FMTyields& yields,
164 const Graph::FMTgraphvertextoyield* graphinfo =nullptr,
165 std::vector<FMTdevelopmentpath> const * paths=nullptr,
166 FMTaction const * action=nullptr) const;
167 inline bool use(const FMTdevelopment& development, const FMTyields& ylds,
168 const Graph::FMTgraphvertextoyield* graphinfo=nullptr) const
169 {
170 return (development.getmask().issubsetof(mask) && development.is(*this, ylds, graphinfo));
171 }
172 FMToutputsource presolve(const FMTmaskfilter& filter,const std::vector<FMTtheme>& newthemes) const;
174 inline bool isaverage() const
175 {
176 return average;
177 }
178 void setsum();
179 inline bool issum() const
180 {
181 return sum;
182 }
184 double getconstantvalue(const std::vector<Core::FMTactualdevelopment>& area,
185 const std::vector<Core::FMTaction>&actions, const FMTyields& yields) const;
186 size_t hash(int period = -1,bool withyield = false) const;
187 void fillhashmask(Core::FMTmask& basemask) const;
188 void fillhashspec(Core::FMTmask& basemask) const;
189 bool isequalbyvalue(const FMToutputsource& rhs) const;
190 inline bool isaction() const
191 {
192 return !action.empty();
193 }
194 };
195
197 {
198 bool variable;
199 public:
201 bool operator()(const FMToutputsource& source) const;
202
203 };
204
205
206
207}
208
209
210
211#endif // FMTOSR_H_INCLUDED
#define FMTEXPORT
Definition: FMTutility.hpp:92
Definition: FMTaction.hpp:42
Definition: FMTdevelopment.hpp:44
const Core::FMTmask & getmask() const
Definition: FMTdevelopment.hpp:106
bool is(const FMTspec &specification, const Core::FMTyields &ylds, const Graph::FMTgraphvertextoyield *graphyieldrequest=nullptr) const
Definition: FMTmask.hpp:96
bool issubsetof(const boost::dynamic_bitset<> &rhs) const
Definition: FMTmask.hpp:352
Definition: FMTmaskfilter.hpp:27
Definition: FMToperator.hpp:36
Definition: FMToutputsource.hpp:40
FMToutputsource presolve(const FMTmaskfilter &filter, const std::vector< FMTtheme > &newthemes) const
const std::string & getyield() const
Definition: FMToutputsource.hpp:106
bool isaction() const
Definition: FMToutputsource.hpp:190
const std::string & getaction() const
Definition: FMToutputsource.hpp:102
double getconstantvalue(const std::vector< Core::FMTactualdevelopment > &area, const std::vector< Core::FMTaction > &actions, const FMTyields &yields) const
std::vector< const FMTaction * > targets(const std::vector< FMTaction > &actions) const
bool isvariablelevel() const
Definition: FMToutputsource.hpp:127
FMToutputsource(const FMTotar ltarget, double lvalue=0, std::string lyield="", std::string laction="", int origin=-1, int ttarget=-1)
void setmask(const FMTmask &newmask)
bool issubsetof(const FMToutputsource &rhs, const std::vector< Core::FMTaction > &actions) const
const FMTotar & gettarget() const
Definition: FMToutputsource.hpp:110
double getcoef(const FMTdevelopment &development, const FMTyields &yields, const Graph::FMTgraphvertextoyield *graphinfo=nullptr, std::vector< FMTdevelopmentpath > const *paths=nullptr, FMTaction const *action=nullptr) const
bool isvariable() const
Definition: FMToutputsource.hpp:115
bool canbededucedtoconstant() const
bool isconstant() const
Definition: FMToutputsource.hpp:123
void settarget(const FMTotar &newtype)
std::unordered_set< int > targetsset(const std::vector< FMTaction > &actions) const
size_t hash(int period=-1, bool withyield=false) const
void setthemetarget(const int &newttarget)
const std::string & getlevel() const
Definition: FMToutputsource.hpp:131
bool isinventory() const
Definition: FMToutputsource.hpp:146
~FMToutputsource()=default
bool isnextperiod() const
Definition: FMToutputsource.hpp:154
bool issum() const
Definition: FMToutputsource.hpp:179
bool isnull(const FMTyields &ylds) const
bool istimeyield() const
Definition: FMToutputsource.hpp:140
void fillhashspec(Core::FMTmask &basemask) const
double getvalue(int period=0) const
bool useoutedges() const
Definition: FMToutputsource.hpp:158
FMToutputsource(const FMTotar ltarget, std::vector< double >lvalues, int origin=-1, int ttarget=-1, std::string llevelname="")
FMToutputsource(const FMTspec &spec, const FMTmask &lmask, const FMTotar ltarget, std::string lyield="", std::string laction="", int origin=-1, int ttarget=-1)
const FMTmask & getmask() const
Definition: FMToutputsource.hpp:92
const std::vector< double > & getvalues() const
Definition: FMToutputsource.hpp:135
FMToutputsource(const FMToutputsource &rhs)
bool isaverage() const
Definition: FMToutputsource.hpp:174
void setaction(const std::string &actionname)
bool isinaggregate(const FMToutputsource &rhs, const std::vector< Core::FMTaction > &actions) const
bool issubsetof(const FMToutputsource &rhs) const
void fillhashmask(Core::FMTmask &basemask) const
bool use(const FMTdevelopment &development, const FMTyields &ylds, const Graph::FMTgraphvertextoyield *graphinfo=nullptr) const
Definition: FMToutputsource.hpp:167
bool useinedges() const
Definition: FMToutputsource.hpp:150
int getoutputorigin() const
Definition: FMToutputsource.hpp:80
int getthemetarget() const
Definition: FMToutputsource.hpp:84
void resetvalues(const FMToperator &op, const FMToutputsource &other)
void setoutputorigin(const int &neworigin)
bool issamebutdifferentaction(const FMToutputsource &rhs) const
bool isequalbyvalue(const FMToutputsource &rhs) const
bool islevel() const
Definition: FMToutputsource.hpp:119
Definition: FMToutputsource.hpp:197
FMToutputsourcecomparator(bool lvariable)
bool operator()(const FMToutputsource &source) const
Definition: FMTbounds.hpp:342
Definition: FMTyields.hpp:40
Definition: FMTgraphvertextoyield.hpp:27
Definition: FMToutputparser.hpp:35
The Core namespace provides classes for simulating stands/strata growth/harvest through time.
Definition: FMTaction.hpp:31
FMTotar
Definition: FMTutility.hpp:74
Namespace for using/building unidirectional graphs in FMT.
Definition: FMTareaparser.hpp:31
Namespace handling all FMT's parsers. Everything related to I/O should be located in this namespace.
Definition: FMTactionparser.hpp:26