FMT 0.9.8
Forest management tools for forest planning
Loading...
Searching...
No Matches
FMTconstraint.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 FMTconstraint_H_INCLUDED
9#define FMTconstraint_H_INCLUDED
10
11#include "FMToutput.hpp"
12#include <vector>
13#include <string>
14#include <limits>
15#include "FMTbounds.hpp"
16#include <boost/serialization/serialization.hpp>
17#include <boost/serialization/nvp.hpp>
18#include <boost/serialization/export.hpp>
19
20namespace Core
21{
22class FMTtransition;
23class FMTtheme;
24class FMTaction;
25class FMTyields;
26// DocString: FMTconstrainttype
32{
44 FMTrandomaction = 12//need to be deleted
45};
46// DocString: FMTconstraint
54 {
55 // DocString: FMTconstraint::serialize
59 friend class boost::serialization::access;
60 template<class Archive>
61 void serialize(Archive& ar, const unsigned int version)
62 {
63 ar & boost::serialization::make_nvp("output", boost::serialization::base_object<FMToutput>(*this));
64 ar & boost::serialization::make_nvp("specification", boost::serialization::base_object<FMTspec>(*this));
65 ar & BOOST_SERIALIZATION_NVP(type);
66 }
67 // DocString: FMTconstraint::type
70 // DocString: FMTconstraint::standardstring
74 void standardstring(std::string& line, std::string& period_bounds, std::string& goal, std::string& global) const;
75 // DocString: FMTconstraint::getmaxandmin
79 void getmaxandmin(const std::vector<double>& values, double& min,double& max) const;
80 // DocString: FMTconstraint::getsum
84 double getsum(const std::vector<double>& values) const;
85 // DocString: FMTconstraint::getperiodicvariationcost
89 double getperiodicvariationcost(const std::vector<double>& values, bool evaluateupper=false) const;
90 // DocString: FMTconstraint::getvariability
94 double getvariability(const std::vector<double>& values,const double& var,const double& lowarvar) const;
95
96 public:
97 // DocString: FMTconstraint()
102 // DocString: FMTconstraint(FMTconstrainttype,const FMToutput&)
107 // DocString: FMTconstraint(const FMTconstraint&)
112 // DocString: FMTconstraint::operator=
116 FMTconstraint& operator = (const FMTconstraint& rhs);
117 // DocString: FMTconstraint::operator==
121 bool operator == (const FMTconstraint& rhs) const;
122 // DocString: FMTconstraint::operator!=
126 bool operator != (const FMTconstraint& rhs) const;
127 // DocString: FMTconstraint::extravariables
131 bool extravariables() const;
132 // DocString: FMTconstraint::isgoal
136 bool isgoal() const;
137 // DocString: FMTconstraint::issetfrom
141 bool issetfrom(const std::string& modeltype) const;
142 // DocString: FMTconstraint::isreignore
146 bool isreignore(const int& replanningperiod) const;
147 // DocString: FMTconstraint::dosupportrandom
152 bool dosupportrandom() const;
153 // DocString: FMTconstraint::setfrom
158 Core::FMTconstraint setfrom(const std::string& modeltype,const double& value) const;
159 // DocString: FMTconstraint::getscheduleweight
163 double getscheduleweight() const;
164 // DocString: FMTconstraint::getiterationchange
169 Core::FMTconstraint getiterationchange(const std::vector<double>& periodchanges,const int& targetperiod) const;
170 // DocString: FMTconstraint::getfromreplicate
175 Core::FMTconstraint getfromreplicate(const size_t& replicate,const int& period) const;
176 // DocString: FMTconstraint::getpenalties
180 std::vector<std::string>getpenalties(double & sense) const;
181 // DocString: FMTconstraint::getvariablelevels
185 std::vector<std::string>getvariablelevels() const;
186 // DocString: FMTconstraint::getgoal
190 void getgoal(std::string& name,double& value) const;
191 // DocString: FMTconstraint::setgoal
195 void setgoal(const std::string& goalname, const double& value);
196 // DocString: FMTconstraint::setpenalties
200 void setpenalties(const std::string& penaltyoperator, const std::vector<std::string>& variables);
201 // DocString: FMTconstraint::isobjective
205 bool isobjective() const;
206 // DocString: FMTconstraint::sense
211 double sense() const;
212 // DocString: FMTconstraint::getbounds
217 void getbounds(double& lower, double& upper,int period = 0) const;
218 // DocString: FMTconstraint::setrhs
222 void setrhs(double lower,double upper);
223 // DocString: FMTconstraint::setlength
227 void setlength(int firstperiod = 1,int lastperiod = std::numeric_limits<int>::max());
228 // DocString: FMTconstraint::getvariations
232 void getvariations(double& lower, double& upper) const;
233 // DocString: FMTconstraint::ismultiple
237 bool ismultiple() const;
238 // DocString: FMTconstraint::acrossperiod
242 bool acrossperiod() const;
243 // DocString: FMTconstraint::hash
247 size_t hash(bool hashrhs = true,bool hashoutputonly = false) const;
248 // DocString: FMTconstraint::hashasoutput
252 size_t hashasoutput() const;
253 // DocString: FMTconstraint::setoutput
257 void setoutput(const FMToutput& out);
258 // DocString: FMTconstraint::setconstrainttype
263 // DocString: FMTconstraint::getconstrainttype
268 // DocString: FMTconstraint::operator std::string
272 operator std::string() const;
273 // DocString: FMTconstraint::isspatial
277 bool isspatial() const;
278 // DocString: FMTconstraint::israndomaction
282 bool israndomaction() const;
283 // DocString: FMTconstraint::getgroup
287 size_t getgroup() const;
288 // DocString: FMTconstraint::outputempty
292 size_t outputempty() const;
293 // DocString: FMTconstraint::presolve
300 const std::vector<FMTtheme>& originalthemes,
301 const std::vector<FMTtheme>& selectedthemes,
302 const std::vector<FMTtheme>& newthemes,
303 const std::vector<FMTaction>& actions, const FMTyields& yields) const;
304 // DocString: ~FMTconstraint()
308 ~FMTconstraint()=default;
309 // DocString: FMTconstraint::evaluate
314 double evaluate(const std::vector<double>& temporalvalues) const;
315 // DocString: FMTconstraint::getactionids
319 std::vector<int>getactionids(const std::vector<Core::FMTaction>& actions) const;
320 // DocString: FMTconstraint::isactionsused
324 std::vector<bool>isactionsused(const std::vector<Core::FMTaction>& actions) const;
325 // DocString: FMTconstraint::canbeturnedtoyieldsbasedontransitions
330 // DocString: FMTconstraint::turntoyieldsbasedontransition
334 void turntoyieldsbasedontransition( const std::vector<Core::FMTtheme>& themes,
335 const std::vector<Core::FMTtransition>& trans,
336 std::vector<Core::FMTaction>&actions,
337 Core::FMTyields& yields,
338 const int& constraintid) const;
339 // DocString: FMTconstraint::canbeturnedtoyields
344 // DocString: FMTconstraint::turntoyieldsandactions
351 void turntoyieldsandactions(const std::vector<Core::FMTtheme>& themes,
352 std::vector<Core::FMTaction>&actions,
353 Core::FMTyields& yields,
354 const int& constraintid) const;
355 };
356}
357
358BOOST_CLASS_EXPORT_KEY(Core::FMTconstraint)
359#endif
#define FMTEXPORT
Definition: FMTutility.hpp:92
Definition: FMTconstraint.hpp:54
void setgoal(const std::string &goalname, const double &value)
bool isobjective() const
std::vector< int > getactionids(const std::vector< Core::FMTaction > &actions) const
bool dosupportrandom() const
void setlength(int firstperiod=1, int lastperiod=std::numeric_limits< int >::max())
bool isreignore(const int &replanningperiod) const
void setpenalties(const std::string &penaltyoperator, const std::vector< std::string > &variables)
size_t hash(bool hashrhs=true, bool hashoutputonly=false) const
void getgoal(std::string &name, double &value) const
void turntoyieldsbasedontransition(const std::vector< Core::FMTtheme > &themes, const std::vector< Core::FMTtransition > &trans, std::vector< Core::FMTaction > &actions, Core::FMTyields &yields, const int &constraintid) const
bool issetfrom(const std::string &modeltype) const
FMTconstraint(FMTconstrainttype ltype, const FMToutput &loutput)
bool ismultiple() const
void setoutput(const FMToutput &out)
bool canbeturnedtoyields() const
std::vector< std::string > getpenalties(double &sense) const
size_t outputempty() const
void turntoyieldsandactions(const std::vector< Core::FMTtheme > &themes, std::vector< Core::FMTaction > &actions, Core::FMTyields &yields, const int &constraintid) const
double evaluate(const std::vector< double > &temporalvalues) const
void setrhs(double lower, double upper)
bool extravariables() const
double sense() const
bool canbeturnedtoyieldsbasedontransitions() const
Core::FMTconstraint getfromreplicate(const size_t &replicate, const int &period) const
void getvariations(double &lower, double &upper) const
size_t getgroup() const
bool acrossperiod() const
double getscheduleweight() const
FMTconstraint(const FMTconstraint &rhs)
bool isgoal() const
Core::FMTconstraint setfrom(const std::string &modeltype, const double &value) const
bool israndomaction() const
bool isspatial() const
size_t hashasoutput() const
~FMTconstraint()=default
void setconstrainttype(FMTconstrainttype ltype)
void getbounds(double &lower, double &upper, int period=0) const
FMTconstrainttype getconstrainttype() const
std::vector< std::string > getvariablelevels() const
std::vector< bool > isactionsused(const std::vector< Core::FMTaction > &actions) const
FMTconstraint 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
Core::FMTconstraint getiterationchange(const std::vector< double > &periodchanges, const int &targetperiod) const
Definition: FMTmaskfilter.hpp:27
Definition: FMToutput.hpp:39
Definition: FMTbounds.hpp:342
Definition: FMTyields.hpp:40
The Core namespace provides classes for simulating stands/strata growth/harvest through time.
Definition: FMTaction.hpp:31
FMTconstrainttype
Definition: FMTconstraint.hpp:32
@ FMTsequence
Definition: FMTconstraint.hpp:39
@ FMTspatialadjacency
Definition: FMTconstraint.hpp:42
@ FMTrandomaction
Definition: FMTconstraint.hpp:44
@ FMTstandard
Definition: FMTconstraint.hpp:40
@ FMTMINMAXobjective
Definition: FMTconstraint.hpp:36
@ FMTnondeclining
Definition: FMTconstraint.hpp:38
@ FMTMAXMINobjective
Definition: FMTconstraint.hpp:35
@ FMTspatialsize
Regular constraint type like output = 1...
Definition: FMTconstraint.hpp:41
@ FMTMAXobjective
Definition: FMTconstraint.hpp:33
@ FMTMINobjective
Definition: FMTconstraint.hpp:34
@ FMTevenflow
Definition: FMTconstraint.hpp:37
@ FMTspatialgreenup
Definition: FMTconstraint.hpp:43