FMT 1.2.0
Forest management tools for forest planning
Loading...
Searching...
No Matches
FMTYieldModelRandom.h
Go to the documentation of this file.
1/*
2Copyright (c) 2024 Gouvernement du Québec
3
4SPDX-License-Identifier: LiLiQ-R-1.1
5License-Filename: LICENSES/EN/LiLiQ-R11unicode.txt
6*/
7
8#ifndef FMTyieldmodelRando_Hm_included
9#define FMTyieldmodelRando_Hm_included
10
11#include "FMTYieldModel.h"
12#include <random>
13#include <string>
14#include <vector>
15#include <unordered_map>
16
17// DocString: FMTYieldModelRandom
22namespace Core
23{
25 public FMTYieldModel
26 {
27 public:
28 // DocString: FMTYieldModelRandom::FMTYieldModelRandom(const boost::property_tree::ptree&,const std::string&)
34 FMTYieldModelRandom(const boost::property_tree::ptree& p_jsonProps, const std::vector<std::string>& p_distribution);
35 // DocString: FMTYieldModelRandom::clearRandomYieldsCache
39 void clearRandomYieldsCache() override;
40 // DocString: FMTYieldModelRandom::predict
46 const std::vector<double>predict(const Core::FMTYieldRequest& p_request) const;
47 // DocString: FMTYieldModelRandom::preSolve
55 std::unique_ptr<FMTYieldModel> preSolve(const FMTMaskFilter& p_filter,
56 const std::vector<FMTTheme>& p_newThemes) const;
57 // DocString: FMTYieldModelRandom::postSolve
64 std::unique_ptr<FMTYieldModel> postSolve(const FMTMaskFilter& p_filter,
65 const std::vector<FMTTheme>& p_baseThemes) const;
66 // DocString: FMTYieldModelRandom::clone
71 std::unique_ptr<FMTYieldModel>clone() const;
72 // DocString: FMTYieldModelRandom:: getModelType
77 static std::string getModelType();
78 // DocString: FMTYieldModelRandom::setModel
83 virtual void setModel(Models::FMTModel* p_modelPtr);
84 private:
85 // DocString: FMTYieldModelRandom::_getNormalizedYields
92 std::vector<size_t> _getNormalizedYields(const std::vector<std::string>& p_yields,const Core::FMTYieldRequest& p_request) const;
93 // DocString: FMTYieldModelRandom::getYield
99 double _getRandomIndex(const std::vector<size_t>& p_distribution) const;
100 // DocString: FMTYieldModelRandom::getYield
105 void _updateGeneratorAndSeed(const Core::FMTYieldRequest& p_request) const;
106 // DocString: FMTYieldModelRandom::m_cache
108 mutable std::unordered_map<int,double>m_cache;
109 // DocString: FMTYieldModelRandom::m_useCache
111 bool m_useCache;
112 };
113}
114
115
116#endif
117
Filter built from masks used to preSolve and postsolve FMTMask objects.
Definition: FMTMaskFilter.h:31
Definition: FMTYieldModelRandom.h:26
std::unique_ptr< FMTYieldModel > postSolve(const FMTMaskFilter &p_filter, const std::vector< FMTTheme > &p_baseThemes) const
Postsolve the yieldmodel by default it will return a clone.
virtual void setModel(Models::FMTModel *p_modelPtr)
set The model to the yielmodel and change the seed.!
std::unique_ptr< FMTYieldModel > clone() const
clone this FMTYieldModel
std::unique_ptr< FMTYieldModel > preSolve(const FMTMaskFilter &p_filter, const std::vector< FMTTheme > &p_newThemes) const
If the FMTYieldModelRandom contains Core classes it also need to be presolved when presolved is calle...
void clearRandomYieldsCache() override
Flush the random number cache to redraw new random sequence.
FMTYieldModelRandom(const boost::property_tree::ptree &p_jsonProps, const std::vector< std::string > &p_distribution)
Main constructor for the random yield model.
const std::vector< double > predict(const Core::FMTYieldRequest &p_request) const
predict the yields values using this class.
static std::string getModelType()
Get the model type.
Abstract class to be implemented as a machine learning yield model.
Definition: FMTYieldModel.h:45
Request for yield values using a development and optionally a graph vertex.
Definition: FMTYieldRequest.h:37
Base class for the different models in FMT.
Definition: FMTModel.h:62
Definition: FMTYieldModel.h:30
The Core namespace provides classes for simulating stands/strata growth/harvest through time.
Definition: FMTAction.h:34