8#ifndef FMTbounds_H_INCLUDED
9#define FMTbounds_H_INCLUDED
15#include <boost/functional/hash.hpp>
16#include <boost/serialization/serialization.hpp>
17#include <boost/serialization/nvp.hpp>
18#include <boost/serialization/string.hpp>
29 template<
class Archive>
30 void serialize(Archive& ar,
const unsigned int version)
32 ar & BOOST_SERIALIZATION_NVP(andbound);
33 ar & BOOST_SERIALIZATION_NVP(use);
34 ar & BOOST_SERIALIZATION_NVP(
section);
35 ar & BOOST_SERIALIZATION_NVP(
keytype);
36 ar & BOOST_SERIALIZATION_NVP(
upper);
37 ar & BOOST_SERIALIZATION_NVP(
lower);
72 inline bool out(
const T& value)
const
76 inline bool in(
const T& value)
const
78 return (
empty() || (value <= upper && value >=
lower));
81 andbound(rhs.andbound),
92 return (andbound == rhs.andbound &&
103 if (andbound < rhs.andbound)
105 if (rhs.andbound < andbound)
134 andbound = rhs.andbound;
151 if (rhs.
lower!=std::numeric_limits<T>::lowest())
155 if (rhs.
upper!= std::numeric_limits<T>::max())
165 std::string
tostring(
const std::string& name)
const
168 const std::string slower = std::to_string(
lower);
169 std::string supper = std::to_string(
upper);
170 bool beenuse =
false;
173 if (name.find(
"_LOCK")!=std::string::npos &&
upper > 0)
175 line+=
"_LOCKEXEMPT";
179 line=name+
" = "+supper;
181 if(
lower!= std::numeric_limits<T>::lowest())
183 line = name+
" >= "+slower;
186 if(
upper!= std::numeric_limits<T>::max())
190 line+=
" AND "+ name+
" <= "+supper;
192 line=name+
" <= "+supper;
201 if(
upper== std::numeric_limits<T>::max())
212 line =
"@YLD("+name+
",";
221 line+=slower+
".."+supper+
")";
225 if (name.find(
"LOCK") != std::string::npos &&
lower >= 1)
228 }
else if(name.find(
"_CP") != std::string::npos &&
lower == 0 &&
upper == 0)
236 if(name.find(
"_LOCK")!= std::string::npos)
238 line+=
"_LOCK " + slower;
240 line=name +
" " + slower;
251 friend class boost::serialization::access;
252 template<
class Archive>
253 void serialize(Archive& ar,
const unsigned int version)
255 ar & boost::serialization::make_nvp(
"bounds",boost::serialization::base_object<
FMTbounds<double>>(*
this));
256 ar & BOOST_SERIALIZATION_NVP(yield);
268 operator std::string()
const;
274 friend class boost::serialization::access;
275 template<
class Archive>
276 void serialize(Archive& ar,
const unsigned int version)
278 ar & boost::serialization::make_nvp(
"bounds", boost::serialization::base_object<
FMTbounds<int>>(*
this));
289 operator std::string()
const;
295 friend class boost::serialization::access;
296 template<
class Archive>
297 void serialize(Archive& ar,
const unsigned int version)
299 ar & boost::serialization::make_nvp(
"bounds", boost::serialization::base_object<
FMTbounds<int>>(*
this));
309 operator std::string()
const;
316 friend class boost::serialization::access;
317 template<
class Archive>
318 void serialize(Archive& ar,
const unsigned int version)
320 ar & boost::serialization::make_nvp(
"bounds", boost::serialization::base_object<
FMTbounds<int>>(*
this));
330 operator std::string()
const;
348 friend class boost::serialization::access;
349 template<
class Archive>
350 void serialize(Archive& ar,
const unsigned int version)
352 ar & BOOST_SERIALIZATION_NVP(per);
353 ar & BOOST_SERIALIZATION_NVP(age);
354 ar & BOOST_SERIALIZATION_NVP(lock);
355 ar & BOOST_SERIALIZATION_NVP(yieldnames);
356 ar & BOOST_SERIALIZATION_NVP(yieldbounds);
426 return (per.
in(tperiod) &&
436 return yieldbounds.at(std::distance(yieldnames.begin(), std::find(yieldnames.begin(), yieldnames.end(), name)));
444 for (
size_t location = 0; location < yieldnames.size(); ++location)
446 if (yieldbounds.at(location).out(values.at(location)))
458 inline bool allow(
const int& tperiod,
const int& tage,
const int& tlock,
const std::vector<double>& values)
const
460 for (
size_t location = 0; location < yieldnames.size(); ++location)
462 if (yieldbounds.at(location).out(values.at(location)))
467 return (allowwithoutyield(tperiod,tage,tlock));
473 inline const std::vector<std::string>&
getylds()
const
489 virtual operator std::string()
const;
#define FMTEXPORT
Definition: FMTutility.hpp:92
Definition: FMTbounds.hpp:272
FMTagebounds(const FMTagebounds &rhs)
FMTagebounds(const FMTbounds< int > &rhs)
FMTagebounds(FMTsection lsection, const int &lupper, const int &llower)
FMTagebounds(FMTsection lsection, FMTkwor key, const int &lupper, const int &llower)
Definition: FMTbounds.hpp:27
FMTbounds(const FMTsection lsection, const T &lupper, const T &llower)
Definition: FMTbounds.hpp:51
FMTsection section
Definition: FMTbounds.hpp:42
std::string tostring(const std::string &name) const
Definition: FMTbounds.hpp:165
bool empty() const
Definition: FMTbounds.hpp:143
FMTbounds(const FMTsection lsection, const FMTkwor key, const T &lupper, const T &llower)
Definition: FMTbounds.hpp:55
bool add(const FMTbounds< T > &rhs)
Definition: FMTbounds.hpp:147
FMTbounds< T > & operator=(const FMTbounds< T > &rhs)
Definition: FMTbounds.hpp:130
void setorbound()
Definition: FMTbounds.hpp:60
bool operator==(const FMTbounds< T > &rhs) const
Definition: FMTbounds.hpp:90
FMTbounds()
Definition: FMTbounds.hpp:47
bool in(const T &value) const
Definition: FMTbounds.hpp:76
FMTkwor keytype
Definition: FMTbounds.hpp:43
friend class boost::serialization::access
Definition: FMTbounds.hpp:28
T getupper() const
Definition: FMTbounds.hpp:68
T lower
Definition: FMTbounds.hpp:45
bool operator<(const FMTbounds< T > &rhs) const
Definition: FMTbounds.hpp:100
T upper
Definition: FMTbounds.hpp:44
bool out(const T &value) const
Definition: FMTbounds.hpp:72
T getlower() const
Definition: FMTbounds.hpp:64
virtual ~FMTbounds()=default
FMTbounds(const FMTbounds< T > &rhs)
Definition: FMTbounds.hpp:80
Definition: FMTbounds.hpp:314
FMTlockbounds(const FMTlockbounds &rhs)
FMTlockbounds(const FMTsection lsection, const int &lupper, const int &llower)
FMTlockbounds(const FMTsection lsection, const FMTkwor key, const int &lupper, const int &llower)
Definition: FMTbounds.hpp:293
FMTperbounds(const FMTsection lsection, const int &lupper, const int &llower)
FMTperbounds(const FMTbounds< int > &rhs)
FMTperbounds(const FMTperbounds &rhs)
Definition: FMTbounds.hpp:342
int getageupperbound() const
const std::vector< FMTyldbounds > & getyldbounds() const
Definition: FMTbounds.hpp:481
bool issubsetof(const FMTspec &rhs) const
FMTlockbounds lock
Lock bounds so lower >= lock <= upper.
Definition: FMTbounds.hpp:367
int getlockupperbound() const
int getlocklowerbound() const
bool addbounds(const FMTyldbounds &bound)
int getperiodlowerbound() const
bool addbounds(const FMTagebounds &bound)
const FMTyldbounds & getyieldbound(const std::string &name) const
Definition: FMTbounds.hpp:434
bool setbounds(const FMTperbounds &bound)
FMTspec(const FMTspec &rhs)
FMTagebounds age
Age bounds so lower >= age <= upper.
Definition: FMTbounds.hpp:364
std::vector< std::string > yieldnames
The names of each yield in the vector of yieldbounds.
Definition: FMTbounds.hpp:370
bool allowyields(const std::vector< double > &values) const
Definition: FMTbounds.hpp:442
virtual ~FMTspec()=default
bool allow(const int &tperiod, const int &tage, const int &tlock, const std::vector< double > &values) const
Definition: FMTbounds.hpp:458
FMTperbounds per
Period bounds so lower >= period <= upper.
Definition: FMTbounds.hpp:361
int getagelowerbound() const
int getperiodupperbound() const
const std::vector< std::string > & getylds() const
Definition: FMTbounds.hpp:473
bool add(const FMTspec &rhs)
bool allowwithoutyield(const int &tperiod, const int &tage, const int &tlock) const
Definition: FMTbounds.hpp:424
std::vector< FMTyldbounds > yieldbounds
the yields bounds vector lower>=y1<=upper,lower>=y2<=upper
Definition: FMTbounds.hpp:373
bool addbounds(const FMTlockbounds &bound)
Definition: FMTyields.hpp:40
Definition: FMTbounds.hpp:249
FMTyldbounds(const std::string &lyield, const FMTbounds< double > &rhs)
FMTyldbounds(const FMTsection lsection, const std::string &lyield, const double &lupper, const double &llower)
FMTyldbounds(const FMTsection lsection, const FMTkwor key, const std::string &lyield, const double &lupper, const double &llower)
FMTyldbounds()
Definition: FMTbounds.hpp:260
FMTyldbounds(const FMTyldbounds &rhs)
Definition: FMTbounds.hpp:265
The Core namespace provides classes for simulating stands/strata growth/harvest through time.
Definition: FMTaction.hpp:31
FMTsection
Definition: FMTutility.hpp:23
@ Outputs
Definition: FMTutility.hpp:30
@ Action
Definition: FMTutility.hpp:27
@ Transition
Definition: FMTutility.hpp:28
FMTkwor
Definition: FMTutility.hpp:39
Definition: FMTaction.hpp:364
std::size_t operator()(const Core::FMTspec &spec) const
Definition: FMTbounds.hpp:574