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

Output methods More...

#include <Output.h>

Inheritance diagram for Output:
Collaboration diagram for Output:

Public Member Functions

 Output (ThreadManager *MTHREAD_h)
 Constructor. More...
 
 ~Output ()
 
void initOutput ()
 
void commonInit ()
 
void initOutputMaps ()
 
void initOutputForestData ()
 
void initOutputProductData ()
 
void initOptimisationLog ()
 
void initDebugOutput ()
 
void initDebugPixelValues ()
 
void initCarbonBalance ()
 
void print (bool earlyPrint=true)
 Print output. If earlyPrinting it doesn't print some stuff for which we don't yet have values. More...
 
void printMaps ()
 
void printForestData (bool finalFlush)
 
void printProductData (bool finalFlush)
 
void printCarbonBalance ()
 
void printFinalOutput ()
 
void printDebugOutput ()
 
void printDetailedHV (map< tr1::array< string, 4 >, double > hVol_byPrd)
 
void printDebugPixelValues ()
 
void printOptLog (bool optimal, int &nIterations, double &obj)
 
char getOutputFieldDelimiter ()
 
void cleanScenario (string fileName, string scenarioName, char d)
 
- 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
 

Public Attributes

vector< vector< vector< vector< vector< double > > > > > expReturnsDebug
 l2_region, for type, d.c., pr prod, variable name More...
 
vector< string > expReturnsDebugVariables
 

Private Attributes

int oLevel
 
char d
 
int inYear
 
int nYears
 
string baseDir
 
string oDir
 
string scenarioName
 
string oFileExt
 
bool oHRedeable
 
bool oSingleFile
 
vector< int > oYears
 
vector< int > mapsOYears
 
int wRegId_l1
 
int wRegId_l2
 
string outFileName
 
vector< string > outForVariables
 
vector< string > outProdVariables
 
bool oForData
 
bool oProdData
 
bool oCarbonData
 
int outStepRange
 
bool forestDiamDetailedOutput
 
vector< string > priPr
 
vector< string > secPr
 
vector< string > allPr
 
vector< int > l1regIds
 
vector< vector< int > > l2r
 
vector< string > fTypes
 
vector< string > dClasses
 
vector< string > pDClasses
 includes an empty string for variables without diameter attribute More...
 
int nPriPr
 
int nSecPr
 
int nAllPr
 
int nL2r
 
string logFilename
 
string debugFilename
 
string debugPxValuesFilename
 
bool spMode
 

Additional Inherited Members

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

Detailed Description

Output methods

Class responsable to output the data, both as all kind of log as well as georeferenciated one.

Author
Antonello Lobianco

Definition at line 48 of file Output.h.

Constructor & Destructor Documentation

Output ( ThreadManager MTHREAD_h)

Constructor.

Definition at line 37 of file Output.cpp.

37  {
38  MTHREAD=MTHREAD_h;
39 }
ThreadManager * MTHREAD
Pointer to the Thread manager.
Definition: BaseClass.h:467
~Output ( )

Definition at line 41 of file Output.cpp.

41  {
42 }

Member Function Documentation

void cleanScenario ( string  fileName,
string  scenarioName,
char  d 
)

This routine clean the output scenario from previous outputs of the defined scenario. Other scenarios are untouched. The scenarioName must be in the first row.

Parameters
filenameFilename of the output file to clean
scenarioNameName of the scenario we are replacing
dField delimiter. It must not be changed in the meantime (between the various scenarios)

Definition at line 1149 of file Output.cpp.

Referenced by initCarbonBalance(), initDebugOutput(), initDebugPixelValues(), initOptimisationLog(), initOutputForestData(), and initOutputProductData().

1149  {
1150  string dStr(&d,1);
1151  vector <string> rows;
1152  string tempRow;
1153  ifstream inFile (fileName.c_str(), ios::in);
1154  if (!inFile){
1155  msgOut(MSG_ERROR,"Error in opening the file "+fileName+" for reading.");
1156  return;
1157  }
1158  while( getline (inFile,tempRow) ){
1159  vector<string> tokens;
1160  tokenize(tempRow,tokens,dStr);
1161  if(tokens[0] != scenarioName)
1162  rows.push_back( tempRow );
1163  }
1164  inFile.close();
1165  ofstream out(fileName.c_str(), ios::out);
1166  for(uint i=0;i<rows.size();i++){
1167  out << rows[i];
1168  out << "\n";
1169  }
1170 }
Print an ERROR message, but don&#39;t stop the model.
Definition: BaseClass.h:61
void tokenize(const string &str, vector< string > &tokens, const string &delimiter=" ") const
Tokenize a string using a delimiter (default is space)
Definition: BaseClass.cpp:374
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
char d
Definition: Output.h:80
string scenarioName
Definition: Output.h:85

Here is the call graph for this function:

Here is the caller graph for this function:

void commonInit ( )

Definition at line 61 of file Output.cpp.

Referenced by initOutput().

61  {
62  oLevel = MTHREAD->MD->getIntSetting("outputLevel");
64  inYear = MTHREAD->MD->getIntSetting("initialYear");
65  nYears = MTHREAD->MD->getIntSetting("simulationYears");
68 // bool initSeed = MTHREAD->MD->getBoolSetting("newRandomSeed");
69 // if (initSeed){
70 // uniform_int_distribution<> d(1, 1000000);
71 // int random = d(*MTHREAD->gen);
72 // scenarioName = MTHREAD->getScenarioName()+"_"+i2s(random);
73 // } else {
74 // scenarioName = MTHREAD->getScenarioName();
75 // }
76  if (MTHREAD->MD->getStringSetting("overridenScenarioName") == "none"){
78  } else {
79  scenarioName = MTHREAD->MD->getStringSetting("overridenScenarioName");
80  }
81  oFileExt = MTHREAD->MD->getStringSetting("outputFileExtension");
82  oHRedeable = MTHREAD->MD->getBoolSetting("outputHumanReadable");
83  oSingleFile = MTHREAD->MD->getBoolSetting("outputSingleFile");
84  oYears = MTHREAD->MD->getIntVectorSetting("outYears");
85  mapsOYears = MTHREAD->MD->getIntVectorSetting("mapsOutYears");
86  wRegId_l1 = MTHREAD->MD->getIntSetting("worldCodeLev1");
87  wRegId_l2 = MTHREAD->MD->getIntSetting("worldCodeLev2");
88  outForVariables = MTHREAD->MD->getStringVectorSetting("outForVariables");
89  outProdVariables = MTHREAD->MD->getStringVectorSetting("outProdVariables");
90  dClasses = MTHREAD->MD->getStringVectorSetting("dClasses");
91  pDClasses.insert(pDClasses.end(), dClasses.begin()+1, dClasses.end() ); // production diameter classes
92  dClasses.push_back(""); // needed for reporting of variables without diameter attribute
93  outStepRange = MTHREAD->MD->getIntSetting("outStepRange");
94  forestDiamDetailedOutput = MTHREAD->MD->getBoolSetting("forestDiamDetailedOutput");
96 
97  oForData = (oLevel>=OUTVL_DETAILED && outForVariables.size() > 0)?true:false;
98  oProdData = (oLevel>=OUTVL_DETAILED && outProdVariables.size() > 0)?true:false;
99  oCarbonData = (oLevel>=OUTVL_DETAILED)?true:false;
100 
101  priPr = MTHREAD->MD->getStringVectorSetting("priProducts");
102  secPr = MTHREAD->MD->getStringVectorSetting("secProducts");
103  allPr = priPr;
104  allPr.insert( allPr.end(), secPr.begin(), secPr.end() );
105  nPriPr = priPr.size();
106  nSecPr = secPr.size();
107  nAllPr = allPr.size();
108  l1regIds = MTHREAD->MD->getRegionIds(1, true);
109  nL2r = MTHREAD->MD->getRegionIds(2, true).size();
110  spMode = MTHREAD->MD->getBoolSetting("usePixelData");
111  //if(spMode) {
112  // pxIds = getXyNPixels();
113  //}
114 
115 
116  for(uint i=0;i<l1regIds.size();i++){
117  std::vector<int> l2ChildrenIds;
118  ModelRegion* l1Region = MTHREAD->MD->getRegion(l1regIds[i]);
119  std::vector<ModelRegion*> l2Childrens = l1Region->getChildren(true);
120  for(uint j=0;j<l2Childrens.size();j++){
121  l2ChildrenIds.push_back(l2Childrens[j]->getRegId());
122  }
123  if(l2ChildrenIds.size()){
124  l2r.push_back(l2ChildrenIds);
125  }
126  }
127 
128 }
vector< int > mapsOYears
Definition: Output.h:90
int nSecPr
Definition: Output.h:110
int getIntSetting(const string &name_h, int position=0, int reg=WORLD) const
Definition: ModelData.cpp:1105
vector< string > dClasses
Definition: Output.h:107
bool getBoolSetting(const string &name_h, int position=0, int reg=WORLD) const
Definition: ModelData.cpp:1117
int nL2r
Definition: Output.h:112
ThreadManager * MTHREAD
Pointer to the Thread manager.
Definition: BaseClass.h:467
ModelData * MD
the model data object
Definition: ThreadManager.h:72
string getBaseDirectory() const
Definition: ModelData.h:118
vector< string > pDClasses
includes an empty string for variables without diameter attribute
Definition: Output.h:108
int outStepRange
Definition: Output.h:99
vector< string > secPr
Definition: Output.h:102
vector< string > getStringVectorSetting(const string &name_h, int reg=WORLD) const
Definition: ModelData.cpp:1129
int oLevel
Definition: Output.h:79
string oFileExt
Definition: Output.h:86
string baseDir
Definition: Output.h:83
vector< int > l1regIds
Definition: Output.h:104
int inYear
Definition: Output.h:81
string getStringSetting(const string &name_h, int position=0, int reg=WORLD) const
Definition: ModelData.cpp:1113
Output verbosity level print (also) detailed output.
Definition: BaseClass.h:86
bool oHRedeable
Definition: Output.h:87
vector< string > allPr
Definition: Output.h:103
vector< vector< int > > l2r
Definition: Output.h:105
int wRegId_l2
Definition: Output.h:92
vector< int > oYears
Definition: Output.h:89
char getOutputFieldDelimiter()
Definition: Output.cpp:802
char d
Definition: Output.h:80
vector< string > getForTypeIds(bool all=false)
By default it doesn&#39;t return forTypes used only as input.
Definition: ModelData.cpp:430
int nAllPr
Definition: Output.h:111
vector< string > priPr
Definition: Output.h:101
bool oCarbonData
Definition: Output.h:98
string getScenarioName()
vector< string > outProdVariables
Definition: Output.h:95
bool oForData
Definition: Output.h:96
int nYears
Definition: Output.h:82
vector< int > getIntVectorSetting(const string &name_h, int reg=WORLD) const
Definition: ModelData.cpp:1121
vector< int > getRegionIds(int level_h, bool excludeResidual=true)
Definition: ModelData.cpp:366
bool oSingleFile
Definition: Output.h:88
bool forestDiamDetailedOutput
Definition: Output.h:100
vector< ModelRegion * > getChildren(bool excludeResidual=true)
Returns a pointer to the parent regions.
Definition: ModelRegion.cpp:55
string getOutputDirectory() const
Return a vector of objects that together provide the specified resource in the specified quantity...
Definition: ModelData.h:113
int nPriPr
Definition: Output.h:109
int wRegId_l1
Definition: Output.h:91
ModelRegion * getRegion(int regId_h)
Definition: ModelData.cpp:346
bool oProdData
Definition: Output.h:97
vector< string > fTypes
Definition: Output.h:106
string scenarioName
Definition: Output.h:85
bool spMode
Definition: Output.h:116
string oDir
Definition: Output.h:84
vector< string > outForVariables
Definition: Output.h:94

