Nemo  2.4.2
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 ( )
43  : LifeCycleEvent("breed_disperse",""),_breed_disperse(0), _T0_exp_growth(0),
45 {
47 
48  LCE_Disperse_base::addParameters("breed_disperse", updater);
49 
50  add_parameter("breed_disperse_dispersing_sex", STR, false, false, 0, 0, updater);
51  add_parameter("breed_disperse_colonizers", INT,false,false,0,0, updater);
52  add_parameter("breed_disperse_growth_model", INT, false, true, 1, 8, updater);
53  add_parameter("breed_disperse_growth_rate", DBL, false, false, 0, 0, updater);
54 }
unsigned int(LCE_Breed_Disperse::* _get_numMalOffspring)(Patch *patch)
Definition: LCEcomposite.h:72
sex_t _dispersing_sex
Which part of the population is dispersing its gametes.
Definition: LCEcomposite.h:67
unsigned int(LCE_Breed_Disperse::* _get_patchFecundity)(Patch *patch, sex_t SEX)
Definition: LCEcomposite.h:73
void(LCE_Breed_Disperse::* _breed_disperse)()
Definition: LCEcomposite.h:49
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:69
virtual bool setParameters()
Definition: LCEcomposite.cc:58
unsigned int _T0_exp_growth
Starting time of the growing phase, can be reset by a parameter update.
Definition: LCEcomposite.h:59
unsigned int(LCE_Breed_Disperse::* _get_numFemOffspring)(Patch *patch)
Definition: LCEcomposite.h:71
void addParameters(string prefix, ParamUpdaterBase *updater)
Definition: LCEdisperse.cc:60
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
@ FEM
Definition: types.h:35
@ DBL
Definition: types.h:76
@ STR
Definition: types.h:76
@ INT
Definition: types.h:76

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
79 {}

Member Function Documentation

◆ addAgeClass()

virtual age_t LCE_Breed_Disperse::addAgeClass ( )
inlinevirtual

Reimplemented from LCE_Disperse_base.

Reimplemented in LCE_Breed_Selection_Disperse.

230 {return (isWrightFisher() ? NONE : OFFSPRG);}
bool isWrightFisher()
Definition: LCEbreed.h:118
#define NONE
No age flag.
Definition: types.h:46
#define OFFSPRG
Offspring age class flag.
Definition: types.h:48

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

◆ clone()

virtual LifeCycleEvent* LCE_Breed_Disperse::clone ( )
inlinevirtual

Implements LifeCycleEvent.

Reimplemented in LCE_Breed_Selection_Disperse.

225 {return new LCE_Breed_Disperse();}
LCE_Breed_Disperse()
Definition: LCEcomposite.cc:43

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.

164  {
165  if (patch->size(SEX, ADLTx) < patch->get_K(SEX)/2) {
166  return fixedFecundityGrowth(patch, SEX);
167  } else {
168  return logisticGrowth(patch, SEX);
169  }
170  }
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:183
unsigned int logisticGrowth(Patch *patch, sex_t SEX)
The number of offspring produced is given by the logistic growth function.
Definition: LCEcomposite.h:146
unsigned int get_K()
Definition: metapop.h:480
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
@ ADLTx
Definition: types.h:40

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.

174  {
175  if (patch->size(SEX, ADLTx) < patch->get_K(SEX)/2) {
176  return stochasticFecundityGrowth(patch, SEX);
177  } else {
178  return stochasticLogisticGrowth(patch, SEX);
179  }
180  }
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:189
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:157

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

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)

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

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

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 ( )
451 {
454 }
void do_breed_disperse()
Definition: LCEcomposite.cc:275
bool setIsland_PropagulePool_Matrix()
Definition: LCEdisperse.cc:579

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.

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

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.

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

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.

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

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

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.

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

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.

226 {}

◆ loadStatServices()

virtual void LCE_Breed_Disperse::loadStatServices ( StatServices loader)
inlinevirtual

Reimplemented from LCE_Disperse_base.

Reimplemented in LCE_Breed_Selection_Disperse.

227 {}

