Nemo  2.3.46
StatServices Class Reference

The Service class used to manage the StatHandler objects. More...

#include <statservices.h>

+ Inheritance diagram for StatServices:
+ Collaboration diagram for StatServices:

Public Types

typedef list< StatHandlerBase * >
::const_iterator 
stat_it
 
typedef list< StatRecBase * >
::const_iterator 
rec_it
 

Public Member Functions

 StatServices ()
 
virtual ~StatServices ()
 
virtual bool init ()
 
Metapopget_pop_ptr ()
 
void set_pop_ptr (Metapop *pop)
 
void set (string &str, unsigned int occ)
 
void setStatOptions (string &str)
 
string & getStatArg ()
 
unsigned int getOccurrence ()
 
void setOcccurrence (unsigned int value)
 
void setOccurrences (map< unsigned int, unsigned int > timeTable)
 Sets the list of generation for which statistics must be recorded during a run. More...
 
unsigned int getNumOccurrences ()
 Returns the maximum number of generation records per replicate. More...
 
unsigned int getNumOccurrences (unsigned int replicate)
 Returns the number of generation records present in the stat table for a replicate. More...
 
unsigned int getCurrentOccurrence ()
 Returns the last generation recorded for current replicate. More...
 
void resetCurrentOccurrence ()
 Resets the occurrence iterator to the beginning of the list of generation occurrences. More...
 
void printStatHeaders (ofstream &FH)
 
void doPrintAverages ()
 
void cancelPrintAverages ()
 
bool getPrintAveragesOpt ()
 
void printStatValue (ofstream &FH, unsigned int repl_idx)
 Prints the stat values to the '.txt' output file. More...
 
void printStatAverage (ofstream &FH)
 
void setCompactOutputFormat ()
 
void setFieldWidth (unsigned int val)
 
void setFieldPrecision (unsigned int val)
 
void setFieldSeparator (unsigned char c)
 
void setDefaultOutputFormat ()
 
list< StatRecBase * > getAllStats ()
 
unsigned int getNumStats ()
 
stat_it getFirst ()
 
stat_it getLast ()
 
vector< double * > * getReplicateStatRecords (unsigned int replicate)
 
double * getGenerationStatValues (unsigned int replicate, unsigned int occurence) const
 
void copyGenerationStatValues (unsigned int replicate, unsigned int occurence, double *values, unsigned int size)
 
void recordStats (unsigned int gen)
 record stat values in stat table by calling all stat recorders. More...
 
virtual void notify ()
 
virtual void load (SimComponent *sc)
 tell the SimComponent to load its stat handlers More...
 
virtual void attach (Handler *H)
 attach the StatHandler to the current list (_statHandlers) of the StatServices More...
 
virtual void reset ()
 clear the list of StatHandler More...
 
void reset_stat_table ()
 Deletes the stat tables. More...
 
- Public Member Functions inherited from Service
 Service ()
 
virtual ~Service ()
 

Private Attributes

Metapop_popPtr
 
list< StatHandlerBase * > _statHandlers
 List of stat handlers declared by currently active simulation components. More...
 
list< StatRecBase * > _statRecorders
 List of stat recorders. More...
 
unsigned int _numRecorders
 Number of stats to record. More...
 
vector< vector< double * > > _statValues
 Table containing all recorded stats, replicate x generation x (num recorders + 2) . More...
 
double * _currentStatValues
 Pointer to the last recorded stats. More...
 
string _statArg
 The string argument of the 'stat' input option. More...
 
unsigned int _occurrence
 Deprecated. More...
 
list< unsigned int_occurrences
 List of all generations to record. More...
 
list< unsigned int >
::const_iterator 
_current_occurrence
 Iterator pointing to the current generation to record. More...
 
unsigned int _width
 
unsigned int _precision
 
unsigned char _separator
 
bool _printAverages
 

Detailed Description

The Service class used to manage the StatHandler objects.

Member Typedef Documentation

typedef list< StatRecBase* >::const_iterator StatServices::rec_it
typedef list< StatHandlerBase* >::const_iterator StatServices::stat_it

Constructor & Destructor Documentation

