FFSM++  1.1.0
French Forest Sector Model ++
ModelCore.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 MODELCORE_H
23 #define MODELCORE_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 // External libraries headers
34 #include "IpIpoptApplication.hpp"
35 
36 // Qt headers...
37 
38 // RegMAS headers...
39 #include "BaseClass.h"
40 #include "ThreadManager.h"
41 #include "ModelData.h"
42 
43 class ModelCore : public BaseClass{
44 
45 public:
46  ModelCore(ThreadManager* MTHREAD_h);
47  ~ModelCore();
48 
49  void runInitPeriod();
50  void runSimulationYear();
51 
52  void initMarketModule(); ///< computes st and pw for second year and several needed-only-at-t0-vars for the market module
53  void runMarketModule(); ///< computes st (supply total) and pw (weighted price). Optimisation inside.
54  void runBiologicalModule(); ///< computes hV, hArea and new vol at end of year
55  void runManagementModule(); ///< computes regArea and expectedReturns
56 
57  void cacheSettings(); ///< just cache exogenous settings from ModelData
58  void cachePixelExogenousData();///< computes pixel level tp, meta and mort
59  void computeInventary(); ///< in=f(vol_t-1)
60  void computeCumulativeData(); ///< computes cumTp, vHa, cumTp_exp, vHa_exp,
61  void updateMapAreas(); ///< computes forArea_{ft}
62 
63 
64 private:
65  // convenient handles to equivalent ModelData functions..
66  double gpd(const string &type_h, const int& regId_h, const string &prodId_h, const int& year=DATA_NOW, const string &freeDim_h="") const {return MTHREAD->MD->getProdData(type_h, regId_h, prodId_h, year, freeDim_h);};
67  double gfd(const string &type_h, const int& regId_h, const string &forType_h, const string &freeDim_h, const int& year=DATA_NOW) const {return MTHREAD->MD->getForData(type_h, regId_h, forType_h, freeDim_h, year);};
68  void spd(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="") const {MTHREAD->MD->setProdData(value_h, type_h, regId_h, prodId_h, year, allowCreate, freeDim_h);};
69  void sfd(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) const {MTHREAD->MD->setForData(value_h, type_h, regId_h, forType_h, freeDim_h, year, allowCreate);};
70  bool app(const string &prod_h, const string &forType_h, const string &dClass_h) const {return MTHREAD->MD->assessProdPossibility(prod_h, forType_h, dClass_h);};
71 
72  //vector <vector <vector <double> cumTp; /// cumulative time to reach a certain diameter class;
73  //vector <vector <vector <double> vHa; /// volumes at hectar [m^3/ha];
74 
75  ModelData* MD;
76  int firstYear;
78  int thirdYear;
79  int WL2;
80  vector <int> regIds2;
81  vector <string> priProducts;
82  vector <string> secProducts;
83  vector <string> allProducts;
84  vector <string> dClasses;
85  vector <string> pDClasses;
86  vector <string> fTypes;
87  vector <vector <int> > l2r;
88  string regType;
89  double expType;
90  double mr;
91  vector < vector < vector < vector <double> > > > hV_byPrd; // by regId, ft, dc, pp
92  //Ipopt::SmartPtr<Ipopt::IpoptApplication> application;
94 
95 
96 };
97 
98 #endif // MODELCORE_H
int thirdYear
Definition: ModelCore.h:78
void runInitPeriod()
Definition: ModelCore.cpp:50
The required data is for the current year.
Definition: BaseClass.h:73
void computeCumulativeData()
computes cumTp, vHa, cumTp_exp, vHa_exp,
Definition: ModelCore.cpp:728
vector< string > priProducts
Definition: ModelCore.h:81
void sfd(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) const
Definition: ModelCore.h:69
vector< int > regIds2
Definition: ModelCore.h:80
ThreadManager * MTHREAD
Pointer to the Thread manager.
Definition: BaseClass.h:467
bool rescaleFrequencies
Definition: ModelCore.h:93
vector< string > dClasses
Definition: ModelCore.h:84
ModelData * MD
the model data object
Definition: ThreadManager.h:72
void runManagementModule()
computes regArea and expectedReturns
Definition: ModelCore.cpp:484
void spd(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="") const
Definition: ModelCore.h:68
Thread manager. Responsable to manage the main thread and "speak" with the GUI.
Definition: ThreadManager.h:65
int secondYear
Definition: ModelCore.h:77
vector< vector< int > > l2r
Definition: ModelCore.h:87
double gfd(const string &type_h, const int &regId_h, const string &forType_h, const string &freeDim_h, const int &year=DATA_NOW) const
Definition: ModelCore.h:67
Regional data, including macros and settings.
Definition: ModelData.h:80
vector< vector< vector< vector< double > > > > hV_byPrd
Definition: ModelCore.h:91
const double getProdData(const string &type_h, const int &regId_h, const string &prodId_h, const int &year=DATA_NOW, const string &freeDim_h="")
Definition: ModelData.cpp:1216
void cachePixelExogenousData()
computes pixel level tp, meta and mort
bool app(const string &prod_h, const string &forType_h, const string &dClass_h) const
Definition: ModelCore.h:70
const double getForData(const string &type_h, const int &regId_h, const string &forType_h, const string &freeDim_h, const int &year=DATA_NOW)
Definition: ModelData.cpp:1281
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="")
Definition: ModelData.cpp:1352
double expType
Definition: ModelCore.h:89
double gpd(const string &type_h, const int &regId_h, const string &prodId_h, const int &year=DATA_NOW, const string &freeDim_h="") const
Definition: ModelCore.h:66
void initMarketModule()
computes st and pw for second year and several needed-only-at-t0-vars for the market module ...
Definition: ModelCore.cpp:93
Base class for the regmas application.
Definition: BaseClass.h:239
vector< string > pDClasses
Definition: ModelCore.h:85
void runBiologicalModule()
computes hV, hArea and new vol at end of year
Definition: ModelCore.cpp:363
double mr
Definition: ModelCore.h:90
int firstYear
Definition: ModelCore.h:76
vector< string > secProducts
Definition: ModelCore.h:82
vector< string > fTypes
Definition: ModelCore.h:86
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)
Definition: ModelData.cpp:1412
int WL2
Definition: ModelCore.h:79
vector< string > allProducts
Definition: ModelCore.h:83
void updateMapAreas()
computes forArea_{ft}
Definition: ModelCore.cpp:896
void runMarketModule()
computes st (supply total) and pw (weighted price). Optimisation inside.
Definition: ModelCore.cpp:211
ModelData * MD
Definition: ModelCore.h:70
This file is the header of BaseClass and it is included by ALL compiled code.
void runSimulationYear()
Definition: ModelCore.cpp:70
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 ...
Definition: ModelData.cpp:441
ModelCore(ThreadManager *MTHREAD_h)
Definition: ModelCore.cpp:37
void cacheSettings()
just cache exogenous settings from ModelData
Definition: ModelCore.cpp:693
void computeInventary()
in=f(vol_t-1)
Definition: ModelCore.cpp:671
string regType
Definition: ModelCore.h:88