FMT 0.9.8
Forest management tools for forest planning
Loading...
Searching...
No Matches
FMToptimizationparser.hpp
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 FMToptimizationparser_H_INCLUDED
9#define FMToptimizationparser_H_INCLUDED
10
11#include "FMTparser.hpp"
12#include <algorithm>
13#include <vector>
14#include <map>
15#include <string>
16#include <queue>
17#include "FMTutility.hpp"
18#include <boost/regex.hpp>
19#include <limits>
20
21
22namespace Core
23{
24 class FMToutput;
25 class FMTconstraint;
26 class FMTtheme;
27 class FMTconstants;
28 class FMTperbounds;
29}
30
31
32namespace Parser
33{
35 {
39 format = 4,
40 none = 5
41 };
42
44 {
45 const static boost::regex rxsections;
46 const static boost::regex rxobjectives;
47 const static boost::regex rxexclude;
48 const static boost::regex rxconstraints;
49 const static boost::regex rxequations;
50 const static boost::regex rxperiods;
51 const static boost::regex rxending;
52 const static boost::regex rxoutput;
53 const static boost::regex rxpenalty;
54 const static boost::regex rxspecialoutput;
55 const static boost::regex rxspatial;
56 const static boost::regex rxspecialobjective;
57 const static boost::regex rxstartwithoperator;
58 std::queue<std::string>ineach;
59 Core::FMTconstraint getobjective(const std::string& line, const Core::FMTconstants& constants,
60 const std::vector<Core::FMToutput>& outputs,
61 const std::vector<Core::FMTtheme>& themes);
62 FMToptimizationsection getsection(const std::string& line) const;
63 bool setending(Core::FMTconstraint& constraint,std::string& line, const Core::FMTconstants& constants);
64 Core::FMTperbounds getperbound(const std::string& lower, const std::string& upper, const Core::FMTconstants& constants) const;
65 void setperiods(Core::FMTspec& constraint, const std::string& lower,const std::string& upper, const Core::FMTconstants& constants) const;
66 Core::FMToutput resume_output(const std::map<std::string,double>& nodes,
67 const std::vector<Core::FMToutput>& outputs,
68 const std::vector<Core::FMTtheme>& themes,
69 const Core::FMTconstants& constants);
70 std::string getoptline(std::ifstream& stream, const std::vector<Core::FMTtheme>& themes,
71 const Core::FMTconstants& cons,const std::vector<Core::FMToutput>& outputs);
72 std::queue<std::string> geteachlines(const std::string& line,const Core::FMTconstants& constants,const std::vector<Core::FMToutput>& outputs, const std::vector<Core::FMTtheme>& themes) const;
73 std::map<std::string,double>getequation(const std::string& line, const Core::FMTconstants& constants,
74 const std::vector<Core::FMToutput>& outputs,size_t lhssize= std::numeric_limits<size_t>::max());
75 std::vector<Core::FMTconstraint> getperiodsbounds(std::string periodstr,const Core::FMTconstraint& constraint, const Core::FMTconstants& constants) const;
76 void fillbounds(const std::string& operatorvalue, const double& rhs, double& lower,double& upper) const;
77 Core::FMTconstraint getspatialconstraint(const Core::FMTconstraint& baseconstraint,
78 const boost::smatch& match, const std::string& line,
79 const Core::FMTconstants& constants,
80 const std::vector<Core::FMTaction>& actions,
81 const std::vector<Core::FMToutput>& outputs,
82 const std::vector<Core::FMTtheme>& themes);
83 std::vector<std::vector<double>>getreplicatechanges(const std::string& replicateargument);
84 public:
87 FMToptimizationparser& operator = (const FMToptimizationparser& rhs)=default;
88 std::vector<Core::FMTconstraint> read(const std::vector<Core::FMTtheme>& themes,
89 const std::vector<Core::FMTaction>& actions,
90 const Core::FMTconstants& constants,
91 const std::vector<Core::FMToutput>& outputs,
92 std::vector<Core::FMTaction>& excluded,
93 const std::string& location);
94 std::vector<Core::FMTconstraint> getconstraints(const std::string& line, const Core::FMTconstants& constants,
95 const std::vector<Core::FMToutput>& outputs, const std::vector<Core::FMTtheme>& themes, const std::vector<Core::FMTaction>& actions);
96 void write(const std::vector<Core::FMTconstraint>& constraints,const std::string& location) const;
98 };
99}
100
101#endif
#define FMTEXPORT
Definition: FMTutility.hpp:92
Definition: FMTconstants.hpp:29
Definition: FMTconstraint.hpp:54
Definition: FMToutput.hpp:39
Definition: FMTbounds.hpp:293
Definition: FMTbounds.hpp:342
Definition: FMToptimizationparser.hpp:44
std::vector< Core::FMTconstraint > read(const std::vector< Core::FMTtheme > &themes, const std::vector< Core::FMTaction > &actions, const Core::FMTconstants &constants, const std::vector< Core::FMToutput > &outputs, std::vector< Core::FMTaction > &excluded, const std::string &location)
FMToptimizationparser(const FMToptimizationparser &rhs)=default
void write(const std::vector< Core::FMTconstraint > &constraints, const std::string &location) const
std::vector< Core::FMTconstraint > getconstraints(const std::string &line, const Core::FMTconstants &constants, const std::vector< Core::FMToutput > &outputs, const std::vector< Core::FMTtheme > &themes, const std::vector< Core::FMTaction > &actions)
Definition: FMTparser.hpp:66
The Core namespace provides classes for simulating stands/strata growth/harvest through time.
Definition: FMTaction.hpp:31
Namespace handling all FMT's parsers. Everything related to I/O should be located in this namespace.
Definition: FMTactionparser.hpp:26
FMToptimizationsection
Definition: FMToptimizationparser.hpp:35
@ exclude
Definition: FMToptimizationparser.hpp:37
@ constraints
Definition: FMToptimizationparser.hpp:38
@ none
Definition: FMToptimizationparser.hpp:40
@ format
Definition: FMToptimizationparser.hpp:39
@ objective
Definition: FMToptimizationparser.hpp:36