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 1123 of file Output.cpp.

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

1123  {
1124  string dStr(&d,1);
1125  vector <string> rows;
1126  string tempRow;
1127  ifstream inFile (fileName.c_str(), ios::in);
1128  if (!inFile){
1129  msgOut(MSG_ERROR,"Error in opening the file "+fileName+" for reading.");
1130  return;
1131  }
1132  while( getline (inFile,tempRow) ){
1133  vector<string> tokens;
1134  tokenize(tempRow,tokens,dStr);
1135  if(tokens[0] != scenarioName)
1136  rows.push_back( tempRow );
1137  }
1138  inFile.close();
1139  ofstream out(fileName.c_str(), ios::out);
1140  for(uint i=0;i<rows.size();i++){
1141  out << rows[i];
1142  out << "\n";
1143  }
1144 }
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:804
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 804 of file Output.cpp.

Referenced by commonInit().

804  {
805  int delimiterID = MTHREAD->MD->getIntSetting("outputFieldDelimiter");
806  switch (delimiterID) {
807  case 1:
808  return ',';
809  break;
810  case 2:
811  return ';';
812  break;
813  case 3:
814  return ':';
815  break;
816  case 4:
817  return '\t';
818  break;
819  case 5:
820  return ' ';
821  break;
822  default:
823  msgOut(MSG_ERROR, "You have specified an unknow output file field delimiter. Using \";\".");
824  return ',';
825  }
826 }
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:1123
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:1123
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:1123
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:1123
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:1123
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:1123
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 
441  cout << "printing " << cYear << endl;
442  printMaps();
444  printForestData(false);
445  printProductData(false);
448  if(!earlyPrint) printDebugPixelValues();
450 }
void printDebugOutput()
Definition: Output.cpp:845
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:729
ThreadManager * MTHREAD
Pointer to the Thread manager.
Definition: BaseClass.h:467
void printMaps()
Definition: Output.cpp:453
void printDebugPixelValues()
Definition: Output.cpp:882
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:591
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:476

Here is the call graph for this function:

Here is the caller graph for this function:

void printCarbonBalance ( )

Definition at line 729 of file Output.cpp.

Referenced by print().

729  {
730 
731  if(!oCarbonData) return;
732  int currentYear = MTHREAD->SCD->getYear();
733  if (currentYear == inYear) {return;} // don't print carbon balance on first year, carbon balance containers has not yet been initialised
734 
735  msgOut(MSG_INFO, "Printing forest data..");
736 
737  if(oSingleFile){
738  outFileName = baseDir+oDir+"results/carbonBalance"+oFileExt;
739  } else {
740  outFileName = baseDir+oDir+"results/carbonBalance_"+scenarioName+oFileExt;
741  }
742  ofstream out (outFileName.c_str(), ios::app);
743  if (!out){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+outFileName+" for writing.");}
744  double outvalue=0;
745 
747 
748  for (uint r1=0;r1<l2r.size();r1++){
749  for (uint r2=0;r2<l2r[r1].size();r2++){
750  int regId = l2r[r1][r2];
751  for (uint b=0;b<balItems.size();b++){
752  out << scenarioName << d;
753  out << MTHREAD->MD->regId2RegSName(l1regIds.at(r1)) << d;
754  out << MTHREAD->MD->regId2RegSName(l2r[r1][r2]) << d;
755  string balItemString;
756  switch(balItems[b]){
757  case STOCK_INV: {
758  balItemString = "STOCK_INV";
759  outvalue = MTHREAD->CBAL->getStock(regId, balItems[b]);
760  break;
761  }
762  case STOCK_EXTRA: {
763  balItemString = "STOCK_EXTRA";
764  outvalue = MTHREAD->CBAL->getStock(regId, balItems[b]);
765  break;
766  }
767  case STOCK_PRODUCTS: {
768  balItemString = "STOCK_PRODUCTS";
769  outvalue = MTHREAD->CBAL->getStock(regId, balItems[b]);
770  break;
771  }
772  case EM_ENSUB: {
773  balItemString = "EM_ENSUB";
774  outvalue = MTHREAD->CBAL->getCumSavedEmissions(regId, balItems[b]);
775  break;
776  }
777  case EM_MATSUB: {
778  balItemString = "EM_MATSUB";
779  outvalue = MTHREAD->CBAL->getCumSavedEmissions(regId, balItems[b]);
780  break;
781  }
782  case EM_FOROP: {
783  balItemString = "EM_FOROP";
784  outvalue = MTHREAD->CBAL->getCumSavedEmissions(regId, balItems[b]);
785  break;
786  }
787  default:
788  msgOut(MSG_CRITICAL_ERROR,"Unexpected balance item type in function printCarbonBalance");
789  }
790  out << balItemString << d;
791  out << currentYear << d;
792  out << outvalue << d;
793  out << "\n";
794 
795 
796  } // end bal items
797  } // end r2
798  } // end r1
799  out.close();
800 }
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 845 of file Output.cpp.

Referenced by print().

