Nemo  2.4.2
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 ( )
45 : LifeCycleEvent("", ""),
48 //_growthRates(0),
49 MatingFuncPtr(0),
52 
53 {
55 
56  add_parameter("mating_system",INT,true,true,1,6, updater);
57  add_parameter("mating_proportion",DBL,false,true,0,1,updater);
58  add_parameter("mating_males",INT,false,false,0,0, updater);
59  add_parameter("mating_isWrightFisher", BOOL, false, false, 0, 0, updater);
60 
61 // add_parameter("growth_model", INT, false, true, 1, 7, updater);
62 // add_parameter("growth_rate", DBL, false, false, 0, 0, updater);
63 
65  add_parameter("mean_fecundity",DBL,false,false,0,0, updater);
66  add_parameter("fecundity_dist_stdev",DBL,false,false,0,0, updater);
67  add_parameter("fecundity_distribution",STR,false,false,0,0, updater);
68 
70  add_parameter("sex_ratio_mode",STR,false,false,0,0, updater);
71 }
unsigned int _alpha_male
Definition: LCEbreed.h:49
bool _do_inherit
Definition: LCEbreed.h:51
double _sd_fecundity
Definition: LCEbreed.h:50
sex_t(LCE_Breed_base::* GetOffsprgSex)()
Definition: LCEbreed.h:62
double(LCE_Breed_base::* FecundityFuncPtr)(double mean)
Definition: LCEbreed.h:60
void(LCE_Breed_base::* PopModelFuncPtr)(void)
Definition: LCEbreed.h:63
Individual *(LCE_Breed_base::* DoBreedFuncPtr)(Individual *mother, Individual *father, unsigned int LocalPatch)
Definition: LCEbreed.h:59
double _mating_proportion
Definition: LCEbreed.h:50
bool setMatingSystem()
Definition: LCEbreed.cc:82
bool setFecundity()
Definition: LCEbreed.cc:262
bool(LCE_Breed_base::* CheckMatingConditionFuncPtr)(Patch *thePatch)
Definition: LCEbreed.h:61
unsigned int _mating_males
Definition: LCEbreed.h:48
TMatrix _mean_fecundity
Definition: LCEbreed.h:66
int _mating_system
Definition: LCEbreed.h:47
bool setSexRatio()
Definition: LCEbreed.cc:222
Individual *(LCE_Breed_base::* MatingFuncPtr)(Patch *, Individual *, unsigned int)
Definition: LCEbreed.h:58
LifeCycleEvent(const char *name, const char *trait_link)
Cstor.
Definition: lifecycleevent.h:96
Implementation of the ParamUpdaterBase interface.
Definition: param.h:371
virtual void add_parameter(Param *param)
Interface to add a parameter to the set.
Definition: simcomponent.h:110
@ DBL
Definition: types.h:76
@ BOOL
Definition: types.h:76
@ STR
Definition: types.h:76
@ INT
Definition: types.h:76

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

◆ ~LCE_Breed_base()

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

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
372 {
373  return _popPtr->makeNewIndividual(mother, father, getOffsprgSex(), LocalPatch);
374 }
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:150
sex_t getOffsprgSex()
Definition: LCEbreed.h:112
Metapop * _popPtr
The ptr to the current Metapop.
Definition: lifecycleevent.h:79

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
379 {
380  Individual *newind;
381 
382  if(mother == father) {
383  newind = _popPtr->getNewIndividual();
384  //cloning:
385  (*newind) = (*mother);
386 
387  newind->reset_counters();
388  newind->setFather(NULL);
389  newind->setFatherID(0);
390  newind->setMother(mother);
391  newind->setMotherID(mother->getID());
392  newind->setIsSelfed(true);
393  newind->setHome(LocalPatch);
394  newind->setAge(0);
395  _do_inherit = false;
396  } else {
397  newind = _popPtr->makeNewIndividual(mother, father, getOffsprgSex(), LocalPatch);
398  _do_inherit = true;
399  }
400 
401  return newind;
402 }
Individual * getNewIndividual()
Creates a blank individual which has to be "decorated" later.
Definition: indfactory.h:83
This class contains traits along with other individual information (sex, pedigree,...
Definition: individual.h:47
void setFather(Individual *f)
Definition: individual.h:107
unsigned long getID()
Definition: individual.h:120
void reset_counters()
Resets the mating and fecundity counters.
Definition: individual.h:208
void setMother(Individual *m)
Definition: individual.h:108
void setIsSelfed(bool s)
Definition: individual.h:112
void setHome(unsigned short value)
Definition: individual.h:109
void setMotherID(unsigned long value)
Definition: individual.h:106
void setFatherID(unsigned long value)
Definition: individual.h:105
void setAge(unsigned short value)
Definition: individual.h:103

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
227  {
228  if(thePatch->size(MAL, ADLTx) != 0) thePatch->flush(MAL, ADLTx, this->_popPtr);
229 
230  return (thePatch->size(FEM, ADLTx) != 0);
231  }
unsigned int size(age_t AGE)
Returns the size of the container of the appropriate age class(es) for both sexes.
Definition: metapop.h:496
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:685
@ FEM
Definition: types.h:35
@ MAL
Definition: types.h:35
@ ADLTx
Definition: types.h:40

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
185  {
186  return (this->* CheckMatingConditionFuncPtr) (thePatch);
187  }

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
193  {
194  return (thePatch->size(FEM, ADLTx) != 0 && thePatch->size(MAL, ADLTx) != 0);
195  }

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

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
217  {
218  if(thePatch->size(MAL, ADLTx) != 0) thePatch->flush(MAL, ADLTx, this->_popPtr);
219  return (thePatch->size(FEM, ADLTx) != 0);
220  }

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.

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

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 ( )
547 {
548  Patch* patch = 0;
549 
550  for(unsigned int i = 0; i < _popPtr->getPatchNbr(); i++) {
551 
552  patch = _popPtr->getPatch(i);
553 
554  if(patch->isEmpty()) {patch->set_isExtinct(true); continue;}
555 
556  // we do the generation change here directly
557  patch->flush(ADLTx, _popPtr); //first move adults to recycling pool
558  patch->move(FEM, OFFSx, ADLTx); //moves offspring to adult containers, resets offsprg size to 0
559  patch->move(MAL, OFFSx, ADLTx);
560  }
561 }
unsigned int getPatchNbr()
Definition: metapop.h:274
Patch * getPatch(unsigned int i)
Patch accessor, return the ith+1 patch in the metapop.
Definition: metapop.h:255
Second class in the metapopulation design structure, between the Metapop and Individual classes.
Definition: metapop.h:430
void set_isExtinct(bool status)
Definition: metapop.h:474
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:609
bool isEmpty()
Definition: metapop.h:486
@ OFFSx
Definition: types.h:40

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
101 {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
300  {
301  if(thePatch->size(MAL, ADLTx) < motherIndex+1)
302  return RandomMating(thePatch, mother, motherIndex);
303  else
304  return thePatch->get(MAL, ADLTx, motherIndex);
305  }
Individual * RandomMating(Patch *thePatch, Individual *mother, unsigned int motherIndex)
Returns a pointer to a male drawn randomly from a patch.
Definition: LCEbreed.h:241
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:532

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)
251  { 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)
259  {
260  if(thePatch->size(MAL,ADLTx) < _mating_males)
261  return thePatch->get(MAL, ADLTx, RAND::Uniform( thePatch->size(MAL, ADLTx) ) );
262  else
263  return thePatch->get(MAL, ADLTx, RAND::Uniform( _mating_males ) );
264  }

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)
327  {
328  return mother;
329  }

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
81  {
82  return (this->*MatingFuncPtr)(thePatch, mother, motherIndex);
83  }

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
111 {return (this->* FecundityFuncPtr)(mean);}

References FecundityFuncPtr.

◆ getFecundity() [2/2]

