Nemo  2.3.56
Simulate forward-in-time genetic evolution in a spatially explicit, individual-based stochastic simulator
LifeCycleEvent Class Referenceabstract

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. More...
 
virtual ~LifeCycleEvent ()
 
virtual void init (Metapop *popPtr)
 Sets the pointer to the current Metapop and the trait link if applicable. More...
 
virtual bool attach_trait (string trait)
 
virtual void set_paramset (std::string name, bool required, SimComponent *owner)
 
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. More...
 
virtual void set_event_name (const char *name)
 
virtual string & get_event_name ()
 Accessor to the LCE's name. More...
 
virtual int get_rank ()
 Accessor to the LCE rank in the life cycle. More...
 
virtual void set_pop_ptr (Metapop *popPtr)
 Accessors for the population pointer. More...
 
virtual Metapopget_pop_ptr ()
 
LCE interface
virtual void execute ()=0
 Execute the event on the pop. More...
 
virtual LifeCycleEventclone ()=0
 Cloning interface. More...
 
virtual age_t removeAgeClass ()=0
 Removes the returned age-class flag(s) from the current Metapop age-class flags. More...
 
virtual age_t addAgeClass ()=0
 Adds the returned age-class flag(s) to the current Metapop age-class flags. More...
 
virtual age_t requiredAgeClass ()=0
 Specifies what age-classes are required by the LCE to execute. More...
 
- Public Member Functions inherited from SimComponent
 SimComponent ()
 
virtual ~SimComponent ()
 
virtual void loadFileServices (FileServices *loader)=0
 Loads the component's FileHandler onto the FileServices. More...
 
virtual void loadStatServices (StatServices *loader)=0
 Loads the component's StatHandler onto the StatServices. More...
 
virtual void loadUpdaters (UpdaterServices *loader)
 Loads the parameters and component updater onto the updater manager. More...
 
virtual bool setParameters ()=0
 Default interface needed to initialize the component's variables from its input parameters value. More...
 
virtual void set_paramset (ParamSet *paramset)
 Sets the ParamSet member. More...
 
virtual void set_paramsetFromCopy (const ParamSet &PSet)
 Reset the set of parameters from a another set. More...
 
virtual ParamSetget_paramset ()
 ParamSet accessor. More...
 
virtual void add_parameter (Param *param)
 Interface to add a parameter to the set. More...
 
virtual void add_parameter (std::string Name, param_t Type, bool isRequired, bool isBounded, double low_bnd, double up_bnd)
 Interface to add a parameter to the set. More...
 
virtual void add_parameter (std::string Name, param_t Type, bool isRequired, bool isBounded, double low_bnd, double up_bnd, ParamUpdaterBase *updater)
 Interface to add a parameter and its updater to the set. More...
 
virtual Paramget_parameter (std::string name)
 Param getter. More...
 
virtual double get_parameter_value (std::string name)
 Param value getter. More...
 
virtual string get_name ()
 Returnd the name of the ParamSet, i.e. More...
 
virtual bool has_parameter (std::string name)
 Param getter. More...
 
virtual bool resetParameterFromSource (std::string param, SimComponent *cmpt)=0
 

Protected Attributes

std::string _event_name
 The param name to be read in the init file. More...
 
Metapop_popPtr
 The ptr to the current Metapop. More...
 
std::string _LCELinkedTraitType
 The name of the linked trait. More...
 
int _LCELinkedTraitIndex
 The index in the individual's trait table of the linked trait. More...
 
- Protected Attributes inherited from SimComponent
ParamSet_paramSet
 The parameters container. More...
 

Detailed Description

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!

Constructor & Destructor Documentation

◆ LifeCycleEvent()

LifeCycleEvent::LifeCycleEvent ( const char *  name,
const char *  trait_link 
)
inline

Cstor.

Parameters
namethe name of the LCE as it must appear in the parameter input file
trait_linkthe name of the linked trait used by this LCE
100 {
101// cout << "calling LifeCycleEvent("<<name<<","<<trait_link<<")\n";
102 set_event_name(name);
103 }
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.
Definition: lifecycleevent.h:148
int _LCELinkedTraitIndex
The index in the individual's trait table of the linked trait.
Definition: lifecycleevent.h:89
std::string _LCELinkedTraitType
The name of the linked trait.
Definition: lifecycleevent.h:85
Metapop * _popPtr
The ptr to the current Metapop.
Definition: lifecycleevent.h:81

References set_event_name().

+ Here is the call graph for this function:

◆ ~LifeCycleEvent()

virtual LifeCycleEvent::~LifeCycleEvent ( )
inlinevirtual
106{ }

Member Function Documentation

◆ addAgeClass()

◆ attach_trait()

