FMT 1.2.0
Forest management tools for forest planning
Loading...
Searching...
No Matches
FMTYields.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 FMTYLD_Hm_included
9#define FMTYLD_Hm_included
10
11#include "FMTList.hpp"
12#include "FMTYieldHandler.h"
13#include "FMTDevelopment.h"
14#include "FMTBounds.hpp"
15#include <vector>
16#include <map>
17#include <string>
18#include <boost/serialization/serialization.hpp>
19#include "FMTutility.h"
20#include "FMTTheme.h"
21#include <unordered_map>
22#include <memory>
23#include <boost/serialization/export.hpp>
24#include "FMTYieldRequest.h"
25
26namespace Models
27{
28 class FMTModel;
29 class FMTNssModel;
30}
31
32
33namespace Core
34{
35class FMTDevelopment;
36class FMTAgeYieldHandler;
37class FMTTimeYieldHandler;
38// DocString: FMTYields
43class FMTEXPORT FMTYields : public FMTList<std::unique_ptr<FMTYieldHandler>>
44 {
45 friend class Models::FMTModel;
46 friend class Models::FMTNssModel;
47 public:
48 // DocString: FMTYields::generateDefaultYields
53 void generateDefaultYields(const std::vector<Core::FMTTheme>& themes);
54 // DocString: FMTYields::swap
59 void swap(FMTYields& rhs);
60 // DocString: FMTYields::gotYieldType
66 bool gotYieldType(FMTyldtype type) const;
67 // DocString: FMTYields::setActionsMappingToModelHandlers
72 void setActionsMappingToModelHandlers(const std::vector<int>& actionids);
73 // DocString: FMTYields::getAllYieldNames
78 std::vector<std::string> getAllYieldNames() const;
79 // DocString: FMTYields()
84 // DocString: ~FMTYields()
88 ~FMTYields()=default;
89 // DocString: FMTYields(const FMTYields&)
94 FMTYields(const FMTYields& rhs);
95 // DocString: FMTYields::operator=
101 FMTYields& operator = (const FMTYields& rhs);
102 // DocString: FMTYields::clearCache
106 void clearCache() final;
107 // DocString: FMTYields::clearRandomYieldsCache
111 void clearRandomYieldsCache();
112 // DocString: FMTYields::isYld
119 bool isYld(const std::string& value,bool fromsource = false) const;
120 // DocString: FMTYields::isNullYld
126 bool isNullYld(const std::string& value) const;
127 // DocString: FMTYields::get
132 //std::vector<double>get(std::vector<FMTYieldRequest>& requests) const;
133 // DocString: FMTYields::getSingle
138 //double getSingle(const FMTDevelopment& dev,const std::string& target) const;
139 //std::map<std::string,double>getYlds(const FMTDevelopment& dev,const FMTSpec& spec) const;
140 // DocString: FMTYields::getYlds
145 //std::vector<double>getYlds(const FMTDevelopment& dev, const FMTSpec& spec) const;
146 // DocString: FMTYields::getAge
153 int getAge(const FMTYieldRequest& request,const FMTSpec& spec) const;
154 // DocString: FMTYields::getAllYields
161 std::map<std::string, std::map<std::string, std::vector<double>>>getAllYields(const FMTTheme& target,FMTyldtype type) const;
162 // DocString: FMTYields::operator==
168 bool operator == (const FMTYields& rhs) const;
169 // DocString: FMTYields::operator!=
175 bool operator != (const FMTYields& rhs) const;
176 // DocString: FMTYields::update
180 void update() override;
181 // DocString: FMTYields::reserve
186 void reserve(const FMTYields& p_other);
187 // DocString: FMTYields::preSolve
195 FMTYields preSolve(const FMTMaskFilter& filter,
196 const std::vector<FMTTheme>& originalthemes,
197 const std::vector<FMTTheme>& newthemes) const;
198 // DocString: FMTYields::preSolveRef
205 void preSolveRef(const FMTMaskFilter& p_filter,
206 const std::vector<FMTTheme>& p_originalThemes,
207 const std::vector<FMTTheme>& p_newThemes);
208 // DocString: FMTYields::getStacked
213 std::vector<std::string>getStacked() const;
214 // DocString: FMTYields::getFromFactor
221 FMTYields getFromFactor(const double& factor,
222 std::vector<std::string>yieldnames = std::vector<std::string>()) const;
223 // DocString: FMTYields::get
230 double get(const FMTYieldRequest& request,const std::string& yld) const;
231 // DocString: FMTYields::pushBackAgeHandler
237 void pushBackAgeHandler(const FMTMask& mask, const FMTAgeYieldHandler& value);
238 // DocString: FMTYields::pushBackTimeHandler
244 void pushBackTimeHandler(const FMTMask& mask, const FMTTimeYieldHandler& value);
245 // DocString: FMTYields::getNullYield
250 static const std::string& getNullYield();
251 // DocString: FMTYields::getMaxBase
257 static int getMaxBase(const std::vector<const FMTYieldHandler*>& handlers);
258 // DocString: FMTYields::clear
262 void clear();
263 private:
264 // DocString: FMTYields::serialize
271 friend class boost::serialization::access;
272 friend class FMTYieldRequest;
273 template<class Archive>
274 void serialize(Archive& ar, const unsigned int version)
275 {
276 try {
277 ar& boost::serialization::make_nvp("handlers", boost::serialization::base_object<FMTList<std::unique_ptr<FMTYieldHandler>>>(*this));
278 _updateYieldLocations();
279 }
280 catch (...)
281 {
282 _exhandler->printExceptions("", "FMTYields::serialize", __LINE__, __FILE__);
283 }
284 }
285 // DocString: FMTYields::m_yieldsLocations
287 std::unordered_map<std::string,size_t>m_yieldsLocations;
288 // DocString: FMTYields::nullYield
290 static const std::string m_nullYield;
291 // DocString: FMTYields::_getHandlerOfType
297 std::vector<const FMTYieldHandler*> _getHandlerOfType(FMTyldtype type) const;
298 // DocString: FMTYields::_getHandlerOfType
304 std::vector<FMTYieldHandler*> _getHandlers(FMTyldtype type);
305 // DocString: FMTYields::_updateYieldLocations
309 void _updateYieldLocations();
310 // DocString: FMTYields::_setModel
315 void _setModel(Models::FMTModel* p_modelPtr);
316 // DocString: FMTYields::_getFirstSeen
322 const_iterator _getFirstSeen(const std::string& p_yield) const;
323 };
324}
325BOOST_CLASS_EXPORT_KEY(Core::FMTYields)
326#endif // FMTYLD_Hm_included
#define FMTEXPORT
Definition: FMTutility.h:125
Yield handler for age based yields, as seen in the yield section with _AGE.
Definition: FMTAgeYieldHandler.h:24
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
Class holding the attributes and aggregates of a single theme, describing a part of a FMTMask.
Definition: FMTTheme.h:47
Yield handler for time based yields, indexed by period.
Definition: FMTTimeYieldHandler.h:25
Base class for yield handlers, holding a mask and the base ages of the yields.
Definition: FMTYieldHandler.h:80
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
void clearCache() final
Clear the caching from all FMTData.
~FMTYields()=default
Default destructor for FMTYields.
void swap(FMTYields &rhs)
Swap this FMTYields with another.
FMTYields(const FMTYields &rhs)
Copy constructor for FMTYields.
void setActionsMappingToModelHandlers(const std::vector< int > &actionids)
Clear and replace the actions mapping of every yield model handler.
FMTYields()
Default constructor for FMTYields.
bool gotYieldType(FMTyldtype type) const
Return true if the yield section has a given yield type.
std::vector< std::string > getAllYieldNames() const
Return all the yield names from the list.
void generateDefaultYields(const std::vector< Core::FMTTheme > &themes)
Generate the default yields such as _TSLA in the yield class.
Base class for the different models in FMT.
Definition: FMTModel.h:62
Non spatial simulation model, mainly used to simulate stochastic actions during the local replanning ...
Definition: FMTNssModel.h:29
The Core namespace provides classes for simulating stands/strata growth/harvest through time.
Definition: FMTAction.h:34
FMTyldtype
Enumerator describing the type of a yield (age, time, complex, model).
Definition: FMTutility.h:62
Namespace containing all enumerator and classes used to construct or manipulate the different type of...
Definition: FMTAreaParser.h:54
Definition: FMTAction.h:463
STL namespace.