|
Nemo
2.2.0
|
Base class of the Life Cycle Events, declares the LCE interface. More...
#include <lifecycleevent.h>
Inheritance diagram for LifeCycleEvent:
Collaboration diagram for LifeCycleEvent:Public Member Functions | |
| LifeCycleEvent (const char *name, const char *trait_link) | |
| Cstor. | |
| virtual | ~LifeCycleEvent () |
| virtual void | init (Metapop *popPtr) |
| Sets the pointer to the current Metapop and the trait link if applicable. | |
| virtual bool | attach_trait (string trait) |
| virtual void | set_paramset (std::string name, bool required, SimComponent *owner) |
| Sets a new ParamSet and name it. | |
| virtual void | set_event_name (std::string &name) |
| Set the name of the event (name of the ParamSet) and add the corresponding parameter to the set. | |
| virtual void | set_event_name (const char *name) |
| virtual string & | get_event_name () |
| Accessor to the LCE's name. | |
| virtual int | get_rank () |
| Accessor to the LCE rank in the life cycle. | |
| virtual void | set_pop_ptr (Metapop *popPtr) |
| Accessors for the population pointer. | |
| virtual Metapop * | get_pop_ptr () |
LCE interface | |
| virtual void | execute ()=0 |
| Execute the event on the pop. | |
| virtual LifeCycleEvent * | clone ()=0 |
| Cloning interface. | |
| virtual age_t | removeAgeClass ()=0 |
| Removes the returned age-class flag(s) from the current Metapop age-class flags. | |
| virtual age_t | addAgeClass ()=0 |
| Adds the returned age-class flag(s) to the current Metapop age-class flags. | |
| virtual age_t | requiredAgeClass ()=0 |
| Specifies what age-classes are required by the LCE to execute. | |
Protected Attributes | |
| std::string | _event_name |
| The param name to be read in the init file. | |
| Metapop * | _popPtr |
| The ptr to the current Metapop. | |
| std::string | _LCELinkedTraitType |
| The name of the linked trait. | |
| int | _LCELinkedTraitIndex |
| The index in the individual's trait table of the linked trait. | |
Base class of the Life Cycle Events, declares the LCE interface.
A Life Cycle Event (LCE) is a population operator that modifies the state of the population at each iteration of the life cycle. It declares the execute() method that is called during the life cycle loop (Metapop::Cycle()). No interface is given to manage the periodicity of the event, the execute() method is called at each iteration. The periodicity check must thus be implemented in the derived class, within the exectute() method.
Each LCE has a link to the current Metapop instance and a link to a particular trait which are set by LifeCycleEvent::init() at simulation initialization time (called by Metapop::setLifeCycle() through Metapop::init() and SimRunner::setup()). The linked trait can be specified in the constructor by its type identifier (a character string literal) or later, at runtime. In the first case, the trait's index will be set by a call to IndFactory::getTraitIndex() at initialization (see LifeCycleEvent::init()). In the later case, the trait to link with must be specified at initialization time and LifeCycleEvent::init() must be overloaded. The linked trait type (or name) can then be specified by the user in the init file and set in the derived class init() method before explicitly calling LifeCycleEvent::init() which will set the linked trait's index (see LCE_Breed_Selection::init() for an example). That index is then used to easily access the given trait through the Individual interface (see Individual::getTrait()).
Each LCE also has a name by which it is called from the user's defined parameter file to specify when in the life cycle that particular event has to be executed. The position in the life cycle is the LCE's rank (i.e. the value given in input to the parameter "name"). As only one rank value is allowed per LCE, it is executed only once in the life cycle, this is a limitation that might be removed in future versions if need be!
The main action of an LCE is often to move individuals between populations, between age-classes or both. The changes done to the population age structure by a particular LCE are tracked through the removeAgeClass() and addAgeClass() interface methods called after each execution of an LCE. The metapopulation age flag is thus updated by these two functions.
Note: Overloading LifeCycleEvent::init(). If more than one trait is used by your LCE, think about overloading the init() function to allow the registration of several trait links within your derived LCE. The init() method will also be overloaded if you add additional parameters to the LCE's ParamSet. In any cases, LifeCycleEvent::init() MUST be called in your init() function to properly set the metapop pointer (unless you copy the code into your function...).
Note: the LCEs must be inited after a call to IndFactory::makePrototype() has been issued so that the trait links can be set!
Definition at line 72 of file lifecycleevent.h.
| LifeCycleEvent::LifeCycleEvent | ( | const char * | name, |
| const char * | trait_link | ||
| ) | [inline] |
Cstor.
| name | the name of the LCE as it must appear in the parameter input file |
| trait_link | the name of the linked trait used by this LCE |
Definition at line 93 of file lifecycleevent.h.
References set_event_name().
: _popPtr(0), _LCELinkedTraitType(trait_link), _LCELinkedTraitIndex(-1) { // cout << "calling LifeCycleEvent("<<name<<","<<trait_link<<")\n"; set_event_name(name); }
Here is the call graph for this function:| virtual LifeCycleEvent::~LifeCycleEvent | ( | ) | [inline, virtual] |
Definition at line 100 of file lifecycleevent.h.
{ }
| virtual age_t LifeCycleEvent::addAgeClass | ( | ) | [pure virtual] |
Adds the returned age-class flag(s) to the current Metapop age-class flags.
Implemented in LCE_Breed_Wolbachia, LCE_Breed, LCE_Resize, LCE_Selection_base, LCE_Breed_Selection_Disperse, LCE_Cross, LCE_StatServiceNotifier, LCE_Patch_Extinction, LCE_Breed_Selection, LCE_Breed_Disperse, LCE_Disperse_base, LCE_Aging, LCE_FileServicesNotifier, BinaryDataSaver, LCE_Regulation, LCE_ParamUpdaterNotifier, and LCE_QuantiInit.
Referenced by Metapop::setCurrentAge().
| virtual bool LifeCycleEvent::attach_trait | ( | string | trait | ) | [inline, virtual] |
Definition at line 113 of file lifecycleevent.h.
References _event_name, _LCELinkedTraitIndex, _LCELinkedTraitType, _popPtr, error(), and IndFactory::getTraitIndex().
Referenced by init(), and LCE_Selection_base::setParameters().
{
_LCELinkedTraitType = trait;
if(_LCELinkedTraitType.size() != 0) {
_LCELinkedTraitIndex = _popPtr->getTraitIndex(_LCELinkedTraitType.c_str());
if(_LCELinkedTraitIndex == -1) {
error("cannot attach trait \"%s\" to life cycle event \"%s\", trait has not been initiated.\n",
_LCELinkedTraitType.c_str(), _event_name.c_str());
return false;
}
}
return true;
}
| virtual LifeCycleEvent* LifeCycleEvent::clone | ( | ) | [pure virtual] |
Cloning interface.
Implemented in LCE_Breed_Wolbachia, LCE_Breed, LCE_Selection_base, LCE_Resize, LCE_Breed_Selection_Disperse, LCE_Cross, LCE_Disperse_EvolDisp, LCE_StatServiceNotifier, LCE_Patch_Extinction, LCE_Breed_Selection, LCE_Disperse_ConstDisp, LCE_Breed_Disperse, LCE_Aging, LCE_FileServicesNotifier, BinaryDataSaver, LCE_Regulation, LCE_ParamUpdaterNotifier, and LCE_QuantiInit.
| virtual void LifeCycleEvent::execute | ( | ) | [pure virtual] |
Execute the event on the pop.
Implemented in LCE_Breed_Wolbachia, LCE_Breed, LCE_Resize, LCE_Selection_base, LCE_Breed_Selection_Disperse, LCE_Cross, LCE_Disperse_EvolDisp, LCE_StatServiceNotifier, LCE_Patch_Extinction, LCE_Breed_Selection, LCE_Disperse_ConstDisp, LCE_Breed_Disperse, LCE_Aging, LCE_FileServicesNotifier, BinaryDataSaver, LCE_Regulation, LCE_ParamUpdaterNotifier, and LCE_QuantiInit.
| virtual string& LifeCycleEvent::get_event_name | ( | ) | [inline, virtual] |
Accessor to the LCE's name.
Definition at line 150 of file lifecycleevent.h.
References _event_name.
{ return _event_name; }
| virtual Metapop* LifeCycleEvent::get_pop_ptr | ( | ) | [inline, virtual] |
Definition at line 163 of file lifecycleevent.h.
References _popPtr.
Referenced by LCE_ParamUpdaterNotifier::execute(), and LCE_FileServicesNotifier::execute().
{ return _popPtr; }
| virtual int LifeCycleEvent::get_rank | ( | ) | [inline, virtual] |
Accessor to the LCE rank in the life cycle.
Definition at line 155 of file lifecycleevent.h.
References _event_name, and SimComponent::get_parameter_value().
Referenced by BinaryDataSaver::setParameters(), and LCE_StatServiceNotifier::setParameters().
{ return (int)get_parameter_value(_event_name.c_str()); }
| virtual void LifeCycleEvent::init | ( | Metapop * | popPtr | ) | [inline, virtual] |
Sets the pointer to the current Metapop and the trait link if applicable.
DEV: Don't forget to explicitly call this function (LifeCycleEvent::init()) when you overload it!
| popPtr | the pointer to the current instance of Metapop |
Definition at line 106 of file lifecycleevent.h.
References _LCELinkedTraitType, _popPtr, attach_trait(), fatal(), and SimComponent::setParameters().
Referenced by SimRunner::init_components().
{
_popPtr = popPtr;
if(!attach_trait(_LCELinkedTraitType)) fatal("bailing out\n");
if(!setParameters()) fatal("bailing out\n");
}
Here is the call graph for this function:| virtual age_t LifeCycleEvent::removeAgeClass | ( | ) | [pure virtual] |
Removes the returned age-class flag(s) from the current Metapop age-class flags.
Implemented in LCE_Breed_Wolbachia, LCE_Breed, LCE_Resize, LCE_Selection_base, LCE_Breed_Selection_Disperse, LCE_Cross, LCE_StatServiceNotifier, LCE_Patch_Extinction, LCE_Breed_Selection, LCE_Breed_Disperse, LCE_Disperse_base, LCE_Aging, LCE_FileServicesNotifier, BinaryDataSaver, LCE_Regulation, LCE_ParamUpdaterNotifier, and LCE_QuantiInit.
Referenced by Metapop::setCurrentAge().
| virtual age_t LifeCycleEvent::requiredAgeClass | ( | ) | [pure virtual] |
Specifies what age-classes are required by the LCE to execute.
Implemented in LCE_Breed_Wolbachia, LCE_Breed, LCE_Resize, LCE_Selection_base, LCE_Breed_Selection_Disperse, LCE_Cross, LCE_StatServiceNotifier, LCE_Patch_Extinction, LCE_Breed_Selection, LCE_Breed_Disperse, LCE_Disperse_base, LCE_Aging, LCE_FileServicesNotifier, BinaryDataSaver, LCE_Regulation, LCE_ParamUpdaterNotifier, and LCE_QuantiInit.
| virtual void LifeCycleEvent::set_event_name | ( | std::string & | name | ) | [inline, virtual] |
Set the name of the event (name of the ParamSet) and add the corresponding parameter to the set.
Definition at line 135 of file lifecycleevent.h.
References _event_name, and set_paramset().
Referenced by LifeCycleEvent().
{
_event_name = name;
set_paramset(name, 0, this);
// add_parameter(name.c_str(),INT,1,0,0,0);
}
| virtual void LifeCycleEvent::set_event_name | ( | const char * | name | ) | [inline, virtual] |
Definition at line 142 of file lifecycleevent.h.
References _event_name, and set_paramset().
{
_event_name = name;
set_paramset(name, 0, this);
// add_parameter(name,INT,1,0,0,0);
}
| virtual void LifeCycleEvent::set_paramset | ( | std::string | name, |
| bool | required, | ||
| SimComponent * | owner | ||
| ) | [inline, virtual] |
Sets a new ParamSet and name it.
| name | the name of the parameters container |
| required | tag whether the component is required to run a simulation |
| owner | a reference to the owner of the ParamSet (should be this). |
Reimplemented from SimComponent.
Definition at line 128 of file lifecycleevent.h.
References SimComponent::add_parameter(), and INT.
Referenced by set_event_name().
{
SimComponent::set_paramset(name, required, owner);
add_parameter(name.c_str(),INT,1,0,0,0,0);
}
| virtual void LifeCycleEvent::set_pop_ptr | ( | Metapop * | popPtr | ) | [inline, virtual] |
Accessors for the population pointer.
| popPtr | The pointer to the current Metapop |
Definition at line 160 of file lifecycleevent.h.
References _popPtr.
{_popPtr = popPtr;}
std::string LifeCycleEvent::_event_name [protected] |
The param name to be read in the init file.
Definition at line 76 of file lifecycleevent.h.
Referenced by attach_trait(), get_event_name(), get_rank(), and set_event_name().
int LifeCycleEvent::_LCELinkedTraitIndex [protected] |
The index in the individual's trait table of the linked trait.
A value of -1 means the link is broken.
Definition at line 82 of file lifecycleevent.h.
Referenced by attach_trait(), LCE_Selection_base::getFitnessDirect(), LCE_Selection_base::getFitnessMultivariateGaussian(), LCE_Selection_base::getFitnessMultivariateGaussian_VE(), LCE_Selection_base::getFitnessUnivariateGaussian(), LCE_Selection_base::getFitnessUnivariateGaussian_VE(), LCE_Breed_Wolbachia::hasInfectedFemale(), LCE_Breed_Wolbachia::inoculate_wolbachia(), LCE_Breed_Selection::makeOffspringWithSelection(), LCE_Breed_Wolbachia::wolbachia_model_1(), and LCE_Breed_Wolbachia::wolbachia_model_2().
std::string LifeCycleEvent::_LCELinkedTraitType [protected] |
The name of the linked trait.
Definition at line 80 of file lifecycleevent.h.
Referenced by attach_trait(), and init().
Metapop* LifeCycleEvent::_popPtr [protected] |
The ptr to the current Metapop.
Definition at line 78 of file lifecycleevent.h.
Referenced by attach_trait(), LCE_Breed_base::breed(), LCE_Breed_base::breed_cloning(), LCE_Breed_Selection_Disperse::breed_selection_disperse(), LCE_Resize::buildNewPatchArrayNoBackup(), LCE_Resize::buildNewPatchArrayWithBackup(), LCE_Disperse_base::checkBackwardDispersalMatrix(), LCE_Disperse_base::checkForwardDispersalMatrix(), LCE_Breed_Disperse::do_breed_disperse(), LCE_Selection_base::doViabilitySelection(), LCE_Disperse_EvolDisp::evoldisp(), LCE_ParamUpdaterNotifier::execute(), BinaryDataSaver::execute(), LCE_Breed_Disperse::execute(), LCE_Disperse_ConstDisp::execute(), LCE_Breed_Selection::execute(), LCE_Disperse_EvolDisp::execute(), LCE_Breed_Selection_Disperse::execute(), LCE_Selection_base::execute(), LCE_Resize::execute(), LCE_Breed::execute(), LCE_Breed_Wolbachia::execute(), LCE_Resize::fillPatchNoBackup(), LCE_Resize::fillPatchWithBackup(), LCE_Resize::fillPop(), BinaryDataSaver::finish(), LCE_Disperse_EvolDisp::fixdisp(), LCE_Breed_Disperse::get_parent(), get_pop_ptr(), LCE_Selection_base::getMeanFitness(), LCE_Selection_base::getMeanPatchFitness(), LCE_Breed_Wolbachia::hasInfectedFemale(), init(), LCE_Breed_Wolbachia::inoculate_wolbachia(), LCE_Breed_Selection::makeOffspringWithSelection(), LCE_Breed_Disperse::mate_full_selfing(), LCE_Breed_Disperse::mate_random(), LCE_Breed_Disperse::mate_random_hermaphrodite(), LCE_Breed_Disperse::mate_selfing(), LCE_Disperse_ConstDisp::Migrate(), LCE_Disperse_ConstDisp::MigratePatch(), LCE_Disperse_ConstDisp::MigratePatch_AbsorbingBorder(), LCE_Resize::regulate(), LCE_Resize::regulateAgeClassNoBackup(), LCE_Resize::removeDesignatedPatch(), LCE_Disperse_base::reset_counters(), set_pop_ptr(), LCE_Disperse_base::setParameters(), LCE_Disperse_EvolDisp::setParameters(), LCE_Selection_base::setParameters(), LCE_Disperse_base::setPropaguleTargets(), LCE_Selection_base::setSelectionMatrix(), LCE_Selection_base::setSpatialMatrix(), BinaryDataSaver::storeData(), LCE_Disperse_base::swapPostDisp(), LCE_Resize::updateParameters(), LCE_Resize::updatePatchCapacities(), LCE_Breed_Wolbachia::wolbachia_model_1(), and LCE_Breed_Wolbachia::wolbachia_model_2().
1.7.5.1 -- Nemo is hosted by