FFSM++ 1.1.0
French Forest Sector Model ++
Loading...
Searching...
No Matches
ModelData.h
Go to the documentation of this file.
1/***************************************************************************
2 * Copyright (C) 2015 by Laboratoire d'Economie Forestière *
3 * http://ffsm-project.org *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 3 of the License, or *
8 * (at your option) any later version, given the compliance with the *
9 * exceptions listed in the file COPYING that is distribued together *
10 * with this file. *
11 * *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the *
19 * Free Software Foundation, Inc., *
20 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21 ***************************************************************************/
22#ifndef MODELDATA_H
23#define MODELDATA_H
24
25// Core C++ headers
26#include <string>
27#include <vector>
28#include <map>
29#include <stdexcept>
30#include <iostream>
31#include <sstream>
32
33// Qt headers...
34#include <QString>
35
36// RegMAS headers...
37#include "BaseClass.h"
38#include "InputNode.h"
39#include "Output.h"
40
41using namespace std;
42
43typedef map<string, vector <double> > DataMap;
44typedef pair<string, vector <double> > DataPair;
45
46struct IFiles;
47struct BasicData;
48class LLData;
49class ModelRegion;
50class Layers;
51class Output;
52struct forData;
53struct prodData;
54struct forToProd;
55struct reclRule;
56struct pathRule;
57struct forType;
58
59
61 string id;
62 string shortDesc;
63 string longDesc;
68 string pathTable;
70};
71
72/// Regional data, including macros and settings
73
74/**
75All regional data are within this class. It may have linked other data-classes.
76<br>On some variables ModelData has just the definition of the objects, but the values may change at the agent-level. This is why each agent has a "personal copy" of them.
77@author Antonello Lobianco
78*/
79
80class ModelData: public BaseClass{
81
82public:
83 ModelData(ThreadManager* MTHREAD_h);
84 ~ModelData();
85
86 /// Unzip the OpenOffice input file (NEW 2008.05.13)
87 void loadInput();
88
89 //void loadDataFromCache(string tablename); ///< Load data from a cached CSV instead of the openoffice file
90 LLData getTableFromFile(string tablename, string filename_h); ///< Load and return a data table from a file (instead that from a spreadsheet sheet)
91 vector<string> getScenarios();
92 int getScenarioIndex();
93 bool delDir(QString dirname); ///< Recursivelly delete a directory
94 void setScenarioData(); ///< Set the infos about this scenario (long description and overriding tables)
95 void setDefaultSettings();
97 void createRegions();
98 void setDefaultForData();
99 void setScenarioForData();
100 void setDefaultProdData();
101 void setScenarioProdData();
104 void setForestTypes();
108 void applyOverrides(); ///< Cancel all reg1 level data and trasform them in reg2 level if not already existing
109 void applyDebugMode(); ///< Works only a specified subset of regions and products
110 void setSpace();
111
112 /// Return a vector of objects that together provide the specified resource in the specified quantity
113 string getOutputDirectory() const {return outputDirname;}
114 int getFilenamesByDir (const string & dir, vector<string> &files, const string &filter = ""); ///< Return a list of files in a directory
115 string getFilenameByType(string type_h);
116 LLData getTable(string tableName_h, int debugLevel=MSG_CRITICAL_ERROR);
117 vector <IFiles> getIFilesVector() const {return iFilesVector;}
118 string getBaseDirectory() const {return baseDirectory;}
119 ModelRegion* getRegion(int regId_h);
120 bool regionExist (const int & regId_h) const ;
121 vector <ModelRegion*> getAllRegions(bool excludeResidual=true);
122 vector<int> getRegionIds(int level_h, bool excludeResidual=true);
123 vector < vector <int> > getRegionIds( bool excludeResidual=true);
124 string regId2RegSName (const int & regId_h) const ;
125 int regSName2RegId (const string & regSName_h) const ;
126 int getNForTypes(){return forTypes.size();}
127 int getNReclRules(){return reclRules.size();}
128 forType* getForType(int position){return &forTypes[position];}
129 forType* getForType(string& forTypeId_h);
130 int getForTypeCounter(string& forTypeId_h, bool all=false); ///< By default it doesn't return forTypes used only as input
131 vector <string> getForTypeIds(bool all=false); ///< By default it doesn't return forTypes used only as input
132 string getForTypeParentId(const string& forTypeId_h);
133 vector<string> getForTypeChilds(const string &forTypeId_h);
134 vector<int> getForTypeChilds_pos(const string &forTypeId_h, bool all=false);
135 vector<string> getForTypeParents();
136 int getNForTypesChilds(const string& forTypeId_h);
137 reclRule* getReclRule(int position){return &reclRules[position];}
138 vector <string> getDiameterClasses(bool productionOnly=false);
139 /// A simple function to assess if a specified product can be made by a certain forest type and diameter class
140 const bool assessProdPossibility(const string &prod_h, const string &forType_h, const string &dClass_h);
141 const int getMaxYearUsableDeathTimber(const string &prod_h, const string &forType_h, const string &dClass_h);
142 const int getMaxYearUsableDeathTimber();
143 void setErrorLevel(int errorLevel_h){errorLevel=errorLevel_h;}
145 bool getTempBool(){return tempBool;}
146 void setTempBool(bool tempBool_h){tempBool = tempBool_h;}
148 void setValueFoundBool(bool valueFoundBool_h){valueFoundBool = valueFoundBool_h;}
149
150 vector < vector <int> > createCombinationsVector(const int& nItems); ///< Return a vector containing any possible combination of nItems items (including any possible subset). The returned vector has in each slot the items present in that specific combination.
151
152 double getTimedData(const vector <double> &dated_vector, const int& year_h) const; ///< Return the value for the specified year in a timelly ordered vector, taking the last value if this is smaller than the required position.
153 void setTimedData(const double& value_h, vector<double> &dated_vector, const int& year_h, const int& MSG_LEVEL=MSG_WARNING);
154
155 int getIntSetting (const string &name_h, int position=0, int reg=WORLD) const;
156 double getDoubleSetting (const string &name_h, int position=0, int reg=WORLD) const;
157 string getStringSetting (const string &name_h, int position=0, int reg=WORLD) const;
158 bool getBoolSetting (const string &name_h, int position=0, int reg=WORLD) const;
159 vector <int> getIntVectorSetting (const string &name_h, int reg=WORLD) const;
160 vector <double> getDoubleVectorSetting (const string &name_h, int reg=WORLD) const;
161 vector <string> getStringVectorSetting (const string &name_h, int reg=WORLD) const;
162 vector <bool> getBoolVectorSetting (const string &name_h, int reg=WORLD) const;
163
164
165 const double getProdData(const string &type_h, const int& regId_h, const string &prodId_h, const int &year=DATA_NOW, const string &freeDim_h="");
166 const double getForData(const string &type_h, const int& regId_h, const string &forType_h, const string &freeDim_h, const int& year=DATA_NOW);
167
168
169 void setProdData(const double& value_h, const string &type_h, const int& regId_h, const string &prodId_h, const int& year=DATA_NOW, const bool& allowCreate=false, const string &freeDim_h=""); // Remember default arguments must be at the end
170 void setForData(const double& value_h, const string &type_h, const int& regId_h, const string &forType_h, const string &freeDim_h, const int& year=DATA_NOW, const bool& allowCreate=false); // Remember default arguments must be at the end
171
172 string makeKeyProdData(const string& parName, const string& regId, const string& prod, const string& freeDim="") const {return parName+"#"+regId+"#"+prod+"#"+freeDim+"#";}
173 string makeKeyForData(const string& parName, const string& regId, const string& forType, const string& diamClass) const {return parName+"#"+regId+"#"+forType+"#"+diamClass+"#";}
174 void unpackKeyProdData(const string& key, string& parName, int &regId, string& prod, string& freeDim) const;
175 void unpackKeyForData(const string& key, string& parName, int &regId, string& forType, string& diamClass) const;
176
177 vector<pathRule*> getPathMortalityRule(const string& forType, const string& dC); ///< Return the pathogen mortality rule(s) associated with a given ft and dc (plural as more than a single pathogen could be found)
178
179 double calculateAnnualisedEquivalent(const double& amount_h, const int& years_h, const double& ir) const; ///< Calculate the annual equivalent flow
180 double calculateAnnualisedEquivalent(const double& amount_h, const double& years_h, const double& ir) const; ///< Transform the double to the highest integer and call calculateAnnualisedEquivalent(double amount_h, int years_h)
181
182 void setOutputDirectory(const char* output_dirname_h);
183 void setBaseDiretory(string baseDirectory_h){baseDirectory=baseDirectory_h;}
184 void addSetting(string name_h, vector <string> values_h, int type_h, string comment_h);
185 void addSetting(string name_h, string value_h, int type_h, string comment_h);
186 void cacheSettings(); ///< Called after input reading, it fix frequently used data;
188
189 //void setBasicData(const string &name_h, int value, int position=0);
190 //void setBasicData(const string &name_h, double value, int position=0);
191 //void setBasicData(const string &name_h, string value, int position=0);
192 //void setBasicData(const string &name_h, bool value, int position=0);
193 friend void Output::printForestData(bool finalFlush);
194 friend void Output::printProductData(bool finalFlush);
195 void deathTimberInventory_incrOrAdd(const iisskey &thekey, double value_h){incrOrAddMapValue(deathTimberInventory,thekey, value_h);}
196 void deathTimberInventory_incr(const iisskey &thekey, double value_h){incrMapValue(deathTimberInventory,thekey, value_h);}
197 double deathTimberInventory_get(const iisskey &thekey){return findMap(deathTimberInventory, thekey);}
198 map<iisskey, double > * getDeathTimberInventory() {return &deathTimberInventory;};
199 double getAvailableDeathTimber(const vector<string> &primProd_h, int regId_h, int year_h); ///< Returns the timber available for a given set of primary products as stored in the deathTimberInventory map
200 double getAvailableAliveTimber(const vector<string> &primProd_h, int regId_h); ///< Returns the timber available for a given set of primary products as stored in the px->vol_l vector
201 vector <int> getAllocableProductIdsFromDeathTimber(const int &regId_h, const string &ft, const string &dc, const int &harvesting_year, int request_year=DATA_NOW); ///< Returns the ids of the primary products that is possible to obtain using the timber recorded death in the specific year, ft, dc combination
203
204private:
205 string getBaseData (const string &name_h, int type_h, int position=0, int regId_h=WORLD);
206 vector <string> getVectorBaseData (const string &name_h, int type_h, int regId_h=WORLD);
207 //void setBasicData(const string &name_h, string value, int type_h, int position);
208
209 bool dataMapCheckExist(const DataMap& map, const string& search_for, const bool& exactMatch=true) const;
210 double dataMapGetValue(const DataMap& map, const string& search_for, const int& year_h, const bool& exactMatch=true);
211 int dataMapSetValue(DataMap& map, const string& search_for, const double& value_h, const int& year_h, const bool& exactMatch=true);
212
213 string inputFilename; // from Qt fileOpen dialog
214 string outputDirname; // from main config files
215 string baseDirectory; // from Qt fileOpen dialog
216
217 map <string, vector<double> > forDataMap; ///< Forestry data
218 map <string, vector<double> > prodDataMap; ///< Product data
219 vector <forToProd> forToProdVector; ///< Vector of coefficients from forest resources to primary products
220
221 vector <IFiles> iFilesVector; ///< List of all input files. Simple (struct)
222 vector <BasicData> programSettingsVector; ///< Setting data. Simple (struct)
223 vector <LLData> LLDataVector; ///< Vector of Low Level Data
224 vector <ModelRegion> regionsVector; ///< Vector of modelled regions
225
226 vector <forType> forTypes; ///< Vector of forest types
227 vector <reclRule> reclRules; ///< Vector of reclassification rules
228 vector <pathRule> pathRules; ///< Vector of pathogen rules
229 vector < vector <int> > l2r; ///< Region2 ids
230 map<iisskey, double > deathTimberInventory; ///< Map that register the death of biomass still usable as timber by year, l2_region, forest type and diameter class [Mm^3 wood]
231
232 // cahced setting data..
233 vector <string> diamClasses; ///< Diameter classes
235 vector <string> priProducts;
236 vector <string> secProducts;
237 vector <string> allProducts;
238
239 bool tempBool; ///< a temporary bool variable used for various functions
240 bool valueFoundBool; ///< a bool used in getForData() and getProdData() to communicate they didn't found a variable
241
242 /// For each agricultural soil type (as defined in the setting "agrLandTypes") this list define the objects that can be placed on that soil type
243 InputNode mainDocument; ///< the main input document, loaded in memory at unzipping stage
245};
246
247/// Input files (struct)
248/**
249Very short struct containing the input files used (one istance==one file).
250<br>A copy of each Istances is saved on vector iFilesVector in class ModelData.
251<br>iFiles are defined in the main config file and parsed subsequently.
252@author Antonello Lobianco
253*/
254//Changed from a class to a structure on 2006.10.17.
255struct IFiles {
256 string directory;
257 string type;
258 string name;
259 string comment;
260};
261
262/// Basic data units (struct)
263/**
264Struct containing the basic data objects. At the moment, data are used to store programm settings or macro data.
265@author Antonello Lobianco
266*/
267struct BasicData {
268 string name;
269 /// Values are stored as "string" because we don't yet know at this point if they are string, double or integers!
270 vector <string> values;
271 int type; //< enum TYPE_*
272 int regId;
273 string comment;
274};
275
276/// IO production matrix between the forest resources and the primary products (struct)
277/**
278Struct containing the io matrix between the forest resources and the primary products. Not to be confunded with the IO matrix between primary products and secondary products.
279*/
280struct forToProd {
281 string product;
282 string forType;
283 string dClass;
284 /// The maximum year for a tree collapse that this product can be harvested from. E.g. a 0 value means it can be obtained only from live trees, a 5 years value mean it can be obtained from trees death no longer than 5 years ago.
286};
287
288/// Forest types (struct)
289/**
290Struct containing the list of the forest types managed in the model.
291@par memType Parameter to define if this type is used only in initial data reading, then is reclassed and no more used (1) or if it is generated from the reclass rule and then used in the model (2). New 20150311: (3) means a layer with spatial data of vol and area added respectiely in layers and proportionally to volumes. New 20170313: (2) also means a ft layer with no initial area nor volumes, but that can be choosen by forest managers (e.g. a new cc adapted ft). No need to introduce a new code specifically for that
292*/
293struct forType {
294 string forTypeId;
295 string forLabel;
297 string forLayer;
300};
301
302/// IO production matrix between the forest resources and the primary products (struct)
303/**
304Struct containing the io matrix between the forest resources and the primary products. Not to be confunded with the IO matrix between primary products and secondary products.
305*/
306struct reclRule {
307 int regId;
308 string forTypeIn;
310 double coeff;
311};
312
313/// Pathogen rule (how pathogen presense influence mortality) for a given forest type and diameter class (struct)
314/**
315Struct containing the rule that affect the mortality of a given ft and dc by a given pathogen: depending on the number of year of presence
316of the pathogen over a given tollerance level the mortality increase more and more.
317*/
318struct pathRule {
319 string forType;
320 string dClass;
321 string pathId; ///< Pathogen id (name)
322 double pres_min; ///< Minimum level of presence of the pathogen to be counted as present (tolerance threshold)
323 vector<double> mortCoefficents; ///< Mortality coefficients ordered by number of presence of the pathogen, e.g. first value is the mortality increase in the first year of pathogen appareance.
324};
325
326
327
328/// Low level data. XML input is reversed here after unzipping oocalc file and parsing content.xml
329class LLData: public BaseClass{
330
331public:
332 LLData(ThreadManager* MTHREAD_h, string tableName_h);
333 ~LLData();
334 void clean(); // clean the data from empty headers
335 string getTableName(){return tableName;}
336 int nrecords(){return records.size();}
337 int nheaders(){return headers.size();}
338 string getData(const int& pos_h, const string& header_h, const int& debugLevel=MSG_CRITICAL_ERROR) const;
339 friend void ModelData::loadInput();
340 //friend void ModelData::loadDataFromCache(string tablename);
341 //friend void ModelData::getTableFromFile(string tablename, string filename_h);
342
343 string tableName;
344 vector<string> headers;
345 vector < vector <string> > records;
346
347};
348
349
350#endif
This file is the header of BaseClass and it is included by ALL compiled code.
@ WORLD
Request something that is not region-specific.
Definition BaseClass.h:80
@ DATA_NOW
The required data is for the current year.
Definition BaseClass.h:73
@ MSG_CRITICAL_ERROR
Print an error message and stop the model.
Definition BaseClass.h:62
@ MSG_WARNING
Print a WARNING message.
Definition BaseClass.h:60
map< string, vector< double > > DataMap
Definition ModelData.h:43
pair< string, vector< double > > DataPair
Definition ModelData.h:44
Base class for the regmas application.
Definition BaseClass.h:239
void incrOrAddMapValue(map< K, V > &mymap, const K &key, const V &value)
Increments a value stored in a map of the specified value, given the key.
Definition BaseClass.h:325
void incrMapValue(map< K, V > &mymap, const K &key, const V &value, const int &error_level=MSG_CRITICAL_ERROR)
Increments a value stored in a map of the specified value, given the key.
Definition BaseClass.h:312
V findMap(const map< K, V > &mymap, const K &key, const int &error_level=MSG_CRITICAL_ERROR, const V &notFoundValue=numeric_limits< V >::min()) const
Lookup a map for a value. Return the value starting from the key.
Definition BaseClass.h:286
Wrapper around the underlying library for reading DOM elements (nodes).
Definition InputNode.h:51
Low level data. XML input is reversed here after unzipping oocalc file and parsing content....
Definition ModelData.h:329
string getData(const int &pos_h, const string &header_h, const int &debugLevel=MSG_CRITICAL_ERROR) const
void clean()
int nheaders()
Definition ModelData.h:337
int nrecords()
Definition ModelData.h:336
vector< vector< string > > records
Definition ModelData.h:345
string tableName
Definition ModelData.h:343
vector< string > headers
Definition ModelData.h:344
string getTableName()
Definition ModelData.h:335
Define layer objects at the regional level.
Definition Layers.h:49
Regional data, including macros and settings.
Definition ModelData.h:80
bool regionExist(const int &regId_h) const
vector< string > getForTypeParents()
forType * getForType(int position)
Definition ModelData.h:128
vector< pathRule > pathRules
Vector of pathogen rules.
Definition ModelData.h:228
string getOutputDirectory() const
Return a vector of objects that together provide the specified resource in the specified quantity.
Definition ModelData.h:113
vector< string > allProducts
Definition ModelData.h:237
vector< int > getIntVectorSetting(const string &name_h, int reg=WORLD) const
vector< int > getAllocableProductIdsFromDeathTimber(const int &regId_h, const string &ft, const string &dc, const int &harvesting_year, int request_year=DATA_NOW)
Returns the ids of the primary products that is possible to obtain using the timber recorded death in...
double getAvailableAliveTimber(const vector< string > &primProd_h, int regId_h)
Returns the timber available for a given set of primary products as stored in the px->vol_l vector.
void cacheSettings()
Called after input reading, it fix frequently used data;.
void setProdData(const double &value_h, const string &type_h, const int &regId_h, const string &prodId_h, const int &year=DATA_NOW, const bool &allowCreate=false, const string &freeDim_h="")
int getForTypeCounter(string &forTypeId_h, bool all=false)
By default it doesn't return forTypes used only as input.
Definition ModelData.cpp:81
double dataMapGetValue(const DataMap &map, const string &search_for, const int &year_h, const bool &exactMatch=true)
void setTimedData(const double &value_h, vector< double > &dated_vector, const int &year_h, const int &MSG_LEVEL=MSG_WARNING)
string outputDirname
Definition ModelData.h:214
vector< string > getScenarios()
void setValueFoundBool(bool valueFoundBool_h)
Definition ModelData.h:148
vector< IFiles > iFilesVector
List of all input files. Simple (struct)
Definition ModelData.h:221
void setDefaultForData()
void setScenarioData()
Set the infos about this scenario (long description and overriding tables)
bool getBoolSetting(const string &name_h, int position=0, int reg=WORLD) const
vector< ModelRegion > regionsVector
Vector of modelled regions.
Definition ModelData.h:224
vector< bool > getBoolVectorSetting(const string &name_h, int reg=WORLD) const
vector< pathRule * > getPathMortalityRule(const string &forType, const string &dC)
Return the pathogen mortality rule(s) associated with a given ft and dc (plural as more than a single...
string makeKeyProdData(const string &parName, const string &regId, const string &prod, const string &freeDim="") const
Definition ModelData.h:172
string makeKeyForData(const string &parName, const string &regId, const string &forType, const string &diamClass) const
Definition ModelData.h:173
void createRegions()
vector< vector< int > > l2r
Region2 ids.
Definition ModelData.h:229
void setDefaultSettings()
int errorLevel
Definition ModelData.h:244
void setScenarioProdData()
void applyDebugMode()
Works only a specified subset of regions and products.
string getBaseDirectory() const
Definition ModelData.h:118
vector< forType > forTypes
Vector of forest types.
Definition ModelData.h:226
void setDefaultPathogenRules()
map< iisskey, double > deathTimberInventory
Map that register the death of biomass still usable as timber by year, l2_region, forest type and dia...
Definition ModelData.h:230
double getDoubleSetting(const string &name_h, int position=0, int reg=WORLD) const
void setScenarioPathogenRules()
vector< string > getForTypeIds(bool all=false)
By default it doesn't return forTypes used only as input.
vector< vector< int > > createCombinationsVector(const int &nItems)
Return a vector containing any possible combination of nItems items (including any possible subset)....
string getBaseData(const string &name_h, int type_h, int position=0, int regId_h=WORLD)
InputNode mainDocument
For each agricultural soil type (as defined in the setting "agrLandTypes") this list define the objec...
Definition ModelData.h:243
vector< int > getForTypeChilds_pos(const string &forTypeId_h, bool all=false)
void setDefaultProdData()
int getNForTypes()
Definition ModelData.h:126
int getErrorLevel()
Definition ModelData.h:144
string getForTypeParentId(const string &forTypeId_h)
Definition ModelData.cpp:90
vector< string > getStringVectorSetting(const string &name_h, int reg=WORLD) const
bool delDir(QString dirname)
Recursivelly delete a directory.
vector< double > getDoubleVectorSetting(const string &name_h, int reg=WORLD) const
vector< string > getForTypeChilds(const string &forTypeId_h)
Definition ModelData.cpp:98
double deathTimberInventory_get(const iisskey &thekey)
Definition ModelData.h:197
bool getTempBool()
Definition ModelData.h:145
vector< string > priProducts
Definition ModelData.h:235
void setScenarioProductResourceMatrixLink()
void deathTimberInventory_incr(const iisskey &thekey, double value_h)
Definition ModelData.h:196
void setReclassificationRules()
const int getMaxYearUsableDeathTimber()
const double getForData(const string &type_h, const int &regId_h, const string &forType_h, const string &freeDim_h, const int &year=DATA_NOW)
string baseDirectory
Definition ModelData.h:215
void setScenarioSettings()
vector< LLData > LLDataVector
Vector of Low Level Data.
Definition ModelData.h:223
scenarioData scenario
Definition ModelData.h:202
LLData getTableFromFile(string tablename, string filename_h)
Load and return a data table from a file (instead that from a spreadsheet sheet)
void setOutputDirectory(const char *output_dirname_h)
string inputFilename
Definition ModelData.h:213
void setSpace()
vector< IFiles > getIFilesVector() const
Definition ModelData.h:117
vector< int > getRegionIds(int level_h, bool excludeResidual=true)
ModelRegion * getRegion(int regId_h)
int getNForTypesChilds(const string &forTypeId_h)
vector< ModelRegion * > getAllRegions(bool excludeResidual=true)
void unpackKeyForData(const string &key, string &parName, int &regId, string &forType, string &diamClass) const
string getFilenameByType(string type_h)
void setForestTypes()
void setErrorLevel(int errorLevel_h)
Definition ModelData.h:143
bool tempBool
a temporary bool variable used for various functions
Definition ModelData.h:239
int getIntSetting(const string &name_h, int position=0, int reg=WORLD) const
vector< string > getDiameterClasses(bool productionOnly=false)
bool getValueFoundBool()
Definition ModelData.h:147
void setTempBool(bool tempBool_h)
Definition ModelData.h:146
void setDefaultProductResourceMatrixLink()
void applyOverrides()
Cancel all reg1 level data and trasform them in reg2 level if not already existing.
int getNReclRules()
Definition ModelData.h:127
void setForData(const double &value_h, const string &type_h, const int &regId_h, const string &forType_h, const string &freeDim_h, const int &year=DATA_NOW, const bool &allowCreate=false)
vector< string > secProducts
Definition ModelData.h:236
void unpackKeyProdData(const string &key, string &parName, int &regId, string &prod, string &freeDim) const
void addSetting(string name_h, vector< string > values_h, int type_h, string comment_h)
double getTimedData(const vector< double > &dated_vector, const int &year_h) const
Return the value for the specified year in a timelly ordered vector, taking the last value if this is...
string getStringSetting(const string &name_h, int position=0, int reg=WORLD) const
reclRule * getReclRule(int position)
Definition ModelData.h:137
bool valueFoundBool
a bool used in getForData() and getProdData() to communicate they didn't found a variable
Definition ModelData.h:240
string regId2RegSName(const int &regId_h) const
int getCachedInitialYear()
Definition ModelData.h:187
int regSName2RegId(const string &regSName_h) const
const bool assessProdPossibility(const string &prod_h, const string &forType_h, const string &dClass_h)
A simple function to assess if a specified product can be made by a certain forest type and diameter ...
void loadInput()
Unzip the OpenOffice input file (NEW 2008.05.13)
vector< reclRule > reclRules
Vector of reclassification rules.
Definition ModelData.h:227
vector< string > getVectorBaseData(const string &name_h, int type_h, int regId_h=WORLD)
map< string, vector< double > > prodDataMap
Product data.
Definition ModelData.h:218
const double getProdData(const string &type_h, const int &regId_h, const string &prodId_h, const int &year=DATA_NOW, const string &freeDim_h="")
int getScenarioIndex()
map< string, vector< double > > forDataMap
Forestry data.
Definition ModelData.h:217
int cached_initialYear
Definition ModelData.h:234
void setBaseDiretory(string baseDirectory_h)
Definition ModelData.h:183
void deathTimberInventory_incrOrAdd(const iisskey &thekey, double value_h)
Definition ModelData.h:195
LLData getTable(string tableName_h, int debugLevel=MSG_CRITICAL_ERROR)
bool dataMapCheckExist(const DataMap &map, const string &search_for, const bool &exactMatch=true) const
int getFilenamesByDir(const string &dir, vector< string > &files, const string &filter="")
Return a list of files in a directory.
void setScenarioForData()
map< iisskey, double > * getDeathTimberInventory()
Definition ModelData.h:198
double calculateAnnualisedEquivalent(const double &amount_h, const int &years_h, const double &ir) const
Calculate the annual equivalent flow.
int dataMapSetValue(DataMap &map, const string &search_for, const double &value_h, const int &year_h, const bool &exactMatch=true)
vector< string > diamClasses
Diameter classes.
Definition ModelData.h:233
vector< forToProd > forToProdVector
Vector of coefficients from forest resources to primary products.
Definition ModelData.h:219
double getAvailableDeathTimber(const vector< string > &primProd_h, int regId_h, int year_h)
Returns the timber available for a given set of primary products as stored in the deathTimberInventor...
vector< BasicData > programSettingsVector
Setting data. Simple (struct)
Definition ModelData.h:222
Output methods
Definition Output.h:48
void printForestData(bool finalFlush)
Definition Output.cpp:474
void printProductData(bool finalFlush)
Definition Output.cpp:589
Thread manager. Responsable to manage the main thread and "speak" with the GUI.
Class to provide a simple integer-integer-string-string key in std maps.
Definition BaseClass.h:213
Basic data units (struct)
Definition ModelData.h:267
string name
Definition ModelData.h:268
string comment
Definition ModelData.h:273
vector< string > values
Values are stored as "string" because we don't yet know at this point if they are string,...
Definition ModelData.h:270
Input files (struct)
Definition ModelData.h:255
string name
Definition ModelData.h:258
string comment
Definition ModelData.h:259
string type
Definition ModelData.h:257
string directory
Definition ModelData.h:256
IO production matrix between the forest resources and the primary products (struct)
Definition ModelData.h:280
string dClass
Definition ModelData.h:283
string product
Definition ModelData.h:281
int maxYears
The maximum year for a tree collapse that this product can be harvested from. E.g....
Definition ModelData.h:285
string forType
Definition ModelData.h:282
Forest types (struct)
Definition ModelData.h:293
string forTypeId
Definition ModelData.h:294
string forLayer
Definition ModelData.h:297
string ereditatedFrom
Definition ModelData.h:298
string forLabel
Definition ModelData.h:295
int memType
Definition ModelData.h:296
Layers * layer
Definition ModelData.h:299
Pathogen rule (how pathogen presense influence mortality) for a given forest type and diameter class ...
Definition ModelData.h:318
string dClass
Definition ModelData.h:320
string forType
Definition ModelData.h:319
vector< double > mortCoefficents
Mortality coefficients ordered by number of presence of the pathogen, e.g. first value is the mortali...
Definition ModelData.h:323
double pres_min
Minimum level of presence of the pathogen to be counted as present (tolerance threshold)
Definition ModelData.h:322
string pathId
Pathogen id (name)
Definition ModelData.h:321
IO production matrix between the forest resources and the primary products (struct)
Definition ModelData.h:306
string forTypeOut
Definition ModelData.h:309
int regId
Definition ModelData.h:307
string forTypeIn
Definition ModelData.h:308
double coeff
Definition ModelData.h:310
string longDesc
Definition ModelData.h:63
string prodDataTable
Definition ModelData.h:66
string forDataTable
Definition ModelData.h:65
string settingFile
Definition ModelData.h:69
string forToProdTable
Definition ModelData.h:67
string pathTable
Definition ModelData.h:68
string settingTable
Definition ModelData.h:64
string shortDesc
Definition ModelData.h:62
string id
Definition ModelData.h:61