Nemo  2.3.46
LCE_Breed_Selection Class Reference

Composite LCE implementing breeding and viability selection on a given trait type. More...

#include <LCEcomposite.h>

+ Inheritance diagram for LCE_Breed_Selection:
+ Collaboration diagram for LCE_Breed_Selection:

Public Member Functions

 LCE_Breed_Selection ()
 
virtual ~LCE_Breed_Selection ()
 
bool setNonSelectedTraitTable ()
 Builds the vector of traits not under selection. More...
 
IndividualmakeOffspringWithSelection (Individual *ind, unsigned int natalpatch)
 Performs viability selection and breeding at the same time. More...
 
void do_breed_selection_FecFitness (Patch *patch, unsigned int patchID, unsigned int *cntr)
 
void do_breed_selection_OffSurvival (Patch *patch, unsigned int patchID, unsigned int *cntr)
 
Implementations
virtual bool setParameters ()
 
virtual void execute ()
 
virtual LifeCycleEventclone ()
 
virtual void loadFileServices (FileServices *loader)
 
virtual void loadStatServices (StatServices *loader)
 
virtual age_t removeAgeClass ()
 
virtual age_t addAgeClass ()
 
virtual age_t requiredAgeClass ()
 
- Public Member Functions inherited from LCE_Breed_base
 LCE_Breed_base ()
 
virtual ~LCE_Breed_base ()
 
virtual IndividualgetFatherPtr (Patch *thePatch, Individual *mother, unsigned int motherIndex)
 Calls the mating function according to the model chosen using the function pointer, used to get the father from the mother in a patch. More...
 
Individualbreed (Individual *mother, Individual *father, unsigned int LocalPatch)
 Makes a new individual with the right parents. More...
 
