|
Nemo
2.2.0
|
Base class of the StatHandler class, implements the Handler interface. More...
#include <stathandler.h>
Inheritance diagram for StatHandlerBase:
Collaboration diagram for StatHandlerBase:Public Member Functions | |
| StatHandlerBase () | |
| virtual | ~StatHandlerBase () |
| virtual void | reset () |
| Empties the _stats list and calls clear() (defined in the derived class). | |
Accessors | |
| Metapop * | get_pop_ptr () |
| void | set_service (StatServices *srv) |
| StatServices * | get_service () |
| unsigned int | getOccurrence () |
| unsigned int | getNbRecorders () |
| unsigned int | get_nrows () |
| unsigned int | get_ncols () |
| std::list< StatRecBase * > & | getStats () |
| virtual void | add (StatRecBase *rec) |
Stat recorder interface | |
| unsigned int | getStatRecIndex (unsigned int i) |
| void | setAverage () |
| void | print_headers (std::ofstream &FH, unsigned int order) |
| void | print_value (std::ofstream &FH, unsigned int i, unsigned int j) |
| void | print_average (std::ofstream &FH, unsigned int i) |
Handler implementation | |
| virtual void | init () |
| Inits state. | |
| virtual void | update () |
| Updates the handler state. | |
StatHandler interface declaration | |
| virtual void | execute ()=0 |
| virtual bool | setStatRecorders (std::string &token)=0 |
| virtual void | clear ()=0 |
Protected Attributes | |
| Metapop * | _pop |
| Link to the current population, set through the link to the StatService. | |
Private Types | |
| typedef std::list< StatRecBase * > ::iterator | STAT_IT |
Private Attributes | |
| std::list< StatRecBase * > | _stats |
| Link to the StatRecorder list elements in the StatHandler derived class. | |
| unsigned int | _nrows |
| Structure of the stats table in the stat recorders. | |
| unsigned int | _ncols |
| StatServices * | _service |
| Link to the StatService. | |
| unsigned int | _GenerationOccurrence |
| Occurence of the stats recording as set by the user (see parameter "stat_log_time"). | |
| unsigned int | _current_replicate |
| Replicate state of this Handler. | |
| unsigned int | _current_generation |
| Generation state of this Handler. | |
| age_t | _current_age |
| Age state of this Handler. | |
Base class of the StatHandler class, implements the Handler interface.
This class stores the Handler state and the list of links to the StatRecBase. This list is duplicated in the StatHandler as a list of the StatRecorder templates. It allows the StatService to access the stat recorders without knowledge of the actual StatHandler and StatRecorder template type.
Definition at line 47 of file stathandler.h.
typedef std::list< StatRecBase* >::iterator StatHandlerBase::STAT_IT [private] |
Definition at line 65 of file stathandler.h.
| StatHandlerBase::StatHandlerBase | ( | ) | [inline] |
Definition at line 73 of file stathandler.h.
: _nrows(0), _ncols(0), _service(0), _GenerationOccurrence(0), _current_replicate(0), _current_generation(0), _current_age(0) { }
| virtual StatHandlerBase::~StatHandlerBase | ( | ) | [inline, virtual] |
Definition at line 78 of file stathandler.h.
{ }
| virtual void StatHandlerBase::add | ( | StatRecBase * | rec | ) | [inline, virtual] |
| virtual void StatHandlerBase::clear | ( | ) | [pure virtual] |
Implemented in StatHandler< SH >, StatHandler< MPStatHandler >, StatHandler< TTDeletMutBitstrSH >, StatHandler< TTWolbachiaSH >, StatHandler< TTDispersalSH >, StatHandler< LCE_StatSH >, StatHandler< TTQuantiSH >, StatHandler< TTNeutralGenesSH >, and StatHandler< LCE_SelectionSH >.
Referenced by reset().
| virtual void StatHandlerBase::execute | ( | ) | [pure virtual] |
Implemented in StatHandler< SH >, StatHandler< MPStatHandler >, StatHandler< TTDeletMutBitstrSH >, StatHandler< TTWolbachiaSH >, StatHandler< TTDispersalSH >, StatHandler< LCE_StatSH >, StatHandler< TTQuantiSH >, StatHandler< TTNeutralGenesSH >, and StatHandler< LCE_SelectionSH >.
Referenced by update().
| unsigned int StatHandlerBase::get_ncols | ( | ) | [inline] |
Definition at line 93 of file stathandler.h.
References _ncols.
Referenced by StatHandler< LCE_SelectionSH >::add().
{return _ncols;}
| unsigned int StatHandlerBase::get_nrows | ( | ) | [inline] |
Definition at line 91 of file stathandler.h.
References _nrows.
Referenced by StatHandler< LCE_SelectionSH >::add().
{return _nrows;}
| Metapop* StatHandlerBase::get_pop_ptr | ( | ) | [inline] |
Definition at line 81 of file stathandler.h.
References _service, and StatServices::get_pop_ptr().
Referenced by init().
{return _service->get_pop_ptr();}
| StatServices* StatHandlerBase::get_service | ( | ) | [inline] |
| unsigned int StatHandlerBase::getNbRecorders | ( | ) | [inline] |
| unsigned int StatHandlerBase::getOccurrence | ( | ) | [inline] |
Definition at line 87 of file stathandler.h.
References _service, and StatServices::getOccurrence().
Referenced by init().
{return _service->getOccurrence();}
| unsigned int StatHandlerBase::getStatRecIndex | ( | unsigned int | i | ) |
Definition at line 90 of file stathandlerbase.cc.
References _stats, and error().
{
STAT_IT el = _stats.begin();
unsigned int index = 0;
if(el != _stats.end()) {
if(i > (*el)->getIndexSize())
error("StatHandlerBase::getStatRecIndex: index vector overflow !!\n");
//find the first statRecorder that has computed some stats
for(; el != _stats.end(); el++)
if((index = (*el)->getIndex(i)) != 0) break;
}
return index;
}
| std::list<StatRecBase*>& StatHandlerBase::getStats | ( | ) | [inline] |
| void StatHandlerBase::init | ( | ) | [virtual] |
Inits state.
Implements Handler.
Reimplemented in TTNeutralGenesSH, TTQuantiSH, TTDispersalSH, and LCE_StatSH.
Definition at line 39 of file stathandlerbase.cc.
References _ncols, _nrows, _pop, fatal(), get_pop_ptr(), SimRunner::getGenerations(), getOccurrence(), SimRunner::getReplicates(), and SIMenv::MainSim.
{
_pop = get_pop_ptr();
unsigned int gen = SIMenv::MainSim->getGenerations(), log = getOccurrence();
if(gen == 0) fatal("cannot initialize stat recorders, generation nbr is null\n");
_nrows = ( log > gen || log == 0 ? 2 : gen/log);
if(log != 1) _nrows++; //automatically save first generation
if(SIMenv::MainSim->getReplicates() == 0) fatal("cannot initialize stat recorders, replicate nbr is null\n");
_ncols = SIMenv::MainSim->getReplicates();
}
| void StatHandlerBase::print_average | ( | std::ofstream & | FH, |
| unsigned int | i | ||
| ) |
| void StatHandlerBase::print_headers | ( | std::ofstream & | FH, |
| unsigned int | order | ||
| ) |
| void StatHandlerBase::print_value | ( | std::ofstream & | FH, |
| unsigned int | i, | ||
| unsigned int | j | ||
| ) |
| void StatHandlerBase::reset | ( | ) | [virtual] |
Empties the _stats list and calls clear() (defined in the derived class).
Definition at line 72 of file stathandlerbase.cc.
| void StatHandlerBase::set_service | ( | StatServices * | srv | ) | [inline] |
Definition at line 83 of file stathandler.h.
References _service.
Referenced by StatServices::attach().
{_service = srv;}
| void StatHandlerBase::setAverage | ( | ) |
| virtual bool StatHandlerBase::setStatRecorders | ( | std::string & | token | ) | [pure virtual] |
Implemented in TTNeutralGenesSH, TTDeletMutBitstrSH, TTQuantiSH, TTDispersalSH, LCE_StatSH, and MPStatHandler.
| void StatHandlerBase::update | ( | ) | [virtual] |
Updates the handler state.
Implements Handler.
Definition at line 57 of file stathandlerbase.cc.
References _current_age, _current_generation, _current_replicate, _pop, execute(), Metapop::getCurrentAge(), Metapop::getCurrentGeneration(), and Metapop::getCurrentReplicate().
{
_current_replicate = _pop->getCurrentReplicate();
_current_generation = _pop->getCurrentGeneration();
_current_age = _pop->getCurrentAge();
//if( !(_current_generation % _GenerationOccurrence) )
execute();
}
age_t StatHandlerBase::_current_age [private] |
unsigned int StatHandlerBase::_current_generation [private] |
Generation state of this Handler.
Definition at line 61 of file stathandler.h.
Referenced by update().
unsigned int StatHandlerBase::_current_replicate [private] |
Replicate state of this Handler.
Definition at line 59 of file stathandler.h.
Referenced by update().
unsigned int StatHandlerBase::_GenerationOccurrence [private] |
Occurence of the stats recording as set by the user (see parameter "stat_log_time").
Definition at line 57 of file stathandler.h.
unsigned int StatHandlerBase::_ncols [private] |
Definition at line 53 of file stathandler.h.
Referenced by get_ncols(), init(), and reset().
unsigned int StatHandlerBase::_nrows [private] |
Structure of the stats table in the stat recorders.
Definition at line 53 of file stathandler.h.
Referenced by get_nrows(), init(), and reset().
Metapop* StatHandlerBase::_pop [protected] |
Link to the current population, set through the link to the StatService.
Definition at line 69 of file stathandler.h.
Referenced by TTNeutralGenesSH::allocateTables(), LCE_StatSH::get_isAlive(), TTWolbachiaSH::getMeanFemaleInfection_perPatch(), TTWolbachiaSH::getMeanMaleInfection_perPatch(), TTWolbachiaSH::getMeanOffsprgFemaleInfection_perPatch(), TTWolbachiaSH::getMeanOffsprgInfection(), TTWolbachiaSH::getMeanOffsprgMaleInfection_perPatch(), LCE_SelectionSH::getPatchFitness(), init(), TTDispersalSH::init(), TTNeutralGenesSH::setCoaMatrixRecorders(), TTNeutralGenesSH::setFstMatrixRecorders(), TTWolbachiaSH::setInfectionStats(), TTNeutralGenesSH::setNeiGeneticDistanceRecorders(), LCE_SelectionSH::setStatRecorders(), update(), and TTQuantiSH::~TTQuantiSH().
StatServices* StatHandlerBase::_service [private] |
Link to the StatService.
Definition at line 55 of file stathandler.h.
Referenced by get_pop_ptr(), get_service(), getOccurrence(), and set_service().
std::list<StatRecBase*> StatHandlerBase::_stats [private] |
Link to the StatRecorder list elements in the StatHandler derived class.
Definition at line 51 of file stathandler.h.
Referenced by add(), getNbRecorders(), getStatRecIndex(), getStats(), print_average(), print_headers(), print_value(), reset(), and setAverage().
1.7.5.1 -- Nemo is hosted by