FMT 1.2.0
Forest management tools for forest planning
Loading...
Searching...
No Matches
FMTDevelopment.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 FMTDEV_Hm_included
9#define FMTDEV_Hm_included
10
11#include "FMTMask.h"
12#include <boost/serialization/serialization.hpp>
13#include <boost/serialization/nvp.hpp>
14#include <boost/serialization/string.hpp>
15#include "FMTObject.h"
16#include <memory>
17#include <vector>
18#include <boost/serialization/export.hpp>
19#include "FMTExceptionHandler.h"
20
21namespace Graph
22{
23 class FMTGraphVertexToYield;
24}
25
26
28namespace Core
29{
30class FMTFuturDevelopment;
31class FMTTransition;
32class FMTAction;
33class FMTYieldRequest;
34class FMTYields;
35class FMTDevelopmentPath;
36class FMTSpec;
37class FMTYldBounds;
38// DocString: FMTDevelopment
44 {
45 public:
46 // DocString: FMTDevelopment::(FMTDevelopment&& rhs)
52 // DocString: FMTDevelopment::operator=(FMTDevelopment&& rhs)
59 // DocString: FMTDevelopment::getAge
64 inline int getAge() const
65 {
66 return static_cast<int>(m_age);
67 }
68 // DocString: FMTDevelopment::getShortAge
73 inline uint8_t getShortAge() const
74 {
75 return m_age;
76 }
77 // DocString: FMTDevelopment::getLock
82 inline int getLock() const
83 {
84 return static_cast<int>(m_lock);
85 }
86 // DocString: FMTDevelopment::getPeriod
91 inline int getPeriod() const
92 {
93 return static_cast<int>(m_period);
94 }
95 // DocString: FMTDevelopment::getMask
100 inline const Core::FMTMask& getMask() const
101 {
102 return m_mask;
103 }
104 // DocString: FMTDevelopment::getMaskCopy
110 {
111 return m_mask;
112 }
113 // DocString: FMTDevelopment::setAge
118 void setAge(const int& lage);
119 // DocString: FMTDevelopment::setLock
124 void setLock(const int& llock);
125 // DocString: FMTDevelopment::setPeriod
130 void setPeriod(const int& lperiod);
131 // DocString: FMTDevelopment::setMask
136 void setMask(const Core::FMTMask& p_mask);
137 // DocString: FMTDevelopment()
142 // DocString: ~FMTDevelopment()
146 virtual ~FMTDevelopment() = default;
147 // DocString: FMTDevelopment(const FMTMask&,const int&,const int&)
154 FMTDevelopment(const FMTMask& p_mask, const int& p_age, const int& p_lock);
155 // DocString: FMTDevelopment(const FMTMask,const int&,const int&,const int&)
163 FMTDevelopment(const FMTMask& p_mask, const int& p_age, const int& p_lock, const int& p_period);
164 // DocString: FMTDevelopment(const FMTDevelopment&)
170 // DocString: FMTDevelopment::clone()
175 virtual std::unique_ptr<FMTDevelopment> clone() const;
176 // DocString: FMTDevelopment::operator=
182 FMTDevelopment& operator = (const FMTDevelopment& rhs);
183 // DocString: FMTDevelopment::operator==
189 bool operator == (const FMTDevelopment& rhs) const;
190 // DocString: FMTDevelopment::operator!=
196 bool operator != (const FMTDevelopment& rhs) const;
197 // DocString: FMTDevelopment::operator<
203 bool operator < (const FMTDevelopment& rhs) const;
204 // DocString: FMTDevelopment::grow
210 // DocString: FMTDevelopment::getYieldRequest
216 FMTYieldRequest getYieldRequest(const Graph::FMTGraphVertexToYield* graphyieldrequest = nullptr) const;
217 // DocString: FMTDevelopment::getNonOperabilityInfo
225 std::string getNonOperabilityInfo(const FMTAction& p_action,
226 const Core::FMTYields& p_yields, const Graph::FMTGraphVertexToYield* p_yieldRequest) const;
227 // DocString: FMTDevelopment::operable
235 bool operable(const FMTAction& action,const Core::FMTYields& ylds,
236 const Graph::FMTGraphVertexToYield* graphyieldrequest = nullptr) const;
237 // DocString: FMTDevelopment::anyOperable
245 bool anyOperable(const std::vector<const FMTAction*>& actions, const Core::FMTYields& ylds,
246 const Graph::FMTGraphVertexToYield* graphyieldrequest = nullptr) const;
247 // DocString: FMTDevelopment::operator std::string
252 virtual operator std::string() const;
253 // DocString: FMTDevelopment::getArea
258 virtual double getArea() const;
259 // DocString: FMTDevelopment::clearLock
265 // DocString: FMTDevelopment::operate
274 std::vector<FMTDevelopmentPath> operate(const FMTAction& action,
275 const FMTTransition& Transition,
276 const Core::FMTYields& ylds,
277 const std::vector<FMTTheme>& themes) const;
278 // DocString: FMTDevelopment::getInventoryCoef
286 double getInventoryCoef(const Core::FMTYields& ylds,const std::string& target_yield,
287 const Graph::FMTGraphVertexToYield* graphyieldrequest = nullptr) const;
288 // DocString: FMTDevelopment::getHarvestCoef
298 double getHarvestCoef(const std::vector<FMTDevelopmentPath>& topaths,
299 const FMTAction& action,const Core::FMTYields& ylds,const std::string& target_yield,
300 const Graph::FMTGraphVertexToYield* graphyieldrequest = nullptr) const;
301 // DocString: FMTDevelopment::is
309 bool is(const FMTSpec& specification, const Core::FMTYields& ylds,
310 const Graph::FMTGraphVertexToYield* graphyieldrequest = nullptr) const;
311 // DocString: FMTDevelopment::worthTestingOperability
317 bool worthTestingOperability(const FMTAction& action) const;
318 // DocString: FMTDevelopment::anyWorthTestingOperability
325 std::vector<int> anyWorthTestingOperability(const std::vector<const FMTAction*>& actions, const FMTAction& firstaction) const;
326 // DocString: FMTDevelopment::isAnyWorthTestingOperability
333 std::vector<bool> isAnyWorthTestingOperability(const std::vector<const FMTAction*>& actions,
334 const std::vector<FMTAction>& allactions) const noexcept;
335 // DocString: FMTDevelopment::hash
340 inline size_t hash() const
341 {
342 std::size_t seed =0;
343 boost::hash_combine(seed, boost::hash<Core::FMTMask>()(m_mask));
344 boost::hash_combine(seed, boost::hash<uint8_t>()(m_age));
345 boost::hash_combine(seed, boost::hash<uint8_t>()(m_lock));
346 boost::hash_combine(seed, boost::hash<uint8_t>()(m_period));
347 return seed;
348 }
349 private:
350 // DocString: FMTDevelopment::_isOutOfBound
359 bool _isOutOfBound(const FMTYieldRequest& p_request,
360 const FMTYields& p_yields,
361 const Core::FMTYldBounds& p_bound,
362 const std::string& p_yield) const;
363 // DocString: FMTDevelopment::serialize
370 friend class boost::serialization::access;
371 template<class Archive>
372 void serialize(Archive& ar, const unsigned int version)
373 {
374 try {
375 ar& boost::serialization::make_nvp("FMTobject", boost::serialization::base_object<FMTObject>(*this));
376 ar& boost::serialization::make_nvp("mask", m_mask);
377 ar& boost::serialization::make_nvp("age", m_age);
378 ar& boost::serialization::make_nvp("lock", m_lock);
379 ar& boost::serialization::make_nvp("period", m_period);
380 }
381 catch (...)
382 {
383 _exhandler->printExceptions("", "FMTDevelopment::serialize", __LINE__, __FILE__);
384 }
385 }
386 // DocString: FMTDevelopment::m_mask
388 FMTMask m_mask;
389 // DocString: FMTDevelopment::m_age
391 uint8_t m_age;
392 // DocString: FMTDevelopment::m_lock
394 uint8_t m_lock;
395 // DocString: FMTDevelopment::m_period
397 uint8_t m_period;
398 };
399
400}
401
402namespace boost {
406 template <>
407 struct hash<Core::FMTDevelopment>
408 {
409 std::size_t operator()(const Core::FMTDevelopment& dev) const
410 {
411 return dev.hash();
412 }
413 };
414
415
416}
417BOOST_SERIALIZATION_ASSUME_ABSTRACT(Core::FMTDevelopment)
418BOOST_CLASS_TRACKING(Core::FMTDevelopment, boost::serialization::track_always)
419BOOST_CLASS_EXPORT_KEY(Core::FMTDevelopment)
420
421#endif // FMTDEV_Hm_included
#define FMTEXPORT
Definition: FMTutility.h:125
List of specifications dictating the operability of a subset of developments to this action.
Definition: FMTAction.h:43
Base class of FMTActualDevelopment and FMTFuturDevelopment representing a forest stand.
Definition: FMTDevelopment.h:44
uint8_t getShortAge() const
Get the age of the development as a short int.
Definition: FMTDevelopment.h:73
void setMask(const Core::FMTMask &p_mask)
Set the mask of the development.
void setLock(const int &llock)
Set the lock of the development.
bool anyOperable(const std::vector< const FMTAction * > &actions, const Core::FMTYields &ylds, const Graph::FMTGraphVertexToYield *graphyieldrequest=nullptr) const
Check if this development is operable to any of the actions based on multiple yields.
bool worthTestingOperability(const FMTAction &action) const
Return true if it is worth testing operability for the action, used for optimization.
virtual ~FMTDevelopment()=default
Default virtual destructor for FMTDevelopment.
size_t hash() const
Return the hash of the development combining its mask, age, lock and period.
Definition: FMTDevelopment.h:340
bool is(const FMTSpec &specification, const Core::FMTYields &ylds, const Graph::FMTGraphVertexToYield *graphyieldrequest=nullptr) const
Check if this development respects a specification based on multiple yields.
const Core::FMTMask & getMask() const
Get a const reference to the mask of the development.
Definition: FMTDevelopment.h:100
std::string getNonOperabilityInfo(const FMTAction &p_action, const Core::FMTYields &p_yields, const Graph::FMTGraphVertexToYield *p_yieldRequest) const
Check why this developpement is not operable for p_action and return the info.
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.
FMTDevelopment(const FMTDevelopment &rhs)
Copy constructor for FMTDevelopment.
FMTDevelopment()
Default constructor for FMTDevelopment.
FMTDevelopment(FMTDevelopment &&rhs)
Move copy constructor.
FMTDevelopment(const FMTMask &p_mask, const int &p_age, const int &p_lock, const int &p_period)
Construct a development from a mask, an age, a lock level and a period.
virtual double getArea() const
Return the area of the development.
std::vector< bool > isAnyWorthTestingOperability(const std::vector< const FMTAction * > &actions, const std::vector< FMTAction > &allactions) const noexcept
Return a vector of booleans, true if the corresponding action is worth testing for operability.
double getInventoryCoef(const Core::FMTYields &ylds, const std::string &target_yield, const Graph::FMTGraphVertexToYield *graphyieldrequest=nullptr) const
Return the inventory coefficient of the development for a given yield based on the yields.
FMTDevelopment(const FMTMask &p_mask, const int &p_age, const int &p_lock)
Construct a development from a mask, an age and a lock level.
virtual std::unique_ptr< FMTDevelopment > clone() const
Virtual clone function for FMTDevelopment.
double getHarvestCoef(const std::vector< FMTDevelopmentPath > &topaths, const FMTAction &action, const Core::FMTYields &ylds, const std::string &target_yield, const Graph::FMTGraphVertexToYield *graphyieldrequest=nullptr) const
Return the harvest coefficient of the development for a given yield following multiple development pa...
FMTDevelopment clearLock() const
Return a copy of this development with the lock level set to 0.
std::vector< int > anyWorthTestingOperability(const std::vector< const FMTAction * > &actions, const FMTAction &firstaction) const
Return the pointer distances from the first action of the actions worth testing for operability.
FMTDevelopment & operator=(FMTDevelopment &&rhs)
Move assignment operator for FMTDevelopment.
Child class of FMTDevelopment representing a future stand generated by growth or transition,...
Definition: FMTFuturDevelopment.h:23
Core class holding, as a boost dynamic bitset, which theme attributes are part of a mask.
Definition: FMTMask.h:96
Base class of multiple FMT classes holding a shared exception handler pointer and logger.
Definition: FMTObject.h:49
List of FMTFork describing the transition of an action, disturbing a development to generate new deve...
Definition: FMTTransition.h:35
Request for yield values using a development and optionally a graph vertex.
Definition: FMTYieldRequest.h:37
FMTList containing multiple yield handlers as seen in the yield section, holding the information rela...
Definition: FMTYields.h:44
Adapter pointing to a vertex of a line graph or a full graph and its model, used to answer a generic ...
Definition: FMTGraphVertexToYield.h:31
The Core namespace provides classes for simulating stands/strata growth/harvest through time.
Definition: FMTAction.h:34
Definition: FMTAreaParser.h:35
Definition: FMTAction.h:463
std::size_t operator()(const Core::FMTDevelopment &dev) const
Definition: FMTDevelopment.h:409