StatServices::StatServices ( )
inline
100  { }
unsigned int _occurrence
Deprecated.
Definition: statservices.h:75
Metapop * _popPtr
Definition: statservices.h:54
unsigned int _width
Definition: statservices.h:86
bool _printAverages
Definition: statservices.h:90
unsigned int _numRecorders
Number of stats to record.
Definition: statservices.h:63
unsigned int _precision
Definition: statservices.h:86
unsigned char _separator
Definition: statservices.h:88
double * _currentStatValues
Pointer to the last recorded stats.
Definition: statservices.h:69
virtual StatServices::~StatServices ( )
inlinevirtual
102 { reset_stat_table(); }
void reset_stat_table()
Deletes the stat tables.
Definition: statservices.cc:231

Member Function Documentation

void StatServices::attach ( Handler H)
virtual

attach the StatHandler to the current list (_statHandlers) of the StatServices

Parameters
Hthe StatHandler

Implements Service.

References StatHandlerBase::set_service().

Referenced by TProtoBDMI::loadStatServices(), TProtoWolbachia::loadStatServices(), TProtoQuanti::loadStatServices(), TProtoNeutralGenes::loadStatServices(), TProtoDeletMutations_bitstring::loadStatServices(), Metapop::loadStatServices(), and LCE_Selection_base::loadStatServices().

178 {
179  StatHandlerBase* SH = dynamic_cast<StatHandlerBase*> (H);
180 
181  _statHandlers.push_back(SH);
182 
183  SH->set_service(this);
184 }
list< StatHandlerBase * > _statHandlers
List of stat handlers declared by currently active simulation components.
Definition: statservices.h:57
void set_service(StatServices *srv)
Definition: stathandler.h:73
Base class of the StatHandler class, implements the Handler interface.
Definition: stathandler.h:48
void StatServices::cancelPrintAverages ( )
inline

Referenced by LCE_StatServiceNotifier::loadStatServices().

143 {_printAverages = 0;}
bool _printAverages
Definition: statservices.h:90
void StatServices::copyGenerationStatValues ( unsigned int  replicate,
unsigned int  occurence,
double *  values,
unsigned int  size 
)
inline
184  {
185  assert( _statValues[ replicate-1 ].size() < _occurrences.size() );
186 
187  assert( size == _numRecorders+2);
188 
189  double* new_record = new double[size];
190 
191  memcpy(new_record, values, size*sizeof(double));
192 
193  _statValues[ replicate-1 ].push_back(new_record);
194  }
list< unsigned int > _occurrences
List of all generations to record.
Definition: statservices.h:78
vector< vector< double * > > _statValues
Table containing all recorded stats, replicate x generation x (num recorders + 2) ...
Definition: statservices.h:66
unsigned int _numRecorders
Number of stats to record.
Definition: statservices.h:63
void StatServices::doPrintAverages ( )
inline

Referenced by LCE_StatServiceNotifier::loadStatServices().

142 {_printAverages = 1;}
bool _printAverages
Definition: statservices.h:90
Metapop* StatServices::get_pop_ptr ( )
inline

Referenced by StatHandlerBase::get_pop_ptr().

106 {return _popPtr;}
Metapop * _popPtr
Definition: statservices.h:54
list< StatRecBase * > StatServices::getAllStats ( )

Referenced by SimRunner::get_allRegisteredStats().

390 {
391  list< StatHandlerBase* >::iterator HIT = _statHandlers.begin();
392 
393  list<StatRecBase*> allStats, stats;
394 
395  while(HIT != _statHandlers.end()) {
396  stats = (*HIT)->getStats();
397  allStats.insert(allStats.end(), stats.begin(), stats.end());
398  HIT++;
399  }
400 
401  return allStats;
402 }
list< StatHandlerBase * > _statHandlers
List of stat handlers declared by currently active simulation components.
Definition: statservices.h:57
unsigned int StatServices::getCurrentOccurrence ( )
inline

Returns the last generation recorded for current replicate.

Referenced by StatHandlerBase::getCurrentOccurrence().