double LCE_Breed_base::getFecundity ( unsigned int  patch)
inline
110 {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:191

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
103 {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
104  {
105  double fec; do{fec = mean + RAND::Gaussian(_sd_fecundity);}while(fec < 0);
106  return fec;}
static double Gaussian(double sigma)
Definition: Uniform.h:271

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
107  {
108  double fec; do{fec = mean + RAND::LogNormal(mean, _sd_fecundity);}while(fec < 0);
109  return fec;}
static double LogNormal(double zeta, double sigma)
Definition: Uniform.h:367

References _sd_fecundity, and RAND::LogNormal().

Referenced by setFecundity().

+ Here is the caller graph for this function:

◆ getMatingProportion()

double LCE_Breed_base::getMatingProportion ( )
inline
98 {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
112 {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
116 {return FEM;}

References FEM.

Referenced by setSexRatio().

+ Here is the caller graph for this function:

◆ getOffsprgSexFixed()

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

References RAND::RandBool().

Referenced by setSexRatio().

+ Here is the caller graph for this function:

◆ getOffsprgSexRandom()

sex_t LCE_Breed_base::getOffsprgSexRandom ( )
inline
113 {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
115 {return FEM;}

References FEM.

Referenced by setSexRatio().

+ Here is the caller graph for this function:

◆ getPoissonFecundity()

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

References RAND::Poisson().

Referenced by setFecundity().

+ Here is the caller graph for this function:

◆ isWrightFisher()

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

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:80
Individual * makeOffspring(Individual *ind)
Last step of the breeding process, does inheritance and mutation of the parents' genes.
Definition: LCEbreed.cc:349
Individual * do_breed(Individual *mother, Individual *father, unsigned int LocalPatch)
Calls the breeding function unsing its pointer.
Definition: LCEbreed.h:175
unsigned int getID()
Definition: metapop.h:479
Parameters
indthe offspring, as returned by the do_breed function.
350 {
351  unsigned int cat = ind->getPedigreeClass();
352 
353  ind->getMother()->DidHaveABaby(cat);
354  if(cat!=4) ind->getFather()->DidHaveABaby(cat);
355 
356  return ind->create(doInheritance(), true);
357 }
Individual * create()
Creates an individual's genotypes and phenotypes with recombination and mutations.
Definition: individual.h:360
Individual * getMother()
Definition: individual.h:125
Individual * getFather()
Definition: individual.h:124
void DidHaveABaby(unsigned int category)
Increments the mating and realized fecundity counters according to the pedigree class of the offsprin...
Definition: individual.h:223
unsigned int getPedigreeClass()
Returns the pedigree class of the individual, as set during offspring creation.
Definition: individual.h:177
bool doInheritance()
Definition: LCEbreed.h:101

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
363 {
364  newind = _popPtr->decorateNewIndividual(newind, mother, father, getOffsprgSex(), natalPatch);
365 
366  return makeOffspring(newind);
367 }
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:178

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

◆ NonWrightFisherPopulation()

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

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
314  {
315  if(RAND::Uniform() > _mating_proportion || thePatch->size(MAL, ADLTx) < motherIndex+1)
316  return RandomMating(thePatch, mother, motherIndex);
317  else
318  return thePatch->get(MAL, ADLTx, motherIndex);
319  }

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)
272  {
274  return RandomMating(thePatch, mother, 0);
275  else
276  return fullPolyginy(thePatch, 0, 0);
277  }
Individual * fullPolyginy(Patch *thePatch, Individual *mother, unsigned int motherIndex)
Returns a pointer to the alpha male of the patch.
Definition: LCEbreed.h:250

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)
286  {
288  return RandomMating(thePatch, mother, 0);
289  else
290  return fullPolyginy_manyMales(thePatch, mother, 0);
291  }
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:258

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)
337  {
338  unsigned int fem;
340  do {
341  fem = RAND::Uniform(thePatch->size(FEM, ADLTx));
342  } while(fem == motherIndex && thePatch->size(FEM, ADLTx) != 1);
343  return thePatch->get(FEM, ADLTx, fem);
344  }else
345  return mother;
346  }

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)
354  {
355  return thePatch->get(FEM, ADLTx, RAND::Uniform(thePatch->size(FEM, ADLTx)) );
356  }

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)
242  { 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 ( )
263 {
264  // FECUNDITY
265 
266  _mean_fecundity.reset(1,1,-1); // set it in the "unset" state with fecundity = -1
267 
268  if (get_parameter("mean_fecundity")->isMatrix()) {
269 
270  get_parameter("mean_fecundity")->getMatrix(&_mean_fecundity);
271 
272  if(_mean_fecundity.nrows() != 1) {
273  return error("\"mean_fecundity\" accepts a single number or a single array with patch-specific values.\n");
274  }
275 
277  return error("\"mean_fecundity\" accepts an array of max num patches in length.\n");
278  }
279  else if (_mean_fecundity.ncols() < _popPtr->getPatchNbr())
280  {
281  // recycle values provided in input until PtachNbr values are reached
282  unsigned int npat = _mean_fecundity.ncols();
283 
285 
287 
288  for (unsigned int i = 0; i < _popPtr->getPatchNbr(); i++) {
289  _mean_fecundity.set(0, i, tmp.get(0 , i % npat));
290  }
291  }
292  } else {
293  //input parameter is not a matrix, copy value into the patch array:
294 
296  }
297 
298 
299  if(get_parameter("fecundity_distribution")->isSet()) {
300 
301  string dist = get_parameter("fecundity_distribution")->getArg();
302 
303  if( dist == "fixed" || dist == "fix" )
304 
306 
307  else if( dist == "poisson" )
308 
310 
311  else if( dist == "normal" || dist == "lognormal" ) {
312 
313  if(get_parameter("fecundity_dist_stdev")->isSet())
314  {
315  _sd_fecundity = get_parameter_value("fecundity_dist_stdev");
316 
317  } else {
318 
319  return error("parameter \"fecundity_dist_stdev\" is missing for \"normal\" fecundity distribution\n");
320  }
321 
322  if(dist == "normal")
324 
325  if(dist == "lognormal")
327 
328  } else {
329  return error("unknown fecundity distribution parameter's argument!\n");
330  }
331 
332  } else { //default distribution is Poisson:
334  }
335  return true;
336 }
double getFixedFecundity(double mean)
Definition: LCEbreed.h:103
double getGaussianFecundity(double mean)
Definition: LCEbreed.h:104
double getLogNormalFecundity(double mean)
Definition: LCEbreed.h:107
double getPoissonFecundity(double mean)
Definition: LCEbreed.h:102
string getArg()
Definition: param.h:142
void getMatrix(TMatrix *mat)
Sets the matrix from the argument string if the parameter is set and of matrix type.
Definition: param.cc:396
virtual double get_parameter_value(std::string name)
Param value getter.
Definition: simcomponent.h:141
A class to handle matrix in params, coerces matrix into a vector of same total size.
Definition: tmatrix.h:48
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:159
void set(unsigned int i, unsigned int j, double val)
Sets element at row i and column j to value val.
Definition: tmatrix.h:101
unsigned int nrows() const
Definition: tmatrix.h:211
int error(const char *str,...)
Definition: output.cc:77

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 ( )
83 {
84  _mating_system = (int)this->get_parameter_value("mating_system");
85 
86  if(get_parameter("mating_proportion")->isSet())
87  _mating_proportion = this->get_parameter_value("mating_proportion");
88  else
90 
91  if(_paramSet->isSet("mating_males"))
92  _mating_males = (int)_paramSet->getValue("mating_males");
93  else
94  _mating_males = 1;
95 
96  //set the mating functions ptr:
98 
100 
101  _do_inherit = true; //is true unless the mating system is cloning
102 
103  //by default, the population is not kept at constant size, ie not Wright-Fisher
105 
106  if(get_parameter("mating_isWrightFisher")->isSet()) {
107 
109 
110  // check if LCE aging is part of the life cycle and complain
111  if( SIMenv::MainSim->get_LCE("aging")->get_parameter("aging")->isSet() )
112  warning("the \"aging\" LCE is not compatible with \"mating_isWrightFisher\"\n\
113 >>>> \"aging\" will empty the population and may cause extinction!\n\
114 >>>> Remove \"aging\" form the life cycle if you want a Wright-Fisher population\n");
115 
116  } else {
117 
118  if( ! _paramSet->isSet("mean_fecundity") ) {
119 
120  // make sure this isn't called from breed_selection_disperse
121  if(! SIMenv::MainSim->get_LCE("breed_selection_disperse")->get_parameter("breed_selection_disperse")->isSet())
122  fatal("breed::parameter \"mean_fecundity\" must be set in non-Wright-Fisher populations.\n");
123 
124  }
125 
126  }
127 
128  switch(_mating_system) {
129  //random mating:
130  case 1:
131  {
133  break;
134  }
135  //polygyny:
136  case 2:
137  {
138  if(_mating_proportion == 1)
139  if(_mating_males == 1)
141  else
143  else
144  if(_mating_males == 1)
146  else
148 
150  break;
151  }
152  //monogamy:
153  case 3:
154  {
155  if(_mating_proportion == 1)
157  else
159 
160  break;
161  }
162  //selfing:
163  case 4:
164  {
165  if(_mating_proportion == 1)
167  else
169 
171 
172  if(_popPtr->get_parameter("patch_capacity")->isSet()){
173 
174  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");
175 
176  }
177 
178  break;
179  }
180  //cloning
181  case 5:
182  {
183  if(_mating_proportion == 1)
185  else
187 
189 
191 
192  if(_popPtr->get_parameter("patch_capacity")->isSet()){
193 
194  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");
195 
196  }
197 
198  break;
199  }
200  //random mating with hermaphrodites:
201  case 6:
202  {
205 
206  if(_popPtr->get_parameter("patch_capacity")->isSet()){
207 
208  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");
209 
210  }
211 
212  break;
213  }
214 
215  }
216 
217  return true;
218 }
bool checkPolygyny(Patch *thePatch)
Checks whether mating will take place in the current patch when mating is polygynous.
Definition: LCEbreed.h:201
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:285
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:313
void NonWrightFisherPopulation()
Definition: LCEbreed.cc:406
Individual * fullSelfing(Patch *thePatch, Individual *mother, unsigned int motherIndex)
Returns the mother pointer.
Definition: LCEbreed.h:326
void WrightFisherPopulation()
Definition: LCEbreed.cc:457
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:271
Individual * breed(Individual *mother, Individual *father, unsigned int LocalPatch)
Makes a new individual with the right parents.
Definition: LCEbreed.cc:371
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:299
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:353
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:378
bool checkCloning(Patch *thePatch)
Checks whether mating will take place in the current patch when mating is cloning.
Definition: LCEbreed.h:226
bool checkNoSelfing(Patch *thePatch)
Checks whether mating will take place in the current patch when mating is not selfing or cloning.
Definition: LCEbreed.h:192
Individual * partialSelfing(Patch *thePatch, Individual *mother, unsigned int motherIndex)
Returns the mother pointer or a random female if _mating_proportion != 1.
Definition: LCEbreed.h:336
bool checkSelfing(Patch *thePatch)
Checks whether mating will take place in the current patch when mating is selfing.
Definition: LCEbreed.h:216
double getValue(string name)
Accessor the parameters value.
Definition: param.h:310
bool isSet()
Accessor to the status flag.
Definition: param.h:296
static SimRunner * MainSim
Definition: simenv.h:40
ParamSet * _paramSet
The parameters container.
Definition: simcomponent.h:46
void fatal(const char *str,...)
Definition: output.cc:98
void warning(const char *str,...)
Definition: output.cc:56

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 ( )
223 {
224  // SEX-RATIO
225 
226  // by default, the gender is set randomly (Bernoulli trial)
227 
229 
230  // this can be changed to a fixed 1:1 male:female ratio
231  if(get_parameter("sex_ratio_mode")->isSet()) {
232 
233  if(get_parameter("sex_ratio_mode")->getArg() == "fixed") {
234 
236 
237  } else if(get_parameter("sex_ratio_mode")->getArg() != "random") {
238 
239  return error("\"sex_ratio_mode\" parameter argument must be either \"fixed\" or \"random\".");
240 
241  }
242 
243  }
244 
245  // gender-setting function differs for selfing and cloning species
246  // in those two cases, only one sex is modeled; females
247 
248  switch(_mating_system) {
250  break;
252  break;
254  break;
255  }
256 
257  return true;
258 }
sex_t getOffsprgSexSelfing()
Definition: LCEbreed.h:115
sex_t getOffsprgSexRandom()
Definition: LCEbreed.h:113
sex_t getOffsprgSexFixed()
Definition: LCEbreed.cc:340
sex_t getOffsprgSexCloning()
Definition: LCEbreed.h:116

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

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.2 by  doxygen 1.9.1

Catalogued on GSR