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

Base class for the breeding (and mating) life cycle events. More...

#include <LCEbreed.h>

+ Inheritance diagram for LCE_Breed_base:
+ Collaboration diagram for LCE_Breed_base:

Public Member Functions

 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...
 
Implementations
virtual bool setParameters ()
 
Parameter setters/updaters
bool setMatingSystem ()
 
bool setFecundity ()
 
bool setSexRatio ()
 
Accessors
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 ()
 
Mating functions
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 ()
 
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 void set_paramset (ParamSet *paramset)
 Sets the ParamSet member. More...
 
virtual void set_paramsetFromCopy (const ParamSet &PSet)
 Reset the set of parameters from a another set. More...
 
virtual ParamSetget_paramset ()
 ParamSet accessor. More...
 
virtual void add_parameter (Param *param)
 Interface to add a parameter to the set. More...
 
virtual void add_parameter (std::string Name, param_t Type, bool isRequired, bool isBounded, double low_bnd, double up_bnd)
 Interface to add a parameter to the set. More...
 
virtual void add_parameter (std::string Name, param_t Type, bool isRequired, bool isBounded, double low_bnd, double up_bnd, ParamUpdaterBase *updater)
 Interface to add a parameter and its updater to the set. More...
 
virtual Paramget_parameter (std::string name)
 Param getter. More...
 
virtual double get_parameter_value (std::string name)
 Param value getter. More...
 
virtual string get_name ()
 Returnd the name of the ParamSet, i.e. More...
 
virtual bool has_parameter (std::string name)
 Param getter. More...
 
virtual bool resetParameterFromSource (std::string param, SimComponent *cmpt)=0
 

Protected Attributes

TMatrix _mean_fecundity
 
Function pointers
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...
 

Private Attributes

Parameters
int _mating_system
 
unsigned int _mating_males
 
unsigned int _alpha_male
 
double _mating_proportion
 
double _sd_fecundity
 
bool _do_inherit
 

Detailed Description

Base class for the breeding (and mating) life cycle events.

This class registers the whole set of basic mating parameters. Sets the function pointers for the mating system, fecundity and sex-ratio models, and breeding conditions checker (mostly checks for state of individual containers).

Constructor & Destructor Documentation

◆ LCE_Breed_base()

LCE_Breed_base::LCE_Breed_base ( )
46 : LifeCycleEvent("", ""),
49 //_growthRates(0),
50 MatingFuncPtr(0),
53 
54 {
56 
57  add_parameter("mating_system",INT,true,true,1,6, updater);
58  add_parameter("mating_proportion",DBL,false,true,0,1,updater);
59  add_parameter("mating_males",INT,false,false,0,0, updater);
60  add_parameter("mating_isWrightFisher", BOOL, false, false, 0, 0, updater);
61 
62 // add_parameter("growth_model", INT, false, true, 1, 7, updater);
63 // add_parameter("growth_rate", DBL, false, false, 0, 0, updater);
64 
66  add_parameter("mean_fecundity",DBL,false,false,0,0, updater);
67  add_parameter("fecundity_dist_stdev",DBL,false,false,0,0, updater);
68  add_parameter("fecundity_distribution",STR,false,false,0,0, updater);
69 
71  add_parameter("sex_ratio_mode",STR,false,false,0,0, updater);
72 }
unsigned int _alpha_male
Definition: LCEbreed.h:50
bool _do_inherit
Definition: LCEbreed.h:52
double _sd_fecundity
Definition: LCEbreed.h:51
sex_t(LCE_Breed_base::* GetOffsprgSex)()
Definition: LCEbreed.h:63
double(LCE_Breed_base::* FecundityFuncPtr)(double mean)
Definition: LCEbreed.h:61
void(LCE_Breed_base::* PopModelFuncPtr)(void)
Definition: LCEbreed.h:64
Individual *(LCE_Breed_base::* DoBreedFuncPtr)(Individual *mother, Individual *father, unsigned int LocalPatch)
Definition: LCEbreed.h:60
double _mating_proportion
Definition: LCEbreed.h:51
bool setMatingSystem()
Definition: LCEbreed.cc:83
bool setFecundity()
Definition: LCEbreed.cc:263
bool(LCE_Breed_base::* CheckMatingConditionFuncPtr)(Patch *thePatch)
Definition: LCEbreed.h:62
unsigned int _mating_males
Definition: LCEbreed.h:49
TMatrix _mean_fecundity
Definition: LCEbreed.h:67
int _mating_system
Definition: LCEbreed.h:48
bool setSexRatio()
Definition: LCEbreed.cc:223
Individual *(LCE_Breed_base::* MatingFuncPtr)(Patch *, Individual *, unsigned int)
Definition: LCEbreed.h:59
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
@ BOOL
Definition: types.h:77
@ STR
Definition: types.h:77
@ INT
Definition: types.h:77

References SimComponent::add_parameter(), BOOL, DBL, INT, setFecundity(), setMatingSystem(), setSexRatio(), and STR.

◆ ~LCE_Breed_base()

virtual LCE_Breed_base::~LCE_Breed_base ( )
inlinevirtual
73 {}

Member Function Documentation

◆ breed()

Individual * LCE_Breed_base::breed ( Individual mother,
Individual father,
unsigned int  LocalPatch 
)

Makes a new individual with the right parents.

Calls IndFactory::makeNewIndividual. The sex of the offspring is determined by a call to getOffsprgSex(). Recombination and mutation are done later, in the makeOffspring() procedure.

Parameters
motherpointer to the mother
fatherpointer to the father
LocalPatchindex of the natal patch
373 {
374  return _popPtr->makeNewIndividual(mother, father, getOffsprgSex(), LocalPatch);
375 }
Individual * makeNewIndividual(Individual *newind, Individual *mother, Individual *father, sex_t sex, unsigned short homepatch)
Creates an individual from existing pointer with new ID.
Definition: indfactory.cc:151
sex_t getOffsprgSex()
Definition: LCEbreed.h:113
Metapop * _popPtr
The ptr to the current Metapop.
Definition: lifecycleevent.h:80

References LifeCycleEvent::_popPtr, getOffsprgSex(), and IndFactory::makeNewIndividual().

Referenced by setMatingSystem().

+ Here is the caller graph for this function:

◆ breed_cloning()

Individual * LCE_Breed_base::breed_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).

Calls IndFactory::getNewIndividual() and then copy the mother into the new offspring.

Parameters
motherpointer to the mother
fatherpointer to the father (of no use here)
LocalPatchindex of the natal patch
380 {
381  Individual *newind;
382 
383  if(mother == father) {
384  newind = _popPtr->getNewIndividual();
385  //cloning:
386  (*newind) = (*mother);
387 
388  newind->reset_counters();
389  newind->setFather(NULL);
390  newind->setFatherID(0);
391  newind->setMother(mother);
392  newind->setMotherID(mother->getID());
393  newind->setIsSelfed(true);
394  newind->setHome(LocalPatch);
395  newind->setAge(0);
396  _do_inherit = false;
397  } else {
398  newind = _popPtr->makeNewIndividual(mother, father, getOffsprgSex(), LocalPatch);
399  _do_inherit = true;
400  }
401 
402  return newind;
403 }
Individual * getNewIndividual()
Creates a blank individual which has to be "decorated" later.
Definition: indfactory.h:84
This class contains traits along with other individual information (sex, pedigree,...
Definition: individual.h:48
void setFather(Individual *f)
Definition: individual.h:108
unsigned long getID()
Definition: individual.h:121
void reset_counters()
Resets the mating and fecundity counters.
Definition: individual.h:209
void setMother(Individual *m)
Definition: individual.h:109
void setIsSelfed(bool s)
Definition: individual.h:113
void setHome(unsigned short value)
Definition: individual.h:110
void setMotherID(unsigned long value)
Definition: individual.h:107
void setFatherID(unsigned long value)
Definition: individual.h:106
void setAge(unsigned short value)
Definition: individual.h:104

References _do_inherit, LifeCycleEvent::_popPtr, Individual::getID(), IndFactory::getNewIndividual(), getOffsprgSex(), IndFactory::makeNewIndividual(), Individual::reset_counters(), Individual::setAge(), Individual::setFather(), Individual::setFatherID(), Individual::setHome(), Individual::setIsSelfed(), Individual::setMother(), and Individual::setMotherID().

Referenced by LCE_Breed_Disperse::mate_cloning(), and setMatingSystem().

+ Here is the caller graph for this function:

◆ checkCloning()

bool LCE_Breed_base::checkCloning ( Patch thePatch)
inline

Checks whether mating will take place in the current patch when mating is cloning.

Only females must be present. Males containers are flushed if not empty.

Parameters
thePatchthe focal patch
228  {
229  if(thePatch->size(MAL, ADLTx) != 0) thePatch->flush(MAL, ADLTx, this->_popPtr);
230 
231  return (thePatch->size(FEM, ADLTx) != 0);
232  }
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
@ FEM
Definition: types.h:36
@ MAL
Definition: types.h:36
@ ADLTx
Definition: types.h:41

References LifeCycleEvent::_popPtr, ADLTx, FEM, Patch::flush(), MAL, and Patch::size().

Referenced by setMatingSystem().

+ Here is the caller graph for this function:

◆ checkMatingCondition()

bool LCE_Breed_base::checkMatingCondition ( Patch thePatch)
inline

Checks if any mating will take place in the patch passed as argument.

Is called prior to breeding in each patch. Calls the check function using its pointer.

Parameters
thePatchthe focal patch
186  {
187  return (this->* CheckMatingConditionFuncPtr) (thePatch);
188  }

References CheckMatingConditionFuncPtr.

Referenced by LCE_BreedAssortativeMating::execute(), LCE_Breed_Selection::execute(), NonWrightFisherPopulation(), LCE_Breed_Quanti::NonWrightFisherPopulation(), WrightFisherPopulation(), and LCE_Breed_Quanti::WrightFisherPopulation().

+ Here is the caller graph for this function:

◆ checkNoSelfing()

bool LCE_Breed_base::checkNoSelfing ( Patch thePatch)
inline

Checks whether mating will take place in the current patch when mating is not selfing or cloning.

Males and females must be present in the patch for mating to occur.

Parameters
thePatchthe focal patch
194  {
195  return (thePatch->size(FEM, ADLTx) != 0 && thePatch->size(MAL, ADLTx) != 0);
196  }

References ADLTx, FEM, MAL, and Patch::size().

Referenced by setMatingSystem().

+ Here is the caller graph for this function:

◆ checkPolygyny()

bool LCE_Breed_base::checkPolygyny ( Patch thePatch)
inline

Checks whether mating will take place in the current patch when mating is polygynous.

Males and females must be present in the patch for mating to occur.

Parameters
thePatchthe focal patch
203  {
204  if(thePatch->size(FEM, ADLTx) == 0 || thePatch->size(MAL, ADLTx) == 0) return false;
205 
206 // if(thePatch->size(MAL, ADLTx) < _mating_males) _mating_males = thePatch->size(MAL, ADLTx);
207 
208  _alpha_male = (unsigned int)RAND::Uniform(thePatch->size(MAL, ADLTx));
209 
210  return true;
211  }
static double Uniform()
Generates a random number from [0.0, 1.0[ uniformly distributed.
Definition: Uniform.h:126

References _alpha_male, ADLTx, FEM, MAL, Patch::size(), and RAND::Uniform().

Referenced by setMatingSystem().

+ Here is the caller graph for this function:

◆ checkSelfing()

bool LCE_Breed_base::checkSelfing ( Patch thePatch)
inline

Checks whether mating will take place in the current patch when mating is selfing.

Only females must be present.

Parameters
thePatchthe focal patch
218  {
219  if(thePatch->size(MAL, ADLTx) != 0) thePatch->flush(MAL, ADLTx, this->_popPtr);
220  return (thePatch->size(FEM, ADLTx) != 0);
221  }

References LifeCycleEvent::_popPtr, ADLTx, FEM, Patch::flush(), MAL, and Patch::size().

Referenced by setMatingSystem().

+ Here is the caller graph for this function:

◆ do_breed()

Individual* LCE_Breed_base::do_breed ( Individual mother,
Individual father,
unsigned int  LocalPatch 
)
inline

Calls the breeding function unsing its pointer.

Used to distinguish cloning from other mating systems.

177  {
178  return (this->* DoBreedFuncPtr)(mother, father, LocalPatch);
179  }

References DoBreedFuncPtr.

Referenced by LCE_Breed_Selection::do_breed_selection_FecFitness(), LCE_Breed_Selection::do_breed_selection_OffSurvival(), LCE_Breed_Selection::do_breed_selection_WrightFisher_1sex(), LCE_Breed_Selection::do_breed_selection_WrightFisher_2sex(), NonWrightFisherPopulation(), LCE_Breed_Quanti::NonWrightFisherPopulation(), WrightFisherPopulation(), and LCE_Breed_Quanti::WrightFisherPopulation().

+ Here is the caller graph for this function:

◆ doAgingInWFpop()

void LCE_Breed_base::doAgingInWFpop ( )
548 {
549  Patch* patch = 0;
550 
551  for(unsigned int i = 0; i < _popPtr->getPatchNbr(); i++) {
552 
553  patch = _popPtr->getPatch(i);
554 
555  if(patch->isEmpty()) {patch->set_isExtinct(true); continue;}
556 
557  // we do the generation change here directly
558  patch->flush(ADLTx, _popPtr); //first move adults to recycling pool
559  patch->move(FEM, OFFSx, ADLTx); //moves offspring to adult containers, resets offsprg size to 0
560  patch->move(MAL, OFFSx, ADLTx);
561  }
562 }
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
Second class in the metapopulation design structure, between the Metapop and Individual classes.
Definition: metapop.h:431
void set_isExtinct(bool status)
Definition: metapop.h:475
void move(sex_t SEX, age_idx from, age_idx to, unsigned int at)
Moves an individual from an age class to an other one.
Definition: metapop.h:610
bool isEmpty()
Definition: metapop.h:487
@ OFFSx
Definition: types.h:41

References LifeCycleEvent::_popPtr, ADLTx, FEM, Patch::flush(), Metapop::getPatch(), Metapop::getPatchNbr(), Patch::isEmpty(), MAL, Patch::move(), OFFSx, and Patch::set_isExtinct().

Referenced by LCE_Breed_Disperse::execute(), and LCE_Breed_Selection_Disperse::execute().

+ Here is the caller graph for this function:

◆ doInheritance()

bool LCE_Breed_base::doInheritance ( )
inline
102 {return _do_inherit;}

References _do_inherit.

Referenced by makeOffspring(), and LCE_Breed_Selection::makeOffspringWithSelection().

+ Here is the caller graph for this function:

◆ fullMonoginy()

Individual* LCE_Breed_base::fullMonoginy ( Patch thePatch,
Individual mother,
unsigned int  motherIndex 
)
inline

Returns a pointer to a male with same index as mother (if available) from the focal patch.

If the male is not available, one is drawn randomly from the patch.

Parameters
thePatchthe focal patch.
motherthe mother to mate with (unused here)
motherIndexindex of the mother in the patch adult female container
301  {
302  if(thePatch->size(MAL, ADLTx) < motherIndex+1)
303  return RandomMating(thePatch, mother, motherIndex);
304  else
305  return thePatch->get(MAL, ADLTx, motherIndex);
306  }
Individual * RandomMating(Patch *thePatch, Individual *mother, unsigned int motherIndex)
Returns a pointer to a male drawn randomly from a patch.
Definition: LCEbreed.h:242
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:533

References ADLTx, Patch::get(), MAL, RandomMating(), and Patch::size().

Referenced by setMatingSystem().

+ Here is the caller graph for this function:

◆ fullPolyginy()

Individual* LCE_Breed_base::fullPolyginy ( Patch thePatch,
Individual mother,
unsigned int  motherIndex 
)
inline

Returns a pointer to the alpha male of the patch.

The alpha male of a patch is set in the LCE_Breed_base::checkPolygyny function called before mating.

Parameters
thePatchthe focal patch.
motherthe mother to mate with (unused here).
motherIndexindex of the mother in the patch adult female container (unused here)
252  { return thePatch->get(MAL, ADLTx, _alpha_male); }

References _alpha_male, ADLTx, Patch::get(), and MAL.

Referenced by partialPolyginy(), and setMatingSystem().

+ Here is the caller graph for this function:

◆ fullPolyginy_manyMales()

Individual* LCE_Breed_base::fullPolyginy_manyMales ( Patch thePatch,
Individual mother,
unsigned int  motherIndex 
)
inline

Returns a pointer to one of the first _mating_males males of the patch.

Parameters
thePatchthe focal patch.
motherthe mother to mate with (unused here).
motherIndexindex of the mother in the patch adult female container (unused here)
260  {
261  if(thePatch->size(MAL,ADLTx) < _mating_males)
262  return thePatch->get(MAL, ADLTx, RAND::Uniform( thePatch->size(MAL, ADLTx) ) );
263  else
264  return thePatch->get(MAL, ADLTx, RAND::Uniform( _mating_males ) );
265  }

References _mating_males, ADLTx, Patch::get(), MAL, Patch::size(), and RAND::Uniform().

Referenced by partialPolyginy_manyMales(), and setMatingSystem().

+ Here is the caller graph for this function:

◆ fullSelfing()

Individual* LCE_Breed_base::fullSelfing ( Patch thePatch,
Individual mother,
unsigned int  motherIndex 
)
inline

Returns the mother pointer.

Parameters
thePatchthe focal patch.
motherthe mother to mate with (returned here)
motherIndexindex of the mother in the patch adult female container (unused here)
328  {
329  return mother;
330  }

Referenced by setMatingSystem().

+ Here is the caller graph for this function:

◆ getFatherPtr()

virtual Individual* LCE_Breed_base::getFatherPtr ( Patch thePatch,
Individual mother,
unsigned int  motherIndex 
)
inlinevirtual

Calls the mating function according to the model chosen using the function pointer, used to get the father from the mother in a patch.

Parameters
thePatchpointer to the focal patch where mating is taking place
motherpointer to the mother, returned when mating is done by self-fertilization or cloning
motherIndexindex of the mother in the current patch female container, used in the polyginy an monoginy mating systems
Returns
the pointer to the father following the mating scheme chosen
82  {
83  return (this->*MatingFuncPtr)(thePatch, mother, motherIndex);
84  }

References MatingFuncPtr.

Referenced by LCE_Breed_Selection::do_breed_selection_FecFitness(), LCE_Breed_Selection::do_breed_selection_OffSurvival(), NonWrightFisherPopulation(), LCE_Breed_Quanti::NonWrightFisherPopulation(), LCE_Breed_Wolbachia::wolbachia_model_1(), LCE_Breed_Wolbachia::wolbachia_model_2(), WrightFisherPopulation(), and LCE_Breed_Quanti::WrightFisherPopulation().

+ Here is the caller graph for this function:

◆ getFecundity() [1/2]

double LCE_Breed_base::getFecundity ( double  mean)
inline
112 {return (this->* FecundityFuncPtr)(mean);}

References FecundityFuncPtr.

◆ getFecundity() [2/2]

double LCE_Breed_base::getFecundity ( unsigned int  patch)
inline
111 {return (this->* FecundityFuncPtr)(_mean_fecundity.get(0, patch));}
double get(unsigned int i, unsigned int j) const
Accessor to element at row i and column j.
Definition: tmatrix.h:192

References FecundityFuncPtr, and TMatrix::get().

Referenced by LCE_Breed_Selection::do_breed_selection_FecFitness(), LCE_Breed_Selection::do_breed_selection_OffSurvival(), NonWrightFisherPopulation(), LCE_Breed_Quanti::NonWrightFisherPopulation(), LCE_Breed_Wolbachia::wolbachia_model_1(), and LCE_Breed_Wolbachia::wolbachia_model_2().

+ Here is the caller graph for this function:

◆ getFixedFecundity()

double LCE_Breed_base::getFixedFecundity ( double  mean)
inline
104 {return (mean < 0) ? 0 : mean;}

Referenced by setFecundity().

+ Here is the caller graph for this function:

◆ getGaussianFecundity()

double LCE_Breed_base::getGaussianFecundity ( double  mean)
inline
105  {
106  double fec; do{fec = mean + RAND::Gaussian(_sd_fecundity);}while(fec < 0);
107  return fec;}
static double Gaussian(double sigma)
Definition: Uniform.h:261

References _sd_fecundity, and RAND::Gaussian().

Referenced by setFecundity().

+ Here is the caller graph for this function:

◆ getLogNormalFecundity()

double LCE_Breed_base::getLogNormalFecundity ( double  mean)
inline
108  {
109  double fec; do{fec = mean + RAND::LogNormal(mean, _sd_fecundity);}while(fec < 0);
110  return fec;}
static double LogNormal(double zeta, double sigma)
Definition: Uniform.h:357

References _sd_fecundity, and RAND::LogNormal().

Referenced by setFecundity().

+ Here is the caller graph for this function:

◆ getMatingProportion()

double LCE_Breed_base::getMatingProportion ( )
inline
99 {return _mating_proportion;}

References _mating_proportion.

Referenced by LCE_Breed_Disperse::mate_selfing(), and LCE_Breed_Disperse::setParameters().

+ Here is the caller graph for this function:

◆ getMatingSystem()

int LCE_Breed_base::getMatingSystem ( )
inline

◆ getMeanFecundity()

◆ getOffsprgSex()

sex_t LCE_Breed_base::getOffsprgSex ( )
inline
113 {return (this->* GetOffsprgSex) ();}

References GetOffsprgSex.

Referenced by breed(), breed_cloning(), and makeOffspring().

+ Here is the caller graph for this function:

◆ getOffsprgSexCloning()

sex_t LCE_Breed_base::getOffsprgSexCloning ( )
inline
117 {return FEM;}

References FEM.

Referenced by setSexRatio().

+ Here is the caller graph for this function:

◆ getOffsprgSexFixed()

sex_t LCE_Breed_base::getOffsprgSexFixed ( )
342 {
343  static bool sex = RAND::RandBool();
344  sex ^= 1;
345  return (sex_t)sex;
346 }
static bool RandBool()
Returns a random boolean.
Definition: Uniform.h:164
sex_t
Sex types, males are always 0 and females 1!!
Definition: types.h:35

References RAND::RandBool().

Referenced by setSexRatio().

+ Here is the caller graph for this function:

◆ getOffsprgSexRandom()

sex_t LCE_Breed_base::getOffsprgSexRandom ( )
inline
114 {return (sex_t)RAND::RandBool();}

References RAND::RandBool().

Referenced by setSexRatio().

+ Here is the caller graph for this function:

◆ getOffsprgSexSelfing()

sex_t LCE_Breed_base::getOffsprgSexSelfing ( )
inline
116 {return FEM;}

References FEM.

Referenced by setSexRatio().

+ Here is the caller graph for this function:

◆ getPoissonFecundity()

double LCE_Breed_base::getPoissonFecundity ( double  mean)
inline
103 {return RAND::Poisson(mean);}
static double Poisson(double mean)
From the Numerical Recieps.
Definition: Uniform.h:219

References RAND::Poisson().

Referenced by setFecundity().

+ Here is the caller graph for this function:

◆ isWrightFisher()

bool LCE_Breed_base::isWrightFisher ( )
inline
119 {return get_parameter("mating_isWrightFisher")->isSet();}
bool isSet()
Definition: param.h:139
virtual Param * get_parameter(std::string name)
Param getter.
Definition: simcomponent.h:138

References SimComponent::get_parameter(), and Param::isSet().

Referenced by LCE_Breed::addAgeClass(), LCE_Breed_Disperse::addAgeClass(), LCE_Breed_Selection::addAgeClass(), LCE_Breed_Selection_Disperse::addAgeClass(), LCE_Breed::execute(), LCE_Breed_Disperse::execute(), and LCE_Breed_Selection_Disperse::execute().

+ Here is the caller graph for this function:

◆ makeOffspring() [1/2]

Individual * LCE_Breed_base::makeOffspring ( Individual ind)

Last step of the breeding process, does inheritance and mutation of the parents' genes.

Calls Individual::create(do_inherit, do_mutate) with do_inherit set following the local _do_inherit value. Updates the parent's fecundity counters. A breeding session looks like that:

Individual* newind;
Patch* natalPatch;
newind = makeOffspring( do_breed( mother, father = getFatherPtr(natalPatch, mother, motherIndex), LocalPatch = natalPatch->getID() ) )
natalPatch->add( newind->getSex(), OFFSx, newind );
virtual Individual * getFatherPtr(Patch *thePatch, Individual *mother, unsigned int motherIndex)
Calls the mating function according to the model chosen using the function pointer,...
Definition: LCEbreed.h:81
Individual * makeOffspring(Individual *ind)
Last step of the breeding process, does inheritance and mutation of the parents' genes.
Definition: LCEbreed.cc:350
Individual * do_breed(Individual *mother, Individual *father, unsigned int LocalPatch)
Calls the breeding function unsing its pointer.
Definition: LCEbreed.h:176
unsigned int getID()
Definition: metapop.h:480
Parameters
indthe offspring, as returned by the do_breed function.
351 {
352  unsigned int cat = ind->getPedigreeClass();
353 
354  ind->getMother()->DidHaveABaby(cat);
355  if(cat!=4) ind->getFather()->DidHaveABaby(cat);
356 
357  return ind->create(doInheritance(), true);
358 }
Individual * create()
Creates an individual's genotypes and phenotypes with recombination and mutations.
Definition: individual.h:361
Individual * getMother()
Definition: individual.h:126
Individual * getFather()
Definition: individual.h:125
void DidHaveABaby(unsigned int category)
Increments the mating and realized fecundity counters according to the pedigree class of the offsprin...
Definition: individual.h:224
unsigned int getPedigreeClass()
Returns the pedigree class of the individual, as set during offspring creation.
Definition: individual.h:178
bool doInheritance()
Definition: LCEbreed.h:102

References Individual::create(), Individual::DidHaveABaby(), doInheritance(), Individual::getFather(), Individual::getMother(), and Individual::getPedigreeClass().

Referenced by LCE_Breed_Disperse::do_breed_disperse_in_empty_patch(), LCE_Breed_Disperse::do_breed_disperse_in_patch(), LCE_Breed_Selection::do_breed_selection_FecFitness(), LCE_Breed_Selection::do_breed_selection_WrightFisher_1sex(), LCE_Breed_Selection::do_breed_selection_WrightFisher_2sex(), makeOffspring(), NonWrightFisherPopulation(), LCE_Breed_Quanti::NonWrightFisherPopulation(), WrightFisherPopulation(), and LCE_Breed_Quanti::WrightFisherPopulation().

+ Here is the caller graph for this function:

◆ makeOffspring() [2/2]

Individual * LCE_Breed_base::makeOffspring ( 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.

Used for mating in Wright-Fisher population to bypass the recycling pool. Individuals are, instead, recycled "in-place".

Parameters
newindptr to new offspring, can be NULL, in which case a new ptr is generated
motherptr to mother individual
fatherptr to father individual
natalPatchthe focal patch where the new offpsring is created
364 {
365  newind = _popPtr->decorateNewIndividual(newind, mother, father, getOffsprgSex(), natalPatch);
366 
367  return makeOffspring(newind);
368 }
Individual * decorateNewIndividual(Individual *newind, Individual *mother, Individual *father, sex_t sex, unsigned short homepatch)
Sets the internals of a new individual with pointers to parents, sex and home ID set.
Definition: indfactory.cc:179

References LifeCycleEvent::_popPtr, IndFactory::decorateNewIndividual(), getOffsprgSex(), and makeOffspring().

◆ NonWrightFisherPopulation()

void LCE_Breed_base::NonWrightFisherPopulation ( )
408 {
409  Patch* patch;
410  Individual* mother;
411  Individual* father;
412  Individual* NewOffsprg;
413  unsigned int nbBaby;
414 
415 #ifdef _DEBUG_
416  message("LCE_Breed::execute::NonWrightFisherPopulation::mating system: %i; mean fecundity[0]: %f",
418 #endif
419 
420  //because mean fecundity can be patch-specific, we have to check whether the patch number changed
422 
423  for(unsigned int i = 0; i < _popPtr->getPatchNbr(); i++) {
424 
425  patch = _popPtr->getPatch(i);
426 
427  if( !checkMatingCondition(patch) ) continue;
428 
429  for(unsigned int size = patch->size(FEM, ADLTx), indexOfMother = 0;
430  indexOfMother < size;
431  indexOfMother++)
432  {
433  mother = patch->get(FEM, ADLTx, indexOfMother);
434 
435  nbBaby = (unsigned int)mother->setFecundity( getFecundity(i) ) ; //allows for patch-specific fec
436  //-----------------------------------------------------------------------
437  while(nbBaby != 0) {
438 
439  father = this->getFatherPtr(patch, mother, indexOfMother);
440 
441  NewOffsprg = makeOffspring( do_breed(mother, father, i) );
442 
443  patch->add(NewOffsprg->getSex(), OFFSx, NewOffsprg);
444 
445  nbBaby--;
446  }//_END__WHILE
447 
448  }
449  }
450 
451 #ifdef _DEBUG_
452  message("done, new offsprg nb: %i \n",_popPtr->size( OFFSPRG ));
453 #endif
454 }
double setFecundity(double value)
Sets the fecundity to the value given and returns it.
Definition: individual.h:206
sex_t getSex()
Definition: individual.h:128
bool checkMatingCondition(Patch *thePatch)
Checks if any mating will take place in the patch passed as argument.
Definition: LCEbreed.h:185
double getFecundity(unsigned int patch)
Definition: LCEbreed.h:111
unsigned int size()
Get the total number of individuals present in the population, all sex and age classes together.
Definition: metapop.h:311
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
unsigned int ncols() const
Definition: tmatrix.h:215
void message(const char *message,...)
Definition: output.cc:39
#define OFFSPRG
Offspring age class flag.
Definition: types.h:49

References _mating_system, _mean_fecundity, LifeCycleEvent::_popPtr, Patch::add(), ADLTx, checkMatingCondition(), do_breed(), FEM, Patch::get(), TMatrix::get(), getFatherPtr(), getFecundity(), Metapop::getPatch(), Metapop::getPatchNbr(), Individual::getSex(), makeOffspring(), message(), TMatrix::ncols(), OFFSPRG, OFFSx, setFecundity(), Individual::setFecundity(), Metapop::size(), and Patch::size().

Referenced by setMatingSystem().

+ Here is the caller graph for this function:

◆ partialMonoginy()

Individual* LCE_Breed_base::partialMonoginy ( Patch thePatch,
Individual mother,
unsigned int  motherIndex 
)
inline

Returns a pointer to a male with same index as mother (if available) from the focal patch.

If the male is not available or _mating_proportion != 1, one is drawn randomly from the patch.

Parameters
thePatchthe focal patch.
motherthe mother to mate with (unused here)
motherIndexindex of the mother in the patch adult female container
315  {
316  if(RAND::Uniform() > _mating_proportion || thePatch->size(MAL, ADLTx) < motherIndex+1)
317  return RandomMating(thePatch, mother, motherIndex);
318  else
319  return thePatch->get(MAL, ADLTx, motherIndex);
320  }

References _mating_proportion, ADLTx, Patch::get(), MAL, RandomMating(), Patch::size(), and RAND::Uniform().

Referenced by setMatingSystem().

+ Here is the caller graph for this function:

◆ partialPolyginy()

Individual* LCE_Breed_base::partialPolyginy ( Patch thePatch,
Individual mother,
unsigned int  motherIndex 
)
inline

Returns a pointer to a male from a patch chosen at random if _mating_proportion != 1, or the first male otherwise.

Parameters
thePatchthe focal patch.
motherthe mother to mate with (unused here).
motherIndexindex of the mother in the patch adult female container (unused here)
273  {
275  return RandomMating(thePatch, mother, 0);
276  else
277  return fullPolyginy(thePatch, 0, 0);
278  }
Individual * fullPolyginy(Patch *thePatch, Individual *mother, unsigned int motherIndex)
Returns a pointer to the alpha male of the patch.
Definition: LCEbreed.h:251

References _mating_proportion, fullPolyginy(), RandomMating(), and RAND::Uniform().

Referenced by setMatingSystem().

+ Here is the caller graph for this function:

◆ partialPolyginy_manyMales()

Individual* LCE_Breed_base::partialPolyginy_manyMales ( Patch thePatch,
Individual mother,
unsigned int  motherIndex 
)
inline

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.

Parameters
thePatchthe focal patch.
motherthe mother to mate with (unused here).
motherIndexindex of the mother in the patch adult female container (unused here)
287  {
289  return RandomMating(thePatch, mother, 0);
290  else
291  return fullPolyginy_manyMales(thePatch, mother, 0);
292  }
Individual * fullPolyginy_manyMales(Patch *thePatch, Individual *mother, unsigned int motherIndex)
Returns a pointer to one of the first _mating_males males of the patch.
Definition: LCEbreed.h:259

References _mating_proportion, fullPolyginy_manyMales(), RandomMating(), and RAND::Uniform().

Referenced by setMatingSystem().

+ Here is the caller graph for this function:

◆ partialSelfing()

Individual* LCE_Breed_base::partialSelfing ( Patch thePatch,
Individual mother,
unsigned int  motherIndex 
)
inline

Returns the mother pointer or a random female if _mating_proportion != 1.

Parameters
thePatchthe focal patch.
motherthe mother to mate with (returned here)
motherIndexindex of the mother in the patch adult female container (unused here)
338  {
339  unsigned int fem;
341  do {
342  fem = RAND::Uniform(thePatch->size(FEM, ADLTx));
343  } while(fem == motherIndex && thePatch->size(FEM, ADLTx) != 1);
344  return thePatch->get(FEM, ADLTx, fem);
345  }else
346  return mother;
347  }

References _mating_proportion, ADLTx, FEM, Patch::get(), Patch::size(), and RAND::Uniform().

Referenced by setMatingSystem().

+ Here is the caller graph for this function:

◆ random_hermaphrodite()

Individual* LCE_Breed_base::random_hermaphrodite ( Patch thePatch,
Individual mother,
unsigned int  motherIndex 
)
inline

Returns a random female from the patch, will be the same mother with probability 1/N (Wright-Fisher model).

Parameters
thePatchthe focal patch.
motherthe mother to mate with (unused here)
motherIndexindex of the mother in the patch adult female container (unused here)
355  {
356  return thePatch->get(FEM, ADLTx, RAND::Uniform(thePatch->size(FEM, ADLTx)) );
357  }

References ADLTx, FEM, Patch::get(), Patch::size(), and RAND::Uniform().

Referenced by setMatingSystem().

+ Here is the caller graph for this function:

◆ RandomMating()

Individual* LCE_Breed_base::RandomMating ( Patch thePatch,
Individual mother,
unsigned int  motherIndex 
)
inline

Returns a pointer to a male drawn randomly from a patch.

Parameters
thePatchthe focal patch.
motherthe mother to mate with (unused here)
motherIndexindex of the mother in the patch adult female container (unused here)
243  { return thePatch->get(MAL, ADLTx, RAND::Uniform(thePatch->size(MAL, ADLTx)) ); }

References ADLTx, Patch::get(), MAL, Patch::size(), and RAND::Uniform().

Referenced by fullMonoginy(), LCE_BreedAssortativeMating::non_assortative_mating(), partialMonoginy(), partialPolyginy(), partialPolyginy_manyMales(), and setMatingSystem().

+ Here is the caller graph for this function:

◆ setFecundity()

bool LCE_Breed_base::setFecundity ( )
264 {
265  // FECUNDITY
266 
267  _mean_fecundity.reset(1,1,-1); // set it in the "unset" state with fecundity = -1
268 
269  if (get_parameter("mean_fecundity")->isMatrix()) {
270 
271  get_parameter("mean_fecundity")->getMatrix(&_mean_fecundity);
272 
273  if(_mean_fecundity.nrows() != 1) {
274  return error("\"mean_fecundity\" accepts a single number or a single array with patch-specific values.\n");
275  }
276 
278  return error("\"mean_fecundity\" accepts an array of max num patches in length.\n");
279  }
280  else if (_mean_fecundity.ncols() < _popPtr->getPatchNbr())
281  {
282  // recycle values provided in input until PtachNbr values are reached
283  unsigned int npat = _mean_fecundity.ncols();
284 
286 
288 
289  for (unsigned int i = 0; i < _popPtr->getPatchNbr(); i++) {
290  _mean_fecundity.set(0, i, tmp.get(0 , i % npat));
291  }
292  }
293  } else {
294  //input parameter is not a matrix, copy value into the patch array:
295 
297  }
298 
299 
300  if(get_parameter("fecundity_distribution")->isSet()) {
301 
302  string dist = get_parameter("fecundity_distribution")->getArg();
303 
304  if( dist == "fixed" || dist == "fix" )
305 
307 
308  else if( dist == "poisson" )
309 
311 
312  else if( dist == "normal" || dist == "lognormal" ) {
313 
314  if(get_parameter("fecundity_dist_stdev")->isSet())
315  {
316  _sd_fecundity = get_parameter_value("fecundity_dist_stdev");
317 
318  } else {
319 
320  return error("parameter \"fecundity_dist_stdev\" is missing for \"normal\" fecundity distribution\n");
321  }
322 
323  if(dist == "normal")
325 
326  if(dist == "lognormal")
328 
329  } else {
330  return error("unknown fecundity distribution parameter's argument!\n");
331  }
332 
333  } else { //default distribution is Poisson:
335  }
336  return true;
337 }
double getFixedFecundity(double mean)
Definition: LCEbreed.h:104
double getGaussianFecundity(double mean)
Definition: LCEbreed.h:105
double getLogNormalFecundity(double mean)
Definition: LCEbreed.h:108
double getPoissonFecundity(double mean)
Definition: LCEbreed.h:103
string getArg()
Definition: param.h:137
void getMatrix(TMatrix *mat)
Sets the matrix from the argument string if the parameter is set and of matrix type.
Definition: param.cc:377
virtual double get_parameter_value(std::string name)
Param value getter.
Definition: simcomponent.h:142
A class to handle matrix in params, coerces matrix into a vector of same total size.
Definition: tmatrix.h:49
void reset(unsigned int rows, unsigned int cols)
Re-allocate the existing matrix with assigned rows and cols dimensions and all elements to 0.
Definition: tmatrix.h:160
void set(unsigned int i, unsigned int j, double val)
Sets element at row i and column j to value val.
Definition: tmatrix.h:102
unsigned int nrows() const
Definition: tmatrix.h:212
int error(const char *str,...)
Definition: output.cc:78

References _mean_fecundity, LifeCycleEvent::_popPtr, _sd_fecundity, error(), FecundityFuncPtr, TMatrix::get(), SimComponent::get_parameter(), SimComponent::get_parameter_value(), Param::getArg(), getFixedFecundity(), getGaussianFecundity(), getLogNormalFecundity(), Param::getMatrix(), Metapop::getPatchNbr(), getPoissonFecundity(), TMatrix::ncols(), TMatrix::nrows(), TMatrix::reset(), and TMatrix::set().

Referenced by LCE_Breed_Quanti::execute(), LCE_Breed_base(), NonWrightFisherPopulation(), and setParameters().

+ Here is the caller graph for this function:

◆ setMatingSystem()

bool LCE_Breed_base::setMatingSystem ( )
84 {
85  _mating_system = (int)this->get_parameter_value("mating_system");
86 
87  if(get_parameter("mating_proportion")->isSet())
88  _mating_proportion = this->get_parameter_value("mating_proportion");
89  else
91 
92  if(_paramSet->isSet("mating_males"))
93  _mating_males = (int)_paramSet->getValue("mating_males");
94  else
95  _mating_males = 1;
96 
97  //set the mating functions ptr:
99 
101 
102  _do_inherit = true; //is true unless the mating system is cloning
103 
104  //by default, the population is not kept at constant size, ie not Wright-Fisher
106 
107  if(get_parameter("mating_isWrightFisher")->isSet()) {
108 
110 
111  // check if LCE aging is part of the life cycle and complain
112  if( SIMenv::MainSim->get_LCE("aging")->get_parameter("aging")->isSet() )
113  warning("the \"aging\" LCE is not compatible with \"mating_isWrightFisher\"\n\
114 >>>> \"aging\" will empty the population and may cause extinction!\n\
115 >>>> Remove \"aging\" form the life cycle if you want a Wright-Fisher population\n");
116 
117  } else {
118 
119  if( ! _paramSet->isSet("mean_fecundity") ) {
120 
121  // make sure this isn't called from breed_selection_disperse
122  if(! SIMenv::MainSim->get_LCE("breed_selection_disperse")->get_parameter("breed_selection_disperse")->isSet())
123  fatal("breed::parameter \"mean_fecundity\" must be set in non-Wright-Fisher populations.\n");
124 
125  }
126 
127  }
128 
129  switch(_mating_system) {
130  //random mating:
131  case 1:
132  {
134  break;
135  }
136  //polygyny:
137  case 2:
138  {
139  if(_mating_proportion == 1)
140  if(_mating_males == 1)
142  else
144  else
145  if(_mating_males == 1)
147  else
149 
151  break;
152  }
153  //monogamy:
154  case 3:
155  {
156  if(_mating_proportion == 1)
158  else
160 
161  break;
162  }
163  //selfing:
164  case 4:
165  {
166  if(_mating_proportion == 1)
168  else
170 
172 
173  if(_popPtr->get_parameter("patch_capacity")->isSet()){
174 
175  warning("breed::\"mating_system 4\": number of females and males set from \"patch_capacity\"\n>>>>> It is better to use \"patch_nbfem ...\" and \"patch_nbmal 0\" to avoid adding males. \n");
176 
177  }
178 
179  break;
180  }
181  //cloning
182  case 5:
183  {
184  if(_mating_proportion == 1)
186  else
188 
190 
192 
193  if(_popPtr->get_parameter("patch_capacity")->isSet()){
194 
195  warning("breed::\"mating_system 5\": number of females and males set from \"patch_capacity\"\n>>>>> It is better to use \"patch_nbfem ...\" and \"patch_nbmal 0\" to avoid adding males. \n");
196 
197  }
198 
199  break;
200  }
201  //random mating with hermaphrodites:
202  case 6:
203  {
206 
207  if(_popPtr->get_parameter("patch_capacity")->isSet()){
208 
209  warning("breed::\"mating_system 6\": number of females and males set from \"patch_capacity\"\n>>>>> It is better to use \"patch_nbfem ...\" and \"patch_nbmal 0\" to avoid adding males. \n");
210 
211  }
212 
213  break;
214  }
215 
216  }
217 
218  return true;
219 }
bool checkPolygyny(Patch *thePatch)
Checks whether mating will take place in the current patch when mating is polygynous.
Definition: LCEbreed.h:202
Individual * partialPolyginy_manyMales(Patch *thePatch, Individual *mother, unsigned int motherIndex)
Returns a pointer to a male from a patch chosen at random if _mating_proportion != 1,...
Definition: LCEbreed.h:286
Individual * partialMonoginy(Patch *thePatch, Individual *mother, unsigned int motherIndex)
Returns a pointer to a male with same index as mother (if available) from the focal patch.
Definition: LCEbreed.h:314
void NonWrightFisherPopulation()
Definition: LCEbreed.cc:407
Individual * fullSelfing(Patch *thePatch, Individual *mother, unsigned int motherIndex)
Returns the mother pointer.
Definition: LCEbreed.h:327
void WrightFisherPopulation()
Definition: LCEbreed.cc:458
Individual * partialPolyginy(Patch *thePatch, Individual *mother, unsigned int motherIndex)
Returns a pointer to a male from a patch chosen at random if _mating_proportion != 1,...
Definition: LCEbreed.h:272
Individual * breed(Individual *mother, Individual *father, unsigned int LocalPatch)
Makes a new individual with the right parents.
Definition: LCEbreed.cc:372
Individual * fullMonoginy(Patch *thePatch, Individual *mother, unsigned int motherIndex)
Returns a pointer to a male with same index as mother (if available) from the focal patch.
Definition: LCEbreed.h:300
Individual * random_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 m...
Definition: LCEbreed.h:354
Individual * breed_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 offspri...
Definition: LCEbreed.cc:379
bool checkCloning(Patch *thePatch)
Checks whether mating will take place in the current patch when mating is cloning.
Definition: LCEbreed.h:227
bool checkNoSelfing(Patch *thePatch)
Checks whether mating will take place in the current patch when mating is not selfing or cloning.
Definition: LCEbreed.h:193
Individual * partialSelfing(Patch *thePatch, Individual *mother, unsigned int motherIndex)
Returns the mother pointer or a random female if _mating_proportion != 1.
Definition: LCEbreed.h:337
bool checkSelfing(Patch *thePatch)
Checks whether mating will take place in the current patch when mating is selfing.
Definition: LCEbreed.h:217
double getValue(string name)
Accessor the parameters value.
Definition: param.h:301
bool isSet()
Accessor to the status flag.
Definition: param.h:287
static SimRunner * MainSim
Definition: simenv.h:41
ParamSet * _paramSet
The parameters container.
Definition: simcomponent.h:47
void fatal(const char *str,...)
Definition: output.cc:99
void warning(const char *str,...)
Definition: output.cc:57

References _do_inherit, _mating_males, _mating_proportion, _mating_system, SimComponent::_paramSet, LifeCycleEvent::_popPtr, breed(), breed_cloning(), checkCloning(), CheckMatingConditionFuncPtr, checkNoSelfing(), checkPolygyny(), checkSelfing(), DoBreedFuncPtr, fatal(), fullMonoginy(), fullPolyginy(), fullPolyginy_manyMales(), fullSelfing(), SimComponent::get_parameter(), SimComponent::get_parameter_value(), ParamSet::getValue(), Param::isSet(), ParamSet::isSet(), SIMenv::MainSim, MatingFuncPtr, NonWrightFisherPopulation(), partialMonoginy(), partialPolyginy(), partialPolyginy_manyMales(), partialSelfing(), PopModelFuncPtr, random_hermaphrodite(), RandomMating(), warning(), and WrightFisherPopulation().

Referenced by LCE_Breed_base(), and setParameters().

+ Here is the caller graph for this function:

◆ setParameters()

◆ setSexRatio()

bool LCE_Breed_base::setSexRatio ( )
224 {
225  // SEX-RATIO
226 
227  // by default, the gender is set randomly (Bernoulli trial)
228 
230 
231  // this can be changed to a fixed 1:1 male:female ratio
232  if(get_parameter("sex_ratio_mode")->isSet()) {
233 
234  if(get_parameter("sex_ratio_mode")->getArg() == "fixed") {
235 
237 
238  } else if(get_parameter("sex_ratio_mode")->getArg() != "random") {
239 
240  return error("\"sex_ratio_mode\" parameter argument must be either \"fixed\" or \"random\".");
241 
242  }
243 
244  }
245 
246  // gender-setting function differs for selfing and cloning species
247  // in those two cases, only one sex is modeled; females
248 
249  switch(_mating_system) {
251  break;
253  break;
255  break;
256  }
257 
258  return true;
259 }
sex_t getOffsprgSexSelfing()
Definition: LCEbreed.h:116
sex_t getOffsprgSexRandom()
Definition: LCEbreed.h:114
sex_t getOffsprgSexFixed()
Definition: LCEbreed.cc:341
sex_t getOffsprgSexCloning()
Definition: LCEbreed.h:117

References _mating_system, error(), SimComponent::get_parameter(), GetOffsprgSex, getOffsprgSexCloning(), getOffsprgSexFixed(), getOffsprgSexRandom(), and getOffsprgSexSelfing().

Referenced by LCE_Breed_base(), and setParameters().

+ Here is the caller graph for this function:

◆ WrightFisherPopulation()

void LCE_Breed_base::WrightFisherPopulation ( )
459 {
460  Patch* patch = 0;
461  Individual* mother = 0;
462  Individual* father = 0;
463  Individual* NewOffsprg = 0;
464  unsigned int indexOfMother = 0;
465  unsigned int num_fem = 0, num_offsprg = 0;
466 
467 #ifdef _DEBUG_
468  message("LCE_Breed::execute::WrightFisherPopulation::");
469 #endif
470 
471  for(unsigned int i = 0; i < _popPtr->getPatchNbr(); i++) {
472 
473  patch = _popPtr->getPatch(i);
474 
475  if( !checkMatingCondition(patch) ) continue;
476 
477  num_fem = patch->size(FEM, ADLTx);
478 
479 // cout << ">>> WF repro in patch "<<i+1<< " num repro female: "<<num_fem<<endl;
480 
481  for(unsigned int s = 0; s < 2; ++s) { //filling male and female offspring containers
482  //-----------------------------------------------------------------------
483  num_offsprg = patch->get_K(sex_t(s));
484 
485  // resize container if necessary, e.g. when carrying capacities change during a run
486  // allows us to use set() instead of add(), to limit push-backs
487  // will exit if size doesn't change
488  patch->resize(sex_t(s), OFFSx, num_offsprg);
489 
490 // cout << ">>> resized offspring container "<<(s==1? "FEM":"MAL")<<" to "<<num_offsprg
491 // <<" (size="<<patch->size(sex_t(s), OFFSx)<<")\n";
492 
493  for(unsigned int c = 0; c < num_offsprg; ++c)
494  {
495  indexOfMother = RAND::Uniform(num_fem);
496 
497  mother = patch->get(FEM, ADLTx, indexOfMother );
498 
499  // choose the father depending on mating system
500  father = this->getFatherPtr(patch, mother, indexOfMother);
501 
502  NewOffsprg = makeOffspring( do_breed(mother, father, i) );
503 
504  NewOffsprg->setSex(sex_t(s));
505 
506  patch->set(sex_t(s), OFFSx, c, NewOffsprg);
507 
508 
509  // create new offspring but skip the recycling pool in popPtr to save time
510  // use existing pointer to individuals in the container instead
511  // containers are swapped for the next generation at the end
512 // NewOffsprg = patch->get(sex_t(s), OFFSx, c);
513 //
514 // NewOffsprg = makeOffspring( NewOffsprg, mother, father, i );
515 //
516 // NewOffsprg->setSex(sex_t(s));
517 
518 // cout << ">>> adding new offspring #"<<NewOffsprg->getID()<<" at pos "<<c<<endl;
519  // (re)set the pointer in the patch container, necessary in case a new offspring has been generated
520 // patch->set(sex_t(s), OFFSx, c, NewOffsprg); // this is unchecked if c is within range
521 
522  }//END FOR ind
523  } //END FOR sex
524 
525  // we do the generation change here directly
526  patch->flush(ADLTx, _popPtr); //first move adults to recycling pool
527  patch->move(FEM, OFFSx, ADLTx); //moves offspring to adult containers, resets offsprg size to 0
528  patch->move(MAL, OFFSx, ADLTx);
529 
530  // swapping instead of moving:
531 // cout << ">>> patch sizes before swapping: offspring="<<patch->size(OFFSx)<<" adluts="<<patch->size(ADLTx)<<endl;
532 //
533 // patch->swap_new(FEM, OFFSx, ADLTx);
534 // patch->swap_new(MAL, OFFSx, ADLTx);
535 //
536 // cout << ">>> patch sizes after swapping: offspring="<<patch->size(OFFSPRG)<<" adluts="<<patch->size(ADLTx)<<endl;
537 
538  } //END FOR patch
539 
540 #ifdef _DEBUG_
541  message("done, new patch size: %i \n",_popPtr->size());
542 #endif
543 }
void setSex(sex_t sex)
Definition: individual.h:111
unsigned int get_K()
Definition: metapop.h:481
void set(sex_t SEX, age_idx AGE, unsigned int at, Individual *ind)
Modifies the appropriate container with value of the pointer given.
Definition: metapop.h:542
void resize(sex_t SEX, age_idx AGE, size_t new_size)
Reserves a certain range of values that are assigned to 0 in a given container.
Definition: metapop.h:573

References LifeCycleEvent::_popPtr, ADLTx, checkMatingCondition(), do_breed(), FEM, Patch::flush(), Patch::get(), Patch::get_K(), getFatherPtr(), Metapop::getPatch(), Metapop::getPatchNbr(), makeOffspring(), MAL, message(), Patch::move(), OFFSx, Patch::resize(), Patch::set(), Individual::setSex(), Metapop::size(), Patch::size(), and RAND::Uniform().

Referenced by setMatingSystem().

+ Here is the caller graph for this function:

Member Data Documentation

◆ _alpha_male

unsigned int LCE_Breed_base::_alpha_male
private

Referenced by checkPolygyny(), and fullPolyginy().

◆ _do_inherit

bool LCE_Breed_base::_do_inherit
private

◆ _mating_males

unsigned int LCE_Breed_base::_mating_males
private

◆ _mating_proportion

double LCE_Breed_base::_mating_proportion
private

◆ _mating_system

int LCE_Breed_base::_mating_system
private

◆ _mean_fecundity

◆ _sd_fecundity

double LCE_Breed_base::_sd_fecundity
private

◆ CheckMatingConditionFuncPtr

bool(LCE_Breed_base::* LCE_Breed_base::CheckMatingConditionFuncPtr) (Patch *thePatch)
protected

◆ DoBreedFuncPtr

Individual*(LCE_Breed_base::* LCE_Breed_base::DoBreedFuncPtr) (Individual *mother, Individual *father, unsigned int LocalPatch)
protected

Referenced by do_breed(), and setMatingSystem().

◆ FecundityFuncPtr

double(LCE_Breed_base::* LCE_Breed_base::FecundityFuncPtr) (double mean)
protected

Referenced by getFecundity(), and setFecundity().

◆ GetOffsprgSex

sex_t(LCE_Breed_base::* LCE_Breed_base::GetOffsprgSex) ()
protected

Referenced by getOffsprgSex(), and setSexRatio().

◆ MatingFuncPtr

Individual*(LCE_Breed_base::* LCE_Breed_base::MatingFuncPtr) (Patch *, Individual *, unsigned int)
protected

◆ PopModelFuncPtr

void(LCE_Breed_base::* LCE_Breed_base::PopModelFuncPtr) (void)
protected

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