136 {return *_current_occurrence;}
list< unsigned int >::const_iterator _current_occurrence
Iterator pointing to the current generation to record.
Definition: statservices.h:83
stat_it StatServices::getFirst ( )
inline
168 {return _statHandlers.begin();}
list< StatHandlerBase * > _statHandlers
List of stat handlers declared by currently active simulation components.
Definition: statservices.h:57
double* StatServices::getGenerationStatValues ( unsigned int  replicate,
unsigned int  occurence 
) const
inline
178  {
179  assert(occurence < _occurrences.size());
180  return _statValues[ replicate-1 ][ occurence ];
181  }
list< unsigned int > _occurrences
List of all generations to record.
Definition: statservices.h:78
vector< vector< double * > > _statValues
Table containing all recorded stats, replicate x generation x (num recorders + 2) ...
Definition: statservices.h:66
stat_it StatServices::getLast ( )
inline
170 {return _statHandlers.end();}
list< StatHandlerBase * > _statHandlers
List of stat handlers declared by currently active simulation components.
Definition: statservices.h:57
unsigned int StatServices::getNumOccurrences ( )
inline

Returns the maximum number of generation records per replicate.

Referenced by StatHandlerBase::getNumOccurrences().

126 {return _occurrences.size();}
list< unsigned int > _occurrences
List of all generations to record.
Definition: statservices.h:78
unsigned int StatServices::getNumOccurrences ( unsigned int  replicate)
inline

Returns the number of generation records present in the stat table for a replicate.

Parameters
replicatethe replicate number (not the index in the stat table).
132  {
133  return _statValues[replicate-1].size();
134  }
vector< vector< double * > > _statValues
Table containing all recorded stats, replicate x generation x (num recorders + 2) ...
Definition: statservices.h:66
unsigned int StatServices::getNumStats ( )
inline
166 {return _statRecorders.size();}
list< StatRecBase * > _statRecorders
List of stat recorders.
Definition: statservices.h:60
unsigned int StatServices::getOccurrence ( )
inline

Referenced by LCE_StatServiceNotifier::execute(), and StatHandlerBase::getOccurrence().

118 {return _occurrence;}
unsigned int _occurrence
Deprecated.
Definition: statservices.h:75
bool StatServices::getPrintAveragesOpt ( )
inline

Referenced by LCE_StatFH::FHwrite().

144 {return _printAverages;}
bool _printAverages
Definition: statservices.h:90
vector<double*>* StatServices::getReplicateStatRecords ( unsigned int  replicate)
inline
173  {
174  return &_statValues[ replicate-1 ];
175  }
vector< vector< double * > > _statValues
Table containing all recorded stats, replicate x generation x (num recorders + 2) ...
Definition: statservices.h:66
string& StatServices::getStatArg ( )
inline
115 {return _statArg;}
string _statArg
The string argument of the 'stat' input option.
Definition: statservices.h:72
bool StatServices::init ( )
virtual

Implements Service.

References error(), and SIMenv::getReplicates().

Referenced by SimRunner::init_components().

48 {
49  stat_it HIT;
50 
51  HIT = _statHandlers.begin();
52 
53  //first init the stat handlers -> will define the dims of the stat tables
54  while(HIT != _statHandlers.end()) {
55  (*HIT)->init();
56  HIT++;
57  }
58 
59  istringstream stats(_statArg);
60  string arg;
61  list<string> args;
62 
63  //extract the stat options from the string read in the init file
64  while(stats>>arg) args.push_back(arg);
65 
66  list<string>::iterator token = args.begin();
67 
68  bool is_set = false;
69 
70  while(token != args.end()) {
71 
72  HIT = _statHandlers.begin();
73 
74  is_set = false;
75 
76  while(HIT != _statHandlers.end() && !is_set) {
77  is_set |= (*HIT)->setStatRecorders( (*token) );
78  HIT++;
79  }
80 
81  if(!is_set) {
82  error("the string \"%s\" is not a valid stat option\n",(*token).c_str());
83  return false;
84  }
85 
86  token++;
87  }
88 
89  //---- set the list of stat recorders:
90  _statRecorders.clear();
91 
92  for (HIT = _statHandlers.begin(); HIT != _statHandlers.end(); ++HIT) {
93 
94  _statRecorders.splice(_statRecorders.end(), (*HIT)->getStats());
95  //this removes the recorders from the handler's list (in principle)
96  //this means we need to delete the recorders within the StatServices!!
97  }
98 
100 
101 
102  //---- set iterator to first generation occurrence to record
104  //this is safe as the occurrence list is set before init() is called.
105 
106 // //reset output option for per-gen mean stats
107 // _printAverages = 1; //this resets user-defined option!!
108 
109  //---- set the stat table:
111 
112  for (unsigned int i = 0; i < SIMenv::getReplicates(); ++i) {
113  _statValues.push_back(vector<double*>());
114  }
115 
116  return true;
117 }
static unsigned int getReplicates()
Definition: simenv.h:63
list< StatRecBase * > _statRecorders
List of stat recorders.
Definition: statservices.h:60
list< StatHandlerBase * > _statHandlers
List of stat handlers declared by currently active simulation components.
Definition: statservices.h:57
list< unsigned int > _occurrences
List of all generations to record.
Definition: statservices.h:78
int error(const char *str,...)
Definition: output.cc:73
vector< vector< double * > > _statValues
Table containing all recorded stats, replicate x generation x (num recorders + 2) ...
Definition: statservices.h:66
unsigned int _numRecorders
Number of stats to record.
Definition: statservices.h:63
void reset_stat_table()
Deletes the stat tables.
Definition: statservices.cc:231
list< unsigned int >::const_iterator _current_occurrence
Iterator pointing to the current generation to record.
Definition: statservices.h:83
string _statArg
The string argument of the 'stat' input option.
Definition: statservices.h:72
list< StatHandlerBase * >::const_iterator stat_it
Definition: statservices.h:94
void StatServices::load ( SimComponent sc)
virtual

