FMT 1.2.0
Forest management tools for forest planning
Loading...
Searching...
No Matches
FMTTransition.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 FMTTRA_Hm_included
9#define FMTTRA_Hm_included
10
11#include "FMTFork.h"
12#include "FMTList.hpp"
13#include <boost/serialization/serialization.hpp>
14#include <boost/serialization/string.hpp>
15#include <boost/serialization/export.hpp>
16#include <vector>
17#include <map>
18#include <string>
19
20
21namespace Core
22{
23class FMTYieldRequest;
24class FMTDevelopment;
25class FMTMask;
26class FMTAction;
27class FMTYields;
28class FMTTheme;
29// DocString: FMTTransition
34class FMTEXPORT FMTTransition : public FMTList<FMTFork>
35 {
36 public:
37 // DocString: FMTTransition::operator+=
43 FMTTransition& operator+=(const FMTTransition& OtherTransition);
44 // DocString: FMTTransition()
49 // DocString: ~FMTTransition()
53 ~FMTTransition() = default;
54 // DocString: FMTTransition(const std::string&)
59 FMTTransition(const std::string& lname);
60 // DocString: FMTTransition(const FMTTransition&)
66 // DocString: FMTTransition::operator=
72 FMTTransition& operator = (const FMTTransition& rhs);
73 // DocString: FMTTransition::operator std::string
78 operator std::string() const;
79 // DocString: FMTTransition::single
85 // DocString: FMTTransition::getName
90 inline std::string getName() const
91 {
92 return name;
93 }
94 // DocString: FMTTransition::setName
99 void setName(const std::string& p_name);
100 // DocString: FMTTransition::isLeaking
105 bool isLeaking() const;
106 // DocString: FMTTransition::getFork
113 const FMTFork* getFork(const Core::FMTDevelopment& development, const FMTYields& ylds) const;
114 // DocString: FMTTransition::getStaticThemes
120 std::vector<const FMTTheme*>getStaticThemes(const std::vector<const FMTTheme*>& themes) const;
121 // DocString: FMTTransition::canProduce
128 std::vector<Core::FMTMask> canProduce(const Core::FMTMask& testmask,const std::vector<Core::FMTTheme>& themes) const;
129 // DocString: FMTTransition::ageAfter
138 unsigned int ageAfter(const std::vector<FMTDevelopment>& devs,
139 const FMTAction& action,
140 const FMTYields& ylds,
141 const std::vector<FMTTheme>& themes) const;
142 // DocString: FMTTransition::mainTarget
149 FMTMask mainTarget(const std::vector<FMTDevelopment>& devs,
150 const FMTYields& ylds) const;
151 // DocString: FMTTransition::attributeTargets
159 std::map<std::string, std::vector<FMTDevelopment>> attributeTargets(const std::vector<FMTDevelopment>& devs,
160 const FMTYields& ylds, const std::vector<FMTTheme>& themes) const;
161 // DocString: FMTTransition::operator<
167 bool operator < (const FMTTransition& rhs) const;
168 // DocString: FMTTransition::operator==
174 bool operator == (const FMTTransition& rhs) const;
175 // DocString: FMTTransition::operator!=
181 bool operator != (const FMTTransition& rhs) const;
182 // DocString: FMTTransition::preSolve
192 const std::vector<FMTTheme>& originalthemes,
193 std::vector<FMTTheme>& newthemes,bool compressdata=false) const;
194 // DocString: FMTTransition::preSolveRef
202 void preSolveRef(const FMTMaskFilter& p_filter,
203 const std::vector<FMTTheme>& p_originalThemes,
204 std::vector<FMTTheme>& p_newthemes, bool p_compressdata = false);
205 protected:
206 // DocString: FMTTransition::name
208 std::string name;
209 private:
210 // DocString: FMTTransition::serialize
217 friend class boost::serialization::access;
218 template<class Archive>
219 void serialize(Archive& ar, const unsigned int version)
220 {
221 try {
222 ar& boost::serialization::make_nvp("data", boost::serialization::base_object<FMTList<FMTFork>>(*this));
223 ar& BOOST_SERIALIZATION_NVP(name);
224 }
225 catch (...)
226 {
227 _exhandler->printExceptions("", "FMTTransition::serialize", __LINE__, __FILE__);
228 }
229 }
230 };
231
232// DocString: FMTTransitionComparator
237{
238public:
239 // DocString: FMTTransitionComparator(std::string)
244 FMTTransitionComparator(std::string name);
245 // DocString: FMTTransitionComparator(const FMTTransition&)
251 bool operator()(const FMTTransition& transition) const;
252
253private:
254 // DocString: FMTTransitionComparator::m_transitionName
256 std::string m_transitionName;
257};
258
259}
260
261BOOST_CLASS_EXPORT_KEY(Core::FMTTransition)
262#endif // FMTTRA_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
Fork of a transition, holding the transition masks (targets and proportions) applied to a development...
Definition: FMTFork.h:38
Definition: FMTAreaParser.h:32
Filter built from masks used to preSolve and postsolve FMTMask objects.
Definition: FMTMaskFilter.h:31
Core class holding, as a boost dynamic bitset, which theme attributes are part of a mask.
Definition: FMTMask.h:96
Comparator used to compare FMTTransition with std::find_if when transitions are in a std container.
Definition: FMTTransition.h:237
FMTTransitionComparator(std::string name)
Construct the comparator from the transition name to match.
bool operator()(const FMTTransition &transition) const
Matching test operator for the comparator.
List of FMTFork describing the transition of an action, disturbing a development to generate new deve...
Definition: FMTTransition.h:35
FMTTransition()
Default constructor for FMTTransition.
std::vector< const FMTTheme * > getStaticThemes(const std::vector< const FMTTheme * > &themes) const
Return the themes that have no attribute change in the transition masks (static themes).
FMTTransition(const std::string &lname)
Construct a transition keeping only its name.
bool isLeaking() const
Return true if a fork has a total proportion different from 1.
FMTTransition & operator+=(const FMTTransition &OtherTransition)
Append another transition to this transition, which needs to be unshrunk otherwise an exception is th...
unsigned int ageAfter(const std::vector< FMTDevelopment > &devs, const FMTAction &action, const FMTYields &ylds, const std::vector< FMTTheme > &themes) const
Return the average age after disturbance across the developments, for GCBM.
const FMTFork * getFork(const Core::FMTDevelopment &development, const FMTYields &ylds) const
Return the first useful fork for which the development can be disturbed based on the yields.
FMTTransition preSolve(const FMTMaskFilter &filter, const std::vector< FMTTheme > &originalthemes, std::vector< FMTTheme > &newthemes, bool compressdata=false) const
Return a presolved transition based on a filter, the original themes and the new presolved themes.
void setName(const std::string &p_name)
Set the name of the transition.
std::string getName() const
Get the name of the transition.
Definition: FMTTransition.h:90
FMTTransition single() const
Return a transition that leads to a single development path, selecting the one with the highest area ...
~FMTTransition()=default
Default destructor for FMTTransition.
std::vector< Core::FMTMask > canProduce(const Core::FMTMask &testmask, const std::vector< Core::FMTTheme > &themes) const
Return all the source masks that can produce the given mask through the transition.
FMTMask mainTarget(const std::vector< FMTDevelopment > &devs, const FMTYields &ylds) const
Return the most targeted mask across the developments based on the yields, for GCBM.
void preSolveRef(const FMTMaskFilter &p_filter, const std::vector< FMTTheme > &p_originalThemes, std::vector< FMTTheme > &p_newthemes, bool p_compressdata=false)
Presolve the transition in place based on a filter, the original themes and the new presolved themes.
std::map< std::string, std::vector< FMTDevelopment > > attributeTargets(const std::vector< FMTDevelopment > &devs, const FMTYields &ylds, const std::vector< FMTTheme > &themes) const
Classify the developments by mask key based on the yields.
std::string name
name of the FMTtranstion same name seen in FMTAction
Definition: FMTTransition.h:208
FMTTransition(const FMTTransition &rhs)
Copy constructor for FMTTransition.
FMTList containing multiple yield handlers as seen in the yield section, holding the information rela...
Definition: FMTYields.h:44
The Core namespace provides classes for simulating stands/strata growth/harvest through time.
Definition: FMTAction.h:34