Nemo  2.3.46
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...
 

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 ( 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

References set_event_name().

99  : _popPtr(0), _LCELinkedTraitType(trait_link), _LCELinkedTraitIndex(-1)
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
Metapop * _popPtr
The ptr to the current Metapop.
Definition: lifecycleevent.h:81
std::string _LCELinkedTraitType
The name of the linked trait.
Definition: lifecycleevent.h:85

+ Here is the call graph for this function:

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

Member Function Documentation

virtual bool LifeCycleEvent::attach_trait ( string  trait)
inlinevirtual

References error(), and IndFactory::getTraitIndex().

Referenced by init().

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 error(const char *str,...)
Definition: output.cc:73
std::string _event_name
The param name to be read in the init file.
Definition: lifecycleevent.h:77
int getTraitIndex(trait_t type)
Gives the index of trait with type.
Definition: indfactory.cc:128
int _LCELinkedTraitIndex
The index in the individual's trait table of the linked trait.
Definition: lifecycleevent.h:89
Metapop * _popPtr
The ptr to the current Metapop.
Definition: lifecycleevent.h:81
std::string _LCELinkedTraitType
The name of the linked trait.
Definition: lifecycleevent.h:85
virtual string& LifeCycleEvent::get_event_name ( )
inlinevirtual

Accessor to the LCE's name.

References _event_name.

162  { return _event_name; }
std::string _event_name
The param name to be read in the init file.
Definition: lifecycleevent.h:77
virtual Metapop* LifeCycleEvent::get_pop_ptr ( )
inlinevirtual

References _popPtr.

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

175  { return _popPtr; }
Metapop * _popPtr
The ptr to the current Metapop.
Definition: lifecycleevent.h:81
virtual int LifeCycleEvent::get_rank ( )
inlinevirtual

Accessor to the LCE rank in the life cycle.

References SimComponent::get_parameter_value().

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

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
std::string _event_name
The param name to be read in the init file.
Definition: lifecycleevent.h:77
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

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

Referenced by SimRunner::init_components().

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

+ Here is the call graph for this function:

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.

References set_paramset().

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

149  {
150  _event_name = name;
151  set_paramset(name, 0, this);
152  }
std::string _event_name
The param name to be read in the init file.
Definition: lifecycleevent.h:77
virtual void set_paramset(std::string name, bool required, SimComponent *owner)
Definition: lifecycleevent.h:141
virtual void LifeCycleEvent::set_event_name ( const char *  name)
inlinevirtual

References set_paramset().

155  {
156  _event_name = name;
157  set_paramset(name, 0, this);
158  }
std::string _event_name
The param name to be read in the init file.
Definition: lifecycleevent.h:77
virtual void set_paramset(std::string name, bool required, SimComponent *owner)
Definition: lifecycleevent.h:141
virtual void LifeCycleEvent::set_paramset ( std::string  name,
bool  required,
SimComponent owner 
)
inlinevirtual

Reimplemented from SimComponent.

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

Referenced by set_event_name().

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
Definition: types.h:78
virtual void LifeCycleEvent::set_pop_ptr ( Metapop popPtr)
inlinevirtual

Accessors for the population pointer.

Parameters
popPtrThe pointer to the current Metapop
172  {_popPtr = popPtr;}
Metapop * _popPtr
The ptr to the current Metapop.
Definition: lifecycleevent.h:81

Member Data Documentation

std::string LifeCycleEvent::_event_name
protected

The param name to be read in the init file.

Referenced by get_event_name(), and LCE_Selection_base::setParameters().

std::string LifeCycleEvent::_LCELinkedTraitType
protected

The name of the linked trait.

Metapop* LifeCycleEvent::_popPtr
protected

The ptr to the current Metapop.

Referenced by LCE_Selection_base::addPhenotypicSD(), LCE_Breed_base::breed(), LCE_Breed_base::breed_cloning(), LCE_Breed_Selection_Disperse::breed_selection_disperse(), LCE_Resize::buildNewPatchArrayNoBackup(), LCE_Resize::buildNewPatchArrayWithBackup(), 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(), LCE_ParamUpdaterNotifier::execute(), LCE_QuantiInit::execute(), LCE_Regulation::execute(), BinaryDataSaver::execute(), LCE_NtrlInit::execute(), LCE_Aging::execute(), LCE_Disperse_ConstDisp::execute(), LCE_Patch_Extinction::execute(), LCE_Cross::execute(), LCE_Breed_Disperse::execute(), LCE_Disperse_EvolDisp::execute(), LCE_Breed_Wolbachia::execute(), LCE_Breed_Selection::execute(), LCE_Resize::execute(), LCE_Breed_Selection_Disperse::execute(), LCE_Selection_base::execute(), LCE_Init_BDMI::execute(), LCE_Breed::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(), LCE_QuantiInit::init_allele_freq(), LCE_NtrlInit::init_allele_freq(), LCE_QuantiInit::init_trait_value(), LCE_Init_BDMI::init_value(), 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_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_std_rate_of_change(), LCE_Disperse_base::setBaseParameters(), LCE_Breed_base::setFecundity(), LCE_Breed_Selection::setNonSelectedTraitTable(), LCE_QuantiInit::setParameters(), BinaryDataSaver::setParameters(), LCE_NtrlInit::setParameters(), LCE_Breed_Disperse::setParameters(), LCE_Disperse_EvolDisp::setParameters(), LCE_Breed_Wolbachia::setParameters(), LCE_Selection_base::setParameters(), LCE_Init_BDMI::setParameters(), LCE_Disperse_base::setPropaguleTargets(), LCE_Selection_base::setSelectionMatrix(), 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().


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

Generated for Nemo v2.3.0 by  doxygen 1.8.8 --
Catalogued on GSR