845  {
846  if(oLevel<OUTVL_ALL) return;
847 
848  // print debugging the expected returns...
849 
850  if (!spMode && !expReturnsDebug.empty()){
851  ofstream out (debugFilename.c_str(), ios::app);
852  if (!out){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+debugFilename+" for writing.");}
853  int currentYear = MTHREAD->SCD->getYear();
854  vector <int> regIds2 = MTHREAD->MD->getRegionIds(2);
855 
856  for (uint r2=0;r2<regIds2.size();r2++){
857  for(uint ft=0;ft<fTypes.size();ft++){
858  for(uint dc=0;dc<(dClasses.size()-1);dc++){
859  for(uint pp=0;pp<priPr.size();pp++){
860  for(uint dv=0;dv<expReturnsDebugVariables.size();dv++){
861  // vector <vector < vector <vector <vector <double> > > > > expReturnsDebug;
862  double outputValue = expReturnsDebug.at(r2).at(ft).at(dc).at(pp).at(dv);
863  out << scenarioName << d;
864  out << currentYear << d;
865  out << MTHREAD->MD->regId2RegSName(regIds2[r2]) << d;
866  out << fTypes[ft] << d;
867  out << dClasses[dc] << d;
868  out << priPr[pp] << d;
869  out << expReturnsDebugVariables[dv] << d;
870  out << outputValue << d;
871  out << "\n";
872  }
873  }
874  }
875  }
876  }
877 
878  } // end initial condition checks
879 }
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 882 of file Output.cpp.

Referenced by print().

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

Referenced by ModelCoreSpatial::sumRegionalForData().

1147  {
1148  if(!MTHREAD->MD->getBoolSetting("outDetailedHv",DATA_NOW)) return;
1149  outFileName = baseDir+oDir+"results/detailedHV_"+scenarioName+oFileExt;
1150  int currentYear = MTHREAD->SCD->getYear();
1151  ofstream outHV(outFileName.c_str(), ios::app);
1152  if (!outHV){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+outFileName+" for reading.");}
1153  //outHV << "scen" << d << "parName" << d << "country" << d << "region" << d << "forType" << d << "freeDim" << d << "prod" << d << "year" << d << "value" << d;
1154  for (uint r1=0;r1<l2r.size();r1++){
1155  string reg1Id = i2s(l1regIds.at(r1));
1156  string reg1Name = MTHREAD->MD->regId2RegSName(l1regIds.at(r1));
1157  for (uint r2=0;r2<l2r[r1].size();r2++){
1158  string reg2Id = i2s(l2r[r1][r2]);
1159  string reg2Name = MTHREAD->MD->regId2RegSName(l2r[r1][r2]);
1160  for(uint j=0;j<fTypes.size();j++){
1161  string ft = fTypes[j];
1162  for(uint u=0;u<dClasses.size();u++){
1163  string dc = dClasses[u];
1164  if(dc == "") continue;
1165  for(uint p=0;p<priPr.size();p++){
1166  string prd = priPr[p];
1167  tr1::array<string, 4> hVKey = {reg2Id, ft, dc, prd};
1168  double value = findMap(hVol_byPrd,hVKey);
1169  outHV << scenarioName << d;
1170  outHV << "hVbyPrd" << d;
1171  outHV << reg1Name << d;
1172  outHV << reg2Name << d;
1173  outHV << ft << d;
1174  outHV << dc << d;
1175  outHV << prd << d;
1176  outHV << currentYear << d;
1177  outHV << value << d;
1178  outHV << "\n";
1179  }
1180  } //end dc
1181  } //end ft
1182  } // end r2
1183  } // end r1
1184 
1185 
1186  outHV.close();
1187 
1188  }
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 464 of file Output.cpp.

Referenced by Init::setInitLevel6().

464  {
465  // we do this only if we choosed the outputHumanReadable settings, as we flush the data all in ones at the end.
466  // oterwise we flush data every year
467  if(oHRedeable){
469  printForestData(true);
470  printProductData(true);
472  }
473 }
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:591
bool oHRedeable
Definition: Output.h:87
void setErrorLevel(int errorLevel_h)
Definition: ModelData.h:143
void printForestData(bool finalFlush)
Definition: Output.cpp:476

Here is the call graph for this function:

Here is the caller graph for this function:

void printForestData ( bool  finalFlush)

Definition at line 476 of file Output.cpp.

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

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

Referenced by print().

453  {
454  if(oLevel<OUTVL_MAPS) return;
455  int cYear = MTHREAD->SCD->getYear();
456  if ( find(mapsOYears.begin(), mapsOYears.end(), cYear) != mapsOYears.end() ){
457  MTHREAD->GIS->printLayers();
458  if(oLevel<OUTVL_BINMAPS) return;
460  }
461 }
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 829 of file Output.cpp.

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

829  {
830  if(oLevel<OUTVL_AGGREGATED) return;
831 
832  ofstream out(logFilename.c_str(), ios::app);
833  if (!out){ msgOut(MSG_CRITICAL_ERROR,"Error in opening the file "+logFilename+" for writing.");}
834  time_t now;
835  time(&now);
836  struct tm *current = localtime(&now);
837  string timemessage = i2s(current->tm_hour)+":"+i2s(current->tm_min)+":"+ i2s(current->tm_sec);
838  out << scenarioName << d << MTHREAD->SCD->getYear() << d << timemessage << d << optimal;
839  out << d << nIterations << d << obj << "\n";
840  out.close();
841 
842 }
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 591 of file Output.cpp.

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

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