FMT 0.9.8
Forest management tools for forest planning
Loading...
Searching...
No Matches
FMTyieldmodelnn.hpp
Go to the documentation of this file.
1
2/*
3Copyright (c) 2019 Gouvernement du Québec
4
5SPDX-License-Identifier: LiLiQ-R-1.1
6License-Filename: LICENSES/EN/LiLiQ-R11unicode.txt
7*/
8#include "FMTobject.hpp"
9#include "FMTyieldmodel.hpp"
10#include <boost/serialization/serialization.hpp>
11#include <boost/serialization/nvp.hpp>
12
13
14#ifndef FMTYIELDMODELNN_H_INCLUDED
15#define FMTYIELDMODELNN_H_INCLUDED
16
17namespace Ort
18{
19 struct Env;
20 struct Session;
21}
22
23
24namespace Core
25{
26 // DocString: FMTyieldmodelnn
31 {
33 template<class Archive>
34 void serialize(Archive& ar, const unsigned int version)
35 {
36 ar & boost::serialization::make_nvp("FMTyieldmodel", boost::serialization::base_object<FMTyieldmodel>(*this));
37 }
38 protected:
39 #ifdef FMTWITHONNXR
40 static std::unique_ptr<Ort::Env> envPtr;
41 std::unique_ptr<Ort::Session> sessionPtr;
42 #endif
43 static const float UNKNOWN_DISTURBANCE_CODE;
44 const std::string JSON_PROP_MODEL_TYPE = "modelType";
45 const std::string JSON_PROP_MODEL_YIELDS = "modelYields";
46 const std::string JSON_PROP_MODEL_OUTPUTS = "outputNames";
47 const std::string JSON_PROP_STAND_FILE_PATH = "csvStandardisationFile";
48 std::string modelType;
49 std::vector<float> standardParamMeans = {};
50 std::vector<float> standardParamVars = {};
51 std::vector<std::string> modelOutputs = {};
52 // DocString: FMTyieldmodelnn::GetNextLineAndSplitIntoTokens
56 static const std::vector<std::string> GetNextLineAndSplitIntoTokens(std::istream& str);
57 // DocString: FMTyieldmodelnn::Standardize
61 static const std::vector<float> Standardize(std::vector<float>& input, const std::vector<float>& means, const std::vector<float>& vars);
62
63 // DocString: FMTyieldmodelnn::ValidateInputYields
67 void ValidateInputYields(std::vector<std::string>& expectedYields, std::vector<std::string>& inputYields) const;
68 // DocString: FMTyieldmodelnn::GetModelType()
72 const std::string& GetModelType() const;
73 // DocString: FMTyieldmodelnn::GetStandardParamMeans()
77 const std::vector<float>& GetStandardParamMeans() const;
78 // DocString: FMTyieldmodelnn::GetStandardParamVars()
82 const std::vector<float>& GetStandardParamVars() const;
83 // DocString: FMTyieldmodelnn::GetModelOutputNames()
87 const std::vector<std::string>& GetModelOutputNames() const;
88 // DocString: FMTyieldmodelnn::GetInputValues()
92 virtual const std::vector<double> GetInputValues(const Graph::FMTpredictor& predictor) const = 0;
93 // DocString: FMTyieldmodelnn::RemoveNans
97 const void RemoveNans(std::vector<float>& input) const;
98 // DocString: FMTyieldmodelnn::FMTyieldmodelpools(const boost::property_tree::ptree& jsonProps, std::vector<std::string>& inputYields)
102 FMTyieldmodelnn(const boost::property_tree::ptree& jsonProps, std::vector<std::string>& inputYields);
103 public:
104 // DocString: FMTyieldmodelnn::~FMTyieldmodel()
109 // DocString: FMTyieldmodelnn::FMTyieldmodelnn()
114 // DocString: FMTyieldmodelnn::FMTyieldmodelnn()
119 // DocString: FMTyieldmodelnn::Predict
123 const std::vector<double>Predict(const Core::FMTyieldrequest& request) const;
124 // DocString: FMTyieldmodelnn::std::string()
128 virtual operator std::string() const;
129 };
130}
131
132#endif
Definition: FMTyieldmodel.hpp:41
Definition: FMTyieldmodelnn.hpp:31
const std::string & GetModelType() const
std::vector< float > standardParamMeans
Definition: FMTyieldmodelnn.hpp:49
FMTyieldmodelnn(const boost::property_tree::ptree &jsonProps, std::vector< std::string > &inputYields)
virtual ~FMTyieldmodelnn()
const std::vector< float > & GetStandardParamVars() const
std::unique_ptr< Ort::Session > sessionPtr
Definition: FMTyieldmodelnn.hpp:41
const std::vector< std::string > & GetModelOutputNames() const
std::vector< float > standardParamVars
Definition: FMTyieldmodelnn.hpp:50
std::string modelType
Definition: FMTyieldmodelnn.hpp:48
const std::string JSON_PROP_MODEL_TYPE
Definition: FMTyieldmodelnn.hpp:44
virtual const std::vector< double > GetInputValues(const Graph::FMTpredictor &predictor) const =0
const std::string JSON_PROP_MODEL_OUTPUTS
Definition: FMTyieldmodelnn.hpp:46
const void RemoveNans(std::vector< float > &input) const
static const std::vector< float > Standardize(std::vector< float > &input, const std::vector< float > &means, const std::vector< float > &vars)
const std::vector< double > Predict(const Core::FMTyieldrequest &request) const
const std::string JSON_PROP_MODEL_YIELDS
Definition: FMTyieldmodelnn.hpp:45
static std::unique_ptr< Ort::Env > envPtr
Definition: FMTyieldmodelnn.hpp:40
void ValidateInputYields(std::vector< std::string > &expectedYields, std::vector< std::string > &inputYields) const
static const float UNKNOWN_DISTURBANCE_CODE
Definition: FMTyieldmodelnn.hpp:43
friend class boost::serialization::access
Definition: FMTyieldmodelnn.hpp:32
static const std::vector< std::string > GetNextLineAndSplitIntoTokens(std::istream &str)
const std::string JSON_PROP_STAND_FILE_PATH
Definition: FMTyieldmodelnn.hpp:47
const std::vector< float > & GetStandardParamMeans() const
FMTyieldmodelnn(const FMTyieldmodelnn &rhs)
std::vector< std::string > modelOutputs
Definition: FMTyieldmodelnn.hpp:51
Definition: FMTyieldrequest.hpp:36
Definition: FMTpredictor.hpp:29
Definition: FMTyieldmodel.hpp:26
The Core namespace provides classes for simulating stands/strata growth/harvest through time.
Definition: FMTaction.hpp:31
Definition: FMTyieldmodelnn.hpp:18