FFSM++  1.1.0
French Forest Sector Model ++
Scheduler Class Reference

Manage the yearly loops. More...

#include <Scheduler.h>

Inheritance diagram for Scheduler:
Collaboration diagram for Scheduler:

Public Member Functions

 Scheduler (ThreadManager *MTHREAD_h)
 
 ~Scheduler ()
 
void run ()
 
int getIteration ()
 
int getYear ()
 
void setYear (const int &year_h)
 
void advanceYear ()
 
- 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 >
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 >
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. 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 >
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 >
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 >
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 Attributes

int iteration
 
int year
 

Additional Inherited Members

- Protected Attributes inherited from BaseClass
ThreadManagerMTHREAD
 Pointer to the Thread manager. More...
 

Detailed Description

Manage the yearly loops.

This class is responsable to manage the time-dimension of the program.
It start its job when Init has ended and schedule the various operation to be done during the year loops.

Author
Antonello Lobianco

Definition at line 42 of file Scheduler.h.

Constructor & Destructor Documentation

Scheduler ( ThreadManager MTHREAD_h)

Definition at line 32 of file Scheduler.cpp.

32  {
33  MTHREAD=MTHREAD_h;
34  iteration=0;
35 }
ThreadManager * MTHREAD
Pointer to the Thread manager.
Definition: BaseClass.h:467
int iteration
Definition: Scheduler.h:54
~Scheduler ( )

Definition at line 37 of file Scheduler.cpp.

37  {
38 }

Member Function Documentation

void advanceYear ( )
inline

Definition at line 51 of file Scheduler.h.

Referenced by ModelCore::runInitPeriod(), and ModelCoreSpatial::runInitPeriod().

51 {year += 1;}
int year
Definition: Scheduler.h:55

Here is the caller graph for this function:

int getIteration ( )
inline

Definition at line 48 of file Scheduler.h.

Referenced by ModelData::getBaseData().

48 {return iteration;};
int iteration
Definition: Scheduler.h:54

Here is the caller graph for this function:

int getYear ( )
inline

Definition at line 49 of file Scheduler.h.

Referenced by ModelCoreSpatial::allocateHarvesting(), ModelCore::cacheSettings(), ModelCore::computeCumulativeData(), ModelCoreSpatial::computeCumulativeData(), ModelCoreSpatial::computeEconomicBalances(), ModelCore::computeInventary(), ModelCoreSpatial::computeInventary(), ModelData::getAllocableProductIdsFromDeathTimber(), Pixel::getMultiplier(), Pixel::getPathMortality(), Pixel::getSTData(), Carbon::getStock(), ModelData::getTimedData(), ModelCoreSpatial::getVHaByYear(), Carbon::HWP_eol2energy(), Carbon::initialiseDeathBiomassStocks(), ModelCoreSpatial::initialiseDeathTimber(), Carbon::initialiseProductsStocks(), Output::print(), Layers::print(), Layers::printBinMap(), Output::printCarbonBalance(), Output::printDebugOutput(), Output::printDebugPixelValues(), Output::printDetailedHV(), Output::printForestData(), Output::printMaps(), Output::printOptLog(), Output::printProductData(), Carbon::registerDeathBiomass(), Carbon::registerHarvesting(), Carbon::registerProducts(), run(), ModelCore::runBiologicalModule(), ModelCoreSpatial::runBiologicalModule(), ModelCoreSpatial::runInitPeriod(), ModelCore::runManagementModule(), ModelCoreSpatial::runManagementModule(), ModelCore::runMarketModule(), ModelCoreSpatial::runMarketModule(), ModelCore::runSimulationYear(), ModelCoreSpatial::runSimulationYear(), ModelData::setTimedData(), ModelCoreSpatial::sumRegionalForData(), ModelCore::updateMapAreas(), and ModelCoreSpatial::updateMapAreas().

49 {return year;}
int year
Definition: Scheduler.h:55

Here is the caller graph for this function:

void run ( )

Definition at line 41 of file Scheduler.cpp.

Referenced by Init::setInitLevel5().

41  {
42 
43  int initialYear = MTHREAD->MD->getIntSetting("initialYear");
44  int initialSimulationYear = MTHREAD->MD->getIntSetting("initialOptYear");
45  int preSimulationYears = initialSimulationYear-initialYear;
46  for (int it=preSimulationYears;it<MTHREAD->MD->getIntSetting("simulationYears")+preSimulationYears;it++){
47  iteration = it;
49  MTHREAD->upgradeMainSBLabel("New year started..");
50  msgOut(MSG_INFO, "### "+i2s(getYear())+ " year started.. ####");
51  time_t now;
52  time(&now);
53  struct tm *current = localtime(&now);
54  string timemessage = "("+i2s(current->tm_hour)+":"+i2s(current->tm_min)+":"+ i2s(current->tm_sec)+")";
57  if(MTHREAD->MD->getBoolSetting("usePixelData")){
58  //MTHREAD->GIS->initLayersModelData(); // removed 20120930, not needed, as data in specific pixel values
60  } else {
62  }
63 
64 
65  //MTHREAD->DO->print(); // done within modelcore now
66 
67  for(int i=0;i<MTHREAD->GIS->getXNPixels();i++){
68  MTHREAD->GIS->getPixel(i)->newYear(); //delete objects for the pixels, in the update the agents will do the same for their objects
69  }
70  }
71 }
int getIntSetting(const string &name_h, int position=0, int reg=WORLD) const
Definition: ModelData.cpp:1105
bool getBoolSetting(const string &name_h, int position=0, int reg=WORLD) const
Definition: ModelData.cpp:1117
string i2s(const int &int_h) const
integer to string conversion
Definition: BaseClass.cpp:219
ThreadManager * MTHREAD
Pointer to the Thread manager.
Definition: BaseClass.h:467
ModelData * MD
the model data object
Definition: ThreadManager.h:72
void msgOut(const int &msgCode_h, const string &msg_h, const bool &refreshGUI_h=true) const
Overloaded function to print the output log.
Definition: BaseClass.cpp:50
int getCachedInitialYear()
Definition: ModelData.h:187
Gis * GIS
GIS information and methods.
Definition: ThreadManager.h:73
void upgradeYearSBLabel(int year)
void newYear()
Definition: Pixel.cpp:385
ModelCore * CORE
Core of the model.
Definition: ThreadManager.h:77
void upgradeMainSBLabel(const string message_h)
ModelCoreSpatial * SCORE
Core of the model (spatial version)
Definition: ThreadManager.h:78
int getYear()
Definition: Scheduler.h:49
int year
Definition: Scheduler.h:55
int iteration
Definition: Scheduler.h:54
Pixel * getPixel(int x_h, int y_h)
Definition: Gis.h:134
void treeViewerChangeGeneralPropertyValue(string propertyName, string newValue)
int getXNPixels() const
Definition: Gis.h:129
Print an INFO message.
Definition: BaseClass.h:59
void runSimulationYear()
Definition: ModelCore.cpp:70

Here is the call graph for this function:

Here is the caller graph for this function:

void setYear ( const int &  year_h)
inline

Definition at line 50 of file Scheduler.h.

Referenced by Init::setInitLevel1().

50 {year = year_h;}
int year
Definition: Scheduler.h:55

Here is the caller graph for this function:

Member Data Documentation

int iteration
private

Definition at line 54 of file Scheduler.h.

Referenced by getIteration(), run(), and Scheduler().

int year
private

Definition at line 55 of file Scheduler.h.

Referenced by advanceYear(), getYear(), run(), and setYear().


The documentation for this class was generated from the following files: