The Service class used to manage the StatHandler objects.
More...
#include <statservices.h>
The Service class used to manage the StatHandler objects.
◆ rec_it
◆ stat_it
◆ StatServices()
| StatServices::StatServices |
( |
| ) |
|
|
inline |
Metapop * _popPtr
Definition: statservices.h:54
unsigned char _separator
Definition: statservices.h:88
unsigned int _occurrence
Deprecated.
Definition: statservices.h:75
unsigned int _width
Definition: statservices.h:86
unsigned int _precision
Definition: statservices.h:86
unsigned int _numRecorders
Number of stats to record.
Definition: statservices.h:63
bool _printAverages
Definition: statservices.h:90
double * _currentStatValues
Pointer to the last recorded stats.
Definition: statservices.h:69
◆ ~StatServices()
| virtual StatServices::~StatServices |
( |
| ) |
|
|
inlinevirtual |
void reset_stat_table()
Deletes the stat tables.
Definition: statservices.cc:240
◆ attach()
| void StatServices::attach |
( |
Handler * |
H | ) |
|
|
virtual |
◆ cancelPrintAverages()
| void StatServices::cancelPrintAverages |
( |
| ) |
|
|
inline |
◆ copyGenerationStatValues()
| void StatServices::copyGenerationStatValues |
( |
unsigned int |
replicate, |
|
|
unsigned int |
occurence, |
|
|
double * |
values, |
|
|
unsigned int |
size |
|
) |
| |
|
inline |
189 double* new_record =
new double[size];
191 memcpy(new_record, values, size*
sizeof(
double));
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
◆ doPrintAverages()
| void StatServices::doPrintAverages |
( |
| ) |
|
|
inline |
◆ get_pop_ptr()
| Metapop* StatServices::get_pop_ptr |
( |
| ) |
|
|
inline |
◆ getAllStats()
407 list< StatHandlerBase* >::iterator HIT =
_statHandlers.begin();
409 list<StatRecBase*> allStats, stats;
412 stats = (*HIT)->getStats();
413 allStats.insert(allStats.end(), stats.begin(), stats.end());
Referenced by SimRunner::get_allRegisteredStats().
◆ getCurrentOccurrence()
| unsigned int StatServices::getCurrentOccurrence |
( |
| ) |
|
|
inline |
Returns the last generation recorded for current replicate.
list< unsigned int >::const_iterator _current_occurrence
Iterator pointing to the current generation to record.
Definition: statservices.h:83
Referenced by StatHandlerBase::getCurrentOccurrence().
◆ getFirst()
◆ getGenerationStatValues()
| double* StatServices::getGenerationStatValues |
( |
unsigned int |
replicate, |
|
|
unsigned int |
occurence |
|
) |
| const |
|
inline |
◆ getLast()
◆ getNumOccurrences() [1/2]
| unsigned int StatServices::getNumOccurrences |
( |
| ) |
|
|
inline |
◆ getNumOccurrences() [2/2]
| unsigned int StatServices::getNumOccurrences |
( |
unsigned int |
replicate | ) |
|
|
inline |
Returns the number of generation records present in the stat table for a replicate.
- Parameters
-
| replicate | the replicate number (not the index in the stat table). |
◆ getNumStats()
| unsigned int StatServices::getNumStats |
( |
| ) |
|
|
inline |
list< StatRecBase * > _statRecorders
List of stat recorders.
Definition: statservices.h:60
◆ getOccurrence()
| unsigned int StatServices::getOccurrence |
( |
| ) |
|
|
inline |
◆ getPrintAveragesOpt()
| bool StatServices::getPrintAveragesOpt |
( |
| ) |
|
|
inline |
◆ getReplicateStatRecords()
| vector<double*>* StatServices::getReplicateStatRecords |
( |
unsigned int |
replicate | ) |
|
|
inline |
◆ getStatArg()
| string& StatServices::getStatArg |
( |
| ) |
|
|
inline |
string _statArg
The string argument of the 'stat' input option.
Definition: statservices.h:72
◆ init()
| bool StatServices::init |
( |
| ) |
|
|
virtual |
Implements Service.
64 while(stats>>arg) args.push_back(arg);
66 list<string>::iterator token = args.begin();
70 while(token != args.end()) {
77 is_set |= (*HIT)->setStatRecorders( (*token) );
82 error(
"the string \"%s\" is not a valid stat option\n",(*token).c_str());
static unsigned int getReplicates()
Definition: simenv.h:63
list< StatHandlerBase * >::const_iterator stat_it
Definition: statservices.h:94
int error(const char *str,...)
Definition: output.cc:77
References error(), and SIMenv::getReplicates().
Referenced by SimRunner::init_components().
◆ load()
◆ notify()
| void StatServices::notify |
( |
| ) |
|
|
virtual |
◆ printStatAverage()
| void StatServices::printStatAverage |
( |
ofstream & |
FH | ) |
|
339 vector< double > means;
340 vector< unsigned int > stat_rep_cntr;
343 unsigned int current_gen = 0;
347 FH << setw(
_width) << left <<
"generation";
356 for (
unsigned int gen = 0; gen < num_gen; ++gen) {
363 for (
unsigned int rep = 0; rep < num_repl; ++rep) {
385 FH << setw(
_width) << left << current_gen;
unsigned int getNumOccurrences()
Returns the maximum number of generation records per replicate.
Definition: statservices.h:126
void printStatHeaders(ofstream &FH)
Definition: statservices.cc:280
References SIMenv::getReplicates().
Referenced by LCE_StatFH::PrintStat_byGen().
◆ printStatHeaders()
| void StatServices::printStatHeaders |
( |
ofstream & |
FH | ) |
|
list< StatRecBase * >::const_iterator rec_it
Definition: statservices.h:96
◆ printStatValue()
| void StatServices::printStatValue |
( |
ofstream & |
FH, |
|
|
unsigned int |
repl_idx |
|
) |
| |
Prints the stat values to the '.txt' output file.
- Parameters
-
| FH | the file output stream |
| repl_idx | the replicate index in the stat tables |
306 for (
unsigned int gen = 0, i = 2; gen <
_statValues[repl_idx].size(); ++gen) {
309 assert( repl_idx + 1 ==
_statValues[repl_idx][gen][0]);
314 FH << setprecision(16);
static unsigned int getCurrentReplicate()
Definition: simenv.h:62
References SIMenv::getCurrentReplicate().
Referenced by LCE_StatFH::FHwrite().
◆ recordStats()
| void StatServices::recordStats |
( |
unsigned int |
gen | ) |
|
◆ reset()
| void StatServices::reset |
( |
| ) |
|
|
virtual |
◆ reset_stat_table()
| void StatServices::reset_stat_table |
( |
| ) |
|
Deletes the stat tables.
242 for (
unsigned int i = 0; i <
_statValues.size(); ++i) {
243 for (
unsigned int j = 0; j <
_statValues[i].size(); ++j) {
◆ resetCurrentOccurrence()
| void StatServices::resetCurrentOccurrence |
( |
| ) |
|
|
inline |
◆ set()
| void StatServices::set |
( |
string & |
str, |
|
|
unsigned int |
occ |
|
) |
| |
|
inline |
◆ set_pop_ptr()
| void StatServices::set_pop_ptr |
( |
Metapop * |
pop | ) |
|
|
inline |
◆ setCompactOutputFormat()
| void StatServices::setCompactOutputFormat |
( |
| ) |
|
|
inline |
◆ setDefaultOutputFormat()
| void StatServices::setDefaultOutputFormat |
( |
| ) |
|
|
inline |
◆ setFieldPrecision()
| void StatServices::setFieldPrecision |
( |
unsigned int |
val | ) |
|
|
inline |
◆ setFieldSeparator()
| void StatServices::setFieldSeparator |
( |
unsigned char |
c | ) |
|
|
inline |
◆ setFieldWidth()
| void StatServices::setFieldWidth |
( |
unsigned int |
val | ) |
|
|
inline |
◆ setOcccurrence()
| void StatServices::setOcccurrence |
( |
unsigned int |
value | ) |
|
|
inline |
◆ setOccurrences()
| void StatServices::setOccurrences |
( |
map< unsigned int, unsigned int > |
timeTable | ) |
|
Sets the list of generation for which statistics must be recorded during a run.
- Parameters
-
| timeTable | a map containing the generations at which stats must be recorded |
123 map<unsigned int, unsigned int>::const_iterator time = timeTable.begin(), next;
128 if (time->first == 0 && time->second != 0) {
130 unsigned int next_term;
132 for (;time != timeTable.end(); ++time) {
136 next_term = ( next != timeTable.end() ?
147 }
else if (time->second == 0) {
149 for (;time != timeTable.end(); ++time)
_occurrences.push_back(time->first);
153 fatal(
"something went wrong while setting stat recording times (first=%i, second=%i)\n",
154 time->first, time->second);
static unsigned int getGenerations()
Definition: simenv.h:61
void fatal(const char *str,...)
Definition: output.cc:96
References fatal(), and SIMenv::getGenerations().
Referenced by LCE_StatServiceNotifier::setOccurence().
◆ setStatOptions()
| void StatServices::setStatOptions |
( |
string & |
str | ) |
|
|
inline |
◆ _current_occurrence
| 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.
◆ _currentStatValues
| double* StatServices::_currentStatValues |
|
private |
Pointer to the last recorded stats.
◆ _numRecorders
| unsigned int StatServices::_numRecorders |
|
private |
Number of stats to record.
◆ _occurrence
| unsigned int StatServices::_occurrence |
|
private |
◆ _occurrences
| list< unsigned int > StatServices::_occurrences |
|
private |
List of all generations to record.
◆ _popPtr
◆ _precision
| unsigned int StatServices::_precision |
|
private |
◆ _printAverages
| bool StatServices::_printAverages |
|
private |
◆ _separator
| unsigned char StatServices::_separator |
|
private |
◆ _statArg
| string StatServices::_statArg |
|
private |
The string argument of the 'stat' input option.
◆ _statHandlers
List of stat handlers declared by currently active simulation components.
◆ _statRecorders
◆ _statValues
| vector< vector< double*> > StatServices::_statValues |
|
private |
Table containing all recorded stats, replicate x generation x (num recorders + 2) .
◆ _width
| unsigned int StatServices::_width |
|
private |
The documentation for this class was generated from the following files: