Nemo  2.4.0
Simulate forward-in-time genetic evolution in a spatially explicit, individual-based stochastic simulator
LCE_Breed_Selection_Disperse Class Reference

Composite LCE performing breeding, migration and viability selection all in one. More...

#include <LCEcomposite.h>

+ Inheritance diagram for LCE_Breed_Selection_Disperse:
+ Collaboration diagram for LCE_Breed_Selection_Disperse:

Public Member Functions

 LCE_Breed_Selection_Disperse ()
 
virtual ~LCE_Breed_Selection_Disperse ()
 
void breed_selection_disperse (int *counter)
 
void breed_selection_disperse_propagule (int *counter)
 
void do_breed (sex_t SEX, unsigned int size, int *counter, Patch *patch, unsigned int patchID)
 
Implementations
virtual bool setParameters ()
 
virtual void execute ()
 
virtual LifeCycleEventclone ()
 
virtual void loadFileServices (FileServices *loader)
 
virtual void loadStatServices (StatServices *loader)
 
virtual bool resetParameterFromSource (std::string param, SimComponent *cmpt)
 
virtual age_t removeAgeClass ()
 
virtual age_t addAgeClass ()
 
virtual age_t requiredAgeClass ()
 
- Public Member Functions inherited from LCE_Breed_Disperse
 LCE_Breed_Disperse ()
 
virtual ~LCE_Breed_Disperse ()
 
void do_breed_disperse ()
 
void do_breed_disperse_propagule ()
 
void do_breed_disperse_in_patch (sex_t SEX, Patch *patch, unsigned int ID, unsigned int num_offsprg)
 
void do_breed_disperse_in_empty_patch (sex_t SEX, Patch *patch, unsigned int ID, unsigned int num_offsprg)
 
unsigned int numFemOffspring (Patch *patch)
 
unsigned int numFemOffspring_colonizers (Patch *patch)
 The number of females produced in case a max number of colonizers was specified. More...
 
unsigned int numMalOffspring_notrandom (Patch *patch)
 The number of males produced is always zero when the mating system is not random mating. More...
 
unsigned int numMalOffspring_random (Patch *patch)
 
unsigned int numMalOffspring_random_colonizers (Patch *patch)
 
unsigned int instantGrowth (Patch *patch, sex_t SEX)
 The number of offspring produced corresponds to the carrying capacity of the patch. More...
 
unsigned int logisticGrowth (Patch *patch, sex_t SEX)
 The number of offspring produced is given by the logistic growth function. More...
 
unsigned int stochasticLogisticGrowth (Patch *patch, sex_t SEX)
 The number of offspring produced is drawn from a Poisson with mean equal to the logistic growth predicate. More...
 
unsigned int conditionalLogisticGrowth (Patch *patch, sex_t SEX)
 The number of offspring produced depends on the adult density. More...
 
unsigned int conditionalStochasticLogisticGrowth (Patch *patch, sex_t SEX)
 The number of offspring produced depends on the adult density, similar to 'conditionalLogisticGrowth' except that this time, the fecundities are drawn from Poisson distributions. More...
 
unsigned int fixedFecundityGrowth (Patch *patch, sex_t SEX)
 The number of offspring produced is equal to the current number of breeders multiplied by the mean fecundity of the focal patch. More...
 
unsigned int stochasticFecundityGrowth (Patch *patch, sex_t SEX)
 The number of offspring produced is a random number drawn from a Poisson distribution with mean equal to the current number of breeders multiplied by the mean fecundity of the focal patch. More...
 
unsigned int exponentialGrowth (Patch *patch, sex_t SEX)
 Exponential growth using current patch size as basis to calculate future sizes, set once the function is first called. More...
 
Individualmate_random (sex_t SEX, Patch *patch, unsigned int LocalPatch, gsl_ran_discrete_t *rate_fem, gsl_ran_discrete_t *rate_mal)
 
Individualmate_random_hermaphrodite (sex_t SEX, Patch *patch, unsigned int LocalPatch, gsl_ran_discrete_t *rate_fem, gsl_ran_discrete_t *rate_mal)
 
Individualmate_selfing (sex_t SEX, Patch *patch, unsigned int LocalPatch, gsl_ran_discrete_t *rate_fem, gsl_ran_discrete_t *rate_mal)
 
Individualmate_full_selfing (sex_t SEX, Patch *patch, unsigned int LocalPatch, gsl_ran_discrete_t *rate_fem, gsl_ran_discrete_t *rate_mal)
 
Individualmate_cloning (sex_t SEX, Patch *patch, unsigned int LocalPatch, gsl_ran_discrete_t *rate_fem, gsl_ran_discrete_t *rate_mal)
 
IndividualmakeOffspring (Individual *ind)
 
Individualget_parent (sex_t SEX, sex_t DispSex, Patch *LocalPatch, unsigned int patchID, gsl_ran_discrete_t *rates)
 
- 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...
 
void NonWrightFisherPopulation ()
 
void WrightFisherPopulation ()
 
void doAgingInWFpop ()
 
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...
 
IndividualmakeOffspring (Individual *newind, Individual *mother, Individual *father, unsigned int natalPatch)
 Overloads previous function when a new offspring is created "in-place", that is from existing pointer in a patch. 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 getLogNormalFecundity (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 ()
 
bool isWrightFisher ()
 
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...
 
virtual bool has_parameter (std::string name)
 Param getter. More...
 
- Public Member Functions inherited from LCE_Disperse_base
 LCE_Disperse_base ()
 
virtual ~LCE_Disperse_base ()
 Deallocates the disp matrix. More...
 
bool setBaseParameters (string prefix)
 
void setParamPrefix (string pref)
 
void addParameters (string prefix, ParamUpdaterBase *updater)
 
void setIndentityDispMatrix (TMatrix *mat)
 
unsigned int getMigrationPatchForward (sex_t SEX, unsigned int LocalPatch)
 
unsigned int getMigrationPatchBackward (sex_t SEX, unsigned int LocalPatch)
 
unsigned int getMigrationIndex (vector< double > &rates)
 
unsigned int getMigrationIndexGSLdiscrete (gsl_ran_discrete_t *rates)
 
void setPropaguleTargets ()
 
void swapPostDisp ()
 
void reset_counters ()
 
void set_isForward (bool val)
 
bool checkForwardDispersalMatrix (TMatrix *mat)
 
bool checkBackwardDispersalMatrix (TMatrix *mat)
 
void allocateDispMatrix (sex_t sex, unsigned int dim)
 
bool updateDispMatrix ()
 
bool setDispMatrix ()
 
bool setReducedMatricesBySex (sex_t SEX, Param &connectivity, Param &rate)
 
bool setReducedDispMatrix ()
 The reduced dispersal matrix contains the indices of the patches to which each patch is connected. More...
 
bool setIsland_MigrantPool_Matrix ()
 
bool setIsland_PropagulePool_Matrix ()
 
bool setSteppingStone1DMatrix ()
 
bool setLatticeMatrix ()
 Sets the dispersal matrices for the Lattice dispersal model. More...
 
bool setBasicLatticeMatrix (int rows, int cols, double phi_mal, double phi_fem, double disp_mal, double disp_fem)
 
bool setLatticeTorrusMatrix (int rows, int cols, double disp_mal, double disp_fem, TMatrix *grid)
 
bool setLatticeAbsorbingMatrix ()
 
bool setLatticeReflectingMatrix (int rows, int cols, TMatrix *grid)
 
bool isForward ()
 
bool isByNumber ()
 
unsigned int getDispersalModel ()
 
double getPropaguleProb ()
 
unsigned int getPropaguleTarget (unsigned int home)
 
vector< double > getConnectedPatches (sex_t SEX, unsigned int local_patch)
 
vector< double > getConnectedRates (sex_t SEX, unsigned int local_patch)
 
double getReducedDispersalRate (sex_t SEX, unsigned int row, unsigned int col)
 
unsigned int getReducedDispersalPatchID (sex_t SEX, unsigned int row, unsigned int col)
 
- Public Member Functions inherited from LCE_Breed_Selection
 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)
 
void do_breed_selection_WrightFisher_2sex (Patch *patch, unsigned int patchID, unsigned int *cntr)
 
void do_breed_selection_WrightFisher_1sex (Patch *patch, unsigned int patchID, unsigned int *cntr)
 
void setReproScaledFitness_sum (sex_t SEX, valarray< double > &survival, unsigned int numReproFem, Patch *patch)
 
gsl_ran_discrete_t * setReproScaledFitness_gsl (sex_t SEX, unsigned int numReproInd, Patch *patch)
 
- Public Member Functions inherited from LCE_Selection_base
 LCE_Selection_base ()
 
virtual ~LCE_Selection_base ()
 
bool setSelectionMatrix ()
 
bool setSelectTraitMapping (unsigned int num_quanti_traits)
 
bool setSelectionOffset (double default_val, double min_val)
 
bool setLocalOptima ()
 
const TMatrixgetLocalOptima () const
 
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...
 
void updateFitnessCounters (double fitness, unsigned int ped_class, bool survived)
 Updates the fitness and survival mean counters. 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 getFitnessUnivariateLinear (Individual *offsprg, unsigned int patch, unsigned int trait)
 Returns the fitness of an individual following a Linear selection model with a single trait under selection. More...
 
double getFitnessUnivariateDisruptive (Individual *offsprg, unsigned int patch, unsigned int trait)
 Returns the fitness of an individual following a Disruptive (inverted Gaussian) selection model with one trait under selection. More...
 
double getFitnessMultivariateDisruptive (Individual *offsprg, unsigned int patch, unsigned int trait)
 Returns the fitness of an individual following a Disruptive (inverted Gaussian) selection model with several traits under selection. More...
 
double getFitnessTruncation (Individual *offsprg, unsigned int patch, unsigned int trait)
 Returns the fitness of an individual following a Truncation selection model. 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 setScalingFactorForLinearSelection (age_idx age, unsigned int p)
 Sets the fitness scaling factor as the mean trait value in the patch to compute the fitness value in the linear selection model. 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...
 
void checkChangeLocalOptima ()
 Check is rate of change in local optima has been set and must be applied. More...
 

Private Attributes

void(LCE_Breed_Selection_Disperse::* _breed_selection_disperse )(int *counter)
 

Additional Inherited Members

- Protected Attributes inherited from LCE_Breed_Disperse
TMatrix _num_colonizers
 Maximum size of a patch after colonisation. More...
 
sex_t _dispersing_sex
 Which part of the population is dispersing its gametes. More...
 
Individual *(LCE_Breed_Disperse::* _make_offspring )(sex_t SEX, Patch *patch, unsigned int LocalPatch, gsl_ran_discrete_t *rate_fem, gsl_ran_discrete_t *rate_mal)
 
unsigned int(LCE_Breed_Disperse::* _get_numFemOffspring )(Patch *patch)
 
unsigned int(LCE_Breed_Disperse::* _get_numMalOffspring )(Patch *patch)
 
unsigned int(LCE_Breed_Disperse::* _get_patchFecundity )(Patch *patch, sex_t SEX)
 
- Protected Attributes inherited from LCE_Breed_base
TMatrix _mean_fecundity
 
Individual *(LCE_Breed_base::* MatingFuncPtr )(Patch *, Individual *, unsigned int)
 
Individual *(LCE_Breed_base::* DoBreedFuncPtr )(Individual *mother, Individual *father, unsigned int LocalPatch)
 
double(LCE_Breed_base::* FecundityFuncPtr )(double mean)
 
bool(LCE_Breed_base::* CheckMatingConditionFuncPtr )(Patch *thePatch)
 
sex_t(LCE_Breed_base::* GetOffsprgSex )()
 
void(LCE_Breed_base::* PopModelFuncPtr )(void)
 
- 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_Disperse_base
unsigned int _npatch
 Number of patches in the population. More...
 
vector< vector< double > > _reducedDispMat [2]
 Matrix containing the indexes of the patches connected to each patch. More...
 
vector< vector< double > > _reducedDispMatProba [2]
 Matrix containing the probability to migrate to/from the connected patches. More...
 
- Protected Attributes inherited from LCE_Selection_base
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< string > _Traits
 The list of trait types under selection. More...
 
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< unsigned int > _selectTraitMapping
 Mapping from selection dimension index to quanti trait index (0-based). 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 performing breeding, migration and viability selection all in one.

Migration rates are backward rates and population sizes are constant. Inherits from LCE_Breed_Disperse and LCE_Breed_Selection (and thus from LCE_Breed_base, LCE_Selection_base, and LCE_Disperse_base as well). Fitness is always absolute here.

Constructor & Destructor Documentation

◆ LCE_Breed_Selection_Disperse()

LCE_Breed_Selection_Disperse::LCE_Breed_Selection_Disperse ( )
641 : LifeCycleEvent("breed_selection_disperse",""), _breed_selection_disperse(0)
642 {
643  add_parameter("breed_selection_disperse_fitness_threshold", DBL, false, true, 0, 1,
645 }
virtual bool setParameters()
Definition: LCEcomposite.cc:649
void(LCE_Breed_Selection_Disperse::* _breed_selection_disperse)(int *counter)
Definition: LCEcomposite.h:301
LifeCycleEvent(const char *name, const char *trait_link)
Cstor.
Definition: lifecycleevent.h:97
Implementation of the ParamUpdaterBase interface.
Definition: param.h:362
virtual void add_parameter(Param *param)
Interface to add a parameter to the set.
Definition: simcomponent.h:111
@ DBL
Definition: types.h:77

References SimComponent::add_parameter(), DBL, and setParameters().

Referenced by clone().

+ Here is the caller graph for this function:

◆ ~LCE_Breed_Selection_Disperse()

virtual LCE_Breed_Selection_Disperse::~LCE_Breed_Selection_Disperse ( )
inlinevirtual
307 {}

Member Function Documentation

◆ addAgeClass()

virtual age_t LCE_Breed_Selection_Disperse::addAgeClass ( )
inlinevirtual

Reimplemented from LCE_Breed_Disperse.

324 {return (isWrightFisher() ? NONE : OFFSPRG);}
bool isWrightFisher()
Definition: LCEbreed.h:119
#define NONE
No age flag.
Definition: types.h:47
#define OFFSPRG
Offspring age class flag.
Definition: types.h:49

References LCE_Breed_base::isWrightFisher(), NONE, and OFFSPRG.

◆ breed_selection_disperse()

void LCE_Breed_Selection_Disperse::breed_selection_disperse ( int *  counter)
723 {
724  Patch* patch;
725  unsigned int nfem, nmal;
726 
727  //-----------------------------------------------------------------------------
728  // mean fitness may be too close or == zero because selection is too strong or mean phenotype is too far from optimum
729  // this is a problem in starting populations
730  if( _popPtr->getCurrentGeneration() == 1 && getMeanFitness(ADLTx) < 1e-08 && _popPtr->size(ADLTx) != 0) {
731  warning("The mean adult fitness in the initial generation is too close to zero, the simulation may hang indefinitely!");
732  warning("The breed_selection_disperse LCE will stall with zero fitness among reproducers.\n\
733  Please check the parameter values of your trait(s) under selection:\n\
734  e.g. check the initial trait and allelic values or initial allele \n\
735  frequencies, and the selection parameters.\n");
736  abort();
737  }
738  //-----------------------------------------------------------------------------
739 
740  for(unsigned int i = 0; i < _popPtr->getPatchNbr(); i++) {
741 
742  patch = _popPtr->getPatch(i);
743 
744  if(patch->size(OFFSx) != 0) patch->flush(OFFSx, _popPtr);
745 
746  // compute per-patch scaling factor (needed by linear selection to set mean trait values)
747  (this->*_setScalingFactor)(ADLTx, i);
748 
750 
751  // catch the case of zero fitness in a population with one patch during a run
752  if( _mean_fitness == 0 && _popPtr->size(ADLTx) != 0 && _popPtr->getPatchNbr() == 1) {
753  warning("The mean adult fitness in patch %i is zero! The simulation may hang indefinitely", i+1);
754  warning("The breed_selection_disperse LCE will stall with zero\n\
755  fitness among reproducers. Please check the parameter values\n\
756  of your trait(s) under selection:\n\
757  e.g. check the change in local optimum, allele frequencies,\n\
758  or selection parameters.\n");
759  abort();
760  }
761 
762  //@TODO breed_selection_disperse fix override of fitness scaling_factor set for linear selection
763  if(_mean_fitness != 0) {
764 
766  warning("breed_selection_disperse::mean fitness is below the minimum fitness threshold set to %f, I'm resetting the fitness scaling factor to %f",
769 
770  } else
771  _scaling_factor = 1;
772  }
773 
774  // determine how many male and female offspring we need to produce
775  nfem = (this->* _get_numFemOffspring)(patch);
776  nmal = (this->* _get_numMalOffspring)(patch);
777 
778  // perform breeding
779  do_breed(FEM, nfem, counter, patch, i);
780  do_breed(MAL, nmal, counter, patch, i);
781 
782  }
783 }
unsigned int(LCE_Breed_Disperse::* _get_numMalOffspring)(Patch *patch)
Definition: LCEcomposite.h:73
unsigned int(LCE_Breed_Disperse::* _get_numFemOffspring)(Patch *patch)
Definition: LCEcomposite.h:72
void do_breed(sex_t SEX, unsigned int size, int *counter, Patch *patch, unsigned int patchID)
Definition: LCEcomposite.cc:795
double _base_fitness
Definition: LCEselection.h:111
double getMeanFitness(age_idx age)
Computes the mean fitness of the whole population for a given age class.
Definition: LCEselection.cc:1163
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:156
double _scaling_factor
Definition: LCEselection.h:112
double getMeanPatchFitness(age_idx age, unsigned int p)
Computes the mean fitness in a given patch for a given age class.
Definition: LCEselection.cc:1181
double _mean_fitness
Definition: LCEselection.h:112
Metapop * _popPtr
The ptr to the current Metapop.
Definition: lifecycleevent.h:80
unsigned int size()
Get the total number of individuals present in the population, all sex and age classes together.
Definition: metapop.h:311
unsigned int getPatchNbr()
Definition: metapop.h:275
Patch * getPatch(unsigned int i)
Patch accessor, return the ith+1 patch in the metapop.
Definition: metapop.h:256
unsigned int getCurrentGeneration()
Definition: metapop.h:295
Second class in the metapopulation design structure, between the Metapop and Individual classes.
Definition: metapop.h:431
unsigned int size(age_t AGE)
Returns the size of the container of the appropriate age class(es) for both sexes.
Definition: metapop.h:497
void flush(sex_t SEX, age_idx AGE, Metapop *pop)
Removes all individual pointers of the appropriate sex and age class and flush them into the recyclin...
Definition: metapop.h:686
void abort()
Definition: output.cc:120
void warning(const char *str,...)
Definition: output.cc:57
@ FEM
Definition: types.h:36
@ MAL
Definition: types.h:36
@ OFFSx
Definition: types.h:41
@ ADLTx
Definition: types.h:41

References LCE_Selection_base::_base_fitness, LCE_Breed_Disperse::_get_numFemOffspring, LCE_Breed_Disperse::_get_numMalOffspring, LCE_Selection_base::_mean_fitness, LifeCycleEvent::_popPtr, LCE_Selection_base::_scaling_factor, LCE_Selection_base::_setScalingFactor, abort(), ADLTx, do_breed(), FEM, Patch::flush(), Metapop::getCurrentGeneration(), LCE_Selection_base::getMeanFitness(), LCE_Selection_base::getMeanPatchFitness(), Metapop::getPatch(), Metapop::getPatchNbr(), MAL, OFFSx, Metapop::size(), Patch::size(), and warning().

Referenced by breed_selection_disperse_propagule(), and setParameters().

+ Here is the caller graph for this function:

◆ breed_selection_disperse_propagule()

void LCE_Breed_Selection_Disperse::breed_selection_disperse_propagule ( int *  counter)
788 {
790  breed_selection_disperse(counter);
791 }
void breed_selection_disperse(int *counter)
Definition: LCEcomposite.cc:722
bool setIsland_PropagulePool_Matrix()
Definition: LCEdisperse.cc:580

References breed_selection_disperse(), and LCE_Disperse_base::setIsland_PropagulePool_Matrix().

Referenced by setParameters().

+ Here is the caller graph for this function:

◆ clone()

virtual LifeCycleEvent* LCE_Breed_Selection_Disperse::clone ( )
inlinevirtual

Reimplemented from LCE_Breed_Disperse.

319 {return new LCE_Breed_Selection_Disperse();}
LCE_Breed_Selection_Disperse()
Definition: LCEcomposite.cc:640

References LCE_Breed_Selection_Disperse().

◆ do_breed()

void LCE_Breed_Selection_Disperse::do_breed ( sex_t  SEX,
unsigned int  size,
int *  counter,
Patch patch,
unsigned int  patchID 
)

females

males

797 {
798 // int viab_count;
799  Individual *new_ind;
800 
801 // cout<<"---- LCE_Breed_Selection_Disperse::do_breed ----\n";
802 //
803 // cout<<" ---- patch "<<patchID<<" ----\n";
804 //
805 // if(patch->size(SEX, ADLTx) == 0)
806 // cout<<" @@@@@ EXTINCTION PATCH @@@@@\n";
807 
808  vector<double> disp_rate_connected_fem = LCE_Disperse_base::getConnectedRates(FEM, patchID);
809  vector<double> disp_rate_connected_mal = LCE_Disperse_base::getConnectedRates(MAL, patchID);
810 
811  double disp_table_fem[disp_rate_connected_fem.size()];
812  double disp_table_mal[disp_rate_connected_mal.size()];
813 
815  // check that the connected patches are not empty
816  unsigned int csize, c_size_fem = 0;
817  vector< double > connected_patches = LCE_Disperse_base::getConnectedPatches(FEM, patchID);
818 
819  // set p(mother is local) = 0 if local patch is empty of females
820 // if(patch->size(FEM, ADLTx) == 0) {
821 // disp_rate_connected_fem[0] = 0;
822 // }
823 
824 // cout<<"\t - female dispersal:\n";
825 
826  for(unsigned int i = 0; i < disp_rate_connected_fem.size(); ++i){
827 
828  csize = _popPtr->size(FEM, ADLTx, (unsigned int)connected_patches[i]);
829 
830  if(csize)
831  disp_table_fem[i] = disp_rate_connected_fem[i];
832  else
833  disp_table_fem[i] = 0;
834 
835 // cout<<"\t > "<<(unsigned int)connected_patches[i]<<": "
836 // <<csize<<" adlt female ("<<disp_table_fem[i]<<")"<<endl;
837 
838  c_size_fem += csize;
839  }
840 
841  // no reproduction can happen if local and all connected patches are empty
842  if( c_size_fem == 0 ) return;
843 
845  unsigned int c_size_mal = 0;
846 
847  // use the dispersal matrices for the dispersing sex
848  connected_patches = LCE_Disperse_base::getConnectedPatches(_dispersing_sex, patchID);
849 
850  // the sex patch size to check depends on the mating system; male for random mating, fem otherwise
851  sex_t sex2check = (this->getMatingSystem() == 1 ? MAL : FEM);
852 
853 // cout<<"\t - male dispersal:\n";
854 
855  for(unsigned int i = 0; i < disp_rate_connected_mal.size(); ++i){
856  csize = _popPtr->size(sex2check, ADLTx, (unsigned int)connected_patches[i]);
857 
858  if(csize)
859  disp_table_mal[i] = disp_rate_connected_mal[i];
860  else
861  disp_table_mal[i] = 0;
862 
863 // cout<<"\t > "<<(unsigned int)connected_patches[i]<<": "
864 // <<csize<<" adlt "<<(sex2check == MAL? "male" :"female")
865 // <<" ("<<disp_table_mal[i]<<")"<<endl;
866 
867  c_size_mal += csize;
868  }
869 
870  // same about males,
871  // or females in connected patches following the male dispersal matrix in case of hermaphroditism and differentiated dispersal
872  if( c_size_mal == 0 ) return;
873 
874 // cout<<"\t - size of connected patch; fem = "<<c_size_fem<<", mal = "<<c_size_mal<<endl;
875 
876  gsl_ran_discrete_t* gsltable_fem = gsl_ran_discrete_preproc(disp_rate_connected_fem.size(), disp_table_fem);
877  gsl_ran_discrete_t* gsltable_mal = gsl_ran_discrete_preproc(disp_rate_connected_mal.size(), disp_table_mal);
878 
879 // cout<<"\t generating "<<size<<" offspring\n ";
880 
881  for(unsigned int j = 0, viab_count; j < size; j++) {
882  viab_count = (*counter);
883  do{
884 
885  // 1. choose the parents and create the offspring object (by recycling)
886  new_ind = (this->*_make_offspring)(SEX, patch, patchID, gsltable_fem, gsltable_mal);
887 
888  if(new_ind) {
889  // 2. compute inheritance of the traits and survival of the offspring
890  new_ind = makeOffspringWithSelection(new_ind , patchID);
891  (*counter)++;
892  }
893 
894  viab_count++;
895 
896  if( viab_count - (*counter) > 100) {
897  warning("it took more than %i trials to get a fit offspring.",viab_count - (*counter));
898  }
899 
900  } while (new_ind == NULL);
901 
902  patch->add(SEX, OFFSx, new_ind);
903  if(patch->size(ADLTx) == 0) patch->nbKolonisers++;
904  }
905 
906 // cout << "done\n";
907 
908  gsl_ran_discrete_free(gsltable_fem);
909  gsl_ran_discrete_free(gsltable_mal);
910 }
This class contains traits along with other individual information (sex, pedigree,...
Definition: individual.h:48
sex_t _dispersing_sex
Which part of the population is dispersing its gametes.
Definition: LCEcomposite.h:68
Individual *(LCE_Breed_Disperse::* _make_offspring)(sex_t SEX, Patch *patch, unsigned int LocalPatch, gsl_ran_discrete_t *rate_fem, gsl_ran_discrete_t *rate_mal)
Definition: LCEcomposite.h:70
Individual * makeOffspringWithSelection(Individual *ind, unsigned int natalpatch)
Performs viability selection and breeding at the same time.
Definition: LCEcomposite.cc:1267
int getMatingSystem()
Definition: LCEbreed.h:101
vector< double > getConnectedPatches(sex_t SEX, unsigned int local_patch)
Definition: LCEdisperse.cc:1300
vector< double > getConnectedRates(sex_t SEX, unsigned int local_patch)
Definition: LCEdisperse.cc:1311
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:550
short nbKolonisers
Definition: metapop.h:454
sex_t
Sex types, males are always 0 and females 1!!
Definition: types.h:35

References LCE_Breed_Disperse::_dispersing_sex, LCE_Breed_Disperse::_make_offspring, LifeCycleEvent::_popPtr, Patch::add(), ADLTx, FEM, LCE_Disperse_base::getConnectedPatches(), LCE_Disperse_base::getConnectedRates(), LCE_Breed_base::getMatingSystem(), LCE_Breed_Selection::makeOffspringWithSelection(), MAL, Patch::nbKolonisers, OFFSx, Metapop::size(), Patch::size(), and warning().

Referenced by breed_selection_disperse().

+ Here is the caller graph for this function:

◆ execute()

void LCE_Breed_Selection_Disperse::execute ( )
virtual

Reimplemented from LCE_Breed_Disperse.

680 {
681  int ind_count = 0;
682 
683 #ifdef _DEBUG_
684  message("LCE_Breed_Selection_Disperse::execute (mean fitness(adlt): %f, fit scale: %f, offsprg nb: %i, adlt nb: %i, "
686  fflush(stdout);
687 #endif
688 
689  // _scaling_factor = (_mean_fitness >= _base_fitness ? 1 : _base_fitness/_mean_fitness);
690 
691  if(_npatch != _popPtr->getPatchNbr()) {
693  if(!updateDispMatrix()) fatal("LCE_Breed_Selection_Disperse::execute: bailing out\n");
694  }
695 
698 
699  // check if change in local optima for quantitative traits
701 
702  (this->*_breed_selection_disperse)(&ind_count);
703 
704  LCE_Selection_base::setMeans(ind_count);
705 
706  // swap parents and offspring in WF populations
708 
709 #ifdef _DEBUG_
710  unsigned int a = 0, b = 0, c = 0;
711  for(unsigned int i = 0; i < _popPtr->getPatchNbr(); i++){
712  a += _popPtr->getPatch(i)->nbEmigrant;
713  b += _popPtr->getPatch(i)->nbImigrant;
714  c += _popPtr->getPatch(i)->nbPhilopat;
715  }
716  message("immigrate: %f, emigrants: %i, imigrants: %i, mean fitness(offsprg): %f)\n",(double)b/(b+c), a, b, _mean_fitness);
717 #endif
718 }
void doAgingInWFpop()
Definition: LCEbreed.cc:547
void reset_counters()
Definition: LCEdisperse.cc:389
bool updateDispMatrix()
Definition: LCEdisperse.cc:364
unsigned int _npatch
Number of patches in the population.
Definition: LCEdisperse.h:63
void checkChangeLocalOptima()
Check is rate of change in local optima has been set and must be applied.
Definition: LCEselection.cc:1322
void setMeans(unsigned int tot_ind)
Computes the average fitness of each pedigree class.
Definition: LCEselection.cc:1417
void resetCounters()
Resets the fitness counters.
Definition: LCEselection.cc:1406
unsigned short nbEmigrant
Definition: metapop.h:453
unsigned short nbPhilopat
Definition: metapop.h:453
unsigned short nbImigrant
Definition: metapop.h:453
void fatal(const char *str,...)
Definition: output.cc:99
void message(const char *message,...)
Definition: output.cc:39
#define ADULTS
Adults age class flag (breeders).
Definition: types.h:53

References _breed_selection_disperse, LCE_Selection_base::_mean_fitness, LCE_Disperse_base::_npatch, LifeCycleEvent::_popPtr, LCE_Selection_base::_scaling_factor, ADLTx, ADULTS, LCE_Selection_base::checkChangeLocalOptima(), LCE_Breed_base::doAgingInWFpop(), fatal(), LCE_Selection_base::getMeanFitness(), Metapop::getPatch(), Metapop::getPatchNbr(), LCE_Breed_base::isWrightFisher(), message(), Patch::nbEmigrant, Patch::nbImigrant, Patch::nbPhilopat, OFFSPRG, LCE_Disperse_base::reset_counters(), LCE_Selection_base::resetCounters(), LCE_Selection_base::setMeans(), Metapop::size(), and LCE_Disperse_base::updateDispMatrix().

◆ loadFileServices()

virtual void LCE_Breed_Selection_Disperse::loadFileServices ( FileServices loader)
inlinevirtual

Reimplemented from LCE_Breed_Disperse.

320 {}

◆ loadStatServices()

void LCE_Breed_Selection_Disperse::loadStatServices ( StatServices loader)
virtual

Reimplemented from LCE_Breed_Disperse.

673 {
675 }
virtual void loadStatServices(StatServices *loader)
Definition: LCEselection.cc:144

References LCE_Selection_base::loadStatServices().

◆ removeAgeClass()

virtual age_t LCE_Breed_Selection_Disperse::removeAgeClass ( )
inlinevirtual

Reimplemented from LCE_Breed_Disperse.

323 {return NONE;}

References NONE.

◆ requiredAgeClass()

virtual age_t LCE_Breed_Selection_Disperse::requiredAgeClass ( )
inlinevirtual

Reimplemented from LCE_Breed_Disperse.

325 {return ADULTS;}

References ADULTS.

◆ resetParameterFromSource()

virtual bool LCE_Breed_Selection_Disperse::resetParameterFromSource ( std::string  param,
SimComponent cmpt 
)
inlinevirtual

Reimplemented from LCE_Breed_Disperse.

322 {return false;}

◆ setParameters()

bool LCE_Breed_Selection_Disperse::setParameters ( )
virtual

Reimplemented from LCE_Breed_Disperse.

650 {
651 
652  if(!LCE_Breed_Disperse::setParameters()) return false;
653  if(!LCE_Selection_base::setParameters()) return false;
655 
656  if(get_parameter("breed_selection_disperse_fitness_threshold")->isSet())
657  _base_fitness = get_parameter_value("breed_selection_disperse_fitness_threshold");
658  else
659  _base_fitness = 0.01;
660 
661  unsigned int model = this->getDispersalModel();
662  if(model == 2)
664  else
666 
667  return true;
668 }
virtual bool setParameters()
Definition: LCEcomposite.cc:59
void breed_selection_disperse_propagule(int *counter)
Definition: LCEcomposite.cc:787
bool setNonSelectedTraitTable()
Builds the vector of traits not under selection.
Definition: LCEcomposite.cc:969
unsigned int getDispersalModel()
Definition: LCEdisperse.h:114
virtual bool setParameters()
Definition: LCEselection.cc:191
virtual double get_parameter_value(std::string name)
Param value getter.
Definition: simcomponent.h:142
virtual Param * get_parameter(std::string name)
Param getter.
Definition: simcomponent.h:138

References LCE_Selection_base::_base_fitness, _breed_selection_disperse, breed_selection_disperse(), breed_selection_disperse_propagule(), SimComponent::get_parameter(), SimComponent::get_parameter_value(), LCE_Disperse_base::getDispersalModel(), LCE_Breed_Selection::setNonSelectedTraitTable(), LCE_Breed_Disperse::setParameters(), and LCE_Selection_base::setParameters().

Referenced by LCE_Breed_Selection_Disperse().

+ Here is the caller graph for this function:

Member Data Documentation

◆ _breed_selection_disperse

void(LCE_Breed_Selection_Disperse::* LCE_Breed_Selection_Disperse::_breed_selection_disperse) (int *counter)
private

Referenced by execute(), and setParameters().


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

Generated for Nemo v2.4.0 by  doxygen 1.9.1 -- Nemo is hosted on  Download Nemo

Locations of visitors to this page
Catalogued on GSR