Here is the call graph for this function:

Here is the caller graph for this function:

char getOutputFieldDelimiter ( )

Definition at line 802 of file Output.cpp.

Referenced by commonInit().

802  {
803  int delimiterID = MTHREAD->MD->getIntSetting("outputFieldDelimiter");
804  switch (delimiterID) {
805  case 1:
806  return ',';
807  break;
808  case 2:
809  return ';';
810  break;
811  case 3:
812  return ':';
813  break;
814  case 4:
815  return '\t';
816  break;
817  case 5:
818  return ' ';
819  break;
820  default:
821  msgOut(MSG_ERROR, "You have specified an unknow output file field delimiter. Using \";\".");
822  return ',';
823  }
824 }
Print an ERROR message, but don&#39;t stop the model.
Definition: BaseClass.h:61
int getIntSetting(const string &name_h, int position=0, int reg=WORLD) const
Definition: ModelData.cpp:1105
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

Here is the call graph for this function:

Here is the caller graph for this function:

void initCarbonBalance ( )

Definition at line 370 of file Output.cpp.

Referenced by initOutput().

370  {
371  if(!oCarbonData) return;
372  if(oSingleFile){
373  outFileName = baseDir+oDir+"results/carbonBalance"+oFileExt;
374  ifstream in(outFileName.c_str(), ios::in);
375  if(in.is_open()) { // file exist, no need to initializate it, but we are gonna clean it of previous data of the same scenario if present...
376  in.close();
378  return;
379  } else {
380  in.close();
381  }
382  } else {
383  outFileName = baseDir+oDir+"results/carbonBalance_"+scenarioName+oFileExt;
384  }
385 
386  ofstream out(outFileName.c_str(), ios::out);
387  if (!out){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+outFileName+" for reading.");}
388  out << "scen" << d << "country" << d << "region" << d << "balItem" << d;
389  //if(oHRedeable){
390  // for(int i=0;i<nYears;i++){
391  // out << i+inYear << d;
392  // }
393  //} else {
394  out << "year" << d << "value" << d;
395  //}
396  out << "\n";
397  out.close();
398 }
string outFileName
Definition: Output.h:93
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
string oFileExt
Definition: Output.h:86
string baseDir
Definition: Output.h:83
Print an error message and stop the model.
Definition: BaseClass.h:62
void cleanScenario(string fileName, string scenarioName, char d)
Definition: Output.cpp:1149
char d
Definition: Output.h:80
bool oCarbonData
Definition: Output.h:98
bool oSingleFile
Definition: Output.h:88
string scenarioName
Definition: Output.h:85
string oDir
Definition: Output.h:84

Here is the call graph for this function:

Here is the caller graph for this function:

void initDebugOutput ( )

Definition at line 170 of file Output.cpp.

Referenced by initOutput().

170  {
171  if(oLevel<OUTVL_ALL) return;
172 
173  // init debugging the expected returns...
174  if(spMode) return;
175  expReturnsDebugVariables.push_back("hVol_byUPp");
176  expReturnsDebugVariables.push_back("hV_byFT");
177  expReturnsDebugVariables.push_back("finalHarvestFlag");
178  expReturnsDebugVariables.push_back("pondCoeff");
179  expReturnsDebugVariables.push_back("pW");
180  expReturnsDebugVariables.push_back("cumTp");
181  expReturnsDebugVariables.push_back("vHa");
182  expReturnsDebugVariables.push_back("expectedReturns");
183  expReturnsDebugVariables.push_back("weightedAvgCompModeFlag");
184 
185  if (oSingleFile){
186  debugFilename = baseDir+oDir+"debugs/debugOut.csv";
187  } else {
188  debugFilename = baseDir+oDir+"debugs/debugOut_"+scenarioName+".csv";
189  }
190 
191  ifstream in(debugFilename.c_str(), ios::in);
192  if(in.is_open()) { // file exist, no need to initializate it, but we are gonna clean it of previous data of the same scenario if present...
193  in.close();
195  return;
196  } else { // file doesn't exist
197  in.close();
198  ofstream out(debugFilename.c_str(), ios::out);
199  if (!out){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+debugFilename+" for writing.");}
200  out << "scenario" << d << "year" << d << "region or pixel" << d << "forType" << d << "freeDim" << d << "prod" << d << "parName" << d << "value" << d <<"\n";
201  out.close();
202  }
203 }
string debugFilename
Definition: Output.h:114
Output verbosity level print everything.
Definition: BaseClass.h:89
vector< string > expReturnsDebugVariables
Definition: Output.h:76
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 oLevel
Definition: Output.h:79
string baseDir
Definition: Output.h:83
Print an error message and stop the model.
Definition: BaseClass.h:62
void cleanScenario(string fileName, string scenarioName, char d)
Definition: Output.cpp:1149
char d
Definition: Output.h:80
bool oSingleFile
Definition: Output.h:88
string scenarioName
Definition: Output.h:85
bool spMode
Definition: Output.h:116
string oDir
Definition: Output.h:84

Here is the call graph for this function:

Here is the caller graph for this function:

void initDebugPixelValues ( )

Definition at line 207 of file Output.cpp.

Referenced by initOutput().

207  {
208  if(oLevel<OUTVL_ALL) return;
209 
210  // init debugging the expected returns...
211  if(!spMode) return;
212 
213  if (oSingleFile){
214  debugPxValuesFilename = baseDir+oDir+"debugs/debugPxValues.csv";
215  } else {
216  debugPxValuesFilename = baseDir+oDir+"debugs/debugPxValues_"+scenarioName+".csv";
217  }
218 
219  ifstream in(debugPxValuesFilename.c_str(), ios::in);
220  if(in.is_open()) { // file exist, no need to initializate it, but we are gonna clean it of previous data of the same scenario if present...
221  in.close();
223  return;
224  } else { // file doesn't exist
225  in.close();
226  ofstream out(debugPxValuesFilename.c_str(), ios::out);
227  if (!out){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+debugPxValuesFilename+" for writing.");}
228  out << "scenario" << d << "year" << d << "region" << d << "pxId" << d << "pxX" << d << "pxY" << d ;
229  /*for(uint f=0;f<fTypes.size();f++){
230  string ft = fTypes[f];
231  string header = "tp_multiplier_"+ft;
232  out << header <<d;
233  }
234  for(uint f=0;f<fTypes.size();f++){
235  string ft = fTypes[f];
236  string header = "mortCoef_multiplier_"+ft;
237  out << header <<d;
238  }*/
239  out << "var" << d ;
240 
241  for(uint f=0;f<fTypes.size();f++){
242  string ft = fTypes[f];
243  for (uint u=0;u<dClasses.size();u++){
244  string dc=dClasses[u];
245  string header = ft+"_"+dc;
246  out << header <<d;
247  }
248  }
249  for(uint f=0;f<fTypes.size()+1;f++){
250  string ft1 = (f == fTypes.size()) ? "NonFor" : fTypes[f];
251  for(uint f2=0;f2<fTypes.size()+1;f2++){
252  string ft2 = (f2 == fTypes.size()) ? "NonFor" : fTypes[f2];
253  string header = ft1+"_2_"+ft2;
254  out << header <<d;
255  }
256  }
257  out << "\n";
258 
259 
260  out.close();
261  }
262 
263 
264 
265 
266  /*
267  if(oSingleFile){
268  outFileName = baseDir+oDir+"results/forestData"+oFileExt;
269  ifstream in(outFileName.c_str(), ios::in);
270  if(in.is_open()) { // file exist, no need to initializate it, but we are gonna clean it of previous data of the same scenario if present...
271  in.close();
272  cleanScenario(outFileName, scenarioName, d);
273  return;
274  } else {
275  in.close();
276  }
277  } else {
278  outFileName = baseDir+oDir+"results/forestData_"+scenarioName+oFileExt;
279  }
280 
281  ofstream out(outFileName.c_str(), ios::out);
282  if (!out){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+outFileName+" for reading.");}
283  out << "scen" << d << "parName" << d << "country" << d << "region" << d << "forType" << d << "freeDim" << d;
284  */
285 
286 
287 
288 
289 
290 
291 
292 
293 }
vector< string > dClasses
Definition: Output.h:107
Output verbosity level print everything.
Definition: BaseClass.h:89
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
string debugPxValuesFilename
Definition: Output.h:115
int oLevel
Definition: Output.h:79
string baseDir
Definition: Output.h:83
Print an error message and stop the model.
Definition: BaseClass.h:62
void cleanScenario(string fileName, string scenarioName, char d)
Definition: Output.cpp:1149
char d
Definition: Output.h:80
bool oSingleFile
Definition: Output.h:88
vector< string > fTypes
Definition: Output.h:106
string scenarioName
Definition: Output.h:85
bool spMode
Definition: Output.h:116
string oDir
Definition: Output.h:84

