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

Performs breeding and migration in one, migration rates are backward rates. More...

#include <LCEcomposite.h>

+ Inheritance diagram for LCE_Breed_Disperse:
+ Collaboration diagram for LCE_Breed_Disperse:

Public Member Functions

 LCE_Breed_Disperse ()
 
virtual ~LCE_Breed_Disperse ()
 
void do_breed_disperse ()
 
void do_breed_disperse_propagule ()
 
void do_breed_disperse_in_patch (sex_t SEX, Patch *patch, unsigned int ID, unsigned int num_offsprg)
 
void do_breed_disperse_in_empty_patch (sex_t SEX, Patch *patch, unsigned int ID, unsigned int num_offsprg)
 
unsigned int numFemOffspring (Patch *patch)
 
unsigned int numFemOffspring_colonizers (Patch *patch)
 The number of females produced in case a max number of colonizers was specified. More...
 
unsigned int numMalOffspring_notrandom (Patch *patch)
 The number of males produced is always zero when the mating system is not random mating. More...
 
unsigned int numMalOffspring_random (Patch *patch)
 
unsigned int numMalOffspring_random_colonizers (Patch *patch)
 
Growth Functions
unsigned int instantGrowth (Patch *patch, sex_t SEX)
 The number of offspring produced corresponds to the carrying capacity of the patch. More...
 
unsigned int logisticGrowth (Patch *patch, sex_t SEX)
 The number of offspring produced is given by the logistic growth function. More...
 
unsigned int stochasticLogisticGrowth (Patch *patch, sex_t SEX)
 The number of offspring produced is drawn from a Poisson with mean equal to the logistic growth predicate. More...
 
unsigned int conditionalLogisticGrowth (Patch *patch, sex_t SEX)
 The number of offspring produced depends on the adult density. More...
 
unsigned int conditionalStochasticLogisticGrowth (Patch *patch, sex_t SEX)
 The number of offspring produced depends on the adult density, similar to 'conditionalLogisticGrowth' except that this time, the fecundities are drawn from Poisson distributions. More...
 
unsigned int fixedFecundityGrowth (Patch *patch, sex_t SEX)
 The number of offspring produced is equal to the current number of breeders multiplied by the mean fecundity of the focal patch. More...
 
unsigned int stochasticFecundityGrowth (Patch *patch, sex_t SEX)
 The number of offspring produced is a random number drawn from a Poisson distribution with mean equal to the current number of breeders multiplied by the mean fecundity of the focal patch. More...
 
unsigned int exponentialGrowth (Patch *patch, sex_t SEX)
 Exponential growth using current patch size as basis to calculate future sizes, set once the function is first called. More...
 
Mating Functions
Individualmate_random (sex_t SEX, Patch *patch, unsigned int LocalPatch, gsl_ran_discrete_t *rate_fem, gsl_ran_discrete_t *rate_mal)
 
Individualmate_random_hermaphrodite (sex_t SEX, Patch *patch, unsigned int LocalPatch, gsl_ran_discrete_t *rate_fem, gsl_ran_discrete_t *rate_mal)
 
Individualmate_selfing (sex_t SEX, Patch *patch, unsigned int LocalPatch, gsl_ran_discrete_t *rate_fem, gsl_ran_discrete_t *rate_mal)
 
Individualmate_full_selfing (sex_t SEX, Patch *patch, unsigned int LocalPatch, gsl_ran_discrete_t *rate_fem, gsl_ran_discrete_t *rate_mal)
 
Individualmate_cloning (sex_t SEX, Patch *patch, unsigned int LocalPatch, gsl_ran_discrete_t *rate_fem, gsl_ran_discrete_t *rate_mal)
 
IndividualmakeOffspring (Individual *ind)
 
Individualget_parent (sex_t SEX, sex_t DispSex, Patch *LocalPatch, unsigned int patchID, gsl_ran_discrete_t *rates)
 
Implementations
virtual bool setParameters ()
 
virtual void execute ()
 
virtual LifeCycleEventclone ()
 
virtual void loadFileServices (FileServices *loader)
 
virtual void loadStatServices (StatServices *loader)
 
virtual bool resetParameterFromSource (std::string param, SimComponent *cmpt)
 
virtual age_t removeAgeClass ()
 
virtual age_t addAgeClass ()
 
virtual age_t requiredAgeClass ()
 
- Public Member Functions inherited from LCE_Breed_base
 LCE_Breed_base ()
 
virtual ~LCE_Breed_base ()
 
virtual IndividualgetFatherPtr (Patch *thePatch, Individual *mother, unsigned int motherIndex)
 Calls the mating function according to the model chosen using the function pointer, used to get the father from the mother in a patch. More...
 
void NonWrightFisherPopulation ()
 
void WrightFisherPopulation ()
 
void doAgingInWFpop ()
 
Individualbreed (Individual *mother, Individual *father, unsigned int LocalPatch)
 Makes a new individual with the right parents. More...
 
Individualbreed_cloning (Individual *mother, Individual *father, unsigned int LocalPatch)
 Makes a new individual by doing a deep copy of the mother (copies the mother's genes into the offspring). More...
 
IndividualmakeOffspring (Individual *ind)
 Last step of the breeding process, does inheritance and mutation of the parents' genes. More...
 
IndividualmakeOffspring (Individual *newind, Individual *mother, Individual *father, unsigned int natalPatch)
 Overloads previous function when a new offspring is created "in-place", that is from existing pointer in a patch. More...
 
Individualdo_breed (Individual *mother, Individual *father, unsigned int LocalPatch)
 Calls the breeding function unsing its pointer. More...
 
bool checkMatingCondition (Patch *thePatch)
 Checks if any mating will take place in the patch passed as argument. More...
 
bool checkNoSelfing (Patch *thePatch)
 Checks whether mating will take place in the current patch when mating is not selfing or cloning. More...
 
bool checkPolygyny (Patch *thePatch)
 Checks whether mating will take place in the current patch when mating is polygynous. More...
 
bool checkSelfing (Patch *thePatch)
 Checks whether mating will take place in the current patch when mating is selfing. More...
 
bool checkCloning (Patch *thePatch)
 Checks whether mating will take place in the current patch when mating is cloning. More...
 
bool setMatingSystem ()
 
bool setFecundity ()
 
bool setSexRatio ()
 
double getMatingProportion ()
 
double getMeanFecundity (unsigned int patch)
 
int getMatingSystem ()
 
bool doInheritance ()
 
double getPoissonFecundity (double mean)
 
double getFixedFecundity (double mean)
 
double getGaussianFecundity (double mean)
 
double getLogNormalFecundity (double mean)
 
double getFecundity (unsigned int patch)
 
double getFecundity (double mean)
 
sex_t getOffsprgSex ()
 
sex_t getOffsprgSexRandom ()
 
sex_t getOffsprgSexFixed ()
 
sex_t getOffsprgSexSelfing ()
 
sex_t getOffsprgSexCloning ()
 
bool isWrightFisher ()
 
IndividualRandomMating (Patch *thePatch, Individual *mother, unsigned int motherIndex)
 Returns a pointer to a male drawn randomly from a patch. More...
 
IndividualfullPolyginy (Patch *thePatch, Individual *mother, unsigned int motherIndex)
 Returns a pointer to the alpha male of the patch. More...
 
IndividualfullPolyginy_manyMales (Patch *thePatch, Individual *mother, unsigned int motherIndex)
 Returns a pointer to one of the first _mating_males males of the patch. More...
 
IndividualpartialPolyginy (Patch *thePatch, Individual *mother, unsigned int motherIndex)
 Returns a pointer to a male from a patch chosen at random if _mating_proportion != 1, or the first male otherwise. More...
 
IndividualpartialPolyginy_manyMales (Patch *thePatch, Individual *mother, unsigned int motherIndex)
 Returns a pointer to a male from a patch chosen at random if _mating_proportion != 1, or one of the _mating_males first males otherwise. More...
 
IndividualfullMonoginy (Patch *thePatch, Individual *mother, unsigned int motherIndex)
 Returns a pointer to a male with same index as mother (if available) from the focal patch. More...
 
IndividualpartialMonoginy (Patch *thePatch, Individual *mother, unsigned int motherIndex)
 Returns a pointer to a male with same index as mother (if available) from the focal patch. More...
 
IndividualfullSelfing (Patch *thePatch, Individual *mother, unsigned int motherIndex)
 Returns the mother pointer. More...
 
IndividualpartialSelfing (Patch *thePatch, Individual *mother, unsigned int motherIndex)
 Returns the mother pointer or a random female if _mating_proportion != 1. More...
 
Individualrandom_hermaphrodite (Patch *thePatch, Individual *mother, unsigned int motherIndex)
 Returns a random female from the patch, will be the same mother with probability 1/N (Wright-Fisher model). More...
 
- Public Member Functions inherited from LifeCycleEvent
 LifeCycleEvent (const char *name, const char *trait_link)
 Cstor. More...
 
virtual ~LifeCycleEvent ()
 
virtual void init (Metapop *popPtr)
 Sets the pointer to the current Metapop and the trait link if applicable. More...
 
virtual bool attach_trait (string trait)
 
virtual void set_paramset (std::string name, bool required, SimComponent *owner)
 
virtual void set_event_name (std::string &name)
 Set the name of the event (name of the ParamSet) and add the corresponding parameter to the set. More...
 
virtual void set_event_name (const char *name)
 
virtual string & get_event_name ()
 Accessor to the LCE's name. More...
 
virtual int get_rank ()
 Accessor to the LCE rank in the life cycle. More...
 
virtual void set_pop_ptr (Metapop *popPtr)
 Accessors for the population pointer. More...
 
virtual Metapopget_pop_ptr ()
 
- Public Member Functions inherited from SimComponent
 SimComponent ()
 
virtual ~SimComponent ()
 
virtual void loadUpdaters (UpdaterServices *loader)
 Loads the parameters and component updater onto the updater manager. More...
 
virtual void set_paramset (ParamSet *paramset)
 Sets the ParamSet member. More...
 
virtual void set_paramsetFromCopy (const ParamSet &PSet)
 Reset the set of parameters from a another set. More...
 
virtual ParamSetget_paramset ()
 ParamSet accessor. More...
 
virtual void add_parameter (Param *param)
 Interface to add a parameter to the set. More...
 
virtual void add_parameter (std::string Name, param_t Type, bool isRequired, bool isBounded, double low_bnd, double up_bnd)
 Interface to add a parameter to the set. More...
 
virtual void add_parameter (std::string Name, param_t Type, bool isRequired, bool isBounded, double low_bnd, double up_bnd, ParamUpdaterBase *updater)
 Interface to add a parameter and its updater to the set. More...
 
virtual Paramget_parameter (std::string name)
 Param getter. More...
 
virtual double get_parameter_value (std::string name)
 Param value getter. More...
 
virtual string get_name ()
 Returnd the name of the ParamSet, i.e. More...
 
virtual bool has_parameter (std::string name)
 Param getter. More...
 
- Public Member Functions inherited from LCE_Disperse_base
 LCE_Disperse_base ()
 
virtual ~LCE_Disperse_base ()
 Deallocates the disp matrix. More...
 
bool setBaseParameters (string prefix)
 
void setParamPrefix (string pref)
 
void addParameters (string prefix, ParamUpdaterBase *updater)
 
void setIndentityDispMatrix (TMatrix *mat)
 
unsigned int getMigrationPatchForward (sex_t SEX, unsigned int LocalPatch)
 
unsigned int getMigrationPatchBackward (sex_t SEX, unsigned int LocalPatch)
 
unsigned int getMigrationIndex (vector< double > &rates)
 
unsigned int getMigrationIndexGSLdiscrete (gsl_ran_discrete_t *rates)
 
void setPropaguleTargets ()
 
void swapPostDisp ()
 
void reset_counters ()
 
void set_isForward (bool val)
 
bool checkForwardDispersalMatrix (TMatrix *mat)
 
bool checkBackwardDispersalMatrix (TMatrix *mat)
 
void allocateDispMatrix (sex_t sex, unsigned int dim)
 
bool updateDispMatrix ()
 
bool setDispMatrix ()
 
bool setReducedMatricesBySex (sex_t SEX, Param &connectivity, Param &rate)
 
bool setReducedDispMatrix ()
 The reduced dispersal matrix contains the indices of the patches to which each patch is connected. More...
 
bool setIsland_MigrantPool_Matrix ()
 
bool setIsland_PropagulePool_Matrix ()
 
bool setSteppingStone1DMatrix ()
 
bool setLatticeMatrix ()
 Sets the dispersal matrices for the Lattice dispersal model. More...
 
bool setBasicLatticeMatrix (int rows, int cols, double phi_mal, double phi_fem, double disp_mal, double disp_fem)
 
bool setLatticeTorrusMatrix (int rows, int cols, double disp_mal, double disp_fem, TMatrix *grid)
 
bool setLatticeAbsorbingMatrix ()
 
bool setLatticeReflectingMatrix (int rows, int cols, TMatrix *grid)
 
bool isForward ()
 
bool isByNumber ()
 
unsigned int getDispersalModel ()
 
double getPropaguleProb ()
 
unsigned int getPropaguleTarget (unsigned int home)
 
vector< double > getConnectedPatches (sex_t SEX, unsigned int local_patch)
 
vector< double > getConnectedRates (sex_t SEX, unsigned int local_patch)
 
double getReducedDispersalRate (sex_t SEX, unsigned int row, unsigned int col)
 
unsigned int getReducedDispersalPatchID (sex_t SEX, unsigned int row, unsigned int col)
 

Protected Attributes

TMatrix _num_colonizers
 Maximum size of a patch after colonisation. More...
 
sex_t _dispersing_sex
 Which part of the population is dispersing its gametes. More...
 
Individual *(LCE_Breed_Disperse::* _make_offspring )(sex_t SEX, Patch *patch, unsigned int LocalPatch, gsl_ran_discrete_t *rate_fem, gsl_ran_discrete_t *rate_mal)
 
unsigned int(LCE_Breed_Disperse::* _get_numFemOffspring )(Patch *patch)
 
unsigned int(LCE_Breed_Disperse::* _get_numMalOffspring )(Patch *patch)
 
unsigned int(LCE_Breed_Disperse::* _get_patchFecundity )(Patch *patch, sex_t SEX)
 
- Protected Attributes inherited from LCE_Breed_base
TMatrix _mean_fecundity
 
Individual *(LCE_Breed_base::* MatingFuncPtr )(Patch *, Individual *, unsigned int)
 
Individual *(LCE_Breed_base::* DoBreedFuncPtr )(Individual *mother, Individual *father, unsigned int LocalPatch)
 
double(LCE_Breed_base::* FecundityFuncPtr )(double mean)
 
bool(LCE_Breed_base::* CheckMatingConditionFuncPtr )(Patch *thePatch)
 
sex_t(LCE_Breed_base::* GetOffsprgSex )()
 
void(LCE_Breed_base::* PopModelFuncPtr )(void)
 
- Protected Attributes inherited from LifeCycleEvent
std::string _event_name
 The param name to be read in the init file. More...
 
Metapop_popPtr
 The ptr to the current Metapop. More...
 
std::string _LCELinkedTraitType
 The name of the linked trait. More...
 
int _LCELinkedTraitIndex
 The index in the individual's trait table of the linked trait. More...
 
- Protected Attributes inherited from SimComponent
ParamSet_paramSet
 The parameters container. More...
 
- Protected Attributes inherited from LCE_Disperse_base
unsigned int _npatch
 Number of patches in the population. More...
 
vector< vector< double > > _reducedDispMat [2]
 Matrix containing the indexes of the patches connected to each patch. More...
 
vector< vector< double > > _reducedDispMatProba [2]
 Matrix containing the probability to migrate to/from the connected patches. More...
 

Private Attributes

void(LCE_Breed_Disperse::* _breed_disperse )()
 
TMatrix _growthRates
 Patch-specific growth rates. More...
 
TMatrix _N_at_T0
 Recorder of original patch sizes used to compute future sizes depending on growth rate model. More...
 
unsigned int _T0_exp_growth
 Starting time of the growing phase, can be reset by a parameter update. More...
 

Detailed Description

Performs breeding and migration in one, migration rates are backward rates.

Inherits parameters from LCE_Breed_base and LCE_Disperse_base. Population size is constant, There is no demographic stochasticity with this LCE. The number of colonizers of extinct patches can be set differently from the patch carrying capacities.

Constructor & Destructor Documentation

◆ LCE_Breed_Disperse()

LCE_Breed_Disperse::LCE_Breed_Disperse ( )
44  : LifeCycleEvent("breed_disperse",""),_breed_disperse(0), _T0_exp_growth(0),
46 {
48 
49  LCE_Disperse_base::addParameters("breed_disperse", updater);
50 
51  add_parameter("breed_disperse_dispersing_sex", STR, false, false, 0, 0, updater);
52  add_parameter("breed_disperse_colonizers", INT,false,false,0,0, updater);
53  add_parameter("breed_disperse_growth_model", INT, false, true, 1, 8, updater);
54  add_parameter("breed_disperse_growth_rate", DBL, false, false, 0, 0, updater);
55 }
unsigned int(LCE_Breed_Disperse::* _get_numMalOffspring)(Patch *patch)
Definition: LCEcomposite.h:73
sex_t _dispersing_sex
Which part of the population is dispersing its gametes.
Definition: LCEcomposite.h:68
unsigned int(LCE_Breed_Disperse::* _get_patchFecundity)(Patch *patch, sex_t SEX)
Definition: LCEcomposite.h:74
void(LCE_Breed_Disperse::* _breed_disperse)()
Definition: LCEcomposite.h:50
Individual *(LCE_Breed_Disperse::* _make_offspring)(sex_t SEX, Patch *patch, unsigned int LocalPatch, gsl_ran_discrete_t *rate_fem, gsl_ran_discrete_t *rate_mal)
Definition: LCEcomposite.h:70
virtual bool setParameters()
Definition: LCEcomposite.cc:59
unsigned int _T0_exp_growth
Starting time of the growing phase, can be reset by a parameter update.
Definition: LCEcomposite.h:60
unsigned int(LCE_Breed_Disperse::* _get_numFemOffspring)(Patch *patch)
Definition: LCEcomposite.h:72
void addParameters(string prefix, ParamUpdaterBase *updater)
Definition: LCEdisperse.cc:61
LifeCycleEvent(const char *name, const char *trait_link)
Cstor.
Definition: lifecycleevent.h:97
Implementation of the ParamUpdaterBase interface.
Definition: param.h:372
virtual void add_parameter(Param *param)
Interface to add a parameter to the set.
Definition: simcomponent.h:111
@ FEM
Definition: types.h:36
@ DBL
Definition: types.h:77
@ STR
Definition: types.h:77
@ INT
Definition: types.h:77

References SimComponent::add_parameter(), LCE_Disperse_base::addParameters(), DBL, INT, setParameters(), and STR.

Referenced by clone().

+ Here is the caller graph for this function:

◆ ~LCE_Breed_Disperse()

virtual LCE_Breed_Disperse::~LCE_Breed_Disperse ( )
inlinevirtual
80 {}

Member Function Documentation

◆ addAgeClass()

virtual age_t LCE_Breed_Disperse::addAgeClass ( )
inlinevirtual

Reimplemented from LCE_Disperse_base.

Reimplemented in LCE_Breed_Selection_Disperse.

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

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

◆ clone()

virtual LifeCycleEvent* LCE_Breed_Disperse::clone ( )
inlinevirtual

Implements LifeCycleEvent.

Reimplemented in LCE_Breed_Selection_Disperse.

226 {return new LCE_Breed_Disperse();}
LCE_Breed_Disperse()
Definition: LCEcomposite.cc:44

References LCE_Breed_Disperse().

◆ conditionalLogisticGrowth()

unsigned int LCE_Breed_Disperse::conditionalLogisticGrowth ( Patch patch,
sex_t  SEX 
)
inline

The number of offspring produced depends on the adult density.

A minimum number of offspring is produced when less than half of the carrying capacity of adults is present. It is logistic otherwise.

165  {
166  if (patch->size(SEX, ADLTx) < patch->get_K(SEX)/2) {
167  return fixedFecundityGrowth(patch, SEX);
168  } else {
169  return logisticGrowth(patch, SEX);
170  }
171  }
unsigned int fixedFecundityGrowth(Patch *patch, sex_t SEX)
The number of offspring produced is equal to the current number of breeders multiplied by the mean fe...
Definition: LCEcomposite.h:184
unsigned int logisticGrowth(Patch *patch, sex_t SEX)
The number of offspring produced is given by the logistic growth function.
Definition: LCEcomposite.h:147
unsigned int get_K()
Definition: metapop.h:481
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
@ ADLTx
Definition: types.h:41

References ADLTx, fixedFecundityGrowth(), Patch::get_K(), logisticGrowth(), and Patch::size().

Referenced by setParameters().

+ Here is the caller graph for this function:

◆ conditionalStochasticLogisticGrowth()

unsigned int LCE_Breed_Disperse::conditionalStochasticLogisticGrowth ( Patch patch,
sex_t  SEX 
)
inline

The number of offspring produced depends on the adult density, similar to 'conditionalLogisticGrowth' except that this time, the fecundities are drawn from Poisson distributions.

175  {
176  if (patch->size(SEX, ADLTx) < patch->get_K(SEX)/2) {
177  return stochasticFecundityGrowth(patch, SEX);
178  } else {
179  return stochasticLogisticGrowth(patch, SEX);
180  }
181  }
unsigned int stochasticFecundityGrowth(Patch *patch, sex_t SEX)
The number of offspring produced is a random number drawn from a Poisson distribution with mean equal...
Definition: LCEcomposite.h:190
unsigned int stochasticLogisticGrowth(Patch *patch, sex_t SEX)
The number of offspring produced is drawn from a Poisson with mean equal to the logistic growth predi...
Definition: LCEcomposite.h:158

References ADLTx, Patch::get_K(), Patch::size(), stochasticFecundityGrowth(), and stochasticLogisticGrowth().

Referenced by setParameters().

+ Here is the caller graph for this function:

◆ do_breed_disperse()

void LCE_Breed_Disperse::do_breed_disperse ( )
277 {
278  Patch* patch;
279  unsigned int nfem, nmal;
280 
281 // cout << endl;
282 
283  for(unsigned int i = 0; i < _popPtr->getPatchNbr(); i++) {
284 
285  patch = _popPtr->getPatch(i);
286 
287  if(patch->size(OFFSx) != 0) patch->flush(OFFSx, _popPtr);
288 
289  nfem = (this->* _get_numFemOffspring)(patch);
290  nmal = (this->* _get_numMalOffspring)(patch);
291 
292 #ifdef _DEBUG_
293  cout << ">>> patch "<<i<<" (size="<<patch->size(ADULTS)<<") nfem = "<<nfem<<"; nmal = "<<nmal<<endl;
294 #endif
295  // we want the catch the cases with empty (extinct) patches to avoid hanging time
296  if(patch->size(FEM, ADLTx) == 0) {
297 
298  if(nfem) do_breed_disperse_in_empty_patch(FEM, patch, i, nfem);
299  if(nmal) do_breed_disperse_in_empty_patch(MAL, patch, i, nmal);
300 
301  } else if (patch->size(MAL, ADLTx) == 0 && this->getMatingSystem() == 1) {
302 
303  if(nfem) do_breed_disperse_in_empty_patch(FEM, patch, i, nfem);
304  if(nmal) do_breed_disperse_in_empty_patch(MAL, patch, i, nmal);
305 
306  } else {
307 
308  if(nfem) do_breed_disperse_in_patch(FEM, patch, i, nfem);
309  if(nmal) do_breed_disperse_in_patch(MAL, patch, i, nmal);
310 
311  }
312  }
313 }
void do_breed_disperse_in_empty_patch(sex_t SEX, Patch *patch, unsigned int ID, unsigned int num_offsprg)
Definition: LCEcomposite.cc:356
void do_breed_disperse_in_patch(sex_t SEX, Patch *patch, unsigned int ID, unsigned int num_offsprg)
Definition: LCEcomposite.cc:317
Metapop * _popPtr
The ptr to the current Metapop.
Definition: lifecycleevent.h:80
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 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
@ MAL
Definition: types.h:36
#define ADULTS
Adults age class flag (breeders).
Definition: types.h:53
@ OFFSx
Definition: types.h:41

References _get_numFemOffspring, _get_numMalOffspring, LifeCycleEvent::_popPtr, ADLTx, ADULTS, do_breed_disperse_in_empty_patch(), do_breed_disperse_in_patch(), FEM, Patch::flush(), Metapop::getPatch(), Metapop::getPatchNbr(), MAL, OFFSx, and Patch::size().

Referenced by do_breed_disperse_propagule(), and setParameters().

+ Here is the caller graph for this function:

◆ do_breed_disperse_in_empty_patch()

void LCE_Breed_Disperse::do_breed_disperse_in_empty_patch ( sex_t  SEX,
Patch patch,
unsigned int  ID,
unsigned int  num_offsprg 
)

"males" (dispersing sex matrix)

357 {
358  Individual* newind;
359 
360 // cout<<"---- do_breed_disperse_in_empty_patch ----\n";
361 //
362 // cout<<" ---- patch "<<ID<<" ----\n";
363  // check that the connected patches are not also empty
364  vector<double> disp_rate_connected_fem = LCE_Disperse_base::getConnectedRates(FEM, ID);
365  vector<double> disp_rate_connected_mal = LCE_Disperse_base::getConnectedRates(MAL, ID);
366 
367  // set local patch disp rate (philopatry) to zero, it is empty
368 // disp_rate_connected_fem[0] = 0;
369 // disp_rate_connected_mal[0] = 0;
370 
371  double disp_table_fem[disp_rate_connected_fem.size()];
372  double disp_table_mal[disp_rate_connected_mal.size()];
373 
374  unsigned int size, c_size_fem = 0;
375  vector< double > connected_patches = LCE_Disperse_base::getConnectedPatches(FEM, ID);
376 
377 // cout<<"\t - female dispersal:\n";
378  // copy vector into table, and count size of connected patches
379  for(unsigned int i = 0; i < disp_rate_connected_fem.size(); ++i){
380  size = _popPtr->size(FEM, ADLTx, (unsigned int)connected_patches[i]);
381  if( size )
382  disp_table_fem[i] = disp_rate_connected_fem[i];
383  else
384  disp_table_fem[i] = 0;
385 
386 // cout<<"\t > "<<(unsigned int)connected_patches[i]<<": "
387 // <<size<<" adlt female ("<<disp_table_fem[i]<<")"<<endl;
388 
389  c_size_fem += size;
390  }
391 
393  unsigned int c_size_mal = 0;
394 
395  // use the dispersal matrices for the dispersing sex
397 
398 // cout<<"\t - male dispersal:\n";
399  // the sex patch size to check depends on the mating system; male for random mating, fem otherwise
400  sex_t sex2check = (this->getMatingSystem() == 1 ? MAL : FEM);
401 
402  for(unsigned int i = 0; i < disp_rate_connected_mal.size(); ++i){
403  size = _popPtr->size(sex2check, ADLTx, (unsigned int)connected_patches[i]);
404 
405  if(size)
406  disp_table_mal[i] = disp_rate_connected_mal[i];
407  else
408  disp_table_mal[i] = 0;
409 
410 // cout<<"\t > "<<(unsigned int)connected_patches[i]<<": "
411 // <<size<<" adlt "<<(sex2check == MAL? "male" :"female")
412 // <<"("<<disp_table_mal[i]<<")"<<endl;
413 
414  c_size_mal += size;
415  }
416 
417 // cout<<"\t - size of connected patch; fem = "<<c_size_fem<<", mal = "<<c_size_mal<<endl;
418  // no reproduction can happen if all connected patches are empty as well
419  if( c_size_fem == 0 ) return;
420 
421  // check for the dispersing sex, which is male under random mating
422  if( c_size_mal == 0 ) return;
423 
424  // these allocations are costly but there isn't an easy workaround when the number of connected patches varies dynamically
425  gsl_ran_discrete_t* gsltable_fem = gsl_ran_discrete_preproc(disp_rate_connected_fem.size(), disp_table_fem);
426  gsl_ran_discrete_t* gsltable_mal = gsl_ran_discrete_preproc(disp_rate_connected_mal.size(), disp_table_mal);
427 
428 // cout<<"\t generating "<<num_offsprg<<" offspring: ";
429  for(unsigned int j = 0; j < num_offsprg; j++) {
430 
431  newind = (this->*_make_offspring)(SEX, patch, ID, gsltable_fem, gsltable_mal);
432 
433  // it is possible that a null pointer is returned when patches are extinct and no migration is possible
434  if(!newind) continue;
435 
436 // cout<<j+1<<" ";
437 
438  patch->add(SEX, OFFSx, LCE_Breed_base::makeOffspring( newind ));
439  patch->nbKolonisers++;
440 
441  }
442 
443 // cout<< "\n\t - num colonizers: "<<patch->nbKolonisers<<endl;
444 
445  gsl_ran_discrete_free(gsltable_fem);
446  gsl_ran_discrete_free(gsltable_mal);
447 }
This class contains traits along with other individual information (sex, pedigree,...
Definition: individual.h:48
int getMatingSystem()
Definition: LCEbreed.h:101
Individual * makeOffspring(Individual *ind)
Last step of the breeding process, does inheritance and mutation of the parents' genes.
Definition: LCEbreed.cc:350
vector< double > getConnectedPatches(sex_t SEX, unsigned int local_patch)
Definition: LCEdisperse.cc:1300
vector< double > getConnectedRates(sex_t SEX, unsigned int local_patch)
Definition: LCEdisperse.cc:1311
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
short nbKolonisers
Definition: metapop.h:454
sex_t
Sex types, males are always 0 and females 1!!
Definition: types.h:35

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

Referenced by do_breed_disperse().

+ Here is the caller graph for this function:

◆ do_breed_disperse_in_patch()

void LCE_Breed_Disperse::do_breed_disperse_in_patch ( sex_t  SEX,
Patch patch,
unsigned int  ID,
unsigned int  num_offsprg 
)
318 {
319  Individual* newind;
320 
321  vector<double> disp_rate_connected_fem = LCE_Disperse_base::getConnectedRates(FEM, ID);
322  vector<double> disp_rate_connected_mal = LCE_Disperse_base::getConnectedRates(MAL, ID);
323 
324  double disp_table_fem[disp_rate_connected_fem.size()];
325  double disp_table_mal[disp_rate_connected_mal.size()];
326 
327  for(unsigned int i = 0; i < disp_rate_connected_fem.size(); ++i){
328  disp_table_fem[i] = disp_rate_connected_fem[i];
329  }
330 
331  for(unsigned int i = 0; i < disp_rate_connected_mal.size(); ++i){
332  disp_table_mal[i] = disp_rate_connected_mal[i];
333  }
334 
335  gsl_ran_discrete_t* gsltable_fem = gsl_ran_discrete_preproc(disp_rate_connected_fem.size(), disp_table_fem);
336  gsl_ran_discrete_t* gsltable_mal = gsl_ran_discrete_preproc(disp_rate_connected_mal.size(), disp_table_mal);
337 
338 
339  for(unsigned int j = 0; j < num_offsprg; j++) {
340 
341  newind = (this->*_make_offspring)(SEX, patch, ID, gsltable_fem, gsltable_mal);
342 
343  // it is possible that a null pointer is returned when connected patches are extinct and no migration is possible
344  if(!newind) continue;
345 
346  patch->add(SEX, OFFSx, LCE_Breed_base::makeOffspring( newind ));
347 
348  }
349 
350  gsl_ran_discrete_free(gsltable_fem);
351  gsl_ran_discrete_free(gsltable_mal);
352 }

References _make_offspring, Patch::add(), FEM, LCE_Disperse_base::getConnectedRates(), LCE_Breed_base::makeOffspring(), MAL, and OFFSx.

Referenced by do_breed_disperse().

+ Here is the caller graph for this function:

◆ do_breed_disperse_propagule()

void LCE_Breed_Disperse::do_breed_disperse_propagule ( )
452 {
455 }
void do_breed_disperse()
Definition: LCEcomposite.cc:276
bool setIsland_PropagulePool_Matrix()
Definition: LCEdisperse.cc:580

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

Referenced by setParameters().

+ Here is the caller graph for this function:

◆ execute()

void LCE_Breed_Disperse::execute ( )
virtual

Implements LifeCycleEvent.

Reimplemented in LCE_Breed_Selection_Disperse.

245 {
246 #ifdef _DEBUG_
247  message("LCE_Breed_Disperse::execute (Patch nb: %i offsprg nb: %i adlt nb: %i "
249 #endif
250 
251  if(_npatch != _popPtr->getPatchNbr()) {
253  if(!updateDispMatrix()) fatal("bailing out\n");
254  }
255 
257 
258  (this->*_breed_disperse)();
259 
260  // swap parents and offspring in WF populations
262 
263 #ifdef _DEBUG_
264  unsigned int a = 0, b = 0, c = 0;
265  for(unsigned int i = 0; i < _popPtr->getPatchNbr(); i++){
266  a += _popPtr->getPatch(i)->nbEmigrant;
267  b += _popPtr->getPatch(i)->nbImigrant;
268  c += _popPtr->getPatch(i)->nbPhilopat;
269  }
270  message("immigrate: %f, emigrants: %i, imigrants: %i)\n",(double)b/(b+c), a, b);
271 #endif
272 }
void doAgingInWFpop()
Definition: LCEbreed.cc:547
void reset_counters()
Definition: LCEdisperse.cc:389
bool updateDispMatrix()
Definition: LCEdisperse.cc:364
unsigned int _npatch
Number of patches in the population.
Definition: LCEdisperse.h:63
unsigned short nbEmigrant
Definition: metapop.h:453
unsigned short nbPhilopat
Definition: metapop.h:453
unsigned short nbImigrant
Definition: metapop.h:453
void fatal(const char *str,...)
Definition: output.cc:99
void message(const char *message,...)
Definition: output.cc:39

References _breed_disperse, LCE_Disperse_base::_npatch, LifeCycleEvent::_popPtr, ADULTS, LCE_Breed_base::doAgingInWFpop(), fatal(), Metapop::getPatch(), Metapop::getPatchNbr(), LCE_Breed_base::isWrightFisher(), message(), Patch::nbEmigrant, Patch::nbImigrant, Patch::nbPhilopat, OFFSPRG, LCE_Disperse_base::reset_counters(), Metapop::size(), and LCE_Disperse_base::updateDispMatrix().

◆ exponentialGrowth()

unsigned int LCE_Breed_Disperse::exponentialGrowth ( Patch patch,
sex_t  SEX 
)

Exponential growth using current patch size as basis to calculate future sizes, set once the function is first called.

460 {
461 // static unsigned int t0 = 0;
462  unsigned int idx = patch->getID();
463  unsigned int cGen = _popPtr->getCurrentGeneration();
464  unsigned int nGen;
465  unsigned int N;
466 
467 // if(t0 == 0) { //mark starting generation of growth model, when first call (in first patch)
468 // t0 = cGen; //cGen can be zero
469 // }
470 
471  if(_T0_exp_growth == cGen) { // that means we have just (re)set t0
472  _N_at_T0.set(0, idx, patch->size(SEX, ADULTS)); //record initial patch size
473  }
474 
475  // patch grows until K; a growth rate of 0 is interpreted as exponential growth is off
476  if(patch->size(SEX, ADULTS) < patch->get_K(SEX) && _growthRates.get(0,idx) != 0) {
477 
478  nGen = cGen - _T0_exp_growth + 1; //we're calculating the size at time = t+1
479 
480  N = _N_at_T0.get(0, idx)*exp(_growthRates.get(0,idx)*nGen);
481 
482  } else {
483  N = patch->get_K(SEX);
484  }
485 
486  return N;
487 }
TMatrix _growthRates
Patch-specific growth rates.
Definition: LCEcomposite.h:54
TMatrix _N_at_T0
Recorder of original patch sizes used to compute future sizes depending on growth rate model.
Definition: LCEcomposite.h:58
unsigned int getCurrentGeneration()
Definition: metapop.h:295
unsigned int getID()
Definition: metapop.h:480
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
double get(unsigned int i, unsigned int j) const
Accessor to element at row i and column j.
Definition: tmatrix.h:192

References _growthRates, _N_at_T0, LifeCycleEvent::_popPtr, _T0_exp_growth, ADULTS, TMatrix::get(), Patch::get_K(), Metapop::getCurrentGeneration(), Patch::getID(), TMatrix::set(), and Patch::size().

Referenced by setParameters().

+ Here is the caller graph for this function:

◆ fixedFecundityGrowth()

unsigned int LCE_Breed_Disperse::fixedFecundityGrowth ( Patch patch,
sex_t  SEX 
)
inline

The number of offspring produced is equal to the current number of breeders multiplied by the mean fecundity of the focal patch.

185  {
186  return patch->size(SEX,ADULTS)*LCE_Breed_base::getMeanFecundity(patch->getID());
187  }
double getMeanFecundity(unsigned int patch)
Definition: LCEbreed.h:100

References ADULTS, Patch::getID(), LCE_Breed_base::getMeanFecundity(), and Patch::size().

Referenced by conditionalLogisticGrowth(), and setParameters().

+ Here is the caller graph for this function:

◆ get_parent()

Individual * LCE_Breed_Disperse::get_parent ( sex_t  SEX,
sex_t  DispSex,
Patch LocalPatch,
unsigned int  patchID,
gsl_ran_discrete_t *  rates 
)
571 {
572  unsigned int SourcePatch = 0;
573  Patch* src_patch;
574 
575  //first check if individuals are available in other patches:
576  if(local_patch->size(SEX, ADLTx) == _popPtr->size(SEX, ADLTx)) {
577 
578  //other patches are empty, force philopatry:
579  SourcePatch = LocalPatch;
580  src_patch = local_patch;
581 
582  } else {
583 
584  // find immigrants from the connected patches
585 
586  unsigned int index;
587 
588  do {
589 
590  index = getMigrationIndexGSLdiscrete(rates);
591 
592  SourcePatch = LCE_Disperse_base::getReducedDispersalPatchID(DispSex, LocalPatch, index);
593 
594  src_patch = _popPtr->getPatchPtr(SourcePatch); // checked version of getPatch, safe to use if SourcePatch if outside range
595 
596  } while (src_patch->size( SEX, ADLTx ) == 0);
597 
598  }
599 
600  //set migrant counters for the stats
601  if(LocalPatch != SourcePatch) {
602  src_patch->nbEmigrant++;
603 
604  if( local_patch->size(ADLTx) != 0 ) // only count immigrants, not colonizers
605  local_patch->nbImigrant++;
606 
607  } else
608  src_patch->nbPhilopat++;
609 
610  //return a pointer to an individual randomly chosen from the source patch:
611  return src_patch->get(SEX, ADLTx, RAND::Uniform( src_patch->size( SEX, ADLTx ) ) );
612 }
unsigned int getReducedDispersalPatchID(sex_t SEX, unsigned int row, unsigned int col)
Definition: LCEdisperse.cc:1332
unsigned int getMigrationIndexGSLdiscrete(gsl_ran_discrete_t *rates)
Definition: LCEdisperse.cc:1293
Patch * getPatchPtr(unsigned int patch)
A secure version of the getPatch() method.
Definition: metapop.h:259
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
static double Uniform()
Generates a random number from [0.0, 1.0[ uniformly distributed.
Definition: Uniform.h:126

References LifeCycleEvent::_popPtr, ADLTx, Patch::get(), LCE_Disperse_base::getMigrationIndexGSLdiscrete(), Metapop::getPatchPtr(), LCE_Disperse_base::getReducedDispersalPatchID(), Patch::nbEmigrant, Patch::nbImigrant, Patch::nbPhilopat, Metapop::size(), Patch::size(), and RAND::Uniform().

Referenced by mate_cloning(), mate_full_selfing(), mate_random(), mate_random_hermaphrodite(), and mate_selfing().

+ Here is the caller graph for this function:

◆ instantGrowth()

unsigned int LCE_Breed_Disperse::instantGrowth ( Patch patch,
sex_t  SEX 
)
inline

The number of offspring produced corresponds to the carrying capacity of the patch.

143  {
144  return patch->get_K(SEX);
145  }

References Patch::get_K().

Referenced by setParameters().

+ Here is the caller graph for this function:

◆ loadFileServices()

virtual void LCE_Breed_Disperse::loadFileServices ( FileServices loader)
inlinevirtual

Reimplemented from LCE_Disperse_base.

Reimplemented in LCE_Breed_Selection_Disperse.

227 {}

◆ loadStatServices()

virtual void LCE_Breed_Disperse::loadStatServices ( StatServices loader)
inlinevirtual

Reimplemented from LCE_Disperse_base.

Reimplemented in LCE_Breed_Selection_Disperse.

228 {}

◆ logisticGrowth()

unsigned int LCE_Breed_Disperse::logisticGrowth ( Patch patch,
sex_t  SEX 
)
inline

The number of offspring produced is given by the logistic growth function.

148  {
149  double K = (double)patch->get_K(SEX);
150  double r = _growthRates.get(0, patch->getID());
151  double N = (double)patch->size(ADLTx);
152  if( K <= N )
153  return K;
154  else
155  return (unsigned int)ceil(N + r*N*((K-N)/K));
156  }

References _growthRates, ADLTx, TMatrix::get(), Patch::get_K(), Patch::getID(), and Patch::size().

Referenced by conditionalLogisticGrowth(), setParameters(), and stochasticLogisticGrowth().

+ Here is the caller graph for this function:

◆ makeOffspring()

Individual* LCE_Breed_Disperse::makeOffspring ( Individual ind)

◆ mate_cloning()

Individual * LCE_Breed_Disperse::mate_cloning ( sex_t  SEX,
Patch patch,
unsigned int  LocalPatch,
gsl_ran_discrete_t *  rate_fem,
gsl_ran_discrete_t *  rate_mal 
)
559 {
560  Individual *mom = get_parent(FEM, FEM, patch, LocalPatch, rate_fem);
561 
562  if(!mom) return NULL;
563 
564  return LCE_Breed_base::breed_cloning(mom, mom, LocalPatch);
565 }
Individual * get_parent(sex_t SEX, sex_t DispSex, Patch *LocalPatch, unsigned int patchID, gsl_ran_discrete_t *rates)
Definition: LCEcomposite.cc:569
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

References LCE_Breed_base::breed_cloning(), FEM, and get_parent().

Referenced by setParameters().

+ Here is the caller graph for this function:

◆ mate_full_selfing()

Individual * LCE_Breed_Disperse::mate_full_selfing ( sex_t  SEX,
Patch patch,
unsigned int  LocalPatch,
gsl_ran_discrete_t *  rate_fem,
gsl_ran_discrete_t *  rate_mal 
)
547 {
548  Individual *mom = get_parent(FEM, FEM, patch, LocalPatch, rate_fem);
549 
550  if(!mom) return NULL;
551 
552  return _popPtr->makeNewIndividual(mom, mom, FEM, LocalPatch);
553 }
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

References LifeCycleEvent::_popPtr, FEM, get_parent(), and IndFactory::makeNewIndividual().

Referenced by setParameters().

+ Here is the caller graph for this function:

◆ mate_random()

Individual * LCE_Breed_Disperse::mate_random ( sex_t  SEX,
Patch patch,
unsigned int  LocalPatch,
gsl_ran_discrete_t *  rate_fem,
gsl_ran_discrete_t *  rate_mal 
)
493 {
494  Individual* p1 = get_parent(FEM, FEM, patch, LocalPatch, rate_fem);
495  Individual* p2 = get_parent(MAL, MAL, patch, LocalPatch, rate_mal);
496 
497  if(! (p1 && p2)) return NULL;
498 
499  return _popPtr->makeNewIndividual(p1, p2, SEX, LocalPatch);
500 }

References LifeCycleEvent::_popPtr, FEM, get_parent(), IndFactory::makeNewIndividual(), and MAL.

Referenced by setParameters().

+ Here is the caller graph for this function:

◆ mate_random_hermaphrodite()

Individual * LCE_Breed_Disperse::mate_random_hermaphrodite ( sex_t  SEX,
Patch patch,
unsigned int  LocalPatch,
gsl_ran_discrete_t *  rate_fem,
gsl_ran_discrete_t *  rate_mal 
)
506 {
507  Individual* p1 = get_parent(FEM, FEM, patch, LocalPatch, rate_fem);
508  Individual* p2 = get_parent(FEM, _dispersing_sex, patch, LocalPatch,
509  (_dispersing_sex == MAL ? rate_mal : rate_fem));
510 
511  if(! (p1 && p2)) return NULL;
512 
513  return _popPtr->makeNewIndividual(p1, p2, FEM, LocalPatch);
514 }

References _dispersing_sex, LifeCycleEvent::_popPtr, FEM, get_parent(), IndFactory::makeNewIndividual(), and MAL.

Referenced by setParameters().

+ Here is the caller graph for this function:

◆ mate_selfing()

Individual * LCE_Breed_Disperse::mate_selfing ( sex_t  SEX,
Patch patch,
unsigned int  LocalPatch,
gsl_ran_discrete_t *  rate_fem,
gsl_ran_discrete_t *  rate_mal 
)
520 {
521  Individual *mom, *dad;
522  // cout << "--- choosing mum in patch "<<LocalPatch<<" ("<<patch->size(FEM, ADLTx)<<")\n";
523  mom = get_parent(FEM, FEM, patch, LocalPatch, rate_fem);
524 
525  // cout << "--- choosing dad \n";
526 
527  if( RAND::Uniform() > this->getMatingProportion() ) {
528  //random mating
529  do{
530  dad = get_parent(FEM, _dispersing_sex, patch, LocalPatch,
531  (_dispersing_sex == MAL ? rate_mal : rate_fem));
532  }while(dad == mom && _popPtr->getPatchNbr() != 1 && patch->size(FEM, ADLTx) > 1);
533  } else
534  dad = mom;
535 
536  // cout << "--- make offspring by crossing "<<mom->getID()<<" with "<<dad->getID()<<endl;
537 
538  if(! (mom && dad)) return NULL;
539 
540  return _popPtr->makeNewIndividual(mom, dad, FEM, LocalPatch);
541 }
double getMatingProportion()
Definition: LCEbreed.h:99

References _dispersing_sex, LifeCycleEvent::_popPtr, ADLTx, FEM, get_parent(), LCE_Breed_base::getMatingProportion(), Metapop::getPatchNbr(), IndFactory::makeNewIndividual(), MAL, Patch::size(), and RAND::Uniform().

Referenced by setParameters().

+ Here is the caller graph for this function:

◆ numFemOffspring()

unsigned int LCE_Breed_Disperse::numFemOffspring ( Patch patch)
inline
89  {
90 // if (patch->size(FEM, ADLTx) == 0 && _dispersing_sex != FEM)//to avoid choosing a local female when there is none
91 // return 0;
92 // else
93  return (this->*_get_patchFecundity)(patch, FEM);
94  }

References _get_patchFecundity, and FEM.

Referenced by setParameters().

+ Here is the caller graph for this function:

◆ numFemOffspring_colonizers()

unsigned int LCE_Breed_Disperse::numFemOffspring_colonizers ( Patch patch)
inline

The number of females produced in case a max number of colonizers was specified.

98  {
99  if(patch->isEmpty()) {
100 // //check if only one sex sends gametes around, capturing the case of pollen dispersal
101 // if(_dispersing_sex != FEM)
102 // return 0;
103 // else
104 
105  return _num_colonizers.get(1, patch->getID()); // Females on second row
106 
107  } else
108  return (this->*_get_patchFecundity)(patch, FEM);
109  }
TMatrix _num_colonizers
Maximum size of a patch after colonisation.
Definition: LCEcomposite.h:65
bool isEmpty()
Definition: metapop.h:487

References _get_patchFecundity, _num_colonizers, FEM, TMatrix::get(), Patch::getID(), and Patch::isEmpty().

Referenced by setParameters().

+ Here is the caller graph for this function:

◆ numMalOffspring_notrandom()

unsigned int LCE_Breed_Disperse::numMalOffspring_notrandom ( Patch patch)
inline

The number of males produced is always zero when the mating system is not random mating.

113  {
114  return 0;
115  }

Referenced by setParameters().

+ Here is the caller graph for this function:

◆ numMalOffspring_random()

unsigned int LCE_Breed_Disperse::numMalOffspring_random ( Patch patch)
inline
118  { //return 0 if only males gametes migrate and there is no females in the patch
119  //to avoid choosing a local female when there is none
120  //(we assume it doesn't make sense to have only female gametes migrating)
121 // if (patch->size(FEM, ADLTx) == 0 && _dispersing_sex != FEM)
122 // return 0;
123 // else
124  return (this->*_get_patchFecundity)(patch, MAL);
125  }

References _get_patchFecundity, and MAL.

Referenced by setParameters().

+ Here is the caller graph for this function:

◆ numMalOffspring_random_colonizers()

unsigned int LCE_Breed_Disperse::numMalOffspring_random_colonizers ( Patch patch)
inline
128  {
129  if(patch->isEmpty()) {
130 // //check if only one sex sends gametes around, capturing the case of pollen dispersal
131 // if(_dispersing_sex != FEM)
132 // return 0;
133 // else
134  return _num_colonizers.get(0, patch->getID()); // Males on first row
135  } else
136  return (this->*_get_patchFecundity)(patch, MAL);
137  }

References _get_patchFecundity, _num_colonizers, TMatrix::get(), Patch::getID(), Patch::isEmpty(), and MAL.

Referenced by setParameters().

+ Here is the caller graph for this function:

◆ removeAgeClass()

virtual age_t LCE_Breed_Disperse::removeAgeClass ( )
inlinevirtual

Reimplemented from LCE_Disperse_base.

Reimplemented in LCE_Breed_Selection_Disperse.

230 {return NONE;}

References NONE.

◆ requiredAgeClass()

virtual age_t LCE_Breed_Disperse::requiredAgeClass ( )
inlinevirtual

Reimplemented from LCE_Disperse_base.

Reimplemented in LCE_Breed_Selection_Disperse.

232 {return ADULTS;}

References ADULTS.

◆ resetParameterFromSource()

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

Reimplemented from LCE_Disperse_base.

Reimplemented in LCE_Breed_Selection_Disperse.

229 {return false;}

◆ setParameters()

bool LCE_Breed_Disperse::setParameters ( )
virtual

Reimplemented from LCE_Breed_base.

Reimplemented in LCE_Breed_Selection_Disperse.

60 {
61  if(!LCE_Breed_base::setParameters()) return false;
62 
64 
65  if(!LCE_Disperse_base::setBaseParameters("breed_disperse")) return false;
66 
67  if(get_parameter("breed_disperse_colonizers")->isSet()) {
68  if(get_parameter("breed_disperse_colonizers")->isMatrix()) {
69 
70  TMatrix tmp;
71 
72  get_parameter("breed_disperse_colonizers")->getMatrix(&tmp);
73 
74  if(tmp.nrows() > 2)
75  return error("breed_disperse_colonizers::matrix should have at most two rows, one for each sex\n");
76 
77  if(tmp.ncols() > _npatch)
78  return error("breed_disperse_colonizers::matrix or array can have at most as many columns (elements) as the number of patches\n");
79 
80  // always fill a 2 x num_patch matrix, even if only one sex
81  // (see numFemOffspring_colonizers())
83 
85 
86  } else {
87  // not a matrix, copy single value to default 2 x num patch matrix
88  _num_colonizers.reset(2, _npatch, get_parameter_value("breed_disperse_colonizers"));
89 
90  }
91 
92  } else {
94 
95  }
96  //some default settings, reset below depending on mating system
101 
102  if(get_parameter("breed_disperse_dispersing_sex")->isSet()) {
103 
104  if (get_parameter("breed_disperse_dispersing_sex")->getArg() == "female") {
106  } else if (get_parameter("breed_disperse_dispersing_sex")->getArg() == "male") {
108  } else {
109  error("the \"breed_disperse_dispersing_sex\" parameter only takes \"female\" or \"male\" as argument\n");
110  }
111 
112  } else { //default depends on mating system
113  // males are the dispersing sex for random mating, female dispersal is always checked, male dispersal is optional
114  if(this->getMatingSystem() == 1)
116  else // all others use females only, since monogamy and polygyny are not allowed here
118  }
119 
120  //check mating system:
121  unsigned int model = this->getMatingSystem();
122 
123  if(model == 2 || model == 3) {
124 
125  return error("Polygyny and Monogamy are not implemented within the breed_disperse LCE.\n");
126 
127  } else if(model == 1) { //promiscuity/random mating
128 
130 
134 
135  } else if(model == 4) { //selfing
136 
137  if(this->getMatingProportion() != 1)
139  else
141 
142  } else if(model == 5) { //cloning
143 
145 
146  } else if(model == 6) { //random mating among hermaphrodites (selfing = 1/N)
147 
149 
150  }
151 
152  //check dispersal model:
153  model = this->getDispersalModel();
154 
155  if(model == 2) //propagule-pool island model
157  else
159 
160  //growth model
161  if(_paramSet->isSet("breed_disperse_growth_model"))
162  model = get_parameter_value("breed_disperse_growth_model");
163  else
164  model = 1;
165 
166  switch (model) {
167  case 1:
169  break;
170  case 2:
172  break;
173  case 3:
175  break;
176  case 4:
178  break;
179  case 5:
181  break;
182  case 6:
184  break;
185  case 7:
187  break;
188  case 8:
190  break;
191  default:
193  break;
194  }
195  //mean fecundity
196  if(_mean_fecundity.get(0,0) == -1) //wasn't set
197  if(model > 3 && model < 8) //4 - 7: conditional logistic growth, fecundity growth
198  return error("parameter \"mean_fecundity\" is needed with growth models 4 to 7 in LCE breed_disperse\n");
199 
200  //growth rate ---------------------------------------------------------------
201 
203 
204  if ((model > 1 && model < 6) || model == 8) {
205 
206  if(!_paramSet->isSet("breed_disperse_growth_rate")) {
207 
208  return error("parameter \"breed_disperse_growth_rate\" needs to be set\n");
209 
210  }
211 
213 
214  if(_paramSet->isMatrix("breed_disperse_growth_rate")) {
215 
216  TMatrix tmp;
217 
218  _paramSet->getMatrix("breed_disperse_growth_rate", &tmp);
219 
220  if(tmp.ncols() > _popPtr->getPatchNbr()){
221  return error("breed_disperse_growth_rate::number of elements in array must be < or = to the number of patches.\n");
222  }
223 
225 
226  } else { //not a matrix
227 
228  _growthRates.set_row(0, get_parameter_value("breed_disperse_growth_rate"));
229 
230  }
231 
232  if(model == 8) { //exponential growth
233  // reset counters
236  }
237  }
238 
239  return true;
240 }
Individual * mate_cloning(sex_t SEX, Patch *patch, unsigned int LocalPatch, gsl_ran_discrete_t *rate_fem, gsl_ran_discrete_t *rate_mal)
Definition: LCEcomposite.cc:557
unsigned int conditionalLogisticGrowth(Patch *patch, sex_t SEX)
The number of offspring produced depends on the adult density.
Definition: LCEcomposite.h:164
unsigned int numMalOffspring_random_colonizers(Patch *patch)
Definition: LCEcomposite.h:127
Individual * mate_full_selfing(sex_t SEX, Patch *patch, unsigned int LocalPatch, gsl_ran_discrete_t *rate_fem, gsl_ran_discrete_t *rate_mal)
Definition: LCEcomposite.cc:545
unsigned int exponentialGrowth(Patch *patch, sex_t SEX)
Exponential growth using current patch size as basis to calculate future sizes, set once the function...
Definition: LCEcomposite.cc:459
unsigned int numMalOffspring_notrandom(Patch *patch)
The number of males produced is always zero when the mating system is not random mating.
Definition: LCEcomposite.h:112
Individual * mate_selfing(sex_t SEX, Patch *patch, unsigned int LocalPatch, gsl_ran_discrete_t *rate_fem, gsl_ran_discrete_t *rate_mal)
Definition: LCEcomposite.cc:518
unsigned int conditionalStochasticLogisticGrowth(Patch *patch, sex_t SEX)
The number of offspring produced depends on the adult density, similar to 'conditionalLogisticGrowth'...
Definition: LCEcomposite.h:174
Individual * mate_random_hermaphrodite(sex_t SEX, Patch *patch, unsigned int LocalPatch, gsl_ran_discrete_t *rate_fem, gsl_ran_discrete_t *rate_mal)
Definition: LCEcomposite.cc:504
unsigned int numFemOffspring(Patch *patch)
Definition: LCEcomposite.h:88
unsigned int numFemOffspring_colonizers(Patch *patch)
The number of females produced in case a max number of colonizers was specified.
Definition: LCEcomposite.h:97
unsigned int numMalOffspring_random(Patch *patch)
Definition: LCEcomposite.h:117
Individual * mate_random(sex_t SEX, Patch *patch, unsigned int LocalPatch, gsl_ran_discrete_t *rate_fem, gsl_ran_discrete_t *rate_mal)
Definition: LCEcomposite.cc:491
unsigned int instantGrowth(Patch *patch, sex_t SEX)
The number of offspring produced corresponds to the carrying capacity of the patch.
Definition: LCEcomposite.h:142
void do_breed_disperse_propagule()
Definition: LCEcomposite.cc:451
TMatrix _mean_fecundity
Definition: LCEbreed.h:67
virtual bool setParameters()
Definition: LCEbreed.cc:76
bool setBaseParameters(string prefix)
Definition: LCEdisperse.cc:87
void set_isForward(bool val)
Definition: LCEdisperse.h:84
unsigned int getDispersalModel()
Definition: LCEdisperse.h:114
void getMatrix(string name, TMatrix *mat)
Accessor to the parameters matrix.
Definition: param.h:313
bool isMatrix(string name)
Check if the parameter "name" is of matrix type.
Definition: param.h:305
bool isSet()
Accessor to the status flag.
Definition: param.h:297
string getArg()
Definition: param.h:143
void getMatrix(TMatrix *mat)
Sets the matrix from the argument string if the parameter is set and of matrix type.
Definition: param.cc:397
bool isSet()
Definition: param.h:147
virtual double get_parameter_value(std::string name)
Param value getter.
Definition: simcomponent.h:142
virtual Param * get_parameter(std::string name)
Param getter.
Definition: simcomponent.h:138
ParamSet * _paramSet
The parameters container.
Definition: simcomponent.h:47
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_row(unsigned int i, double val)
Sets all elements at row i to value val.
Definition: tmatrix.h:110
unsigned int ncols() const
Definition: tmatrix.h:215
void copy_recycle(const TMatrix &mat)
Copy elements of 'mat', recycling elements of 'mat' if its size is smaller than current matrix.
Definition: tmatrix.h:89
unsigned int length() const
Returns the number of elements in the matrix.
Definition: tmatrix.h:217
unsigned int nrows() const
Definition: tmatrix.h:212
int error(const char *str,...)
Definition: output.cc:78

References _breed_disperse, _dispersing_sex, _get_numFemOffspring, _get_numMalOffspring, _get_patchFecundity, _growthRates, _make_offspring, LCE_Breed_base::_mean_fecundity, _N_at_T0, LCE_Disperse_base::_npatch, _num_colonizers, SimComponent::_paramSet, LifeCycleEvent::_popPtr, _T0_exp_growth, conditionalLogisticGrowth(), conditionalStochasticLogisticGrowth(), TMatrix::copy_recycle(), do_breed_disperse(), do_breed_disperse_propagule(), error(), exponentialGrowth(), FEM, fixedFecundityGrowth(), TMatrix::get(), SimComponent::get_parameter(), SimComponent::get_parameter_value(), Param::getArg(), Metapop::getCurrentGeneration(), LCE_Disperse_base::getDispersalModel(), LCE_Breed_base::getMatingProportion(), LCE_Breed_base::getMatingSystem(), ParamSet::getMatrix(), Param::getMatrix(), Metapop::getPatchNbr(), instantGrowth(), ParamSet::isMatrix(), Param::isSet(), ParamSet::isSet(), TMatrix::length(), logisticGrowth(), MAL, mate_cloning(), mate_full_selfing(), mate_random(), mate_random_hermaphrodite(), mate_selfing(), TMatrix::ncols(), TMatrix::nrows(), numFemOffspring(), numFemOffspring_colonizers(), numMalOffspring_notrandom(), numMalOffspring_random(), numMalOffspring_random_colonizers(), TMatrix::reset(), LCE_Disperse_base::set_isForward(), TMatrix::set_row(), LCE_Disperse_base::setBaseParameters(), LCE_Breed_base::setParameters(), stochasticFecundityGrowth(), and stochasticLogisticGrowth().

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

+ Here is the caller graph for this function:

◆ stochasticFecundityGrowth()

unsigned int LCE_Breed_Disperse::stochasticFecundityGrowth ( Patch patch,
sex_t  SEX 
)
inline

The number of offspring produced is a random number drawn from a Poisson distribution with mean equal to the current number of breeders multiplied by the mean fecundity of the focal patch.

191  {
192  return RAND::Uniform(patch->size(SEX,ADULTS)*LCE_Breed_base::getMeanFecundity(patch->getID()));
193  }

References ADULTS, Patch::getID(), LCE_Breed_base::getMeanFecundity(), Patch::size(), and RAND::Uniform().

Referenced by conditionalStochasticLogisticGrowth(), and setParameters().

+ Here is the caller graph for this function:

◆ stochasticLogisticGrowth()

unsigned int LCE_Breed_Disperse::stochasticLogisticGrowth ( Patch patch,
sex_t  SEX 
)
inline

The number of offspring produced is drawn from a Poisson with mean equal to the logistic growth predicate.

159  {
160  return (unsigned int)RAND::Poisson((double)logisticGrowth(patch, SEX));
161  }
static double Poisson(double mean)
From the Numerical Recieps.
Definition: Uniform.h:219

References logisticGrowth(), and RAND::Poisson().

Referenced by conditionalStochasticLogisticGrowth(), and setParameters().

+ Here is the caller graph for this function:

Member Data Documentation

◆ _breed_disperse

void(LCE_Breed_Disperse::* LCE_Breed_Disperse::_breed_disperse) ()
private

Referenced by execute(), and setParameters().

◆ _dispersing_sex

sex_t LCE_Breed_Disperse::_dispersing_sex
protected

◆ _get_numFemOffspring

unsigned int(LCE_Breed_Disperse::* LCE_Breed_Disperse::_get_numFemOffspring) (Patch *patch)
protected

◆ _get_numMalOffspring

unsigned int(LCE_Breed_Disperse::* LCE_Breed_Disperse::_get_numMalOffspring) (Patch *patch)
protected

◆ _get_patchFecundity

unsigned int(LCE_Breed_Disperse::* LCE_Breed_Disperse::_get_patchFecundity) (Patch *patch, sex_t SEX)
protected

◆ _growthRates

TMatrix LCE_Breed_Disperse::_growthRates
private

Patch-specific growth rates.

Referenced by exponentialGrowth(), logisticGrowth(), and setParameters().

◆ _make_offspring

Individual*(LCE_Breed_Disperse::* LCE_Breed_Disperse::_make_offspring) (sex_t SEX, Patch *patch, unsigned int LocalPatch, gsl_ran_discrete_t *rate_fem, gsl_ran_discrete_t *rate_mal)
protected

◆ _N_at_T0

TMatrix LCE_Breed_Disperse::_N_at_T0
private

Recorder of original patch sizes used to compute future sizes depending on growth rate model.

Referenced by exponentialGrowth(), and setParameters().

◆ _num_colonizers

TMatrix LCE_Breed_Disperse::_num_colonizers
protected

Maximum size of a patch after colonisation.

Referenced by numFemOffspring_colonizers(), numMalOffspring_random_colonizers(), and setParameters().

◆ _T0_exp_growth

unsigned int LCE_Breed_Disperse::_T0_exp_growth
private

Starting time of the growing phase, can be reset by a parameter update.

Referenced by exponentialGrowth(), and setParameters().


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

Generated for Nemo v2.4.1 by  doxygen 1.9.1

Catalogued on GSR