FFSM++ 1.1.0
French Forest Sector Model ++
Loading...
Searching...
No Matches
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
43class ModelCore : public BaseClass{
44
45public:
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
64private:
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
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
This file is the header of BaseClass and it is included by ALL compiled code.
@ DATA_NOW
The required data is for the current year.
Definition BaseClass.h:73
Base class for the regmas application.
Definition BaseClass.h:239
ThreadManager * MTHREAD
Pointer to the Thread manager.
Definition BaseClass.h:467
void runMarketModule()
computes st (supply total) and pw (weighted price). Optimisation inside.
vector< string > allProducts
Definition ModelCore.h:83
vector< string > fTypes
Definition ModelCore.h:86
void cachePixelExogenousData()
computes pixel level tp, meta and mort
void cacheSettings()
just cache exogenous settings from ModelData
void computeInventary()
in=f(vol_t-1)
int thirdYear
Definition ModelCore.h:78
void runBiologicalModule()
computes hV, hArea and new vol at end of year
void runInitPeriod()
Definition ModelCore.cpp:50
void updateMapAreas()
computes forArea_{ft}
vector< string > priProducts
Definition ModelCore.h:81
double expType
Definition ModelCore.h:89
int secondYear
Definition ModelCore.h:77
double mr
Definition ModelCore.h:90
ModelData * MD
Definition ModelCore.h:75
void runManagementModule()
computes regArea and expectedReturns
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
void computeCumulativeData()
computes cumTp, vHa, cumTp_exp, vHa_exp,
void initMarketModule()
computes st and pw for second year and several needed-only-at-t0-vars for the market module
Definition ModelCore.cpp:93
vector< vector< int > > l2r
Definition ModelCore.h:87
int firstYear
Definition ModelCore.h:76
vector< string > secProducts
Definition ModelCore.h:82
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
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 runSimulationYear()
Definition ModelCore.cpp:70
bool app(const string &prod_h, const string &forType_h, const string &dClass_h) const
Definition ModelCore.h:70
string regType
Definition ModelCore.h:88
vector< string > dClasses
Definition ModelCore.h:84
vector< string > pDClasses
Definition ModelCore.h:85
vector< vector< vector< vector< double > > > > hV_byPrd
Definition ModelCore.h:91
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
bool rescaleFrequencies
Definition ModelCore.h:93
vector< int > regIds2
Definition ModelCore.h:80
Regional data, including macros and settings.
Definition ModelData.h:80
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="")
const double getForData(const string &type_h, const int &regId_h, const string &forType_h, const string &freeDim_h, const int &year=DATA_NOW)
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)
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 ...
const double getProdData(const string &type_h, const int &regId_h, const string &prodId_h, const int &year=DATA_NOW, const string &freeDim_h="")
Thread manager. Responsable to manage the main thread and "speak" with the GUI.
ModelData * MD
the model data object