Here is the call graph for this function:

Here is the caller graph for this function:

void initOptimisationLog ( )

Definition at line 131 of file Output.cpp.

Referenced by initOutput().

131  {
132  if(oLevel<OUTVL_AGGREGATED) return;
133 
134  if (oSingleFile){
135  logFilename = baseDir+oDir+"optimisationLogs/optimisationLogs.txt";
136 
137  } else {
138  logFilename = baseDir+oDir+"optimisationLogs/"+scenarioName+".txt";
139  }
140 
141 
142  ifstream in(logFilename.c_str(), ios::in);
143  if(in.is_open()) { // file exist, no need to initializate it, but we are gonna clean it of previous data of the same scenario if present...
144  in.close();
146  ofstream out(logFilename.c_str(), ios::app);
147  if (!out){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+logFilename+" for writing.");}
148  time_t now;
149  time(&now);
150  struct tm *current = localtime(&now);
151  string timemessage = i2s(current->tm_hour)+":"+i2s(current->tm_min)+":"+ i2s(current->tm_sec);
152  out << scenarioName << d << "0000" << d << timemessage << d << d << d <<"\n";
153  out.close();
154  return;
155  } else { // file doesn't exist
156  in.close();
157  ofstream out(logFilename.c_str(), ios::out);
158  if (!out){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+logFilename+" for writing.");}
159  out << "scenario" << d << "year" << d << "time" << d << "opt flag" << d << "iterations" << d <<"\n";
160  time_t now;
161  time(&now);
162  struct tm *current = localtime(&now);
163  string timemessage = i2s(current->tm_hour)+":"+i2s(current->tm_min)+":"+ i2s(current->tm_sec);
164  out << scenarioName << d << "0000" << d << timemessage << d << d << d <<"\n";
165  out.close();
166  }
167 }
string i2s(const int &int_h) const
integer to string conversion
Definition: BaseClass.cpp:219
string logFilename
Definition: Output.h:113
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 oLevel
Definition: Output.h:79
string baseDir
Definition: Output.h:83
Output verbosity level print aggregated output (e.g. optimisation log)
Definition: BaseClass.h:85
Print an error message and stop the model.
Definition: BaseClass.h:62
void cleanScenario(string fileName, string scenarioName, char d)
Definition: Output.cpp:1149
char d
Definition: Output.h:80
bool oSingleFile
Definition: Output.h:88
string scenarioName
Definition: Output.h:85
string oDir
Definition: Output.h:84

Here is the call graph for this function:

Here is the caller graph for this function:

void initOutput ( )

Definition at line 48 of file Output.cpp.

Referenced by Init::setInitLevel3().

48  {
49  commonInit();
57 }
void initOutputProductData()
Definition: Output.cpp:338
void initOutputForestData()
Definition: Output.cpp:296
void initDebugPixelValues()
Definition: Output.cpp:207
void initOptimisationLog()
Definition: Output.cpp:131
void initCarbonBalance()
Definition: Output.cpp:370
void commonInit()
Definition: Output.cpp:61
void initDebugOutput()
Definition: Output.cpp:170
void initOutputMaps()
Definition: Output.cpp:406

Here is the call graph for this function:

Here is the caller graph for this function:

void initOutputForestData ( )

Definition at line 296 of file Output.cpp.

Referenced by initOutput().

296  {
297  if(!oForData) return;
298 
299  if(oSingleFile){
300  outFileName = baseDir+oDir+"results/forestData"+oFileExt;
301  ifstream in(outFileName.c_str(), ios::in);
302  if(in.is_open()) { // file exist, no need to initializate it, but we are gonna clean it of previous data of the same scenario if present...
303  in.close();
305  return;
306  } else {
307  in.close();
308  }
309  } else {
310  outFileName = baseDir+oDir+"results/forestData_"+scenarioName+oFileExt;
311  }
312 
313  ofstream out(outFileName.c_str(), ios::out);
314  if (!out){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+outFileName+" for reading.");}
315  out << "scen" << d << "parName" << d << "country" << d << "region" << d << "forType" << d << "freeDim" << d;
316  if(oHRedeable){
317  for(int i=0;i<nYears;i++){
318  out << i+inYear << d;
319  }
320  } else {
321  out << "year" << d << "value" << d;
322  }
323  out << "\n";
324  out.close();
325 
326  // gonna do the same for detailed hV..
327  if(!MTHREAD->MD->getBoolSetting("outDetailedHv",DATA_NOW)) return;
328  outFileName = baseDir+oDir+"results/detailedHV_"+scenarioName+oFileExt;
329  ofstream outHV(outFileName.c_str(), ios::out);
330  if (!outHV){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+outFileName+" for reading.");}
331  outHV << "scen" << d << "parName" << d << "country" << d << "region" << d << "forType" << d << "freeDim" << d << "prod" << d << "year" << d << "value" << d;
332  outHV << "\n";
333  outHV.close();
334 
335 }
The required data is for the current year.
Definition: BaseClass.h:73
bool getBoolSetting(const string &name_h, int position=0, int reg=WORLD) const
Definition: ModelData.cpp:1117
ThreadManager * MTHREAD
Pointer to the Thread manager.
Definition: BaseClass.h:467
ModelData * MD
the model data object
Definition: ThreadManager.h:72
string outFileName
Definition: Output.h:93
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
string oFileExt
Definition: Output.h:86
string baseDir
Definition: Output.h:83
int inYear
Definition: Output.h:81
bool oHRedeable
Definition: Output.h:87
Print an error message and stop the model.
Definition: BaseClass.h:62
void cleanScenario(string fileName, string scenarioName, char d)
Definition: Output.cpp:1149
char d
Definition: Output.h:80
bool oForData
Definition: Output.h:96
int nYears
Definition: Output.h:82
bool oSingleFile
Definition: Output.h:88
string scenarioName
Definition: Output.h:85
string oDir
Definition: Output.h:84

Here is the call graph for this function:

Here is the caller graph for this function:

void initOutputMaps ( )

Resetting the list of printed layers and the scenario name..
Printing scenario name for post-processing scripts

Definition at line 406 of file Output.cpp.

Referenced by initOutput().

406  {
407  if(oLevel<OUTVL_MAPS) return;
408  string mapBaseDirectory = baseDir+oDir+"maps/";
409  string filenameToSaveScenarioName = mapBaseDirectory+"scenarioNames/"+scenarioName;
410  string filenameListIntLayers = mapBaseDirectory+"integerListLayers/"+scenarioName;
411  string filenameListFloatLayers = mapBaseDirectory+"floatListLayers/"+scenarioName;
412 
413  // printing the scenario name in the "scenarioName file"...
414  ofstream outSN(filenameToSaveScenarioName.c_str(), ios::out);
415  if (!outSN){ msgOut(MSG_ERROR,"Error in opening the file "+filenameToSaveScenarioName+".");}
416  outSN << scenarioName << "\n";
417  outSN.close();
418  // cleaning the "integerListLayers" and "floatListLayers" file...
419  ofstream outi(filenameListIntLayers.c_str(), ios::out);
420  outi.close();
421  ofstream outf(filenameListFloatLayers.c_str(), ios::out);
422  outf.close();
423 }
Print an ERROR message, but don&#39;t stop the model.
Definition: BaseClass.h:61
Output verbosity level print (also) the maps in ascii grid format.
Definition: BaseClass.h:87
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 oLevel
Definition: Output.h:79
string baseDir
Definition: Output.h:83
string scenarioName
Definition: Output.h:85
string oDir
Definition: Output.h:84

Here is the call graph for this function:

Here is the caller graph for this function:

void initOutputProductData ( )

Definition at line 338 of file Output.cpp.

Referenced by initOutput().

338  {
339  if(!oProdData) return;
340 
341  if(oSingleFile){
342  outFileName = baseDir+oDir+"results/productData"+oFileExt;
343  ifstream in(outFileName.c_str(), ios::in);
344  if(in.is_open()) { // file exist, no need to initializate it, but we are gonna clean it of previous data of the same scenario if present...
345  in.close();
347  return;
348  } else {
349  in.close();
350  }
351  } else {
352  outFileName = baseDir+oDir+"results/productData_"+scenarioName+oFileExt;
353  }
354 
355  ofstream out(outFileName.c_str(), ios::out);
356  if (!out){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+outFileName+" for reading.");}
357  out << "scen" << d << "parName" << d << "country" << d << "region" << d << "prod" << d << "freeDim" << d;
358  if(oHRedeable){
359  for(int i=0;i<nYears;i++){
360  out << i+inYear << d;
361  }
362  } else {
363  out << "year" << d << "value" << d;
364  }
365  out << "\n";
366  out.close();
367 }
string outFileName
Definition: Output.h:93
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
string oFileExt
Definition: Output.h:86
string baseDir
Definition: Output.h:83
int inYear
Definition: Output.h:81
bool oHRedeable
Definition: Output.h:87
Print an error message and stop the model.
Definition: BaseClass.h:62
void cleanScenario(string fileName, string scenarioName, char d)
Definition: Output.cpp:1149
char d
Definition: Output.h:80
int nYears
Definition: Output.h:82
bool oSingleFile
Definition: Output.h:88
bool oProdData
Definition: Output.h:97
string scenarioName
Definition: Output.h:85
string oDir
Definition: Output.h:84

Here is the call graph for this function:

Here is the caller graph for this function:

void print ( bool  earlyPrint = true)

Print output. If earlyPrinting it doesn't print some stuff for which we don't yet have values.

Definition at line 426 of file Output.cpp.

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

426  {
427  int cYear = MTHREAD->SCD->getYear();
428  int initialSimulationYear = MTHREAD->MD->getIntSetting("initialOptYear");
429 
430  if (outStepRange != -1 && (cYear-initialSimulationYear)%outStepRange != 0 && cYear != (initialSimulationYear+nYears)-1 ) {
431  cout << cYear << " not printed" << endl;
432  return;
433  }
434  bool printThisYear = false;
435  for(uint i=0;i<oYears.size();i++){
436  if (outStepRange == -1 && oYears[i] == cYear) printThisYear = true;
437  }
438  if(outStepRange == -1 && !printThisYear) return;
439 
440  printMaps();
442  printForestData(false);
443  printProductData(false);
446  if(!earlyPrint) printDebugPixelValues();
448 }
void printDebugOutput()
Definition: Output.cpp:843
Print an ERROR message, but don&#39;t stop the model.
Definition: BaseClass.h:61
int getIntSetting(const string &name_h, int position=0, int reg=WORLD) const
Definition: ModelData.cpp:1105
Do not actually output any message.
Definition: BaseClass.h:57
void printCarbonBalance()
Definition: Output.cpp:727
ThreadManager * MTHREAD
Pointer to the Thread manager.
Definition: BaseClass.h:467
void printMaps()
Definition: Output.cpp:451
void printDebugPixelValues()
Definition: Output.cpp:880
ModelData * MD
the model data object
Definition: ThreadManager.h:72
int outStepRange
Definition: Output.h:99
Scheduler * SCD
the scheduler object (simulation-loops scheduler)
Definition: ThreadManager.h:75
void printProductData(bool finalFlush)
Definition: Output.cpp:589
int getYear()
Definition: Scheduler.h:49
vector< int > oYears
Definition: Output.h:89
int nYears
Definition: Output.h:82
void setErrorLevel(int errorLevel_h)
Definition: ModelData.h:143
void printForestData(bool finalFlush)
Definition: Output.cpp:474

Here is the call graph for this function:

Here is the caller graph for this function:

void printCarbonBalance ( )

Definition at line 727 of file Output.cpp.

Referenced by print().

727  {
728 
729  if(!oCarbonData) return;
730  int currentYear = MTHREAD->SCD->getYear();
731  if (currentYear == inYear) {return;} // don't print carbon balance on first year, carbon balance containers has not yet been initialised
732 
733  msgOut(MSG_INFO, "Printing forest data..");
734 
735  if(oSingleFile){
736  outFileName = baseDir+oDir+"results/carbonBalance"+oFileExt;
737  } else {
738  outFileName = baseDir+oDir+"results/carbonBalance_"+scenarioName+oFileExt;
739  }
740  ofstream out (outFileName.c_str(), ios::app);
741  if (!out){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+outFileName+" for writing.");}
742  double outvalue=0;
743 
745 
746  for (uint r1=0;r1<l2r.size();r1++){
747  for (uint r2=0;r2<l2r[r1].size();r2++){
748  int regId = l2r[r1][r2];
749  for (uint b=0;b<balItems.size();b++){
750  out << scenarioName << d;
751  out << MTHREAD->MD->regId2RegSName(l1regIds.at(r1)) << d;
752  out << MTHREAD->MD->regId2RegSName(l2r[r1][r2]) << d;
753  string balItemString;
754  switch(balItems[b]){
755  case STOCK_INV: {
756  balItemString = "STOCK_INV";
757  outvalue = MTHREAD->CBAL->getStock(regId, balItems[b]);
758  break;
759  }
760  case STOCK_EXTRA: {
761  balItemString = "STOCK_EXTRA";
762  outvalue = MTHREAD->CBAL->getStock(regId, balItems[b]);
763  break;
764  }
765  case STOCK_PRODUCTS: {
766  balItemString = "STOCK_PRODUCTS";
767  outvalue = MTHREAD->CBAL->getStock(regId, balItems[b]);
768  break;
769  }
770  case EM_ENSUB: {
771  balItemString = "EM_ENSUB";
772  outvalue = MTHREAD->CBAL->getCumSavedEmissions(regId, balItems[b]);
773  break;
774  }
775  case EM_MATSUB: {
776  balItemString = "EM_MATSUB";
777  outvalue = MTHREAD->CBAL->getCumSavedEmissions(regId, balItems[b]);
778  break;
779  }
780  case EM_FOROP: {
781  balItemString = "EM_FOROP";
782  outvalue = MTHREAD->CBAL->getCumSavedEmissions(regId, balItems[b]);
783  break;
784  }
785  default:
786  msgOut(MSG_CRITICAL_ERROR,"Unexpected balance item type in function printCarbonBalance");
787  }
788  out << balItemString << d;
789  out << currentYear << d;
790  out << outvalue << d;
791  out << "\n";
792 
793 
794  } // end bal items
795  } // end r2
796  } // end r1
797  out.close();
798 }
ThreadManager * MTHREAD
Pointer to the Thread manager.
Definition: BaseClass.h:467
ModelData * MD
the model data object
Definition: ThreadManager.h:72
string outFileName
Definition: Output.h:93
double getCumSavedEmissions(const int &regId, const int &em_type) const
Returns the current cumulative saved emissions by type [Mt CO2].
Definition: Carbon.cpp:138
double getStock(const int &regId, const int &stock_type) const
Returns the current stock of carbon [Mt CO2].
Definition: Carbon.cpp:53
Scheduler * SCD
the scheduler object (simulation-loops scheduler)
Definition: ThreadManager.h:75
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
Material substitution.
Definition: BaseClass.h:111
string oFileExt
Definition: Output.h:86
string baseDir
Definition: Output.h:83
vector< int > l1regIds
Definition: Output.h:104
int inYear
Definition: Output.h:81
Print an error message and stop the model.
Definition: BaseClass.h:62
vector< vector< int > > l2r
Definition: Output.h:105
Flow from forest operations.
Definition: BaseClass.h:112
int getYear()
Definition: Scheduler.h:49
Invetoried biomass (live and death tree logs)
Definition: BaseClass.h:104
Extra biomass (soils, branches..)
Definition: BaseClass.h:105
Carbon * CBAL
Module for the Carbon Balance.
Definition: ThreadManager.h:79
char d
Definition: Output.h:80
bool oCarbonData
Definition: Output.h:98
Energy substitution.
Definition: BaseClass.h:110
bool oSingleFile
Definition: Output.h:88
Print an INFO message.
Definition: BaseClass.h:59
Biomass in forest products (sawns, pannels..)
Definition: BaseClass.h:106
string scenarioName
Definition: Output.h:85
string regId2RegSName(const int &regId_h) const
Definition: ModelData.cpp:408
string oDir
Definition: Output.h:84

Here is the call graph for this function:

Here is the caller graph for this function:

void printDebugOutput ( )

Definition at line 843 of file Output.cpp.

Referenced by print().

