Nemo
2.3.56
Simulate forward-in-time genetic evolution in a spatially explicit, individual-based stochastic simulator
|
The Service class used to manage the StatHandler objects. More...
#include <statservices.h>
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 () |
Metapop * | get_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... | |
![]() | |
Service () | |
virtual | ~Service () |
virtual bool | init ()=0 |
Inits internals. More... | |
virtual void | notify ()=0 |
Notifies all observers to update their state. More... | |
virtual void | load (SimComponent *sc)=0 |
Interface used by a simulation component to load its obervers onto a service provider. More... | |
virtual void | attach (Handler *h)=0 |
Adds an observer to the list. More... | |
virtual void | reset ()=0 |
Clears the observers list. More... | |
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< unsignedint >::const_iterator | _current_occurrence |
Iterator pointing to the current generation to record. More... | |
unsigned int | _width |
unsigned int | _precision |
unsigned char | _separator |
bool | _printAverages |
The Service class used to manage the StatHandler objects.
typedef list<StatRecBase*>::const_iterator StatServices::rec_it |
typedef list<StatHandlerBase*>::const_iterator StatServices::stat_it |
|
inline |
|
inlinevirtual |
References reset_stat_table().
|
virtual |
attach the StatHandler to the current list (_statHandlers) of the StatServices
H | the StatHandler |
Implements Service.
References _statHandlers, and StatHandlerBase::set_service().
Referenced by LCE_Selection_base::loadStatServices(), Metapop::loadStatServices(), TProtoBDMI::loadStatServices(), TProtoDeletMutations_bitstring::loadStatServices(), TProtoDispersal::loadStatServices(), TProtoNeutralGenes::loadStatServices(), TProtoQuanti::loadStatServices(), and TProtoWolbachia::loadStatServices().
|
inline |
References _printAverages.
Referenced by LCE_StatServiceNotifier::loadStatServices().
|
inline |
References _numRecorders, _occurrences, and _statValues.
|
inline |
References _printAverages.
Referenced by LCE_StatServiceNotifier::loadStatServices().
|
inline |
References _popPtr.
Referenced by StatHandlerBase::get_pop_ptr().
list< StatRecBase * > StatServices::getAllStats | ( | ) |
References _statHandlers.
Referenced by SimRunner::get_allRegisteredStats().
|
inline |
Returns the last generation recorded for current replicate.
References _current_occurrence.
Referenced by StatHandlerBase::getCurrentOccurrence().
|
inline |
References _statHandlers.
|
inline |
References _occurrences, and _statValues.
|
inline |
References _statHandlers.
|
inline |
Returns the maximum number of generation records per replicate.
References _occurrences.
Referenced by StatHandlerBase::getNumOccurrences(), printStatAverage(), and recordStats().
Returns the number of generation records present in the stat table for a replicate.
replicate | the replicate number (not the index in the stat table). |
References _statValues.
|
inline |
References _statRecorders.
|
inline |
References _occurrence.
Referenced by LCE_StatServiceNotifier::execute(), and StatHandlerBase::getOccurrence().
|
inline |
References _printAverages.
Referenced by LCE_StatFH::FHwrite().
|
inline |
References _statValues.
|
inline |
References _statArg.
|
virtual |
Implements Service.
References _current_occurrence, _numRecorders, _occurrences, _statArg, _statHandlers, _statRecorders, _statValues, error(), SIMenv::getReplicates(), and reset_stat_table().
Referenced by SimRunner::init_components().
|
virtual |
tell the SimComponent to load its stat handlers
sc | the SimComponent |
Implements Service.
References SimComponent::loadStatServices().
Referenced by SimRunner::register_component().
|
virtual |
Implements Service.
References _current_occurrence, SIMenv::getCurrentGeneration(), message(), and recordStats().
Referenced by LCE_StatServiceNotifier::execute().
void StatServices::printStatAverage | ( | ofstream & | FH | ) |
References _numRecorders, _precision, _separator, _statValues, _width, getNumOccurrences(), SIMenv::getReplicates(), and printStatHeaders().
Referenced by LCE_StatFH::PrintStat_byGen().
void StatServices::printStatHeaders | ( | ofstream & | FH | ) |
References _separator, _statRecorders, and _width.
Referenced by printStatAverage(), and printStatValue().
void StatServices::printStatValue | ( | ofstream & | FH, |
unsigned int | repl_idx | ||
) |
Prints the stat values to the '.txt' output file.
FH | the file output stream |
repl_idx | the replicate index in the stat tables |
References _numRecorders, _precision, _separator, _statRecorders, _statValues, _width, SIMenv::getCurrentReplicate(), and printStatHeaders().
Referenced by LCE_StatFH::FHwrite().
void StatServices::recordStats | ( | unsigned int | gen | ) |
record stat values in stat table by calling all stat recorders.
References _currentStatValues, _numRecorders, _popPtr, _statRecorders, _statValues, Metapop::getCurrentAge(), SIMenv::getCurrentReplicate(), and getNumOccurrences().
Referenced by notify().
|
virtual |
clear the list of StatHandler
Implements Service.
References _statHandlers, _statRecorders, and reset_stat_table().
Referenced by SimRunner::reset_services().
void StatServices::reset_stat_table | ( | ) |
Deletes the stat tables.
References _currentStatValues, and _statValues.
Referenced by init(), reset(), and ~StatServices().
|
inline |
Resets the occurrence iterator to the beginning of the list of generation occurrences.
References _current_occurrence, and _occurrences.
Referenced by SimRunner::setForFirstGeneration().
|
inline |
References _occurrence, and _statArg.
|
inline |
References _popPtr.
Referenced by SimRunner::init_components().
|
inline |
References _separator, and _width.
Referenced by LCE_StatServiceNotifier::setParameters().
|
inline |
References _precision, _separator, and _width.
Referenced by LCE_StatServiceNotifier::setParameters().
|
inline |
References _precision.
Referenced by LCE_StatServiceNotifier::setParameters().
|
inline |
References _separator.
Referenced by LCE_StatServiceNotifier::setParameters().
|
inline |
References _width.
Referenced by LCE_StatServiceNotifier::setParameters().
|
inline |
References _occurrence.
Sets the list of generation for which statistics must be recorded during a run.
timeTable | a map containing the generations at which stats must be recorded |
References _occurrences, fatal(), and SIMenv::getGenerations().
Referenced by LCE_StatServiceNotifier::setOccurence().
|
inline |
References _statArg.
Referenced by LCE_StatServiceNotifier::loadStatServices().
|
private |
Iterator pointing to the current generation to record.
Is incremented once all stats have been recorded for the current generation.
Referenced by getCurrentOccurrence(), init(), notify(), and resetCurrentOccurrence().
|
private |
Pointer to the last recorded stats.
Referenced by recordStats(), and reset_stat_table().
|
private |
Number of stats to record.
Referenced by copyGenerationStatValues(), init(), printStatAverage(), printStatValue(), and recordStats().
|
private |
Deprecated.
Referenced by getOccurrence(), set(), and setOcccurrence().
|
private |
List of all generations to record.
Referenced by copyGenerationStatValues(), getGenerationStatValues(), getNumOccurrences(), init(), resetCurrentOccurrence(), and setOccurrences().
|
private |
Referenced by get_pop_ptr(), recordStats(), and set_pop_ptr().
|
private |
Referenced by printStatAverage(), printStatValue(), setDefaultOutputFormat(), and setFieldPrecision().
|
private |
Referenced by cancelPrintAverages(), doPrintAverages(), and getPrintAveragesOpt().
|
private |
|
private |
The string argument of the 'stat' input option.
Referenced by getStatArg(), init(), set(), and setStatOptions().
|
private |
List of stat handlers declared by currently active simulation components.
Referenced by attach(), getAllStats(), getFirst(), getLast(), init(), and reset().
|
private |
List of stat recorders.
Referenced by getNumStats(), init(), printStatHeaders(), printStatValue(), recordStats(), and reset().
|
private |
Table containing all recorded stats, replicate x generation x (num recorders + 2) .
Referenced by copyGenerationStatValues(), getGenerationStatValues(), getNumOccurrences(), getReplicateStatRecords(), init(), printStatAverage(), printStatValue(), recordStats(), and reset_stat_table().
|
private |
Referenced by printStatAverage(), printStatHeaders(), printStatValue(), setCompactOutputFormat(), setDefaultOutputFormat(), and setFieldWidth().