tell the SimComponent to load its stat handlers

Parameters
scthe SimComponent

Implements Service.

References SimComponent::loadStatServices().

Referenced by SimRunner::register_component().

171 {
172  sc->loadStatServices(this);
173 }
virtual void loadStatServices(StatServices *loader)=0
Loads the component's StatHandler onto the StatServices.
void StatServices::notify ( )
virtual

Implements Service.

References SIMenv::getCurrentGeneration(), and message().

Referenced by LCE_StatServiceNotifier::execute().

189 {
190 #ifdef _DEBUG_
191  message("StatServices::notify (%i/%i): ", SIMenv::getCurrentGeneration(),
193  fflush(stdout);
194 #endif
195 
199  }
200 
201 #ifdef _DEBUG_
202  message("\n");
203 #endif
204 }
void message(const char *message,...)
Definition: output.cc:40
static unsigned int getCurrentGeneration()
Definition: simenv.h:60
list< unsigned int >::const_iterator _current_occurrence
Iterator pointing to the current generation to record.
Definition: statservices.h:83
void recordStats(unsigned int gen)
record stat values in stat table by calling all stat recorders.
Definition: statservices.cc:246
void StatServices::printStatAverage ( ofstream &  FH)

References SIMenv::getReplicates().

Referenced by LCE_StatFH::PrintStat_byGen().

329 {
330  vector< double > means;
331  unsigned int num_repl = SIMenv::getReplicates(), rep_cntr;
332  unsigned int num_gen = getNumOccurrences();
333  unsigned int current_gen = 0;
334 
335  //print the first row with stats headers:
336 // FH.setf(ios::left,ios::adjustfield);
337  FH << setw(_width) << left <<"generation";
338 
339  //print the stat names:
340  printStatHeaders(FH);
341 
342  FH<< _separator << setw(_width) << "alive.rpl" << endl;
343 
344 // FH << setprecision(_precision);
345 
346  for (unsigned int gen = 0; gen < num_gen; ++gen) {
347 
348  rep_cntr = 0;
349 
350  means.assign(_numRecorders,0);
351 
352  for (unsigned int rep = 0; rep < num_repl; ++rep) {
353 
354  //verify if this replicate was not extinct at this generation
355  if ( _statValues[ rep ].size() > gen ) rep_cntr++;
356  else continue; //skip this replicate
357 
358  for (unsigned int j = 0; j < _numRecorders; ++j) {
359  means[j] += _statValues[rep][gen][j+2]; //two first are replicate and generation
360  }
361  current_gen = _statValues[rep][gen][1];
362  }
363 
364  if(rep_cntr != 0) {
365 
366 // FH.width(_width);
367 // FH.setf(ios::left,ios::adjustfield);
368  //FH<<_statValues[0][gen][1];
369  FH << setw(_width) << left << current_gen;
370 
371  FH << setprecision(_precision);
372 
373  for (unsigned int j = 0; j < _numRecorders; ++j) {
374  FH << _separator << setw(_width) << means[j] / rep_cntr;
375  }
376  //print number of alive replicates 'til this generation
377  FH << _separator << setw(_width) << rep_cntr;
378 
379  FH << endl;
380  }
381 
382  }
383 
384 
385 }
static unsigned int getReplicates()
Definition: simenv.h:63
vector< vector< double * > > _statValues
Table containing all recorded stats, replicate x generation x (num recorders + 2) ...
Definition: statservices.h:66
void printStatHeaders(ofstream &FH)
Definition: statservices.cc:271
unsigned int _width
Definition: statservices.h:86
unsigned int getNumOccurrences()
Returns the maximum number of generation records per replicate.
Definition: statservices.h:126
unsigned int _numRecorders
Number of stats to record.
Definition: statservices.h:63
unsigned int _precision
Definition: statservices.h:86
unsigned char _separator
Definition: statservices.h:88
void StatServices::printStatHeaders ( ofstream &  FH)
272 {
273  for (rec_it IT = _statRecorders.begin(); IT != _statRecorders.end(); ++IT) {
274  FH << _separator << setw(_width) << (*IT)->getName();
275  }
276 }
list< StatRecBase * > _statRecorders
List of stat recorders.
Definition: statservices.h:60
unsigned int _width
Definition: statservices.h:86
unsigned char _separator
Definition: statservices.h:88
list< StatRecBase * >::const_iterator rec_it
Definition: statservices.h:96
void StatServices::printStatValue ( ofstream &  FH,
unsigned int  repl_idx 
)

Prints the stat values to the '.txt' output file.

Parameters
FHthe file output stream
repl_idxthe replicate index in the stat tables

References SIMenv::getCurrentReplicate().

Referenced by LCE_StatFH::FHwrite().

281 {
282 
283 // FH.width(_width);
284 // FH.setf(ios::left,ios::adjustfield);
285 
286  if(SIMenv::getCurrentReplicate() == 1) {
287 
288  //print the first row with stat headers:
289  FH << setw(_width) << left <<"replicate"<< _separator << setw(_width) <<"generation";
290 
291  //print the stat names:
292  printStatHeaders(FH);
293 
294  FH << endl;
295  }
296 
297  for (unsigned int gen = 0, i = 2; gen < _statValues[repl_idx].size(); ++gen) {
298  //for all generations recorded, print stuff:
299 
300  assert( repl_idx + 1 == _statValues[repl_idx][gen][0]); //check if replicate is ok
301 
302 // FH.width(_width);
303  FH << setw(_width) << left << _statValues[repl_idx][gen][0]; //replicate number
304  FH << _separator;
305  FH << setprecision(16); //to avoid scientific notation for generation number
306  FH << setw(_width) << _statValues[repl_idx][gen][1]; //generation recorded
307  FH << setprecision(_precision); //this precision is needed only for stat values
308 
309  i = 2;
310  //print all stats on one line
311  for (rec_it IT = _statRecorders.begin(); IT != _statRecorders.end(); ++IT) {
312 
313  FH << _separator << setw(_width) << _statValues[repl_idx][gen][i];
314 
315  i++;
316 
317  }
318 
319  FH<<endl;
320 
321  assert( i == _numRecorders + 2 );
322  }
323 
324 }
list< StatRecBase * > _statRecorders
List of stat recorders.
Definition: statservices.h:60
vector< vector< double * > > _statValues
Table containing all recorded stats, replicate x generation x (num recorders + 2) ...
Definition: statservices.h:66
void printStatHeaders(ofstream &FH)
Definition: statservices.cc:271
static unsigned int getCurrentReplicate()
Definition: simenv.h:62
unsigned int _width
Definition: statservices.h:86
unsigned int _numRecorders
Number of stats to record.
Definition: statservices.h:63
unsigned int _precision
Definition: statservices.h:86
unsigned char _separator
Definition: statservices.h:88
list< StatRecBase * >::const_iterator rec_it
Definition: statservices.h:96
void StatServices::recordStats ( unsigned int  gen)

record stat values in stat table by calling all stat recorders.

References SIMenv::getCurrentReplicate().