843  {
844  if(oLevel<OUTVL_ALL) return;
845 
846  // print debugging the expected returns...
847 
848  if (!spMode && !expReturnsDebug.empty()){
849  ofstream out (debugFilename.c_str(), ios::app);
850  if (!out){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+debugFilename+" for writing.");}
851  int currentYear = MTHREAD->SCD->getYear();
852  vector <int> regIds2 = MTHREAD->MD->getRegionIds(2);
853 
854  for (uint r2=0;r2<regIds2.size();r2++){
855  for(uint ft=0;ft<fTypes.size();ft++){
856  for(uint dc=0;dc<(dClasses.size()-1);dc++){
857  for(uint pp=0;pp<priPr.size();pp++){
858  for(uint dv=0;dv<expReturnsDebugVariables.size();dv++){
859  // vector <vector < vector <vector <vector <double> > > > > expReturnsDebug;
860  double outputValue = expReturnsDebug.at(r2).at(ft).at(dc).at(pp).at(dv);
861  out << scenarioName << d;
862  out << currentYear << d;
863  out << MTHREAD->MD->regId2RegSName(regIds2[r2]) << d;
864  out << fTypes[ft] << d;
865  out << dClasses[dc] << d;
866  out << priPr[pp] << d;
867  out << expReturnsDebugVariables[dv] << d;
868  out << outputValue << d;
869  out << "\n";
870  }
871  }
872  }
873  }
874  }
875 
876  } // end initial condition checks
877 }
string debugFilename
Definition: Output.h:114
vector< string > dClasses
Definition: Output.h:107
ThreadManager * MTHREAD
Pointer to the Thread manager.
Definition: BaseClass.h:467
ModelData * MD
the model data object
Definition: ThreadManager.h:72
Output verbosity level print everything.
Definition: BaseClass.h:89
vector< string > expReturnsDebugVariables
Definition: Output.h:76
Scheduler * SCD
the scheduler object (simulation-loops scheduler)
Definition: ThreadManager.h:75
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 oLevel
Definition: Output.h:79
Print an error message and stop the model.
Definition: BaseClass.h:62
int getYear()
Definition: Scheduler.h:49
char d
Definition: Output.h:80
vector< string > priPr
Definition: Output.h:101
vector< int > getRegionIds(int level_h, bool excludeResidual=true)
Definition: ModelData.cpp:366
vector< vector< vector< vector< vector< double > > > > > expReturnsDebug
l2_region, for type, d.c., pr prod, variable name
Definition: Output.h:75
vector< string > fTypes
Definition: Output.h:106
string scenarioName
Definition: Output.h:85
bool spMode
Definition: Output.h:116
string regId2RegSName(const int &regId_h) const
Definition: ModelData.cpp:408

Here is the call graph for this function:

Here is the caller graph for this function:

void printDebugPixelValues ( )

Definition at line 880 of file Output.cpp.

Referenced by print().

880  {
881 
882  if(oLevel<OUTVL_ALL) return;
883 
884  bool filter;
885  filter = true; //use this to filter output
886  if(filter && spMode){
887  ofstream out (debugPxValuesFilename.c_str(), ios::app);
888  if (!out){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+debugPxValuesFilename+" for writing.");}
889  int currentYear = MTHREAD->SCD->getYear();
890  vector <int> regIds2 = MTHREAD->MD->getRegionIds(2);
891  for (uint r=0;r<regIds2.size();r++){
892  int rId = regIds2[r];
893  //if(rId != 11002) continue;
894  ModelRegion* REG = MTHREAD->MD->getRegion(rId);
895  vector<Pixel*> regPx = REG->getMyPixels();
896  for (uint p=0;p<regPx.size();p++){
897  Pixel* px = regPx[p];
898  int pxID = px->getID();
899  int pxX = px->getX();
900  int pxY = px->getY();
901  string common = scenarioName + d + i2s(currentYear) + d + i2s(rId) + d+ i2s(pxID) +d +i2s(pxX)+d+i2s(pxY)+d;
902 
903 
904 // for(uint f=0;f<fTypes.size();f++){
905 // double tp_m = px->getMultiplier("tp_multiplier",fTypes[f]);
906 // common += d2s(tp_m)+d;
907 // }
908 // for(uint f=0;f<fTypes.size();f++){
909 // double m_m = px->getMultiplier("mortCoef_multiplier",fTypes[f]);
910 // common += d2s(m_m)+d;
911 // }
912 
913 
914 // // First vars by only ft...
915 // // expectedReturns
916 // out << common << "expectedReturns" << d;
917 // for(uint f=0;f<fTypes.size();f++){
918 // for(uint u=0;u<dClasses.size()-1;u++){
919 // out << d;
920 // }
921 // out << px->expectedReturns[f] << d;
922 // //out << 0.0 << d;
923 // }
924 // out << "\n";
925 
926  //----
927 
928  vector <string> outVars = MTHREAD->MD->getStringVectorSetting("debugVariablesToPrint");
929 
930  if (std::find(outVars.begin(), outVars.end(), "vol") != outVars.end()){
931  out << common <<"vol" << d;
932  for(uint f=0;f<fTypes.size();f++){
933  for(uint u=0;u<dClasses.size()-1;u++){
934  out << px->vol[f][u]<< d;
935  }
936  out << vSum(px->vol[f]) << d;
937  }
938  out << "\n";
939  }
940 
941  if (std::find(outVars.begin(), outVars.end(), "area") != outVars.end()){
942  out << common <<"area" << d;
943  for(uint f=0;f<fTypes.size();f++){
944  for(uint u=0;u<dClasses.size()-1;u++){
945  out << px->area[f][u]<< d;
946  }
947  out << vSum(px->area[f]) << d;
948  }
949  out << "\n";
950  }
951 
952  if (std::find(outVars.begin(), outVars.end(), "hArea") != outVars.end()){
953  out << common <<"hArea" << d;
954  for(uint f=0;f<fTypes.size();f++){
955  for(uint u=0;u<dClasses.size()-1;u++){
956  out << px->hArea[f][u]<< d;
957  }
958  out << vSum(px->hArea[f]) << d;
959  }
960  out << "\n";
961  }
962 
963  if (std::find(outVars.begin(), outVars.end(), "hVol") != outVars.end()){
964  out << common <<"hVol" << d;
965  for(uint f=0;f<fTypes.size();f++){
966  for(uint u=0;u<dClasses.size()-1;u++){
967  out << px->hVol[f][u]<< d;
968  }
969  out << vSum(px->hVol[f]) << d;
970  }
971  out << "\n";
972  }
973 
974  if (std::find(outVars.begin(), outVars.end(), "tp") != outVars.end()){
975  out << common <<"tp" << d;
976  for(uint f=0;f<fTypes.size();f++){
977  for(uint u=0;u<dClasses.size()-1;u++){
978  out << px->tp[f][u]<< d;
979  }
980  out << 0 << d;
981  }
982  out << "\n";
983  }
984 
985  if (std::find(outVars.begin(), outVars.end(), "mort") != outVars.end()){
986  out << common <<"mort" << d;
987  for(uint f=0;f<fTypes.size();f++){
988  for(uint u=0;u<dClasses.size()-1;u++){
989  out << px->mort[f][u]<< d;
990  }
991  out << 0 << d;
992  }
993  out << "\n";
994  }
995 
996  if (std::find(outVars.begin(), outVars.end(), "tp_multiplier") != outVars.end()){
997  out << common <<"tp_multiplier" << d;
998  for(uint f=0;f<fTypes.size();f++){
999  for(uint u=0;u<dClasses.size()-1;u++){
1000  out << d;
1001  }
1002  out << px->getMultiplier("tp_multiplier",fTypes[f]) << d;
1003  }
1004  out << "\n";
1005  }
1006 
1007  if (std::find(outVars.begin(), outVars.end(), "mortCoef_multiplier") != outVars.end()){
1008  out << common <<"mortCoef_multiplier" << d;
1009  for(uint f=0;f<fTypes.size();f++){
1010  for(uint u=0;u<dClasses.size()-1;u++){
1011  out << d;
1012  }
1013  out << px->getMultiplier("mortCoef_multiplier",fTypes[f]) << d;
1014  }
1015  out << "\n";
1016  }
1017 
1018  if (std::find(outVars.begin(), outVars.end(), "vMort") != outVars.end()){
1019  out << common <<"vMort" << d;
1020  for(uint f=0;f<fTypes.size();f++){
1021  for(uint u=0;u<dClasses.size()-1;u++){
1022  out << px->vMort[f][u]<< d;
1023  }
1024  out << vSum(px->vMort[f]) << d;
1025  }
1026  out << "\n";
1027  }
1028 
1029  if (std::find(outVars.begin(), outVars.end(), "vMortAdd") != outVars.end()){
1030  out << common <<"vMortAdd" << d;
1031  for(uint f=0;f<fTypes.size();f++){
1032  for(uint u=0;u<dClasses.size()-1;u++){
1033  out << px->vMortAdd[f][u]<< d;
1034  }
1035  out << vSum(px->vMortAdd[f]) << d;
1036  }
1037  out << "\n";
1038  }
1039 
1040  if (std::find(outVars.begin(), outVars.end(), "optDc") != outVars.end()){
1041  out << common <<"optDc" << d;
1042  for(uint f=0;f<fTypes.size();f++){
1043  for(uint u=0;u<dClasses.size()-1;u++){
1044  out << d;
1045  }
1046  out << px->optDc[f] << d;
1047  }
1048  out << "\n";
1049  }
1050 
1051  if (std::find(outVars.begin(), outVars.end(), "expectedAnnualIncome_timber") != outVars.end()){
1052  out << common <<"expectedAnnualIncome_timber" << d;
1053  for(uint f=0;f<fTypes.size();f++){
1054  for(uint u=0;u<dClasses.size()-1;u++){
1055  out << d;
1056  }
1057  out << px->expectedAnnualIncome_timber[f] << d;
1058  }
1059  out << "\n";
1060  }
1061 
1062  if (std::find(outVars.begin(), outVars.end(), "expectedAnnualIncome_carbon") != outVars.end()){
1063  out << common <<"expectedAnnualIncome_carbon" << d;
1064  for(uint f=0;f<fTypes.size();f++){
1065  for(uint u=0;u<dClasses.size()-1;u++){
1066  out << d;
1067  }
1068  out << px->expectedAnnualIncome_carbon[f] << d;
1069  }
1070  out << "\n";
1071  }
1072 
1073  if (std::find(outVars.begin(), outVars.end(), "expectedReturnsNotCorrByRa") != outVars.end()){
1074  out << common <<"expectedReturnsNotCorrByRa" << d;
1075  for(uint f=0;f<fTypes.size();f++){
1076  for(uint u=0;u<dClasses.size()-1;u++){
1077  out << d;
1078  }
1079  out << px->expectedReturnsNotCorrByRa[f] << d;
1080  }
1081  out << "\n";
1082  }
1083 
1084  if (std::find(outVars.begin(), outVars.end(), "expectedReturns") != outVars.end()){
1085  out << common <<"expectedReturns" << d;
1086  for(uint f=0;f<fTypes.size();f++){
1087  for(uint u=0;u<dClasses.size()-1;u++){
1088  out << d;
1089  }
1090  out << px->expectedReturns[f] << d;
1091  }
1092  out << "\n";
1093  }
1094 
1095  if (std::find(outVars.begin(), outVars.end(), "optFtChosen") != outVars.end()){
1096  out << common <<"optFtChosen" << d;
1097  for(uint f=0;f<fTypes.size();f++){
1098  for(uint u=0;u<dClasses.size()-1;u++){
1099  out << d;
1100  }
1101  out << px->optFtChosen[f] << d;
1102  }
1103  out << "\n";
1104  }
1105 
1106  if (std::find(outVars.begin(), outVars.end(), "optDcChosen") != outVars.end()){
1107  out << common <<"optDcChosen" << d;
1108  for(uint f=0;f<fTypes.size();f++){
1109  for(uint u=0;u<dClasses.size()-1;u++){
1110  out << d;
1111  }
1112  out << px->optDcChosen[f] << d;
1113  }
1114  out << "\n";
1115  }
1116 
1117  if (std::find(outVars.begin(), outVars.end(), "deltaAreas") != outVars.end()){
1118  out << common <<"deltaAreas" << d;
1119  for(uint f=0;f<fTypes.size();f++){
1120  for(uint u=0;u<dClasses.size()-1;u++){
1121  out << d;
1122  }
1123  out << d;
1124  }
1125  for(uint f=0;f<fTypes.size()+1;f++){
1126  for(uint f2=0;f2<fTypes.size()+1;f2++){ // +1 because there is also noforest
1127  out << px->deltaArea[f][f2]<<d;
1128  }
1129  }
1130  out << "\n";
1131  }
1132 
1133 
1134 
1135  } // end for each pixel
1136  } // end for each region
1137  } // end filter
1138 } // end function printDebugPixelValues
vector< vector< double > > deltaArea
Definition: Pixel.h:108
vector< vector< double > > area
Definition: Pixel.h:107
vector< string > dClasses
Definition: Output.h:107
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
int getX() const
Definition: Pixel.h:68
Output verbosity level print everything.
Definition: BaseClass.h:89
vector< vector< double > > mort
Definition: Pixel.h:133
Scheduler * SCD
the scheduler object (simulation-loops scheduler)
Definition: ThreadManager.h:75
vector< vector< double > > vMort
Definition: Pixel.h:118
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
string debugPxValuesFilename
Definition: Output.h:115
vector< double > expectedAnnualIncome_carbon
Definition: Pixel.h:124
vector< string > getStringVectorSetting(const string &name_h, int reg=WORLD) const
Definition: ModelData.cpp:1129
int oLevel
Definition: Output.h:79
Print an error message and stop the model.
Definition: BaseClass.h:62
vector< vector< double > > vMortAdd
Definition: Pixel.h:119
vector< int > optDcChosen
Definition: Pixel.h:123
vector< double > expectedAnnualIncome_timber
Definition: Pixel.h:125
int vSum(const vector< int > &vector_h) const
Definition: BaseClass.h:276
int getYear()
Definition: Scheduler.h:49
Pixel-level class.
Definition: Pixel.h:47
vector< vector< double > > vol
Definition: Pixel.h:90
double getMultiplier(const string &multiplierName, const string &forName, int year=DATA_NOW)
Definition: Pixel.cpp:184
char d
Definition: Output.h:80
vector< int > optFtChosen
Definition: Pixel.h:122
vector< int > optDc
Definition: Pixel.h:121
vector< double > expectedReturns
Definition: Pixel.h:120
vector< vector< double > > tp
Definition: Pixel.h:135
vector< double > expectedReturnsNotCorrByRa
by ft. Attenction, reported expReturns at "forest" level (compared with those at forest type level) d...
Definition: Pixel.h:127
vector< vector< double > > hVol
Definition: Pixel.h:111
vector< int > getRegionIds(int level_h, bool excludeResidual=true)
Definition: ModelData.cpp:366
vector< vector< double > > hArea
Definition: Pixel.h:110
vector< Pixel * > getMyPixels()
Definition: ModelRegion.h:86
ModelRegion * getRegion(int regId_h)
Definition: ModelData.cpp:346
vector< string > fTypes
Definition: Output.h:106
int getY() const
Definition: Pixel.h:69
string scenarioName
Definition: Output.h:85
bool spMode
Definition: Output.h:116
double getID() const
Definition: Pixel.h:67