virtual bool LifeCycleEvent::attach_trait ( string  trait)
inlinevirtual
124 {
125 _LCELinkedTraitType = trait;
126
127 if(_LCELinkedTraitType.size() != 0) {
128
130
131 if(_LCELinkedTraitIndex == -1) {
132 return error("cannot attach trait \"%s\" to life cycle event \"%s\", trait has not been initiated.\n",
133 _LCELinkedTraitType.c_str(), _event_name.c_str());
134 }
135
136 }
137
138 return true;
139 }
int getTraitIndex(trait_t type)
Gives the index of trait with type.
Definition: indfactory.cc:128
std::string _event_name
The param name to be read in the init file.
Definition: lifecycleevent.h:77
int error(const char *str,...)
Definition: output.cc:77

References _event_name, _LCELinkedTraitIndex, _LCELinkedTraitType, _popPtr, error(), and IndFactory::getTraitIndex().

Referenced by init().

+ Here is the caller graph for this function:

◆ clone()

◆ execute()

◆ get_event_name()

virtual string & LifeCycleEvent::get_event_name ( )
inlinevirtual

Accessor to the LCE's name.

162 { return _event_name; }

References _event_name.

◆ get_pop_ptr()

virtual Metapop * LifeCycleEvent::get_pop_ptr ( )
inlinevirtual
175 { return _popPtr; }

References _popPtr.

Referenced by LCE_ParamUpdaterNotifier::execute(), and LCE_FileServicesNotifier::execute().

+ Here is the caller graph for this function:

◆ get_rank()

virtual int LifeCycleEvent::get_rank ( )
inlinevirtual

Accessor to the LCE rank in the life cycle.

167 { return (int)get_parameter_value(_event_name.c_str()); }
virtual double get_parameter_value(std::string name)
Param value getter.
Definition: simcomponent.h:143

References _event_name, and SimComponent::get_parameter_value().

Referenced by BinaryDataSaver::FHwrite(), BinaryDataSaver::setParameters(), and LCE_StatServiceNotifier::setParameters().

+ Here is the caller graph for this function:

◆ init()

virtual void LifeCycleEvent::init ( Metapop popPtr)
inlinevirtual

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!

Parameters
popPtrthe pointer to the current instance of Metapop
115 {
116 _popPtr = popPtr;
117 if(!attach_trait(_LCELinkedTraitType)) fatal("bailing out\n");
118 if(!setParameters()) fatal("bailing out\n");
119 }
virtual bool attach_trait(string trait)
Definition: lifecycleevent.h:123
virtual bool setParameters()=0
Default interface needed to initialize the component's variables from its input parameters value.
void fatal(const char *str,...)
Definition: output.cc:96

References _LCELinkedTraitType, _popPtr, attach_trait(), fatal(), and SimComponent::setParameters().

Referenced by SimRunner::init_components().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeAgeClass()

◆ requiredAgeClass()

◆ set_event_name() [1/2]

virtual void LifeCycleEvent::set_event_name ( const char *  name)
inlinevirtual
155 {
156 _event_name = name;
157 set_paramset(name, 0, this);
158 }
virtual void set_paramset(std::string name, bool required, SimComponent *owner)
Definition: lifecycleevent.h:141

References _event_name, and set_paramset().

◆ set_event_name() [2/2]

virtual void LifeCycleEvent::set_event_name ( std::string &  name)
inlinevirtual

Set the name of the event (name of the ParamSet) and add the corresponding parameter to the set.


149 {
150 _event_name = name;
151 set_paramset(name, 0, this);
152 }

References _event_name, and set_paramset().

Referenced by LCE_SeedDisp::LCE_SeedDisp(), and LifeCycleEvent().

+ Here is the caller graph for this function:

◆ set_paramset()

virtual void LifeCycleEvent::set_paramset ( std::string  name,
bool  required,
SimComponent owner 
)
inlinevirtual

Reimplemented from SimComponent.

142 {
143 SimComponent::set_paramset(name, required, owner);
144 add_parameter(name.c_str(),INT,1,0,0,0,0);
145 }
virtual void set_paramset(ParamSet *paramset)
Sets the ParamSet member.
Definition: simcomponent.h:86
virtual void add_parameter(Param *param)
Interface to add a parameter to the set.
Definition: simcomponent.h:112
@ INT
Definition: types.h:78

References SimComponent::add_parameter(), INT, and SimComponent::set_paramset().

Referenced by set_event_name().

+ Here is the caller graph for this function:

◆ set_pop_ptr()

virtual void LifeCycleEvent::set_pop_ptr ( Metapop popPtr)
inlinevirtual

Accessors for the population pointer.

Parameters
popPtrThe pointer to the current Metapop
172 {_popPtr = popPtr;}

References _popPtr.

Member Data Documentation

◆ _event_name

std::string LifeCycleEvent::_event_name
protected

The param name to be read in the init file.

Referenced by attach_trait(), get_event_name(), get_rank(), set_event_name(), and LCE_Selection_base::setParameters().

