FFSM++  1.1.0
French Forest Sector Model ++
BaseClass.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 
23 /**
24  * \file BaseClass.h
25  * \brief This file is the header of BaseClass and it is included by ALL compiled code.
26  *
27  * It contains also global enum and macro definitions that can be used anywhere in the code.
28  * If the code require some "case" parameter, put the cases in the enum here.
29  * DON'T USE NEGATIVE NUMBERS in the enums, as often negative numbers have a different meaning !
30  *
31  */
32 
33 #ifndef BASECLASSBASECLASS_H
34 #define BASECLASSBASECLASS_H
35 
36 #include <iostream>
37 #include <string>
38 #include <sstream>
39 #include <vector>
40 #include <map>
41 #include <algorithm>
42 #include <numeric>
43 #include <limits>
44 #include <cstddef>
45 #include <random>
46 #include <fenv.h> // for division by zero runtime error
47 
48 // regmas headers...
49 
50 class ThreadManager;
51 
52 using namespace std;
53 
54 /// Type of message to be printed
56 
57  MSG_NO_MSG = 0, ///< Do not actually output any message
58  MSG_DEBUG = 1, ///< Print a debug message, normally filtered out
59  MSG_INFO = 2, ///< Print an INFO message
60  MSG_WARNING = 3, ///< Print a WARNING message
61  MSG_ERROR = 4, ///< Print an ERROR message, but don't stop the model
62  MSG_CRITICAL_ERROR = 5, ///< Print an error message and stop the model
63 };
64 /// Type of data requested
65 enum dataType{
66  TYPE_INT =0, ///< The required data is an integer
67  TYPE_DOUBLE =1, ///< The required data is a double
68  TYPE_STRING =2, ///< The required data is a string
69  TYPE_BOOL =3, ///< The required data is a bool
70 };
71 /// A generic enum to deal with data requests
73  DATA_NOW = -1, ///< The required data is for the current year
74  DATA_INIT = -2, ///< Setting a data request for the init period
75  DATA_ERROR = -99999999999, ///< There is an error in retrieving the data
76  // operations possible in certain contexts
77  OP_SUM =1, ///< Perform a SUM operation
78  OP_AVG =5, ///< Perform an AVERAGE operation
79  RETNA = -9999, ///< Request the (scenario specific) NO VALUE to be returned
80  WORLD = -99999 ///< Request something that is not region-specific
81 };
82 /// Verbosity level of the output
84  OUTVL_NONE =0, ///< Output verbosity level none
85  OUTVL_AGGREGATED =10, ///< Output verbosity level print aggregated output (e.g. optimisation log)
86  OUTVL_DETAILED =15, ///< Output verbosity level print (also) detailed output
87  OUTVL_MAPS =18, ///< Output verbosity level print (also) the maps in ascii grid format
88  OUTVL_BINMAPS =20, ///< Output verbosity level print (also) binary (png) maps
89  OUTVL_ALL =25, ///< Output verbosity level print everything
90 };
91 /// Domain associated to a variable or a constrain in the optimisation of the market module
92 enum domains {
93  DOM_PRI_PR =1, ///< Primary products // domain of variables and constrains: primary, secondary, all products or all products over r2 couple regions (in-country commercial flows)
94  DOM_SEC_PR =2, ///< Secondary products
95  DOM_ALL_PR =3, ///< All products (primary+secondary)
96  DOM_R2_PRI_PR =4, ///< Primary products over r2 couple regions (in-country commercial flows)
97  DOM_R2_SEC_PR =5, ///< Secondary products over r2 couple regions (in-country commercial flows)
98  DOM_R2_ALL_PR =6, ///< All products over r2 couple regions (in-country commercial flows)
99  DOM_SCALAR =7, ///< Scalar variable (not used)
100  DOM_PRI_PR_ALLCOMBS =8, ///< All possible combinations of primary products (2^ number of primary products)
101 };
102 /// Carbon stocks
104  STOCK_INV =1, ///< Invetoried biomass (live and death tree logs)
105  STOCK_EXTRA =2, ///< Extra biomass (soils, branches..)
106  STOCK_PRODUCTS =3, ///< Biomass in forest products (sawns, pannels..)
107 };
108 /// Emission types
110  EM_ENSUB =4, ///< Energy substitution
111  EM_MATSUB =5, ///< Material substitution
112  EM_FOROP =6, ///< Flow from forest operations
113 };
114 
116  CONSTR_EQ =1, // constrain of type equality
117  CONSTR_LE0 =2, // constrain of type lower or equal than 0
118  CONSTR_GE0 =3, // constrain of type greater or equal 0
119 };
120 
121 enum varType {
125 };
126 
127 enum boundType {
128  LBOUND =1,
130 };
131 
132 // mathematical defines (not correctly implemented in some compilers, namely MS VisualStudio..)
133 
134 #ifndef M_PI
135 #define M_PI 3.1415926535897932384626433832795
136 #endif
137 
138 #ifndef M_LN2
139 #define M_LN2 0.69314718055994530941723212145818
140 #endif
141 
142 #ifndef M_LN10
143 #define M_LN10 2.3025850929940456840179914546844
144 #endif
145 
146 // some macro for specific keywords in the model
147 #ifndef PROD_ALL
148 #define PROD_ALL "PROD_ALL" ///< All primary and transformed products
149 #endif
150 #ifndef PROD_PRI
151 #define PROD_PRI "PROD_PRI" ///< Primary products
152 #endif
153 #ifndef PROD_SEC
154 #define PROD_SEC "PROD_SEC" ///< Secondary products
155 #endif
156 #ifndef DIAM_ALL
157 #define DIAM_ALL "DIAM_ALL" ///< All diameter classes
158 #endif
159 #ifndef DIAM_PROD
160 #define DIAM_PROD "DIAM_PROD" ///< Diameter classes used for production (e.g. excluded the first one)
161 #endif
162 #ifndef DIAM_FIRST
163 #define DIAM_FIRST "DIAM_FIRST_CLASS" ///< First diameter class (NOT used for production)
164 #endif
165 #ifndef FT_ALL
166 #define FT_ALL "FT_ALL" ///< All forest types
167 #endif
168 
169 // Bounds for optimisation
170 #ifndef LBOUND_MIN
171 #define LBOUND_MIN -20000000000000000000.0 ///< Lower bound in optimisation -10^19
172 #endif
173 #ifndef UBOUND_MAX
174 #define UBOUND_MAX 20000000000000000000.0 ///< Upper bound in optimisation 10^19
175 #endif
176 
177 
178 /// Class to provide a simple integer-string key to be used in std maps
179 class iskey {
180 public:
181  iskey();
182  iskey(int i_h, string s_h);
183  ~iskey();
184  bool operator == (const iskey &op2) const;
185  bool operator != (const iskey &op2) const;
186  bool operator < (const iskey &op2) const;
187  bool operator > (const iskey &op2) const;
188  bool operator <= (const iskey &op2) const;
189  bool operator >= (const iskey &op2) const;
190  int i;
191  string s;
192 };
193 
194 /// Class to provide a simple integer-integer-string key in std maps
195 class iiskey {
196 public:
197  iiskey();
198  iiskey(int i_h, int i2_h, string s_h);
199  ~iiskey();
200  bool operator == (const iiskey &op2) const;
201  bool operator != (const iiskey &op2) const;
202  bool operator < (const iiskey &op2) const;
203  bool operator > (const iiskey &op2) const;
204  bool operator <= (const iiskey &op2) const;
205  bool operator >= (const iiskey &op2) const;
206  int i;
207  int i2;
208  string s;
209 
210 };
211 
212 /// Class to provide a simple integer-integer-string-string key in std maps
213 class iisskey {
214 public:
215  iisskey();
216  iisskey(int i_h, int i2_h, string s_h, string s2_h);
217  ~iisskey();
218  bool filter(const iisskey & key_h) const;
219  string print() const;
220  bool operator == (const iisskey &op2) const;
221  bool operator != (const iisskey &op2) const;
222  bool operator < (const iisskey &op2) const;
223  bool operator > (const iisskey &op2) const;
224  bool operator <= (const iisskey &op2) const;
225  bool operator >= (const iisskey &op2) const;
226  int i;
227  int i2;
228  string s;
229  string s2;
230 };
231 
232 /// Base class for the regmas application.
233 /**
234 This class is the base class for all classes in regmas. \\
235 It provides common methods in all parts of the application for printing the output, converting strings vs. values or regularly "ping" the GUI. \\
236 @author Antonello Lobianco
237 */
238 
239 class BaseClass{
240 
241 public:
242  BaseClass();
243  ~BaseClass();
244 
245  void msgOut(const int& msgCode_h, const string& msg_h, const bool& refreshGUI_h=true) const; ///< Overloaded function to print the output log
246  void msgOut(const int& msgCode_h, const int& msg_h, const bool& refreshGUI_h=true) const; ///< Overloaded function to print the output log
247  void msgOut(const int& msgCode_h, const double& msg_h, const bool& refreshGUI_h=true) const; ///< Overloaded function to print the output log
248 
249  int s2i (const string& string_h) const; ///< string to integer conversion
250  double s2d (const string& string_h) const; ///< string to double conversion
251  double s2d (const string& string_h, const bool& replaceComma) const; ///< string to double conversion
252  bool s2b (const string& string_h) const; ///< string to bool conversion
253  // as of 20120909 c++11 to_string(), stoi and stod functions not working in MinGw, as bug http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52015
254  // reverting to old code :-(
255  //string i2s (const int& int_h) const {return to_string(int_h);}; ///< integer to string conversion
256  //string d2s (const double& double_h) const {return to_string(double_h);}; ///< double to string conversion
257  string i2s (const int& int_h) const; ///< integer to string conversion
258  string d2s (const double& double_h) const; ///< double to string conversion
259  string b2s (const bool& bool_h) const; ///< bool to string conversion
260 
261  vector<int> s2i (const vector<string>& string_h) const; ///< string to integer conversion (vector)
262  vector<double> s2d (const vector<string>& string_h, const bool& replaceComma = false) const; ///< string to double conversion (vector)
263  vector<bool> s2b (const vector<string>& string_h) const; ///< string to bool conversion (vector)
264  vector<string> i2s (const vector<int>& int_h) const; ///< integer to string conversion (vector)
265  vector<string> d2s (const vector<double>& double_h) const; ///< double to string conversion (vector)
266  vector<string> b2s (const vector<bool>& bool_h) const; ///< bool to string conversion (vector)
267 
268  int getType(const string &type_h) const; ///< Return a type according to enum TYPE_* from a string (eg: "string" -> TYPE_STRING (2))
269  void refreshGUI() const; ///< Ping to periodically return the control to the GUI
270 
271  //string intToString(int x);
272  template<typename T> string toString(const T& x) const; // string s = toString(x);
273  template<typename T> T stringTo(const std::string& s) const; // e.g. int x = stringTo<int>("123");
274 
275  // vector and vector of vector sums
276  int vSum(const vector<int>& vector_h) const {return accumulate(vector_h.begin(),vector_h.end(),0);};
277  double vSum(const vector<double>& vector_h) const {return accumulate(vector_h.begin(),vector_h.end(),0.);};
278  int vSum(const vector< vector <int> >& vector_h) const;
279  double vSum(const vector< vector <double> >& vector_h) const;
280 
281  /// Tokenize a string using a delimiter (default is space)
282  void tokenize(const string& str, vector<string>& tokens, const string& delimiter = " ") const; // See also http://stackoverflow.com/questions/236129/split-a-string-in-c that could be faster
283  void untokenize(string &str, vector<string>& tokens, const string& delimiter = " ") const;
284 
285  /// Lookup a map for a value. Return the value starting from the key
286  template <typename K, typename V> 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{
287  typename map<K, V>::const_iterator p;
288  p=mymap.find(key);
289  if(p != mymap.end()) {
290  return p->second;
291  }
292  else {
293  msgOut(error_level, "Error in finding a value in a map (no value found)");
294  return notFoundValue;
295  }
296  }
297 
298  /// Change the value stored in a map given the key and the new value
299  template <typename K, typename V> void changeMapValue(map <K, V> &mymap, const K& key, const V& value, const int& error_level=MSG_CRITICAL_ERROR){
300  typename map<K, V>::iterator p;
301  p=mymap.find(key);
302  if(p != mymap.end()) {
303  p->second = value;
304  return;
305  }
306  else {
307  msgOut(error_level, "Error in finding a value in a map (no value found)");
308  }
309  }
310 
311  /// Increments a value stored in a map of the specified value, given the key
312  template <typename K, typename V> void incrMapValue(map <K, V> &mymap, const K& key, const V& value, const int& error_level=MSG_CRITICAL_ERROR){
313  typename map<K, V>::iterator p;
314  p=mymap.find(key);
315  if(p != mymap.end()) {
316  p->second = p->second + value;
317  return;
318  }
319  else {
320  msgOut(error_level, "Error in finding a value in a map (no value found)");
321  }
322  }
323 
324  /// Increments a value stored in a map of the specified value, given the key
325  template <typename K, typename V> void incrOrAddMapValue(map <K, V> &mymap, const K& key, const V& value){
326  typename map<K, V>::iterator p;
327  p=mymap.find(key);
328  if(p != mymap.end()) {
329  // We found the key, we gonna add the value..
330  p->second = p->second + value;
331  return;
332  }
333  else {
334  // We didn't find the key, we gonna add it together with the value
335  pair<K,V> myPair(key,value);
336  mymap.insert(myPair);
337  }
338  }
339 
340  /// Reset all values stored in a map to the specified one
341  template <typename K, typename V> void resetMapValues(map <K, V> &mymap, const V& value){
342  typename map<K, V>::iterator p;
343  for(p=mymap.begin(); p!=mymap.end(); p++) {
344  p->second =value;
345  }
346  }
347 
348  /// Returns a map built using the given vector and the given (scalar) value as keys/values pairs
349  template <typename K, typename V> map <K, V> vectorToMap(const vector <K>& keys, const V& value=0.0){
350  map<K,V> returnMap;
351  for(unsigned int i=0; i<keys.size();i++){
352  pair<K,V> apair(keys[i],value);
353  returnMap.insert(apair);
354  }
355  return returnMap;
356  }
357 
358  /// Return a vector of content from a vector and a vector of positions (int)
359  template <typename T> vector <T> positionsToContent(const vector <T> & vector_h, const vector<int> &positions){
360  vector <T> toReturn;
361  for(uint i=0; i<positions.size(); i++){
362  toReturn.push_back(vector_h.at(positions[i]));
363  }
364  return toReturn;
365  }
366 
367  /// Debug a map
368  template <typename V> void debugMap(const map <iisskey, V> &mymap){
369  iisskey mykey(NULL,NULL,"","");
370  debugMap(mymap, mykey);
371  }
372  template <typename K, typename V> void debugMap(const map <K, V> &mymap, const K& key){
373  cout<<"Debugging a map" << endl;
374  for (auto const &themap: mymap) {
375  if(themap.first.filter(key)){
376  cout << themap.first.print() << '\t' << themap.second << endl;
377  }
378  }
379  }
380 
381 
382  /// Returns the position of the maximum element in the vector (the last one in case of multiple equivalent maxima)
383  template <typename K> int getMaxPos (const vector <K> & v){
384  return (minmax_element(v.begin(), v.end()).second - v.begin());
385  }
386  /// Returns the position of the minimum element in the vector (the first one in case of multiple equivalent minima)
387  template <typename K> int getMinPos (const vector <K> & v){
388  return (minmax_element(v.begin(), v.end()).first - v.begin());
389  }
390  /// Returns the value of the maximum element in the vector (the last one in case of multiple equivalent maxima)
391  template <typename K> K getMax(const vector <K> & v){
392  return *minmax_element(v.begin(), v.end()).second;
393  }
394  /// Returns the value of the minimum element in the vector (the first one in case of multiple equivalent minima)
395  template <typename K> K getMin (const vector <K> & v){
396  return *minmax_element(v.begin(), v.end()).first;
397  }
398  /// Returns the average of the elements in the vector
399  template <typename K> double getAvg (const vector <K> & v){
400  return v.size()==0 ? 0.0 : vSum(v)/ ( (double) v.size() );
401  }
402 
403  /** Returns the sd of the elements of a vector. Default to sample sd.
404  *
405  * See http://stackoverflow.com/questions/7616511/calculate-mean-and-standard-deviation-from-a-vector-of-samples-in-c-using-boos
406  * where there is also an example for covariance
407  */
408  template <typename K> double getSd (const vector <K> & v, bool sample=true){
409  if (v.size()==0) return 0.0;
410  int sampleCorrection = sample==true?1:0;
411  double sum = std::accumulate(std::begin(v), std::end(v), 0.0);
412  double m = sum / v.size();
413  double accum = 0.0;
414  std::for_each (std::begin(v), std::end(v), [&](const double d) {
415  accum += (d - m) * (d - m);
416  });
417  double stdev = sqrt(accum / ( (double) (v.size()-sampleCorrection)));
418  return stdev;
419  }
420 
421  template <typename K> int getPos (const K & element, const vector <K> & v, const int& msgCode_h=MSG_CRITICAL_ERROR){
422  for(unsigned int i=0; i<v.size(); i++){
423  if(v[i]== element) return i;
424  }
425  msgOut(msgCode_h, "Element not found in vector in getPos()");
426  return -1;
427  }
428 
429  template <typename K> bool inVector (const K & element, const vector <K> & v){
430  for(unsigned int i=0; i<v.size(); i++){
431  if(v[i]== element) return true;
432  }
433  return false;
434  }
435 
436  /// Sample from a normal distribution with bounds. Slower (double time, but still you see the diff only after milion of loops).
437 
438  /// It doesn't require the normal_distribution to be passed to it, but due to including MTHREAD its definition can't be placed
439  /// in the header and hence it can not be templated, so it works only with doubles.
440  double normSample (const double& avg, const double& stdev, const double& minval=NULL, const double& maxval=NULL) const;
441 
442  /// Sample from a normal distribution with bounds. Faster (half time) as the normal_distribution is made only once.
443  template <typename K> K normSample (normal_distribution<K>& d, std::mt19937& gen, const K& minval=NULL, const K& maxval=NULL) const {
444  if(minval != NULL && maxval != NULL){
445  if (maxval <= minval){
446  msgOut(MSG_CRITICAL_ERROR,"Error in normSample: the maxvalue is lower than the minvalue");
447  }
448  }
449  for(;;){
450  K c = d(gen);
451  if( (minval == NULL || c >= minval) && (maxval == NULL || c <= maxval) ){
452  return c;
453  }
454  }
455  return minval;
456  }
457 
458 
459 
460 
461 protected:
462 
463  /**
464  * Through this pointer each derived subclass (the vast maiority of those used on FFSM) can "ask"
465  * for sending signals to the GUI, like append the log or modify the map.
466  */
467  ThreadManager* MTHREAD; ///< Pointer to the Thread manager.
468  // ATTENTION
469  // I can't create member variables to host return values as these would break all the const mechanism..
470 
471 private:
472  void msgOut2(const int& msgCode_h, const string& msg_h, const bool& refreshGUI_h) const; ///< Do the job of the overloaded functions
473 
474 };
475 
476 
477 
478 
479 #endif
Class to provide a simple integer-integer-string-string key in std maps.
Definition: BaseClass.h:213
int getPos(const K &element, const vector< K > &v, const int &msgCode_h=MSG_CRITICAL_ERROR)
Definition: BaseClass.h:421
dataType
Type of data requested.
Definition: BaseClass.h:65
Print an ERROR message, but don&#39;t stop the model.
Definition: BaseClass.h:61
The required data is for the current year.
Definition: BaseClass.h:73
Class to provide a simple integer-integer-string key in std maps.
Definition: BaseClass.h:195
Setting a data request for the init period.
Definition: BaseClass.h:74
Do not actually output any message.
Definition: BaseClass.h:57
carbonStocks
Carbon stocks.
Definition: BaseClass.h:103
varType
Definition: BaseClass.h:121
The required data is a string.
Definition: BaseClass.h:68
ThreadManager * MTHREAD
Pointer to the Thread manager.
Definition: BaseClass.h:467
K getMax(const vector< K > &v)
Returns the value of the maximum element in the vector (the last one in case of multiple equivalent m...
Definition: BaseClass.h:391
double vSum(const vector< double > &vector_h) const
Definition: BaseClass.h:277
void resetMapValues(map< K, V > &mymap, const V &value)
Reset all values stored in a map to the specified one.
Definition: BaseClass.h:341
Output verbosity level none.
Definition: BaseClass.h:84
Request something that is not region-specific.
Definition: BaseClass.h:80
Output verbosity level print everything.
Definition: BaseClass.h:89
The required data is a bool.
Definition: BaseClass.h:69
string s
Definition: BaseClass.h:228
int i2
Definition: BaseClass.h:227
Output verbosity level print (also) the maps in ascii grid format.
Definition: BaseClass.h:87
contrainDirection
Definition: BaseClass.h:115
vector< T > positionsToContent(const vector< T > &vector_h, const vector< int > &positions)
Return a vector of content from a vector and a vector of positions (int)
Definition: BaseClass.h:359
STL namespace.
K normSample(normal_distribution< K > &d, std::mt19937 &gen, const K &minval=NULL, const K &maxval=NULL) const
Sample from a normal distribution with bounds. Faster (half time) as the normal_distribution is made ...
Definition: BaseClass.h:443
Thread manager. Responsable to manage the main thread and "speak" with the GUI.
Definition: ThreadManager.h:65
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
Primary products // domain of variables and constrains: primary, secondary, all products or all produ...
Definition: BaseClass.h:93
Perform a SUM operation.
Definition: BaseClass.h:77
Material substitution.
Definition: BaseClass.h:111
int getMaxPos(const vector< K > &v)
Returns the position of the maximum element in the vector (the last one in case of multiple equivalen...
Definition: BaseClass.h:383
Output verbosity level print aggregated output (e.g. optimisation log)
Definition: BaseClass.h:85
emissionType
Emission types.
Definition: BaseClass.h:109
int i
Definition: BaseClass.h:190
Output verbosity level print (also) detailed output.
Definition: BaseClass.h:86
Class to provide a simple integer-string key to be used in std maps.
Definition: BaseClass.h:179
string s2
Definition: BaseClass.h:229
Print an error message and stop the model.
Definition: BaseClass.h:62
K getMin(const vector< K > &v)
Returns the value of the minimum element in the vector (the first one in case of multiple equivalent ...
Definition: BaseClass.h:395
Output verbosity level print (also) binary (png) maps.
Definition: BaseClass.h:88
Secondary products over r2 couple regions (in-country commercial flows)
Definition: BaseClass.h:97
void debugMap(const map< iisskey, V > &mymap)
Debug a map.
Definition: BaseClass.h:368
Flow from forest operations.
Definition: BaseClass.h:112
There is an error in retrieving the data.
Definition: BaseClass.h:75
int vSum(const vector< int > &vector_h) const
Definition: BaseClass.h:276
Secondary products.
Definition: BaseClass.h:94
Invetoried biomass (live and death tree logs)
Definition: BaseClass.h:104
Extra biomass (soils, branches..)
Definition: BaseClass.h:105
int i2
Definition: BaseClass.h:207
domains
Domain associated to a variable or a constrain in the optimisation of the market module.
Definition: BaseClass.h:92
Print a debug message, normally filtered out.
Definition: BaseClass.h:58
bool inVector(const K &element, const vector< K > &v)
Definition: BaseClass.h:429
Primary products over r2 couple regions (in-country commercial flows)
Definition: BaseClass.h:96
The required data is a double.
Definition: BaseClass.h:67
Request the (scenario specific) NO VALUE to be returned.
Definition: BaseClass.h:79
Print a WARNING message.
Definition: BaseClass.h:60
int getMinPos(const vector< K > &v)
Returns the position of the minimum element in the vector (the first one in case of multiple equivale...
Definition: BaseClass.h:387
string s
Definition: BaseClass.h:208
Scalar variable (not used)
Definition: BaseClass.h:99
double getSd(const vector< K > &v, bool sample=true)
Definition: BaseClass.h:408
map< K, V > vectorToMap(const vector< K > &keys, const V &value=0.0)
Returns a map built using the given vector and the given (scalar) value as keys/values pairs...
Definition: BaseClass.h:349
All products over r2 couple regions (in-country commercial flows)
Definition: BaseClass.h:98
Base class for the regmas application.
Definition: BaseClass.h:239
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
void debugMap(const map< K, V > &mymap, const K &key)
Definition: BaseClass.h:372
All possible combinations of primary products (2^ number of primary products)
Definition: BaseClass.h:100
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
int i
Definition: BaseClass.h:206
string s
Definition: BaseClass.h:191
Energy substitution.
Definition: BaseClass.h:110
dataRequest
A generic enum to deal with data requests.
Definition: BaseClass.h:72
The required data is an integer.
Definition: BaseClass.h:66
messageType
Type of message to be printed.
Definition: BaseClass.h:55
Perform an AVERAGE operation.
Definition: BaseClass.h:78
void changeMapValue(map< K, V > &mymap, const K &key, const V &value, const int &error_level=MSG_CRITICAL_ERROR)
Change the value stored in a map given the key and the new value.
Definition: BaseClass.h:299
int i
Definition: BaseClass.h:226
outputVerbosity
Verbosity level of the output.
Definition: BaseClass.h:83
Print an INFO message.
Definition: BaseClass.h:59
All products (primary+secondary)
Definition: BaseClass.h:95
double getAvg(const vector< K > &v)
Returns the average of the elements in the vector.
Definition: BaseClass.h:399
Biomass in forest products (sawns, pannels..)
Definition: BaseClass.h:106
boundType
Definition: BaseClass.h:127