Here is the call graph for this function:

Here is the caller graph for this function:

void printDetailedHV ( map< tr1::array< string, 4 >, double >  hVol_byPrd)

Definition at line 1173 of file Output.cpp.

Referenced by ModelCoreSpatial::sumRegionalForData().

1173  {
1174  if(!MTHREAD->MD->getBoolSetting("outDetailedHv",DATA_NOW)) return;
1175  outFileName = baseDir+oDir+"results/detailedHV_"+scenarioName+oFileExt;
1176  int currentYear = MTHREAD->SCD->getYear();
1177  ofstream outHV(outFileName.c_str(), ios::app);
1178  if (!outHV){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+outFileName+" for reading.");}
1179  //outHV << "scen" << d << "parName" << d << "country" << d << "region" << d << "forType" << d << "freeDim" << d << "prod" << d << "year" << d << "value" << d;
1180  for (uint r1=0;r1<l2r.size();r1++){
1181  string reg1Id = i2s(l1regIds.at(r1));
1182  string reg1Name = MTHREAD->MD->regId2RegSName(l1regIds.at(r1));
1183  for (uint r2=0;r2<l2r[r1].size();r2++){
1184  string reg2Id = i2s(l2r[r1][r2]);
1185  string reg2Name = MTHREAD->MD->regId2RegSName(l2r[r1][r2]);
1186  for(uint j=0;j<fTypes.size();j++){
1187  string ft = fTypes[j];
1188  for(uint u=0;u<dClasses.size();u++){
1189  string dc = dClasses[u];
1190  if(dc == "") continue;
1191  for(uint p=0;p<priPr.size();p++){
1192  string prd = priPr[p];
1193  tr1::array<string, 4> hVKey = {reg2Id, ft, dc, prd};
1194  double value = findMap(hVol_byPrd,hVKey);
1195  outHV << scenarioName << d;
1196  outHV << "hVbyPrd" << d;
1197  outHV << reg1Name << d;
1198  outHV << reg2Name << d;
1199  outHV << ft << d;
1200  outHV << dc << d;
1201  outHV << prd << d;
1202  outHV << currentYear << d;
1203  outHV << value << d;
1204  outHV << "\n";
1205  }
1206  } //end dc
1207  } //end ft
1208  } // end r2
1209  } // end r1
1210 
1211 
1212  outHV.close();
1213 
1214  }
The required data is for the current year.
Definition: BaseClass.h:73
vector< string > dClasses
Definition: Output.h:107
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
string outFileName
Definition: Output.h:93
Scheduler * SCD
the scheduler object (simulation-loops scheduler)
Definition: ThreadManager.h:75
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
string oFileExt
Definition: Output.h:86
string baseDir
Definition: Output.h:83
vector< int > l1regIds
Definition: Output.h:104
Print an error message and stop the model.
Definition: BaseClass.h:62
vector< vector< int > > l2r
Definition: Output.h:105
int getYear()
Definition: Scheduler.h:49
char d
Definition: Output.h:80
vector< string > priPr
Definition: Output.h:101
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
vector< string > fTypes
Definition: Output.h:106
string scenarioName
Definition: Output.h:85
string regId2RegSName(const int &regId_h) const
Definition: ModelData.cpp:408
string oDir
Definition: Output.h:84

Here is the call graph for this function:

Here is the caller graph for this function:

void printFinalOutput ( )

Definition at line 462 of file Output.cpp.

Referenced by Init::setInitLevel6().

462  {
463  // we do this only if we choosed the outputHumanReadable settings, as we flush the data all in ones at the end.
464  // oterwise we flush data every year
465  if(oHRedeable){
467  printForestData(true);
468  printProductData(true);
470  }
471 }
Print an ERROR message, but don&#39;t stop the model.
Definition: BaseClass.h:61
Do not actually output any message.
Definition: BaseClass.h:57
ThreadManager * MTHREAD
Pointer to the Thread manager.
Definition: BaseClass.h:467
ModelData * MD
the model data object
Definition: ThreadManager.h:72
void printProductData(bool finalFlush)
Definition: Output.cpp:589
bool oHRedeable
Definition: Output.h:87
void setErrorLevel(int errorLevel_h)
Definition: ModelData.h:143
void printForestData(bool finalFlush)
Definition: Output.cpp:474

Here is the call graph for this function:

Here is the caller graph for this function:

void printForestData ( bool  finalFlush)

Definition at line 474 of file Output.cpp.

Referenced by ModelData::getCachedInitialYear(), print(), and printFinalOutput().