247 {
248  _currentStatValues = new double [ _numRecorders + 2]; //+ replicate + generation
249 
251  _currentStatValues[1] = gen;
252 
253  unsigned int i = 2, tab_idx = SIMenv::getCurrentReplicate() - 1;
254 
255  for (rec_it REC = _statRecorders.begin(); REC != _statRecorders.end(); ++REC)
256  {
257 
258  assert(i < _numRecorders+2 );
259 
260  _currentStatValues[i++] = (*REC)->setVal( _popPtr->getCurrentAge() );
261 
262  }
263 
264  _statValues[ tab_idx ].push_back(_currentStatValues);
265 
266  assert( _statValues[ tab_idx ].size() <= getNumOccurrences() );
267 }
list< StatRecBase * > _statRecorders
List of stat recorders.
Definition: statservices.h:60
vector< vector< double * > > _statValues
Table containing all recorded stats, replicate x generation x (num recorders + 2) ...
Definition: statservices.h:66
Metapop * _popPtr
Definition: statservices.h:54
static unsigned int getCurrentReplicate()
Definition: simenv.h:62
unsigned int getNumOccurrences()
Returns the maximum number of generation records per replicate.
Definition: statservices.h:126
unsigned int _numRecorders
Number of stats to record.
Definition: statservices.h:63
list< StatRecBase * >::const_iterator rec_it
Definition: statservices.h:96
age_t getCurrentAge()
Definition: metapop.h:289
double * _currentStatValues
Pointer to the last recorded stats.
Definition: statservices.h:69
void StatServices::reset ( )
virtual

clear the list of StatHandler

Implements Service.

Referenced by SimRunner::reset_services().

209 {
210  stat_it HIT = _statHandlers.begin();
211 
212  while(HIT != _statHandlers.end()) {
213  (*HIT)->reset();
214  HIT++;
215  }
216 
217  _statHandlers.clear();
218 
219  //the stat recorders must be freed here, they have been removed from the StatHandlers
220  rec_it REC = _statRecorders.begin();
221 
222  for(; REC != _statRecorders.end(); ++REC) delete (*REC);
223 
224  _statRecorders.clear();
225 
227 }
list< StatRecBase * > _statRecorders
List of stat recorders.
Definition: statservices.h:60
list< StatHandlerBase * > _statHandlers
List of stat handlers declared by currently active simulation components.
Definition: statservices.h:57
void reset_stat_table()
Deletes the stat tables.
Definition: statservices.cc:231
list< StatRecBase * >::const_iterator rec_it
Definition: statservices.h:96
list< StatHandlerBase * >::const_iterator stat_it
Definition: statservices.h:94
void StatServices::reset_stat_table ( )

Deletes the stat tables.

232 {
233  for (unsigned int i = 0; i < _statValues.size(); ++i) {
234  for (unsigned int j = 0; j < _statValues[i].size(); ++j) {
235  delete [] _statValues[i][j];
236  }
237  _statValues[i].clear();
238  }
239  _statValues.clear();
240 
241  _currentStatValues = 0;
242 }
vector< vector< double * > > _statValues
Table containing all recorded stats, replicate x generation x (num recorders + 2) ...
Definition: statservices.h:66
double * _currentStatValues
Pointer to the last recorded stats.
Definition: statservices.h:69
void StatServices::resetCurrentOccurrence ( )
inline

Resets the occurrence iterator to the beginning of the list of generation occurrences.

Referenced by SimRunner::setForFirstGeneration().

list< unsigned int > _occurrences
List of all generations to record.
Definition: statservices.h:78
list< unsigned int >::const_iterator _current_occurrence
Iterator pointing to the current generation to record.
Definition: statservices.h:83
void StatServices::set ( string &  str,
unsigned int  occ 
)
inline
111  {_statArg = str; _occurrence = occ;}
unsigned int _occurrence
Deprecated.
Definition: statservices.h:75
string _statArg
The string argument of the 'stat' input option.
Definition: statservices.h:72
void StatServices::set_pop_ptr ( Metapop pop)
inline

Referenced by SimRunner::init_components().

108 {_popPtr=pop;}
Metapop * _popPtr
Definition: statservices.h:54
void StatServices::setCompactOutputFormat ( )
inline

Referenced by LCE_StatServiceNotifier::setParameters().

153 {_width = 0; _separator = ' ';}
unsigned int _width
Definition: statservices.h:86
unsigned char _separator
Definition: statservices.h:88
void StatServices::setDefaultOutputFormat ( )
inline

Referenced by LCE_StatServiceNotifier::setParameters().