◆ 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.

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

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

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 
)
546 {
547  Individual *mom = get_parent(FEM, FEM, patch, LocalPatch, rate_fem);
548 
549  if(!mom) return NULL;
550 
551  return _popPtr->makeNewIndividual(mom, mom, FEM, LocalPatch);
552 }
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

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 
)
492 {
493  Individual* p1 = get_parent(FEM, FEM, patch, LocalPatch, rate_fem);
494  Individual* p2 = get_parent(MAL, MAL, patch, LocalPatch, rate_mal);
495 
496  if(! (p1 && p2)) return NULL;
497 
498  return _popPtr->makeNewIndividual(p1, p2, SEX, LocalPatch);
499 }

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 
)
505 {
506  Individual* p1 = get_parent(FEM, FEM, patch, LocalPatch, rate_fem);
507  Individual* p2 = get_parent(FEM, _dispersing_sex, patch, LocalPatch,
508  (_dispersing_sex == MAL ? rate_mal : rate_fem));
509 
510  if(! (p1 && p2)) return NULL;
511 
512  return _popPtr->makeNewIndividual(p1, p2, FEM, LocalPatch);
513 }

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

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
88  {
89 // if (patch->size(FEM, ADLTx) == 0 && _dispersing_sex != FEM)//to avoid choosing a local female when there is none
90 // return 0;
91 // else
92  return (this->*_get_patchFecundity)(patch, FEM);
93  }

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.

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

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.

112  {
113  return 0;
114  }

Referenced by setParameters().

+ Here is the caller graph for this function:

◆ numMalOffspring_random()

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

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
127  {
128  if(patch->isEmpty()) {
129 // //check if only one sex sends gametes around, capturing the case of pollen dispersal
130 // if(_dispersing_sex != FEM)
131 // return 0;
132 // else
133  return _num_colonizers.get(0, patch->getID()); // Males on first row
134  } else
135  return (this->*_get_patchFecundity)(patch, MAL);
136  }

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.

229 {return NONE;}

References NONE.

◆ requiredAgeClass()

virtual age_t LCE_Breed_Disperse::requiredAgeClass ( )
inlinevirtual

Reimplemented from LCE_Disperse_base.

Reimplemented in LCE_Breed_Selection_Disperse.