474  {
475 
476  if(!oForData) return;
477  if(oHRedeable && !finalFlush) return;
478 
479  msgOut(MSG_INFO, "Printing forest data..");
480  int currentYear = MTHREAD->SCD->getYear();
481  if(oSingleFile){
482  outFileName = baseDir+oDir+"results/forestData"+oFileExt;
483  } else {
484  outFileName = baseDir+oDir+"results/forestData_"+scenarioName+oFileExt;
485  }
486  ofstream out (outFileName.c_str(), ios::app);
487  if (!out){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+outFileName+" for writing.");}
488  double outvalue;
489  for(uint v=0;v<outForVariables.size();v++){
490  vector<string>fTypes_temp = fTypes;
491  if( outForVariables[v]=="expReturns" || outForVariables[v]=="sumExpReturns" || outForVariables[v]=="totalShareInvadedArea") {
492  fTypes_temp.push_back(""); // adding an empty forest type to report for variables that doesn't have a forestType dimension
493  vector<string> ftParents = MTHREAD->MD->getForTypeParents();
494  fTypes_temp.insert(fTypes_temp.end(),ftParents.begin(),ftParents.end()); // also inserting forest type "parents" for expected returns
495  }
496  for (uint r1=0;r1<l2r.size();r1++){
497  for (uint r2=0;r2<l2r[r1].size();r2++){
498  for(uint ft=0;ft<fTypes_temp.size();ft++){
500  for(uint dc=0;dc<dClasses.size();dc++){ // an empty "" dc has been already added to the vector
501  out << scenarioName << d;
502  out << outForVariables[v] << d;
503  out << MTHREAD->MD->regId2RegSName(l1regIds.at(r1)) << d;
504  out << MTHREAD->MD->regId2RegSName(l2r[r1][r2]) << d;
505  out << fTypes_temp[ft] << d;
506  out << dClasses[dc] << d;
507  if (oHRedeable){
508  for(int y=0;y<nYears;y++){
509  outvalue = MTHREAD->MD->getForData(outForVariables[v],l2r[r1][r2],fTypes_temp[ft],dClasses[dc],y+inYear);
510  out << outvalue << d;
511  }
512  out << "\n";
513  } else {
514  outvalue = MTHREAD->MD->getForData(outForVariables[v],l2r[r1][r2],fTypes_temp[ft],dClasses[dc]);
515  out << currentYear << d;
516  out << outvalue << d;
517  out << "\n";
518  }
519  }
520  } else {
521  out << scenarioName << d;
522  out << outForVariables[v] << d;
523  out << MTHREAD->MD->regId2RegSName(l1regIds.at(r1)) << d;
524  out << MTHREAD->MD->regId2RegSName(l2r[r1][r2]) << d;
525  out << fTypes_temp[ft] << d;
526  out << d;
527  if (oHRedeable){
528  for(int y=0;y<nYears;y++){
529  outvalue = MTHREAD->MD->getForData(outForVariables[v],l2r[r1][r2],fTypes_temp[ft],DIAM_ALL,y+inYear);
530  out << outvalue << d;
531  }
532  out << "\n";
533  } else {
534  outvalue = MTHREAD->MD->getForData(outForVariables[v],l2r[r1][r2],fTypes_temp[ft],DIAM_ALL);
535  out << currentYear << d;
536  out << outvalue << d;
537  out << "\n";
538  }
539  }
540  }
541  }
542  }
543  }
544  /*
545  DataMap::const_iterator i;
546  string key;
547  vector <double> values;
548  string parName;
549  int regId;
550  string forType;
551  string diamClass;
552  for(i=MTHREAD->MD->forDataMap.begin();i!=MTHREAD->MD->forDataMap.end();i++){
553  key = i->first;
554  values = i->second;
555  MTHREAD->MD->unpackKeyForData(key, parName, regId, forType, diamClass);
556  ModelRegion* REG = MTHREAD->MD->getRegion(regId);
557  // we don't want to output data from residual region unless it's the world region we are speaking of
558  if(REG->getIsResidual() && !(regId==wRegId_l1 || regId==wRegId_l2)) continue;
559  out << scenarioName << d;
560  out << parName << d;
561  if (REG->getRegLevel()==2){
562  ModelRegion* pREG = MTHREAD->MD->getRegion(REG->getParRegId());
563  out << pREG->getRegSName() << d;
564  out << REG->getRegSName() << d;
565  } else if (REG->getRegLevel()==1){
566  out << REG->getRegSName() << d;
567  out << d;
568  } else {
569  out << d << d;
570  }
571  out << forType << d;
572  out << diamClass << d;
573  if (oHRedeable){
574  for(int y=0;y<nYears;y++){
575  out << MTHREAD->MD->getTimedData(values,y+inYear) << d;
576  }
577  out << "\n";
578  } else {
579  out << currentYear << d;
580  out << MTHREAD->MD->getTimedData(values,currentYear) << d;
581  out << "\n";
582  }
583  }
584  */
585  out.close();
586 }
vector< string > getForTypeParents()
Definition: ModelData.cpp:122
vector< string > dClasses
Definition: Output.h:107
ThreadManager * MTHREAD
Pointer to the Thread manager.
Definition: BaseClass.h:467
ModelData * MD
the model data object
Definition: ThreadManager.h:72
string outFileName
Definition: Output.h:93
Scheduler * SCD
the scheduler object (simulation-loops scheduler)
Definition: ThreadManager.h:75
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
string oFileExt
Definition: Output.h:86
string baseDir
Definition: Output.h:83
vector< int > l1regIds
Definition: Output.h:104
int inYear
Definition: Output.h:81
bool oHRedeable
Definition: Output.h:87
Print an error message and stop the model.
Definition: BaseClass.h:62
vector< vector< int > > l2r
Definition: Output.h:105
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
int getYear()
Definition: Scheduler.h:49
char d
Definition: Output.h:80
bool oForData
Definition: Output.h:96
int nYears
Definition: Output.h:82
bool oSingleFile
Definition: Output.h:88
bool forestDiamDetailedOutput
Definition: Output.h:100
Print an INFO message.
Definition: BaseClass.h:59
#define DIAM_ALL
All diameter classes.
Definition: BaseClass.h:157
vector< string > fTypes
Definition: Output.h:106
string scenarioName
Definition: Output.h:85
string regId2RegSName(const int &regId_h) const
Definition: ModelData.cpp:408
string oDir
Definition: Output.h:84
vector< string > outForVariables
Definition: Output.h:94

Here is the call graph for this function:

Here is the caller graph for this function:

void printMaps ( )

Definition at line 451 of file Output.cpp.

Referenced by print().

451  {
452  if(oLevel<OUTVL_MAPS) return;
453  int cYear = MTHREAD->SCD->getYear();
454  if ( find(mapsOYears.begin(), mapsOYears.end(), cYear) != mapsOYears.end() ){
455  MTHREAD->GIS->printLayers();
456  if(oLevel<OUTVL_BINMAPS) return;
458  }
459 }
vector< int > mapsOYears
Definition: Output.h:90
ThreadManager * MTHREAD
Pointer to the Thread manager.
Definition: BaseClass.h:467
Output verbosity level print (also) the maps in ascii grid format.
Definition: BaseClass.h:87
Scheduler * SCD
the scheduler object (simulation-loops scheduler)
Definition: ThreadManager.h:75
Gis * GIS
GIS information and methods.
Definition: ThreadManager.h:73
int oLevel
Definition: Output.h:79
Output verbosity level print (also) binary (png) maps.
Definition: BaseClass.h:88
void printBinMaps(string layerName_h="")
Save an image in standard png format.
Definition: Gis.cpp:963
int getYear()
Definition: Scheduler.h:49
void printLayers(string layerName_h="")
Print the specified layer or all layers (if param layerName_h is missing).
Definition: Gis.cpp:940

Here is the call graph for this function:

Here is the caller graph for this function:

void printOptLog ( bool  optimal,
int &  nIterations,
double &  obj 
)

Definition at line 827 of file Output.cpp.

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

827  {
828  if(oLevel<OUTVL_AGGREGATED) return;
829 
830  ofstream out(logFilename.c_str(), ios::app);
831  if (!out){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+logFilename+" for writing.");}
832  time_t now;
833  time(&now);
834  struct tm *current = localtime(&now);
835  string timemessage = i2s(current->tm_hour)+":"+i2s(current->tm_min)+":"+ i2s(current->tm_sec);
836  out << scenarioName << d << MTHREAD->SCD->getYear() << d << timemessage << d << optimal;
837  out << d << nIterations << d << obj << "\n";
838  out.close();
839 
840 }
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
string logFilename
Definition: Output.h:113
Scheduler * SCD
the scheduler object (simulation-loops scheduler)
Definition: ThreadManager.h:75
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 oLevel
Definition: Output.h:79
Output verbosity level print aggregated output (e.g. optimisation log)
Definition: BaseClass.h:85
Print an error message and stop the model.
Definition: BaseClass.h:62
int getYear()
Definition: Scheduler.h:49
char d
Definition: Output.h:80
string scenarioName
Definition: Output.h:85

Here is the call graph for this function:

Here is the caller graph for this function:

void printProductData ( bool  finalFlush)

Definition at line 589 of file Output.cpp.

Referenced by ModelData::getCachedInitialYear(), print(), and printFinalOutput().