◆ _LCELinkedTraitIndex

◆ _LCELinkedTraitType

std::string LifeCycleEvent::_LCELinkedTraitType
protected

The name of the linked trait.

Referenced by attach_trait(), and init().

◆ _popPtr

Metapop* LifeCycleEvent::_popPtr
protected

The ptr to the current Metapop.

Referenced by LCE_Selection_base::addPhenotypicSD(), 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_Breed_base::checkCloning(), LCE_Breed_base::checkSelfing(), LCE_Cross::create_individual_ancestors(), LCE_Breed_Disperse::do_breed_disperse(), LCE_Patch_Extinction::do_flush(), LCE_Patch_Extinction::do_remove(), LCE_Selection_base::doViabilitySelection(), LCE_Disperse_EvolDisp::evoldisp(), BinaryDataSaver::execute(), LCE_Breed::execute(), LCE_Breed_Disperse::execute(), LCE_Breed_Selection::execute(), LCE_Breed_Selection_Disperse::execute(), LCE_Disperse_ConstDisp::execute(), LCE_Disperse_EvolDisp::execute(), LCE_Regulation::execute(), LCE_Aging::execute(), LCE_Patch_Extinction::execute(), LCE_Cross::execute(), LCE_Resize::execute(), LCE_QuantiInit::execute(), LCE_QuantiModifier::execute(), LCE_Breed_Quanti::execute(), LCE_Selection_base::execute(), LCE_ParamUpdaterNotifier::execute(), LCE_Init_BDMI::execute(), LCE_NtrlInit::execute(), LCE_Breed_Wolbachia::execute(), LCE_Resize::fillPatchNoBackup(), LCE_Resize::fillPatchWithBackup(), LCE_Resize::fillPop(), BinaryDataSaver::finish(), LCE_Disperse_EvolDisp::fixdisp(), LCE_Cross::generatePedigree(), LCE_Breed_Disperse::get_parent(), get_pop_ptr(), LCE_Selection_base::getMaxFitness(), LCE_Selection_base::getMaxPatchFitness(), LCE_Selection_base::getMeanFitness(), LCE_Selection_base::getMeanPatchFitness(), LCE_Breed_Wolbachia::hasInfectedFemale(), init(), LCE_NtrlInit::init_allele_freq(), LCE_QuantiInit::init_allele_freq(), LCE_QuantiInit::init_trait_value(), LCE_Init_BDMI::init_value(), LCE_Breed_Wolbachia::inoculate_wolbachia(), LCE_FileServicesNotifier::loadFileServices(), 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_Disperse_ConstDisp::MigratePatchByNumber(), LCE_Breed_base::NonWrightFisherPopulation(), LCE_Breed_Quanti::NonWrightFisherPopulation(), BinaryDataSaver::printOffsetTable(), LCE_Resize::regulate(), LCE_Resize::regulateAgeClassNoBackup(), LCE_Regulation::regulatePatch(), LCE_Resize::removeDesignatedPatch(), LCE_Disperse_base::reset_counters(), LCE_Cross::sampleAmongPop(), LCE_Cross::sampleWithinPop(), LCE_Selection_base::set_local_optima(), LCE_Patch_Extinction::set_matrix_param(), LCE_Selection_base::set_param_rate_of_change(), set_pop_ptr(), LCE_Selection_base::set_sel_model(), LCE_Selection_base::set_std_rate_of_change(), LCE_Disperse_base::setBaseParameters(), LCE_Breed_base::setFecundity(), LCE_Breed_base::setMatingSystem(), LCE_Breed_Selection::setNonSelectedTraitTable(), BinaryDataSaver::setParameters(), LCE_Breed_Disperse::setParameters(), LCE_Disperse_EvolDisp::setParameters(), LCE_QuantiInit::setParameters(), LCE_QuantiModifier::setParameters(), LCE_Breed_Quanti::setParameters(), LCE_Selection_base::setParameters(), LCE_Init_BDMI::setParameters(), LCE_NtrlInit::setParameters(), LCE_Breed_Wolbachia::setParameters(), LCE_Disperse_base::setPropaguleTargets(), LCE_Selection_base::setSelectionMatrix(), LCE_Breed_Quanti::setVefromVa(), BinaryDataSaver::storeData(), LCE_Disperse_base::swapPostDisp(), LCE_Resize::updateParameters(), LCE_Resize::updatePatchCapacities(), LCE_Breed_Wolbachia::wolbachia_model_1(), LCE_Breed_Wolbachia::wolbachia_model_2(), LCE_Breed_base::WrightFisherPopulation(), and LCE_Breed_Quanti::WrightFisherPopulation().


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

Generated for Nemo v2.3.56 by  doxygen 1.9.0 -- Nemo is hosted on  Download Nemo

Locations of visitors to this page
Catalogued on GSR