FFSM++
1.1.0
French Forest Sector Model ++
|
#include <ModelCore.h>
Public Member Functions | |
ModelCore (ThreadManager *MTHREAD_h) | |
~ModelCore () | |
void | runInitPeriod () |
void | runSimulationYear () |
void | initMarketModule () |
computes st and pw for second year and several needed-only-at-t0-vars for the market module More... | |
void | runMarketModule () |
computes st (supply total) and pw (weighted price). Optimisation inside. More... | |
void | runBiologicalModule () |
computes hV, hArea and new vol at end of year More... | |
void | runManagementModule () |
computes regArea and expectedReturns More... | |
void | cacheSettings () |
just cache exogenous settings from ModelData More... | |
void | cachePixelExogenousData () |
computes pixel level tp, meta and mort More... | |
void | computeInventary () |
in=f(vol_t-1) More... | |
void | computeCumulativeData () |
computes cumTp, vHa, cumTp_exp, vHa_exp, More... | |
void | updateMapAreas () |
computes forArea_{ft} More... | |
Public Member Functions inherited from BaseClass | |
BaseClass () | |
~BaseClass () | |
void | msgOut (const int &msgCode_h, const string &msg_h, const bool &refreshGUI_h=true) const |
Overloaded function to print the output log. More... | |
void | msgOut (const int &msgCode_h, const int &msg_h, const bool &refreshGUI_h=true) const |
Overloaded function to print the output log. More... | |
void | msgOut (const int &msgCode_h, const double &msg_h, const bool &refreshGUI_h=true) const |
Overloaded function to print the output log. More... | |
int | s2i (const string &string_h) const |
string to integer conversion More... | |
double | s2d (const string &string_h) const |
string to double conversion More... | |
double | s2d (const string &string_h, const bool &replaceComma) const |
string to double conversion More... | |
bool | s2b (const string &string_h) const |
string to bool conversion More... | |
string | i2s (const int &int_h) const |
integer to string conversion More... | |
string | d2s (const double &double_h) const |
double to string conversion More... | |
string | b2s (const bool &bool_h) const |
bool to string conversion More... | |
vector< int > | s2i (const vector< string > &string_h) const |
string to integer conversion (vector) More... | |
vector< double > | s2d (const vector< string > &string_h, const bool &replaceComma=false) const |
string to double conversion (vector) More... | |
vector< bool > | s2b (const vector< string > &string_h) const |
string to bool conversion (vector) More... | |
vector< string > | i2s (const vector< int > &int_h) const |
integer to string conversion (vector) More... | |
vector< string > | d2s (const vector< double > &double_h) const |
double to string conversion (vector) More... | |
vector< string > | b2s (const vector< bool > &bool_h) const |
bool to string conversion (vector) More... | |
int | getType (const string &type_h) const |
Return a type according to enum TYPE_* from a string (eg: "string" -> TYPE_STRING (2)) More... | |
void | refreshGUI () const |
Ping to periodically return the control to the GUI. More... | |
template<typename T > | |
string | toString (const T &x) const |
template<typename T > | |
T | stringTo (const std::string &s) const |
int | vSum (const vector< int > &vector_h) const |
double | vSum (const vector< double > &vector_h) const |
int | vSum (const vector< vector< int > > &vector_h) const |
double | vSum (const vector< vector< double > > &vector_h) const |
void | tokenize (const string &str, vector< string > &tokens, const string &delimiter=" ") const |
Tokenize a string using a delimiter (default is space) More... | |
void | untokenize (string &str, vector< string > &tokens, const string &delimiter=" ") const |
template<typename K , typename V > | |
V | findMap (const map< K, V > &mymap, const K &key, const int &error_level=MSG_CRITICAL_ERROR, const V ¬FoundValue=numeric_limits< V >::min()) const |
Lookup a map for a value. Return the value starting from the key. More... | |
template<typename K , typename V > | |
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. More... | |
template<typename K , typename V > | |
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. More... | |
template<typename K , typename V > | |
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. More... | |
template<typename K , typename V > | |
void | resetMapValues (map< K, V > &mymap, const V &value) |
Reset all values stored in a map to the specified one. More... | |
template<typename K , typename V > | |
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. More... | |
template<typename T > | |
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) More... | |
template<typename V > | |
void | debugMap (const map< iisskey, V > &mymap) |
Debug a map. More... | |
template<typename K , typename V > | |
void | debugMap (const map< K, V > &mymap, const K &key) |
template<typename K > | |
int | getMaxPos (const vector< K > &v) |
Returns the position of the maximum element in the vector (the last one in case of multiple equivalent maxima) More... | |
template<typename K > | |
int | getMinPos (const vector< K > &v) |
Returns the position of the minimum element in the vector (the first one in case of multiple equivalent minima) More... | |
template<typename K > | |
K | getMax (const vector< K > &v) |
Returns the value of the maximum element in the vector (the last one in case of multiple equivalent maxima) More... | |
template<typename K > | |
K | getMin (const vector< K > &v) |
Returns the value of the minimum element in the vector (the first one in case of multiple equivalent minima) More... | |
template<typename K > | |
double | getAvg (const vector< K > &v) |
Returns the average of the elements in the vector. More... | |
template<typename K > | |
double | getSd (const vector< K > &v, bool sample=true) |
template<typename K > | |
int | getPos (const K &element, const vector< K > &v, const int &msgCode_h=MSG_CRITICAL_ERROR) |
template<typename K > | |
bool | inVector (const K &element, const vector< K > &v) |
double | normSample (const double &avg, const double &stdev, const double &minval=NULL, const double &maxval=NULL) const |
Sample from a normal distribution with bounds. Slower (double time, but still you see the diff only after milion of loops). More... | |
template<typename K > | |
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 only once. More... | |
template<typename T > | |
std::string | toString (const T &x) const |
Private Member Functions | |
double | gpd (const string &type_h, const int ®Id_h, const string &prodId_h, const int &year=DATA_NOW, const string &freeDim_h="") const |
double | gfd (const string &type_h, const int ®Id_h, const string &forType_h, const string &freeDim_h, const int &year=DATA_NOW) const |
void | spd (const double &value_h, const string &type_h, const int ®Id_h, const string &prodId_h, const int &year=DATA_NOW, const bool &allowCreate=false, const string &freeDim_h="") const |
void | sfd (const double &value_h, const string &type_h, const int ®Id_h, const string &forType_h, const string &freeDim_h, const int &year=DATA_NOW, const bool &allowCreate=false) const |
bool | app (const string &prod_h, const string &forType_h, const string &dClass_h) const |
Private Attributes | |
ModelData * | MD |
int | firstYear |
int | secondYear |
int | thirdYear |
int | WL2 |
vector< int > | regIds2 |
vector< string > | priProducts |
vector< string > | secProducts |
vector< string > | allProducts |
vector< string > | dClasses |
vector< string > | pDClasses |
vector< string > | fTypes |
vector< vector< int > > | l2r |
string | regType |
double | expType |
double | mr |
vector< vector< vector< vector< double > > > > | hV_byPrd |
bool | rescaleFrequencies |
Additional Inherited Members | |
Protected Attributes inherited from BaseClass | |
ThreadManager * | MTHREAD |
Pointer to the Thread manager. More... | |
Definition at line 43 of file ModelCore.h.
ModelCore | ( | ThreadManager * | MTHREAD_h | ) |
Definition at line 37 of file ModelCore.cpp.
~ModelCore | ( | ) |
Definition at line 41 of file ModelCore.cpp.
|
inlineprivate |
Definition at line 70 of file ModelCore.h.
Referenced by computeInventary(), runBiologicalModule(), and runManagementModule().
void cachePixelExogenousData | ( | ) |
computes pixel level tp, meta and mort
void cacheSettings | ( | ) |
just cache exogenous settings from ModelData
Definition at line 693 of file ModelCore.cpp.
Referenced by runInitPeriod().
void computeCumulativeData | ( | ) |
computes cumTp, vHa, cumTp_exp, vHa_exp,
Computing some fully exogenous parameters that require complex operations, e.g. cumulative time of passage or volume per hectare. This happen at the very beginning of the init period and after each simulated year
It doesn't include tp and mort multipliers, but this could be added as now there is a regional versiopn of them and not just a pixel version.
param expType Specify how the forest owners (those that make the investments) behave will be the time of passage in the future in order to calculate the cumulative time of passage in turn used to discount future revenues. Will forest owners behave adaptively believing the time of passage between diameter classes will be like the observed one at time they make decision (0) or they will have full expectations believing forecasts (1) or something in the middle ?
For compatibility with the GAMS code, a -1 value means using initial simulation tp values (fixed cumTp)."
Definition at line 728 of file ModelCore.cpp.
Referenced by runInitPeriod(), and runSimulationYear().
void computeInventary | ( | ) |
in=f(vol_t-1)
Definition at line 671 of file ModelCore.cpp.
Referenced by runInitPeriod(), and runSimulationYear().
|
inlineprivate |
Definition at line 67 of file ModelCore.h.
Referenced by computeCumulativeData(), computeInventary(), runBiologicalModule(), runManagementModule(), and updateMapAreas().
|
inlineprivate |
Definition at line 66 of file ModelCore.h.
Referenced by initMarketModule(), runBiologicalModule(), runManagementModule(), and runMarketModule().
void initMarketModule | ( | ) |
computes st and pw for second year and several needed-only-at-t0-vars for the market module
Definition at line 93 of file ModelCore.cpp.
Referenced by runInitPeriod().
void runBiologicalModule | ( | ) |
computes hV, hArea and new vol at end of year
Definition at line 363 of file ModelCore.cpp.
Referenced by runInitPeriod(), and runSimulationYear().
void runInitPeriod | ( | ) |
IMPORTANT NOTE: Volumes in Mm^3, Areas in the model in Ha (10000 m^2), in the layers in m^2
Some importan notes: V (volumes) -> at the end of the year In (inventary) -> at the beginning of the year Volumes are in Mm^3, Areas in the model in Ha (10000 m^2), in the layers in m^2
Definition at line 50 of file ModelCore.cpp.
Referenced by Init::setInitLevel3().
void runManagementModule | ( | ) |
computes regArea and expectedReturns
see ::calculateAnnualisedEquivalent
Definition at line 484 of file ModelCore.cpp.
Referenced by runInitPeriod(), and runSimulationYear().
void runMarketModule | ( | ) |
computes st (supply total) and pw (weighted price). Optimisation inside.
Definition at line 211 of file ModelCore.cpp.
Referenced by runSimulationYear().
void runSimulationYear | ( | ) |
Definition at line 70 of file ModelCore.cpp.
Referenced by Scheduler::run().
|
inlineprivate |
Definition at line 69 of file ModelCore.h.
Referenced by computeCumulativeData(), runBiologicalModule(), runManagementModule(), and updateMapAreas().
|
inlineprivate |
Definition at line 68 of file ModelCore.h.
Referenced by computeInventary(), initMarketModule(), and runMarketModule().
void updateMapAreas | ( | ) |
computes forArea_{ft}
This function take for each region the difference for each forest type between the harvested area and the new regeneration one and apply such delta to each pixel of the region proportionally to the area that it already hosts.
Definition at line 896 of file ModelCore.cpp.
Referenced by runInitPeriod(), and runSimulationYear().
|
private |
Definition at line 83 of file ModelCore.h.
Referenced by cacheSettings(), initMarketModule(), and runMarketModule().
|
private |
Definition at line 84 of file ModelCore.h.
Referenced by cacheSettings(), computeCumulativeData(), computeInventary(), runBiologicalModule(), and runManagementModule().
|
private |
Definition at line 89 of file ModelCore.h.
Referenced by cacheSettings(), and computeCumulativeData().
|
private |
Definition at line 76 of file ModelCore.h.
Referenced by cacheSettings(), computeCumulativeData(), initMarketModule(), and updateMapAreas().
|
private |
Definition at line 86 of file ModelCore.h.
Referenced by cacheSettings(), computeCumulativeData(), computeInventary(), runBiologicalModule(), runManagementModule(), and updateMapAreas().
|
private |
Definition at line 91 of file ModelCore.h.
Referenced by runBiologicalModule(), and runManagementModule().
|
private |
Definition at line 87 of file ModelCore.h.
Referenced by cacheSettings(), and initMarketModule().
|
private |
Definition at line 70 of file ModelCore.h.
Referenced by cacheSettings(), computeCumulativeData(), and runManagementModule().
|
private |
Definition at line 90 of file ModelCore.h.
Referenced by cacheSettings(), and runManagementModule().
|
private |
Definition at line 85 of file ModelCore.h.
Referenced by cacheSettings().
|
private |
Definition at line 81 of file ModelCore.h.
Referenced by cacheSettings(), computeInventary(), initMarketModule(), runBiologicalModule(), runManagementModule(), and runMarketModule().
|
private |
Definition at line 80 of file ModelCore.h.
Referenced by cacheSettings(), computeCumulativeData(), computeInventary(), initMarketModule(), runBiologicalModule(), runManagementModule(), and runMarketModule().
|
private |
Definition at line 88 of file ModelCore.h.
Referenced by cacheSettings(), runBiologicalModule(), and runManagementModule().
|
private |
Definition at line 93 of file ModelCore.h.
Referenced by cacheSettings(), and runManagementModule().
|
private |
Definition at line 77 of file ModelCore.h.
Referenced by cacheSettings(), initMarketModule(), and runBiologicalModule().
|
private |
Definition at line 82 of file ModelCore.h.
Referenced by cacheSettings(), initMarketModule(), and runMarketModule().
|
private |
Definition at line 78 of file ModelCore.h.
Referenced by cacheSettings().
|
private |
Definition at line 79 of file ModelCore.h.
Referenced by cacheSettings(), initMarketModule(), and runMarketModule().