589  {
590 
591  if(!oProdData) return;
592  if(oHRedeable && !finalFlush) return;
593 
594  msgOut(MSG_INFO, "Printing market data..");
595  int currentYear = MTHREAD->SCD->getYear();
596 
597  if(oSingleFile){
598  outFileName = baseDir+oDir+"results/productData"+oFileExt;
599  } else {
600  outFileName = baseDir+oDir+"results/productData_"+scenarioName+oFileExt;
601  }
602  ofstream out (outFileName.c_str(), ios::app);
603  if (!out){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+outFileName+" for writing.");}
604 
605 
606  //11042 hardWSawnW 11083 0.00230651
607  //11042 hardWSawnW 11082 0.0390874
608 
609  //if(MTHREAD->SCD->getYear() == 2007){
610 // double test = MTHREAD->MD->getProdData("rt",11042,"hardWSawnW",DATA_NOW);
611 // double test2 = MTHREAD->MD->getProdData("rt",11042,"hardWSawnW",DATA_NOW,"11083");
612 // double test3 = MTHREAD->MD->getProdData("rt",11042,"hardWSawnW",DATA_NOW,"11082");
613 // cout << test << '\t' << test2 << '\t' << test3 << endl;
614 // exit(0);
615 // }
616 
617  double outvalue;
618  for(uint v=0;v<outProdVariables.size();v++){
619  for (uint r1=0;r1<l2r.size();r1++){
620  for (uint r2=0;r2<l2r[r1].size();r2++){
621  for(uint p=0;p<allPr.size();p++){
622 
623  if(outProdVariables[v]=="rt"){
624  for(uint r2b=0;r2b<l2r[r1].size();r2b++){
625  out << scenarioName << d;
626  out << outProdVariables[v] << d;
627  out << MTHREAD->MD->regId2RegSName(l1regIds.at(r1)) << d;
628  out << MTHREAD->MD->regId2RegSName(l2r[r1][r2]) << d;
629  out << allPr[p] << d;
630  out << l2r[r1][r2b] << d;
631  if (oHRedeable){
632  for(int y=0;y<nYears;y++){
633  outvalue = MTHREAD->MD->getProdData(outProdVariables[v],l2r[r1][r2],allPr[p],y+inYear,i2s(l2r[r1][r2b]));
634  out << outvalue << d;
635  }
636  out << "\n";
637  } else {
638 // if(MTHREAD->SCD->getYear() == 2007 && l2r[r1][r2] == 11042 && allPr[p] == "hardWSawnW" && (l2r[r1][r2b]== 11083 || l2r[r1][r2b]== 11082 )){
639 // outvalue = MTHREAD->MD->getProdData(outProdVariables[v],l2r[r1][r2],allPr[p],currentYear,i2s(l2r[r1][r2b]));
640 // cout << outvalue << endl;
641 // }
642  outvalue = MTHREAD->MD->getProdData(outProdVariables[v],l2r[r1][r2],allPr[p],currentYear,i2s(l2r[r1][r2b]));
643  out << currentYear << d;
644  out << outvalue << d;
645  out << "\n";
646  }
647  }
648  } else {
649  out << scenarioName << d;
650  out << outProdVariables[v] << d;
651  out << MTHREAD->MD->regId2RegSName(l1regIds.at(r1)) << d;
652  out << MTHREAD->MD->regId2RegSName(l2r[r1][r2]) << d;
653  out << allPr[p] << d;
654  out << d;
655  if (oHRedeable){
656  for(int y=0;y<nYears;y++){
657  outvalue = MTHREAD->MD->getProdData(outProdVariables[v],l2r[r1][r2],allPr[p],y+inYear);
658  out << outvalue << d;
659  }
660  out << "\n";
661  } else {
662  outvalue = MTHREAD->MD->getProdData(outProdVariables[v],l2r[r1][r2],allPr[p]);
663  out << currentYear << d;
664  out << outvalue << d;
665  out << "\n";
666  }
667 
668  }
669  }
670  }
671  }
672  }
673 
674 
675 
676 
677 /*
678  DataMap::const_iterator i;
679  string key;
680  vector <double> values;
681  string parName;
682  int regId;
683  string prod;
684  string freeDim;
685  for(i=MTHREAD->MD->prodDataMap.begin();i!=MTHREAD->MD->prodDataMap.end();i++){
686  key = i->first;
687  values = i->second;
688  MTHREAD->MD->unpackKeyProdData(key, parName, regId, prod, freeDim);
689  ModelRegion* REG = MTHREAD->MD->getRegion(regId);
690  // we don't want to output data from residual region unless it's the world region we are speaking of
691  if(REG->getIsResidual() && !(regId==wRegId_l1 || regId==wRegId_l2)) continue;
692  out << scenarioName << d;
693  out << parName << d;
694  if (REG->getRegLevel()==2){
695  ModelRegion* pREG = MTHREAD->MD->getRegion(REG->getParRegId());
696  out << pREG->getRegSName() << d;
697  out << REG->getRegSName() << d;
698  } else if (REG->getRegLevel()==1){
699  out << REG->getRegSName() << d;
700  out << d;
701  } else {
702  out << d << d;
703  }
704  out << prod << d;
705  out << freeDim << d;
706  if (oHRedeable){
707  for(int y=0;y<nYears;y++){
708  out << MTHREAD->MD->getTimedData(values,y+inYear) << d;
709  }
710  out << "\n";
711  } else {
712  out << currentYear << d;
713  out << MTHREAD->MD->getTimedData(values,currentYear) << d;
714  out << "\n";
715  }
716  }
717 
718 */
719  out.close();
720 }
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
string outFileName
Definition: Output.h:93
Scheduler * SCD
the scheduler object (simulation-loops scheduler)
Definition: ThreadManager.h:75
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
string oFileExt
Definition: Output.h:86
string baseDir
Definition: Output.h:83
vector< int > l1regIds
Definition: Output.h:104
int inYear
Definition: Output.h:81
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
bool oHRedeable
Definition: Output.h:87
Print an error message and stop the model.
Definition: BaseClass.h:62
vector< string > allPr
Definition: Output.h:103
vector< vector< int > > l2r
Definition: Output.h:105
int getYear()
Definition: Scheduler.h:49
char d
Definition: Output.h:80
vector< string > outProdVariables
Definition: Output.h:95
int nYears
Definition: Output.h:82
bool oSingleFile
Definition: Output.h:88
Print an INFO message.
Definition: BaseClass.h:59
bool oProdData
Definition: Output.h:97
string scenarioName
Definition: Output.h:85
string regId2RegSName(const int &regId_h) const
Definition: ModelData.cpp:408
string oDir
Definition: Output.h:84

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

vector<string> allPr
private

Definition at line 103 of file Output.h.

Referenced by commonInit(), and printProductData().

vector<string> dClasses
private
string debugFilename
private

Definition at line 114 of file Output.h.

Referenced by initDebugOutput(), and printDebugOutput().

string debugPxValuesFilename
private

Definition at line 115 of file Output.h.

Referenced by initDebugPixelValues(), and printDebugPixelValues().

vector<vector < vector <vector <vector <double> > > > > expReturnsDebug

l2_region, for type, d.c., pr prod, variable name

Definition at line 75 of file Output.h.

Referenced by printDebugOutput(), and ModelCore::runManagementModule().

vector<string> expReturnsDebugVariables

Definition at line 76 of file Output.h.

Referenced by initDebugOutput(), and printDebugOutput().

bool forestDiamDetailedOutput
private

Definition at line 100 of file Output.h.

Referenced by commonInit(), and printForestData().

vector<string> fTypes
private
vector<int> l1regIds
private
vector< vector <int> > l2r
private
string logFilename
private

Definition at line 113 of file Output.h.

Referenced by initOptimisationLog(), and printOptLog().

vector<int> mapsOYears
private

Definition at line 90 of file Output.h.

Referenced by commonInit(), and printMaps().

int nAllPr
private

Definition at line 111 of file Output.h.

Referenced by commonInit().

int nL2r
private

Definition at line 112 of file Output.h.

Referenced by commonInit().

int nPriPr
private

Definition at line 109 of file Output.h.

Referenced by commonInit().

int nSecPr
private

Definition at line 110 of file Output.h.

Referenced by commonInit().

int nYears
private
bool oCarbonData
private

Definition at line 98 of file Output.h.

Referenced by commonInit(), initCarbonBalance(), and printCarbonBalance().

bool oForData
private

Definition at line 96 of file Output.h.

Referenced by commonInit(), initOutputForestData(), and printForestData().

bool oHRedeable
private
bool oProdData
private

Definition at line 97 of file Output.h.

Referenced by commonInit(), initOutputProductData(), and printProductData().

vector<string> outForVariables
private

Definition at line 94 of file Output.h.

Referenced by commonInit(), and printForestData().

vector<string> outProdVariables
private

Definition at line 95 of file Output.h.

Referenced by commonInit(), and printProductData().

int outStepRange
private

Definition at line 99 of file Output.h.

Referenced by commonInit(), and print().

vector<int> oYears
private

Definition at line 89 of file Output.h.

Referenced by commonInit(), and print().

vector<string> pDClasses
private

includes an empty string for variables without diameter attribute

production diameter classes: exclude the fist diameter class below 15 cm

Definition at line 108 of file Output.h.

Referenced by commonInit().

vector<string> priPr
private

Definition at line 101 of file Output.h.

Referenced by commonInit(), printDebugOutput(), and printDetailedHV().

vector<string> secPr
private

Definition at line 102 of file Output.h.

Referenced by commonInit().

bool spMode
private
int wRegId_l1
private

Definition at line 91 of file Output.h.

Referenced by commonInit().

int wRegId_l2
private

Definition at line 92 of file Output.h.

Referenced by commonInit().


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