Individualbreed_cloning (Individual *mother, Individual *father, unsigned int LocalPatch)
 Makes a new individual by doing a deep copy of the mother (copies the mother's genes into the offspring). More...
 
IndividualmakeOffspring (Individual *ind)
 Last step of the breeding process, does inheritance and mutation of the parents' genes. More...
 
Individualdo_breed (Individual *mother, Individual *father, unsigned int LocalPatch)
 Calls the breeding function unsing its pointer. More...
 
bool checkMatingCondition (Patch *thePatch)
 Checks if any mating will take place in the patch passed as argument. More...
 
bool checkNoSelfing (Patch *thePatch)
 Checks whether mating will take place in the current patch when mating is not selfing or cloning. More...
 
bool checkPolygyny (Patch *thePatch)
 Checks whether mating will take place in the current patch when mating is polygynous. More...
 
bool checkSelfing (Patch *thePatch)
 Checks whether mating will take place in the current patch when mating is selfing. More...
 
bool checkCloning (Patch *thePatch)
 Checks whether mating will take place in the current patch when mating is cloning. More...
 
bool setMatingSystem ()
 
bool setFecundity ()
 
bool setSexRatio ()
 
double getMatingProportion ()
 
double getMeanFecundity (unsigned int patch)
 
int getMatingSystem ()
 
bool doInheritance ()
 
double getPoissonFecundity (double mean)
 
double getFixedFecundity (double mean)
 
double getGaussianFecundity (double mean)
 
double getFecundity (unsigned int patch)
 
double getFecundity (double mean)
 
sex_t getOffsprgSex ()
 
sex_t getOffsprgSexRandom ()
 
sex_t getOffsprgSexFixed ()
 
sex_t getOffsprgSexSelfing ()
 
sex_t getOffsprgSexCloning ()
 
IndividualRandomMating (Patch *thePatch, Individual *mother, unsigned int motherIndex)
 Returns a pointer to a male drawn randomly from a patch. More...
 
IndividualfullPolyginy (Patch *thePatch, Individual *mother, unsigned int motherIndex)
 Returns a pointer to the alpha male of the patch. More...
 
IndividualfullPolyginy_manyMales (Patch *thePatch, Individual *mother, unsigned int motherIndex)
 Returns a pointer to one of the first _mating_males males of the patch. More...
 
IndividualpartialPolyginy (Patch *thePatch, Individual *mother, unsigned int motherIndex)
 Returns a pointer to a male from a patch chosen at random if _mating_proportion != 1, or the first male otherwise. More...
 
IndividualpartialPolyginy_manyMales (Patch *thePatch, Individual *mother, unsigned int motherIndex)
 Returns a pointer to a male from a patch chosen at random if _mating_proportion != 1, or one of the _mating_males first males otherwise. More...
 
IndividualfullMonoginy (Patch *thePatch, Individual *mother, unsigned int motherIndex)
 Returns a pointer to a male with same index as mother (if available) from the focal patch. More...
 
IndividualpartialMonoginy (Patch *thePatch, Individual *mother, unsigned int motherIndex)
 Returns a pointer to a male with same index as mother (if available) from the focal patch. More...
 
IndividualfullSelfing (Patch *thePatch, Individual *mother, unsigned int motherIndex)
 Returns the mother pointer. More...
 
IndividualpartialSelfing (Patch *thePatch, Individual *mother, unsigned int motherIndex)
 Returns the mother pointer or a random female if _mating_proportion != 1. More...
 
Individualrandom_hermaphrodite (Patch *thePatch, Individual *mother, unsigned int motherIndex)
 Returns a random female from the patch, will be the same mother with probability 1/N (Wright-Fisher model). More...
 
- Public Member Functions inherited from LifeCycleEvent
 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 ()
 
- Public Member Functions inherited from SimComponent
 SimComponent ()
 
virtual ~SimComponent ()
 
virtual void loadUpdaters (UpdaterServices *loader)
 Loads the parameters and component updater onto the updater manager. 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...
 
- Public Member Functions inherited from LCE_Selection_base
 LCE_Selection_base ()
 
virtual ~LCE_Selection_base ()
 
bool setSelectionMatrix ()
 
bool setLocalOptima ()
 
bool set_sel_model ()
 
bool set_fit_model ()
 
bool set_local_optima ()
 
bool set_param_rate_of_change ()
 
void set_std_rate_of_change ()
 
void addPhenotypicSD (unsigned int deme, double *stDev)
 
void changeLocalOptima ()
 
void resetCounters ()
 Resets the fitness counters. More...
 
void setMeans (unsigned int tot_ind)
 Computes the average fitness of each pedigree class. More...
 
double getMeanFitness (age_idx age)
 Computes the mean fitness of the whole population for a given age class. More...
 
double getMeanPatchFitness (age_idx age, unsigned int p)
 Computes the mean fitness in a given patch for a given age class. More...
 
double getMaxFitness (age_idx age)
 Computes the maximum fitness value of the whole population for a given age class. More...
 
double getMaxPatchFitness (age_idx age, unsigned int p)
 Computes the maximum fitness value in a given patch for a given age class. More...
 
double setMeanFitness (age_idx age)
 Sets the _mean_fitness variable to the value of the mean population fitness. More...
 
double getFitness (Individual *ind, unsigned int patch)
 Calls the fitness function according to the fitness model. More...
 
double getFitnessFixedEffect (Individual *offsprg, unsigned int patch, unsigned int trait)
 Returns the fitness of an individual in the fixed selection model. More...
 
double getFitnessDirect (Individual *offsprg, unsigned int patch, unsigned int trait)
 Returns the fitness of an individual following the direct selection model. More...
 
double getFitnessUnivariateQuadratic (Individual *ind, unsigned int patch, unsigned int trait)
 Quadratic fitness surface, approximates the Gaussian model for weak selection and/or small deviation from the optimum. More...
 
double getFitnessMultivariateGaussian (Individual *offsprg, unsigned int patch, unsigned int trait)
 Returns the fitness of an individual following the Gaussian selection model with one trait under selection. More...
 
double getFitnessUnivariateGaussian (Individual *offsprg, unsigned int patch, unsigned int trait)
 Returns the fitness of an individual following the Gaussian selection model with several traits under selection. More...
 
double getFitnessMultivariateGaussian_VE (Individual *offsprg, unsigned int patch, unsigned int trait)
 Returns the fitness of an individual following the Gaussian selection model with one trait under selection and environmental variance. More...
 
double getFitnessUnivariateGaussian_VE (Individual *offsprg, unsigned int patch, unsigned int trait)
 Returns the fitness of an individual following the Gaussian selection model with several traits under selection and environmental variance. More...
 
double getFitnessAbsolute (Individual *ind, unsigned int patch)
 Returns the raw fitness of the individual, without adjustment (absolute fitness). More...
 
double getFitnessRelative (Individual *ind, unsigned int patch)
 Returns the relative fitness of the individual, adjusted by a scaling factor. More...
 
void setScalingFactorLocal (age_idx age, unsigned int p)
 Sets the fitness scaling factor equal to the inverse of the mean local patch fitness. More...
 
void setScalingFactorGlobal (age_idx age, unsigned int p)
 Sets the fitness scaling factor equal to the inverse of the mean population fitness. More...
 
void setScalingFactorMaxLocal (age_idx age, unsigned int p)
 Sets the fitness scaling factor equal to the inverse of the maximum local patch fitness value. More...
 
void setScalingFactorMaxGlobal (age_idx age, unsigned int p)
 Sets the fitness scaling factor equal to the inverse of the maximum population fitness value. More...
 
void setScalingFactorAbsolute (age_idx age, unsigned int p)
 Resets the fitness scaling factor equal to one. More...
 
void doViabilitySelection (sex_t SEX, age_idx AGE, Patch *patch, unsigned int p)
 Selectively removes individuals in the population depending on their fitness. More...
 

Private Attributes

void(LCE_Breed_Selection::* _breed_selection )(Patch *patch, unsigned int patchID, unsigned int *cntr)
 
unsigned int _nb_trait
 
vector< unsigned int_nonSelectedTraitIndices
 

Additional Inherited Members

- Protected Attributes inherited from LCE_Breed_base
TMatrix_mean_fecundity
 
- Protected Attributes inherited from LifeCycleEvent
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...
 
- Protected Attributes inherited from LCE_Selection_base
double _letheq
 
double _base_fitness
 
double _mean_fitness
 
double _max_fitness
 
double _scaling_factor
 
bool _is_local
 
bool _is_absolute
 
double _fitness [5]
 Fitness counters, one for each pedigree class. More...
 
double _survival [5]
 
double _ind_cntr [5]
 
vector< unsigned int_TraitIndices
 The indices of the traits under selection. More...
 
vector< string > _SelectionModels
 The selection models associated with each trait under selection. More...
 
LCE_SelectionSH_stater
 
LCE_SelectionFH_writer
 
int _selectTraitDimension
 Number of quantitative traits under selection. More...
 
vector< double > _selection_variance
 Patch-specific selection variance. More...
 
double _eVariance
 Evironmental variance. More...
 
vector< double(LCE_Selection_base::*)(Individual
*, unsigned int, unsigned int) > 
_getRawFitness
 A vector containing pointers to fitness function related to each trait under selection. More...
 
double(LCE_Selection_base::* _getFitness )(Individual *, unsigned int)
 Pointer to the function returning the individual fitness. More...
 
void(LCE_Selection_base::* _setScalingFactor )(age_idx, unsigned int)
 Pointer to the function used to set the fitness scaling factor when fitness is relative. More...
 
void(LCE_Selection_base::* _setNewLocalOptima )(void)
 Pointer to the function used to change the local phenotypic optima or its rate of change. More...
 

Detailed Description

Composite LCE implementing breeding and viability selection on a given trait type.

Inherits from LCE_Breed_base and LCE_Selection_base.

Constructor & Destructor Documentation

LCE_Breed_Selection::LCE_Breed_Selection ( )

References SimComponent::add_parameter(), and BOOL.

Referenced by clone().

502  : LifeCycleEvent("breed_selection",""),
504 {
505  add_parameter("breed_selection_fecundity_fitness", BOOL, false, false, 0, 0, 0);
506 }
LifeCycleEvent(const char *name, const char *trait_link)
Cstor.
Definition: lifecycleevent.h:98
unsigned int _nb_trait
Definition: LCEcomposite.h:214
virtual void add_parameter(Param *param)
Interface to add a parameter to the set.
Definition: simcomponent.h:112
void(LCE_Breed_Selection::* _breed_selection)(Patch *patch, unsigned int patchID, unsigned int *cntr)
Definition: LCEcomposite.h:212
Definition: types.h:78
virtual LCE_Breed_Selection::~LCE_Breed_Selection ( )
inlinevirtual
221 {}

Member Function Documentation

virtual age_t LCE_Breed_Selection::addAgeClass ( )
inlinevirtual

Reimplemented from LCE_Selection_base.

Reimplemented in LCE_Breed_Selection_Disperse.

References OFFSPRG.

246 {return OFFSPRG;}
#define OFFSPRG
Offspring age class flag.
Definition: types.h:50
virtual LifeCycleEvent* LCE_Breed_Selection::clone ( )
inlinevirtual

Reimplemented from LCE_Selection_base.

Reimplemented in LCE_Breed_Selection_Disperse.

References LCE_Breed_Selection().

242 { return new LCE_Breed_Selection(); }
LCE_Breed_Selection()
Definition: LCEcomposite.cc:502
void LCE_Breed_Selection::do_breed_selection_FecFitness ( Patch patch,
unsigned int  patchID,
unsigned int cntr 
)

References LCE_Selection_base::_fitness, LCE_Selection_base::_ind_cntr, LCE_Selection_base::_setScalingFactor, LCE_Selection_base::_survival, Patch::add(), ADLTx, LCE_Breed_base::do_breed(), FEM, Patch::get(), LCE_Breed_base::getFatherPtr(), LCE_Breed_base::getFecundity(), LCE_Selection_base::getFitness(), LCE_Breed_base::getMeanFecundity(), Individual::getPedigreeClass(), Individual::getSex(), LCE_Breed_base::makeOffspring(), OFFSx, Individual::setFecundity(), and Patch::size().

Referenced by setParameters().

645 {
646  unsigned int nbBaby;
647  //double mean_fec;
648  Individual* FatherPtr;
649  Individual* MotherPtr;
650  Individual* NewOffsprg;
651  unsigned int cat;
652 
653  for(unsigned int size = patch->size(FEM, ADLTx), indexOfMother = 0;
654  indexOfMother < size;
655  indexOfMother++) {
656 
657  (this->*_setScalingFactor)(ADLTx, patchID); //from within LCE_selection_base
658 
659  MotherPtr = patch->get(FEM, ADLTx, indexOfMother);
660 
661  nbBaby = (unsigned int)MotherPtr->setFecundity( getFecundity(getMeanFecundity(patchID)*
662  getFitness(MotherPtr, patchID)) );
663 
664  (*cntr) += nbBaby;
665  //-----------------------------------------------------------------------
666  while(nbBaby != 0) {
667 
668 
669  FatherPtr = this->getFatherPtr(patch, MotherPtr, indexOfMother);
670 
671  NewOffsprg = LCE_Breed_base::makeOffspring( LCE_Breed_base::do_breed(MotherPtr, FatherPtr, patchID) );
672 
673  patch->add(NewOffsprg->getSex(), OFFSx, NewOffsprg);
674 
675  nbBaby--;
676 
677  cat = NewOffsprg->getPedigreeClass();
678 
679  _fitness[cat] += getFitness(NewOffsprg, patchID);
680  _ind_cntr[cat]++;
681  _survival[cat]++;
682 
683  }//_END__WHILE;
684  }//end_for indexOfMother
685 
686 }
double _ind_cntr[5]
Definition: LCEselection.h:92
double getFecundity(unsigned int patch)
Definition: LCEbreed.h:102
unsigned int size(age_t AGE)
Returns the size of the container of the appropriate age class(es) for both sexes.
Definition: metapop.h:487
double _fitness[5]
Fitness counters, one for each pedigree class.
Definition: LCEselection.h:92
virtual Individual * getFatherPtr(Patch *thePatch, Individual *mother, unsigned int motherIndex)
Calls the mating function according to the model chosen using the function pointer, used to get the father from the mother in a patch.
Definition: LCEbreed.h:75
Individual * do_breed(Individual *mother, Individual *father, unsigned int LocalPatch)
Calls the breeding function unsing its pointer.
Definition: LCEbreed.h:148
Definition: types.h:42
double getMeanFecundity(unsigned int patch)
Definition: LCEbreed.h:94
double setFecundity(double value)
Sets the fecundity to the value given and returns it.
Definition: individual.h:207
unsigned int getPedigreeClass()
Returns the pedigree class of the individual, as set during offspring creation.
Definition: individual.h:179
Definition: types.h:42
Individual * get(sex_t SEX, age_idx AGE, unsigned int at)
Returns a pointer to the individual sitting at the index passed.
Definition: metapop.h:523
double getFitness(Individual *ind, unsigned int patch)
Calls the fitness function according to the fitness model.
Definition: LCEselection.h:204
double _survival[5]
Definition: LCEselection.h:92
sex_t getSex()
Definition: individual.h:129
This class contains traits along with other individual information (sex, pedigree, etc. ).
Definition: individual.h:49
void add(sex_t SEX, age_idx AGE, Individual *ind)
Adds an individual to the appropriate container, increments its size, eventually resizing it...
Definition: metapop.h:540
Definition: types.h:37
Individual * makeOffspring(Individual *ind)
Last step of the breeding process, does inheritance and mutation of the parents' genes.
Definition: LCEbreed.cc:362
void(LCE_Selection_base::* _setScalingFactor)(age_idx, unsigned int)
Pointer to the function used to set the fitness scaling factor when fitness is relative.
Definition: LCEselection.h:125
void LCE_Breed_Selection::do_breed_selection_OffSurvival ( Patch patch,
unsigned int  patchID,
unsigned int cntr 
)

References Patch::add(), ADLTx, LCE_Breed_base::do_breed(), FEM, Patch::get(), LCE_Breed_base::getFatherPtr(), LCE_Breed_base::getFecundity(), Individual::getSex(), makeOffspringWithSelection(), OFFSx, Individual::setFecundity(), and Patch::size().

Referenced by setParameters().

609 {
610  unsigned int nbBaby;
611  //double mean_fec;
612  Individual* FatherPtr;
613  Individual* MotherPtr;
614  Individual* NewOffsprg;
615 
616  for(unsigned int size = patch->size(FEM, ADLTx), indexOfMother = 0;
617  indexOfMother < size;
618  indexOfMother++) {
619 
620  MotherPtr = patch->get(FEM, ADLTx, indexOfMother);
621 
622  nbBaby = (unsigned int)MotherPtr->setFecundity( getFecundity(patchID) );
623 
624  (*cntr) += nbBaby;
625  //-----------------------------------------------------------------------
626  while(nbBaby != 0) {
627 
628  FatherPtr = this->getFatherPtr(patch, MotherPtr, indexOfMother);
629 
630  NewOffsprg = makeOffspringWithSelection( LCE_Breed_base::do_breed(MotherPtr, FatherPtr, patchID), patchID );
631 
632  if(NewOffsprg != NULL)
633  patch->add(NewOffsprg->getSex(), OFFSx, NewOffsprg);
634 
635  nbBaby--;
636 
637  }//_END__WHILE;
638  }//end_for indexOfMother
639 
640 }
double getFecundity(unsigned int patch)
Definition: LCEbreed.h:102
unsigned int size(age_t AGE)
Returns the size of the container of the appropriate age class(es) for both sexes.
Definition: metapop.h:487
virtual Individual * getFatherPtr(Patch *thePatch, Individual *mother, unsigned int motherIndex)
Calls the mating function according to the model chosen using the function pointer, used to get the father from the mother in a patch.
Definition: LCEbreed.h:75
Individual * makeOffspringWithSelection(Individual *ind, unsigned int natalpatch)
Performs viability selection and breeding at the same time.
Definition: LCEcomposite.cc:690
Individual * do_breed(Individual *mother, Individual *father, unsigned int LocalPatch)
Calls the breeding function unsing its pointer.
Definition: LCEbreed.h:148
Definition: types.h:42
double setFecundity(double value)
Sets the fecundity to the value given and returns it.
Definition: individual.h:207
Definition: types.h:42
Individual * get(sex_t SEX, age_idx AGE, unsigned int at)
Returns a pointer to the individual sitting at the index passed.
Definition: metapop.h:523
sex_t getSex()
Definition: individual.h:129
This class contains traits along with other individual information (sex, pedigree, etc. ).
Definition: individual.h:49
void add(sex_t SEX, age_idx AGE, Individual *ind)
Adds an individual to the appropriate container, increments its size, eventually resizing it...
Definition: metapop.h:540
Definition: types.h:37
void LCE_Breed_Selection::execute ( )
virtual

Reimplemented from LCE_Selection_base.

Reimplemented in LCE_Breed_Selection_Disperse.

References _breed_selection, LCE_Selection_base::_mean_fitness, LifeCycleEvent::_popPtr, LCE_Selection_base::_scaling_factor, ADULTS, LCE_Breed_base::checkMatingCondition(), Metapop::flush(), Metapop::getPatch(), Metapop::getPatchNbr(), message(), OFFSPRG, OFFSx, LCE_Selection_base::resetCounters(), LCE_Selection_base::setMeans(), Metapop::size(), and warning().

568 {
569  Patch* current_patch;
570  unsigned int ind_count;
571 
572  if(_popPtr->size(OFFSPRG) != 0) {
573  warning("offspring containers not empty at time of breeding, flushing.\n");
574  _popPtr->flush(OFFSx);
575  }
576 
577 #ifdef _DEBUG_
578  message("LCE_Breed_Selection::execute\n");
579 #endif
580 
581  _scaling_factor = 1;
582  _mean_fitness = 0;
583  ind_count = 0;
584 
586 
587  for(unsigned int home = 0; home < _popPtr->getPatchNbr(); home++) {
588 
589  current_patch = _popPtr->getPatch(home);
590 
591  if( !checkMatingCondition(current_patch) ) continue;
592 
593  (this->* _breed_selection) (current_patch, home, &ind_count);
594 
595  }//end_for home
596 
597  LCE_Selection_base::setMeans(ind_count);
598 
599 #ifdef _DEBUG_
600  message(" (offsprg nb: %i adults nb: %i, mean fitness: %f)\n",_popPtr->size(OFFSPRG),
602 #endif
603 
604 }
void message(const char *message,...)
Definition: output.cc:40
#define ADULTS
Adults age class flag (breeders).
Definition: types.h:54
void setMeans(unsigned int tot_ind)
Computes the average fitness of each pedigree class.
Definition: LCEselection.h:164
Second class in the metapopulation design structure, between the Metapop and Individual classes...
Definition: metapop.h:421
Patch * getPatch(unsigned int i)
Patch accessor, return the ith+1 patch in the metapop.
Definition: metapop.h:251
unsigned int getPatchNbr()
Definition: metapop.h:270
double _mean_fitness
Definition: LCEselection.h:89
void warning(const char *str,...)
Definition: output.cc:56
void resetCounters()
Resets the fitness counters.
Definition: LCEselection.h:153
bool checkMatingCondition(Patch *thePatch)
Checks if any mating will take place in the patch passed as argument.
Definition: LCEbreed.h:157
void flush()
Removes all individual pointers and flush them into the recycling pool.
Definition: metapop.h:796
void(LCE_Breed_Selection::* _breed_selection)(Patch *patch, unsigned int patchID, unsigned int *cntr)
Definition: LCEcomposite.h:212
Definition: types.h:42
#define OFFSPRG
Offspring age class flag.
Definition: types.h:50
unsigned int size()
Get the total number of individuals present in the population, all sex and age classes together...
Definition: metapop.h:302
double _scaling_factor
Definition: LCEselection.h:89
Metapop * _popPtr
The ptr to the current Metapop.
Definition: lifecycleevent.h:81
virtual void LCE_Breed_Selection::loadFileServices ( FileServices loader)
inlinevirtual

Reimplemented from LCE_Selection_base.

Reimplemented in LCE_Breed_Selection_Disperse.

243 {}
void LCE_Breed_Selection::loadStatServices ( StatServices loader)
virtual

Reimplemented from LCE_Selection_base.

Reimplemented in LCE_Breed_Selection_Disperse.

References LCE_Selection_base::loadStatServices().

561 {
563 }
virtual void loadStatServices(StatServices *loader)
Definition: LCEselection.cc:106
Individual * LCE_Breed_Selection::makeOffspringWithSelection ( Individual ind,
unsigned int  natalpatch 
)

Performs viability selection and breeding at the same time.

The selected trait is first inherited (with recombination and mutations) and survival checked before the remaining traits are inherited. This helps save some computing time. The function returns a null pointer in case of selective death.

Parameters
indthe newborn, its new traits have not been computed yet
natalpatchthe index of the natal patch of the offfspring where selectin takes palce

References LCE_Selection_base::_fitness, LCE_Selection_base::_ind_cntr, _nonSelectedTraitIndices, LifeCycleEvent::_popPtr, LCE_Selection_base::_survival, LCE_Selection_base::_TraitIndices, Individual::addMating(), Individual::createTrait(), Individual::DidHaveABaby(), LCE_Breed_base::doInheritance(), fatal(), Individual::getFather(), LCE_Selection_base::getFitness(), Individual::getMother(), Individual::getPedigreeClass(), IndFactory::recycle(), and RAND::Uniform().

Referenced by LCE_Breed_Selection_Disperse::do_breed(), and do_breed_selection_OffSurvival().

692 {
693  if(!ind->getMother() || !ind->getFather())
694  fatal("found NULL parent ptr in offspring (LCE_Breed_Selection::makeOffspringWithSelection)\n");
695 
696  for(unsigned int i = 0; i < _TraitIndices.size(); ++i)
698 
699  register double fitness = getFitness(ind, natalpatch);
700  register unsigned int cat = ind->getPedigreeClass();
701 
702  _fitness[cat] += fitness;
703  _ind_cntr[cat]++;
704 
705  if( RAND::Uniform() > fitness ) {
706  //this one dies
707  _popPtr->recycle(ind);
708 
709  ind->getMother()->addMating(cat);
710  if(cat!=4) ind->getFather()->addMating(cat);
711 
712  return NULL;
713 
714  } else {
715 
716  //update counters
717  _survival[cat]++;
718 
719  ind->getMother()->DidHaveABaby(cat);
720  if(cat!=4) ind->getFather()->DidHaveABaby(cat);
721  }
722 
723  //compute inheritance and mutation of the other traits:
724  for(unsigned int i = 0; i < _nonSelectedTraitIndices.size(); i++)
726 
727  return ind;
728 }
double _ind_cntr[5]
Definition: LCEselection.h:92
void recycle(Individual *ind)
Put an individual in the recycling pool.
Definition: indfactory.h:62
double _fitness[5]
Fitness counters, one for each pedigree class.
Definition: LCEselection.h:92
Individual * getFather()
Definition: individual.h:126
Individual * getMother()
Definition: individual.h:127
void fatal(const char *str,...)
Definition: output.cc:90
bool doInheritance()
Definition: LCEbreed.h:96
vector< unsigned int > _nonSelectedTraitIndices
Definition: LCEcomposite.h:216
vector< unsigned int > _TraitIndices
The indices of the traits under selection.
Definition: LCEselection.h:108
void createTrait(IDX i, Individual *mother, Individual *father)
Sets a particular trait's genotype and phenotype values from the two parents.
Definition: individual.h:325
void DidHaveABaby(unsigned int category)
Increments the mating and realized fecundity counters according to the pedigree class of the offsprin...
Definition: individual.h:225
unsigned int getPedigreeClass()
Returns the pedigree class of the individual, as set during offspring creation.
Definition: individual.h:179
static double Uniform()
Generates a random number from [0.0, 1.0[ uniformly distributed.
Definition: Uniform.h:101
double getFitness(Individual *ind, unsigned int patch)
Calls the fitness function according to the fitness model.
Definition: LCEselection.h:204
double _survival[5]
Definition: LCEselection.h:92
Metapop * _popPtr
The ptr to the current Metapop.
Definition: lifecycleevent.h:81
void addMating(unsigned int category)
Increments the mating counter according to the pedigree class of the offspring.
Definition: individual.h:219
virtual age_t LCE_Breed_Selection::removeAgeClass ( )
inlinevirtual

Reimplemented from LCE_Selection_base.

Reimplemented in LCE_Breed_Selection_Disperse.

References NONE.

245 {return NONE;}
#define NONE
No age flag.
Definition: types.h:48
virtual age_t LCE_Breed_Selection::requiredAgeClass ( )
inlinevirtual

Reimplemented from LCE_Selection_base.

Reimplemented in LCE_Breed_Selection_Disperse.

References ADULTS.

247 {return ADULTS;}
#define ADULTS
Adults age class flag (breeders).
Definition: types.h:54
bool LCE_Breed_Selection::setNonSelectedTraitTable ( )

Builds the vector of traits not under selection.

Used in LCE_Breed_Selection_Disperse as well.

References _nb_trait, _nonSelectedTraitIndices, LifeCycleEvent::_popPtr, LCE_Selection_base::_TraitIndices, error(), IndFactory::getIndividualProtoype(), and Individual::getTraitNumber().

Referenced by setParameters(), and LCE_Breed_Selection_Disperse::setParameters().

531  {
532 
534 
535  _nonSelectedTraitIndices.clear();
536 
537 #ifdef _DEBUG_
538  cout << "@@@@ " << _nb_trait - _TraitIndices.size()<< " trait(s) not under selection\n";
539 #endif
540 
541  if (_nb_trait > _TraitIndices.size()) { //means we have some traits not under selection
542 
543  for (unsigned int i = 0; i < _nb_trait; ++i) {
544  //check which trait is not under selection and add its index into the vector
545  if (find(_TraitIndices.begin(), _TraitIndices.end(), i) == _TraitIndices.end()) {
546  _nonSelectedTraitIndices.push_back(i);
547  }
548  }
549 
550  if(_nonSelectedTraitIndices.size() != _nb_trait - _TraitIndices.size())
551  return error("LCE_Breed_Selection::setParameters:: trait not under selection was not found at initialization\n");
552 
553  }
554 
555  return true;
556 }
unsigned int _nb_trait
Definition: LCEcomposite.h:214
Individual * getIndividualProtoype()
Individual prototype accessor.
Definition: indfactory.h:109
vector< unsigned int > _nonSelectedTraitIndices
Definition: LCEcomposite.h:216
int error(const char *str,...)
Definition: output.cc:73
vector< unsigned int > _TraitIndices
The indices of the traits under selection.
Definition: LCEselection.h:108
unsigned int getTraitNumber()
Accessor to the size of the traits table.
Definition: individual.h:247
Metapop * _popPtr
The ptr to the current Metapop.
Definition: lifecycleevent.h:81
bool LCE_Breed_Selection::setParameters ( )
virtual

Reimplemented from LCE_Breed_base.

Reimplemented in LCE_Breed_Selection_Disperse.

References _breed_selection, do_breed_selection_FecFitness(), do_breed_selection_OffSurvival(), error(), SimComponent::get_parameter(), LCE_Breed_base::getMeanFecundity(), setNonSelectedTraitTable(), LCE_Breed_base::setParameters(), and LCE_Selection_base::setParameters().

511 {
513  return false;
514 
515  if(getMeanFecundity(0) <= 0)
516  return error("\"mean_fecundity\" is not set!\n");
517 
518  if(get_parameter("breed_selection_fecundity_fitness")->isSet()){
519 
521 
522  } else {
524  }
525 
526  return setNonSelectedTraitTable();
527 }
virtual bool setParameters()
Definition: LCEselection.cc:150
virtual bool setParameters()
Definition: LCEbreed.cc:71
int error(const char *str,...)
Definition: output.cc:73
double getMeanFecundity(unsigned int patch)
Definition: LCEbreed.h:94
bool setNonSelectedTraitTable()
Builds the vector of traits not under selection.
Definition: LCEcomposite.cc:531
void do_breed_selection_FecFitness(Patch *patch, unsigned int patchID, unsigned int *cntr)
Definition: LCEcomposite.cc:644
void(LCE_Breed_Selection::* _breed_selection)(Patch *patch, unsigned int patchID, unsigned int *cntr)
Definition: LCEcomposite.h:212
virtual Param * get_parameter(std::string name)
Param getter.
Definition: simcomponent.h:139
void do_breed_selection_OffSurvival(Patch *patch, unsigned int patchID, unsigned int *cntr)
Definition: LCEcomposite.cc:608

Member Data Documentation

void(LCE_Breed_Selection::* LCE_Breed_Selection::_breed_selection)(Patch *patch, unsigned int patchID, unsigned int *cntr)
private

Referenced by execute(), and setParameters().

unsigned int LCE_Breed_Selection::_nb_trait
private
vector< unsigned int > LCE_Breed_Selection::_nonSelectedTraitIndices
private

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

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