161 {_width = 12; _precision = 6; _separator = '\t';}
unsigned int _width
Definition: statservices.h:86
unsigned int _precision
Definition: statservices.h:86
unsigned char _separator
Definition: statservices.h:88
void StatServices::setFieldPrecision ( unsigned int  val)
inline

Referenced by LCE_StatServiceNotifier::setParameters().

157 {_precision = val;}
unsigned int _precision
Definition: statservices.h:86
void StatServices::setFieldSeparator ( unsigned char  c)
inline

Referenced by LCE_StatServiceNotifier::setParameters().

159 {_separator = c;}
unsigned char _separator
Definition: statservices.h:88
void StatServices::setFieldWidth ( unsigned int  val)
inline

Referenced by LCE_StatServiceNotifier::setParameters().

155 {_width = val;}
unsigned int _width
Definition: statservices.h:86
void StatServices::setOcccurrence ( unsigned int  value)
inline
120 {_occurrence = value;}
unsigned int _occurrence
Deprecated.
Definition: statservices.h:75
void StatServices::setOccurrences ( map< unsigned int, unsigned int timeTable)

Sets the list of generation for which statistics must be recorded during a run.

Parameters
timeTablea map containing the generations at which stats must be recorded

References fatal(), and SIMenv::getGenerations().

Referenced by LCE_StatServiceNotifier::setOccurence().

122 {
123  map<unsigned int, unsigned int>::const_iterator time = timeTable.begin(), next;
124 
125  _occurrences.clear();
126  _occurrences.push_front(0);
127 
128  if (time->first == 0 && time->second != 0) { //this is a recursive logtime
129 
130  unsigned int next_term;
131 
132  for (;time != timeTable.end(); ++time) {
133 
134  next = time;
135  next++;
136  next_term = ( next != timeTable.end() ?
137  next->first : SIMenv::getGenerations() );
138 
139  while( _occurrences.back() + time->second < next_term)
140  {
141  _occurrences.push_back( _occurrences.back() + time->second );
142  }
143  _occurrences.push_back(next_term);
144  }
145 
146 
147  } else if (time->second == 0) { //non-recursive logtime, only records specific times
148 
149  for (;time != timeTable.end(); ++time) _occurrences.push_back(time->first);
150 
151  } else {
152 
153  fatal("something went wrong while setting stat recording times (first=%i, second=%i)\n",
154  time->first, time->second);
155  }
156 
157  //clean up:
158  while (_occurrences.back() > SIMenv::getGenerations()) _occurrences.pop_back();
159 
160  if(_occurrences.back() != SIMenv::getGenerations()) //automatically record last gen
162 
163  if (_occurrences.front() == 0) _occurrences.pop_front();
164  if (_occurrences.front() != 1) _occurrences.push_front(1); //automatically record first gen
165 }
list< unsigned int > _occurrences
List of all generations to record.
Definition: statservices.h:78
void fatal(const char *str,...)
Definition: output.cc:90
static unsigned int getGenerations()
Definition: simenv.h:61
void StatServices::setStatOptions ( string &  str)
inline

Referenced by LCE_StatServiceNotifier::loadStatServices().

113 {_statArg = str;}
string _statArg
The string argument of the 'stat' input option.
Definition: statservices.h:72

Member Data Documentation

list< unsigned int >::const_iterator StatServices::_current_occurrence
private

Iterator pointing to the current generation to record.

Is incremented once all stats have been recorded for the current generation.

double* StatServices::_currentStatValues
private

Pointer to the last recorded stats.

unsigned int StatServices::_numRecorders
private

Number of stats to record.

unsigned int StatServices::_occurrence
private

Deprecated.

list< unsigned int > StatServices::_occurrences
private

List of all generations to record.

Metapop* StatServices::_popPtr
private
unsigned int StatServices::_precision
private
bool StatServices::_printAverages
private
unsigned char StatServices::_separator
private
string StatServices::_statArg
private

The string argument of the 'stat' input option.

list< StatHandlerBase* > StatServices::_statHandlers
private

List of stat handlers declared by currently active simulation components.

list< StatRecBase *> StatServices::_statRecorders
private

List of stat recorders.

vector< vector< double*> > StatServices::_statValues
private

Table containing all recorded stats, replicate x generation x (num recorders + 2) .

unsigned int StatServices::_width
private

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

Generated for Nemo v2.3.0 by  doxygen 1.8.8 --
Catalogued on GSR