231 {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.

228 {return false;}

◆ setParameters()

bool LCE_Breed_Disperse::setParameters ( )
virtual

Reimplemented from LCE_Breed_base.

Reimplemented in LCE_Breed_Selection_Disperse.

59 {
60  if(!LCE_Breed_base::setParameters()) return false;
61 
63 
64  if(!LCE_Disperse_base::setBaseParameters("breed_disperse")) return false;
65 
66  if(get_parameter("breed_disperse_colonizers")->isSet()) {
67  if(get_parameter("breed_disperse_colonizers")->isMatrix()) {
68 
69  TMatrix tmp;
70 
71  get_parameter("breed_disperse_colonizers")->getMatrix(&tmp);
72 
73  if(tmp.nrows() > 2)
74  return error("breed_disperse_colonizers::matrix should have at most two rows, one for each sex\n");
75 
76  if(tmp.ncols() > _npatch)
77  return error("breed_disperse_colonizers::matrix or array can have at most as many columns (elements) as the number of patches\n");
78 
79  // always fill a 2 x num_patch matrix, even if only one sex
80  // (see numFemOffspring_colonizers())
82 
84 
85  } else {
86  // not a matrix, copy single value to default 2 x num patch matrix
87  _num_colonizers.reset(2, _npatch, get_parameter_value("breed_disperse_colonizers"));
88 
89  }
90 
91  } else {
93 
94  }
95  //some default settings, reset below depending on mating system
100 
101  if(get_parameter("breed_disperse_dispersing_sex")->isSet()) {
102 
103  if (get_parameter("breed_disperse_dispersing_sex")->getArg() == "female") {
105  } else if (get_parameter("breed_disperse_dispersing_sex")->getArg() == "male") {
107  } else {
108  error("the \"breed_disperse_dispersing_sex\" parameter only takes \"female\" or \"male\" as argument\n");
109  }
110 
111  } else { //default depends on mating system
112  // males are the dispersing sex for random mating, female dispersal is always checked, male dispersal is optional
113  if(this->getMatingSystem() == 1)
115  else // all others use females only, since monogamy and polygyny are not allowed here
117  }
118 
119  //check mating system:
120  unsigned int model = this->getMatingSystem();
121 
122  if(model == 2 || model == 3) {
123 
124  return error("Polygyny and Monogamy are not implemented within the breed_disperse LCE.\n");
125 
126  } else if(model == 1) { //promiscuity/random mating
127 
129 
133 
134  } else if(model == 4) { //selfing
135 
136  if(this->getMatingProportion() != 1)
138  else
140 
141  } else if(model == 5) { //cloning
142 
144 
145  } else if(model == 6) { //random mating among hermaphrodites (selfing = 1/N)
146 
148 
149  }
150 
151  //check dispersal model:
152  model = this->getDispersalModel();
153 
154  if(model == 2) //propagule-pool island model
156  else
158 
159  //growth model
160  if(_paramSet->isSet("breed_disperse_growth_model"))
161  model = get_parameter_value("breed_disperse_growth_model");
162  else
163  model = 1;
164 
165  switch (model) {
166  case 1:
168  break;
169  case 2:
171  break;
172  case 3:
174  break;
175  case 4:
177  break;
178  case 5:
180  break;
181  case 6:
183  break;
184  case 7:
186  break;
187  case 8:
189  break;
190  default:
192  break;
193  }
194  //mean fecundity
195  if(_mean_fecundity.get(0,0) == -1) //wasn't set
196  if(model > 3 && model < 8) //4 - 7: conditional logistic growth, fecundity growth
197  return error("parameter \"mean_fecundity\" is needed with growth models 4 to 7 in LCE breed_disperse\n");
198 
199  //growth rate ---------------------------------------------------------------
200 
202 
203  if ((model > 1 && model < 6) || model == 8) {
204 
205  if(!_paramSet->isSet("breed_disperse_growth_rate")) {
206 
207  return error("parameter \"breed_disperse_growth_rate\" needs to be set\n");
208 
209  }
210 
212 
213  if(_paramSet->isMatrix("breed_disperse_growth_rate")) {
214 
215  TMatrix tmp;
216 
217  _paramSet->getMatrix("breed_disperse_growth_rate", &tmp);
218 
219  if(tmp.ncols() > _popPtr->getPatchNbr()){
220  return error("breed_disperse_growth_rate::number of elements in array must be < or = to the number of patches.\n");
221  }
222 
224 
225  } else { //not a matrix
226 
227  _growthRates.set_row(0, get_parameter_value("breed_disperse_growth_rate"));
228 
229  }
230 
231  if(model == 8) { //exponential growth
232  // reset counters
235  }
236  }
237 
238  return true;
239 }
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:556
unsigned int conditionalLogisticGrowth(Patch *patch, sex_t SEX)
The number of offspring produced depends on the adult density.
Definition: LCEcomposite.h:163
unsigned int numMalOffspring_random_colonizers(Patch *patch)
Definition: LCEcomposite.h:126
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:544
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:458
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:111
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:517
unsigned int conditionalStochasticLogisticGrowth(Patch *patch, sex_t SEX)
The number of offspring produced depends on the adult density, similar to 'conditionalLogisticGrowth'...
Definition: LCEcomposite.h:173
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:503
unsigned int numFemOffspring(Patch *patch)
Definition: LCEcomposite.h:87
unsigned int numFemOffspring_colonizers(Patch *patch)
The number of females produced in case a max number of colonizers was specified.
Definition: LCEcomposite.h:96
unsigned int numMalOffspring_random(Patch *patch)
Definition: LCEcomposite.h:116
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:490
unsigned int instantGrowth(Patch *patch, sex_t SEX)
The number of offspring produced corresponds to the carrying capacity of the patch.
Definition: LCEcomposite.h:141
void do_breed_disperse_propagule()
Definition: LCEcomposite.cc:450
TMatrix _mean_fecundity
Definition: LCEbreed.h:66
virtual bool setParameters()
Definition: LCEbreed.cc:75
bool setBaseParameters(string prefix)
Definition: LCEdisperse.cc:86
void set_isForward(bool val)
Definition: LCEdisperse.h:83
unsigned int getDispersalModel()
Definition: LCEdisperse.h:113
void getMatrix(string name, TMatrix *mat)
Accessor to the parameters matrix.
Definition: param.h:312
bool isMatrix(string name)
Check if the parameter "name" is of matrix type.
Definition: param.h:304
bool isSet()
Accessor to the status flag.
Definition: param.h:296
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
bool isSet()
Definition: param.h:146
virtual double get_parameter_value(std::string name)
Param value getter.
Definition: simcomponent.h:141
virtual Param * get_parameter(std::string name)
Param getter.
Definition: simcomponent.h:137
ParamSet * _paramSet
The parameters container.
Definition: simcomponent.h:46
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_row(unsigned int i, double val)
Sets all elements at row i to value val.
Definition: tmatrix.h:109
unsigned int ncols() const
Definition: tmatrix.h:214
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:88
unsigned int length() const
Returns the number of elements in the matrix.
Definition: tmatrix.h:216
unsigned int nrows() const
Definition: tmatrix.h:211
int error(const char *str,...)
Definition: output.cc:77

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.

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

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.

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

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

Catalogued on GSR