Nemo  2.4.0
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:362
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 ( )
299 {
300  Patch* patch;
301  unsigned int nfem, nmal;
302 
303 // cout << endl;
304 
305  for(unsigned int i = 0; i < _popPtr->getPatchNbr(); i++) {
306 
307  patch = _popPtr->getPatch(i);
308 
309  if(patch->size(OFFSx) != 0) patch->flush(OFFSx, _popPtr);
310 
311  nfem = (this->* _get_numFemOffspring)(patch);
312  nmal = (this->* _get_numMalOffspring)(patch);
313 
314 // cout << ">>> patch "<<i<<" (size="<<patch->size(ADULTS)<<") nfem = "<<nfem<<"; nmal = "<<nmal<<endl;
315  // we want the catch the cases with empty (extinct) patches to avoid hanging time
316  if(patch->size(FEM, ADLTx) == 0) {
317 
318  if(nfem) do_breed_disperse_in_empty_patch(FEM, patch, i, nfem);
319  if(nmal) do_breed_disperse_in_empty_patch(MAL, patch, i, nmal);
320 
321  } else if (patch->size(MAL, ADLTx) == 0 && this->getMatingSystem() == 1) {
322 
323  if(nfem) do_breed_disperse_in_empty_patch(FEM, patch, i, nfem);
324  if(nmal) do_breed_disperse_in_empty_patch(MAL, patch, i, nmal);
325 
326  } else {
327 
328  if(nfem) do_breed_disperse_in_patch(FEM, patch, i, nfem);
329  if(nmal) do_breed_disperse_in_patch(MAL, patch, i, nmal);
330 
331  }
332  }
333 }
void do_breed_disperse_in_empty_patch(sex_t SEX, Patch *patch, unsigned int ID, unsigned int num_offsprg)
Definition: LCEcomposite.cc:376
void do_breed_disperse_in_patch(sex_t SEX, Patch *patch, unsigned int ID, unsigned int num_offsprg)
Definition: LCEcomposite.cc:337
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
@ OFFSx
Definition: types.h:41

References _get_numFemOffspring, _get_numMalOffspring, LifeCycleEvent::_popPtr, ADLTx, 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)

377 {
378  Individual* newind;
379 
380 // cout<<"---- do_breed_disperse_in_empty_patch ----\n";
381 //
382 // cout<<" ---- patch "<<ID<<" ----\n";
383  // check that the connected patches are not also empty
384  vector<double> disp_rate_connected_fem = LCE_Disperse_base::getConnectedRates(FEM, ID);
385  vector<double> disp_rate_connected_mal = LCE_Disperse_base::getConnectedRates(MAL, ID);
386 
387  // set local patch disp rate (philopatry) to zero, it is empty
388 // disp_rate_connected_fem[0] = 0;
389 // disp_rate_connected_mal[0] = 0;
390 
391  double disp_table_fem[disp_rate_connected_fem.size()];
392  double disp_table_mal[disp_rate_connected_mal.size()];
393 
394  unsigned int size, c_size_fem = 0;
395  vector< double > connected_patches = LCE_Disperse_base::getConnectedPatches(FEM, ID);
396 
397 // cout<<"\t - female dispersal:\n";
398  // copy vector into table, and count size of connected patches
399  for(unsigned int i = 0; i < disp_rate_connected_fem.size(); ++i){
400  size = _popPtr->size(FEM, ADLTx, (unsigned int)connected_patches[i]);
401  if( size )
402  disp_table_fem[i] = disp_rate_connected_fem[i];
403  else
404  disp_table_fem[i] = 0;
405 
406 // cout<<"\t > "<<(unsigned int)connected_patches[i]<<": "
407 // <<size<<" adlt female ("<<disp_table_fem[i]<<")"<<endl;
408 
409  c_size_fem += size;
410  }
411 
413  unsigned int c_size_mal = 0;
414 
415  // use the dispersal matrices for the dispersing sex
417 
418 // cout<<"\t - male dispersal:\n";
419  // the sex patch size to check depends on the mating system; male for random mating, fem otherwise
420  sex_t sex2check = (this->getMatingSystem() == 1 ? MAL : FEM);
421 
422  for(unsigned int i = 0; i < disp_rate_connected_mal.size(); ++i){
423  size = _popPtr->size(sex2check, ADLTx, (unsigned int)connected_patches[i]);
424 
425  if(size)
426  disp_table_mal[i] = disp_rate_connected_mal[i];
427  else
428  disp_table_mal[i] = 0;
429 
430 // cout<<"\t > "<<(unsigned int)connected_patches[i]<<": "
431 // <<size<<" adlt "<<(sex2check == MAL? "male" :"female")
432 // <<"("<<disp_table_mal[i]<<")"<<endl;
433 
434  c_size_mal += size;
435  }
436 
437 // cout<<"\t - size of connected patch; fem = "<<c_size_fem<<", mal = "<<c_size_mal<<endl;
438  // no reproduction can happen if all connected patches are empty as well
439  if( c_size_fem == 0 ) return;
440 
441  // check for the dispersing sex, which is male under random mating
442  if( c_size_mal == 0 ) return;
443 
444  // these allocations are costly but there isn't an easy workaround when the number of connected patches varies dynamically
445  gsl_ran_discrete_t* gsltable_fem = gsl_ran_discrete_preproc(disp_rate_connected_fem.size(), disp_table_fem);
446  gsl_ran_discrete_t* gsltable_mal = gsl_ran_discrete_preproc(disp_rate_connected_mal.size(), disp_table_mal);
447 
448 // cout<<"\t generating "<<num_offsprg<<" offspring: ";
449  for(unsigned int j = 0; j < num_offsprg; j++) {
450 
451  newind = (this->*_make_offspring)(SEX, patch, ID, gsltable_fem, gsltable_mal);
452 
453  // it is possible that a null pointer is returned when patches are extinct and no migration is possible
454  if(!newind) continue;
455 
456 // cout<<j+1<<" ";
457 
458  patch->add(SEX, OFFSx, LCE_Breed_base::makeOffspring( newind ));
459  patch->nbKolonisers++;
460 
461  }
462 
463 // cout<< "\n\t - num colonizers: "<<patch->nbKolonisers<<endl;
464 
465  gsl_ran_discrete_free(gsltable_fem);
466  gsl_ran_discrete_free(gsltable_mal);
467 }
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 
)
338 {
339  Individual* newind;
340 
341  vector<double> disp_rate_connected_fem = LCE_Disperse_base::getConnectedRates(FEM, ID);
342  vector<double> disp_rate_connected_mal = LCE_Disperse_base::getConnectedRates(MAL, ID);
343 
344  double disp_table_fem[disp_rate_connected_fem.size()];
345  double disp_table_mal[disp_rate_connected_mal.size()];
346 
347  for(unsigned int i = 0; i < disp_rate_connected_fem.size(); ++i){
348  disp_table_fem[i] = disp_rate_connected_fem[i];
349  }
350 
351  for(unsigned int i = 0; i < disp_rate_connected_mal.size(); ++i){
352  disp_table_mal[i] = disp_rate_connected_mal[i];
353  }
354 
355  gsl_ran_discrete_t* gsltable_fem = gsl_ran_discrete_preproc(disp_rate_connected_fem.size(), disp_table_fem);
356  gsl_ran_discrete_t* gsltable_mal = gsl_ran_discrete_preproc(disp_rate_connected_mal.size(), disp_table_mal);
357 
358 
359  for(unsigned int j = 0; j < num_offsprg; j++) {
360 
361  newind = (this->*_make_offspring)(SEX, patch, ID, gsltable_fem, gsltable_mal);
362 
363  // it is possible that a null pointer is returned when connected patches are extinct and no migration is possible
364  if(!newind) continue;
365 
366  patch->add(SEX, OFFSx, LCE_Breed_base::makeOffspring( newind ));
367 
368  }
369 
370  gsl_ran_discrete_free(gsltable_fem);
371  gsl_ran_discrete_free(gsltable_mal);
372 }

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 ( )
472 {
475 }
void do_breed_disperse()
Definition: LCEcomposite.cc:298
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.

267 {
268 #ifdef _DEBUG_
269  message("LCE_Breed_Disperse::execute (Patch nb: %i offsprg nb: %i adlt nb: %i "
271 #endif
272 
273  if(_npatch != _popPtr->getPatchNbr()) {
275  if(!updateDispMatrix()) fatal("bailing out\n");
276  }
277 
279 
280  (this->*_breed_disperse)();
281 
282  // swap parents and offspring in WF populations
284 
285 #ifdef _DEBUG_
286  unsigned int a = 0, b = 0, c = 0;
287  for(unsigned int i = 0; i < _popPtr->getPatchNbr(); i++){
288  a += _popPtr->getPatch(i)->nbEmigrant;
289  b += _popPtr->getPatch(i)->nbImigrant;
290  c += _popPtr->getPatch(i)->nbPhilopat;
291  }
292  message("immigrate: %f, emigrants: %i, imigrants: %i)\n",(double)b/(b+c), a, b);
293 #endif
294 }
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
#define ADULTS
Adults age class flag (breeders).
Definition: types.h:53

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.

480 {
481 // static unsigned int t0 = 0;
482  unsigned int idx = patch->getID();
483  unsigned int cGen = _popPtr->getCurrentGeneration();
484  unsigned int nGen;
485  unsigned int N;
486 
487 // if(t0 == 0) { //mark starting generation of growth model, when first call (in first patch)
488 // t0 = cGen; //cGen can be zero
489 // }
490 
491  if(_T0_exp_growth == cGen) { // that means we have just (re)set t0
492  _N_at_T0.set(0, idx, patch->size(SEX, ADULTS)); //record initial patch size
493  }
494 
495  // patch grows until K; a growth rate of 0 is interpreted as exponential growth is off
496  if(patch->size(SEX, ADULTS) < patch->get_K(SEX) && _growthRates.get(0,idx) != 0) {
497 
498  nGen = cGen - _T0_exp_growth + 1; //we're calculating the size at time = t+1
499 
500  N = _N_at_T0.get(0, idx)*exp(_growthRates.get(0,idx)*nGen);
501 
502  } else {
503  N = patch->get_K(SEX);
504  }
505 
506  return N;
507 }
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 
)
591 {
592  unsigned int SourcePatch = 0;
593  Patch* src_patch;
594 
595  //first check if individuals are available in other patches:
596  if(local_patch->size(SEX, ADLTx) == _popPtr->size(SEX, ADLTx)) {
597 
598  //other patches are empty, force philopatry:
599  SourcePatch = LocalPatch;
600  src_patch = local_patch;
601 
602  } else {
603 
604  // find immigrants from the connected patches
605 
606  unsigned int index;
607 
608  do {
609 
610  index = getMigrationIndexGSLdiscrete(rates);
611 
612  SourcePatch = LCE_Disperse_base::getReducedDispersalPatchID(DispSex, LocalPatch, index);
613 
614  src_patch = _popPtr->getPatchPtr(SourcePatch); // checked version of getPatch, safe to use if SourcePatch if outside range
615 
616  } while (src_patch->size( SEX, ADLTx ) == 0);
617 
618  }
619 
620  //set migrant counters for the stats
621  if(LocalPatch != SourcePatch) {
622  src_patch->nbEmigrant++;
623 
624  if( local_patch->size(ADLTx) != 0 ) // only count immigrants, not colonizers
625  local_patch->nbImigrant++;
626 
627  } else
628  src_patch->nbPhilopat++;
629 
630  //return a pointer to an individual randomly chosen from the source patch:
631  return src_patch->get(SEX, ADLTx, RAND::Uniform( src_patch->size( SEX, ADLTx ) ) );
632 }
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 
)
579 {
580  Individual *mom = get_parent(FEM, FEM, patch, LocalPatch, rate_fem);
581 
582  if(!mom) return NULL;
583 
584  return LCE_Breed_base::breed_cloning(mom, mom, LocalPatch);
585 }
Individual * get_parent(sex_t SEX, sex_t DispSex, Patch *LocalPatch, unsigned int patchID, gsl_ran_discrete_t *rates)
Definition: LCEcomposite.cc:589
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 
)
567 {
568  Individual *mom = get_parent(FEM, FEM, patch, LocalPatch, rate_fem);
569 
570  if(!mom) return NULL;
571 
572  return _popPtr->makeNewIndividual(mom, mom, FEM, LocalPatch);
573 }
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 
)
513 {
514  Individual* p1 = get_parent(FEM, FEM, patch, LocalPatch, rate_fem);
515  Individual* p2 = get_parent(MAL, MAL, patch, LocalPatch, rate_mal);
516 
517  if(! (p1 && p2)) return NULL;
518 
519  return _popPtr->makeNewIndividual(p1, p2, SEX, LocalPatch);
520 }

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 
)
526 {
527  Individual* p1 = get_parent(FEM, FEM, patch, LocalPatch, rate_fem);
528  Individual* p2 = get_parent(FEM, _dispersing_sex, patch, LocalPatch,
529  (_dispersing_sex == MAL ? rate_mal : rate_fem));
530 
531  if(! (p1 && p2)) return NULL;
532 
533  return _popPtr->makeNewIndividual(p1, p2, FEM, LocalPatch);
534 }

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 
)
540 {
541  Individual *mom, *dad;
542  // cout << "--- choosing mum in patch "<<LocalPatch<<" ("<<patch->size(FEM, ADLTx)<<")\n";
543  mom = get_parent(FEM, FEM, patch, LocalPatch, rate_fem);
544 
545  // cout << "--- choosing dad \n";
546 
547  if( RAND::Uniform() > this->getMatingProportion() ) {
548  //random mating
549  do{
550  dad = get_parent(FEM, _dispersing_sex, patch, LocalPatch,
551  (_dispersing_sex == MAL ? rate_mal : rate_fem));
552  }while(dad == mom && _popPtr->getPatchNbr() != 1 && patch->size(FEM, ADLTx) > 1);
553  } else
554  dad = mom;
555 
556  // cout << "--- make offspring by crossing "<<mom->getID()<<" with "<<dad->getID()<<endl;
557 
558  if(! (mom && dad)) return NULL;
559 
560  return _popPtr->makeNewIndividual(mom, dad, FEM, LocalPatch);
561 }
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 
83 
84  // only for mating systems with two sexes
85 
87 
89 
90  } else {
91  // mating system has one sex only
92 
93  if(tmp.nrows() == 2)
94  return error("breed_disperse_colonizers::argument is a matrix with 2 rows when an array is expected, check parameter or the mating system.\n");
95 
97 
99  }
100 
101  } else {
102 
106  // set sex-specific values in each patch
107  _num_colonizers.reset(2, _npatch, get_parameter_value("breed_disperse_colonizers"));
108 
109  } else {
110  _num_colonizers.reset(1, _npatch, get_parameter_value("breed_disperse_colonizers"));
111  }
112  }
113 
114  } else {
116 
117  }
118  //some default settings, reset below depending on mating system
123 
124  if(get_parameter("breed_disperse_dispersing_sex")->isSet()) {
125 
126  if (get_parameter("breed_disperse_dispersing_sex")->getArg() == "female") {
128  } else if (get_parameter("breed_disperse_dispersing_sex")->getArg() == "male") {
130  } else {
131  error("the \"breed_disperse_dispersing_sex\" parameter only takes \"female\" or \"male\" as argument\n");
132  }
133 
134  } else { //default depends on mating system
135  // males are the dispersing sex for random mating, female dispersal is always checked, male dispersal is optional
136  if(this->getMatingSystem() == 1)
138  else // all others use females only, since monogamy and polygyny are not allowed here
140  }
141 
142  //check mating system:
143  unsigned int model = this->getMatingSystem();
144 
145  if(model == 2 || model == 3) {
146 
147  return error("Polygyny and Monogamy are not implemented within the breed_disperse LCE.\n");
148 
149  } else if(model == 1) { //promiscuity/random mating
150 
152 
156 
157  } else if(model == 4) { //selfing
158 
159  if(this->getMatingProportion() != 1)
161  else
163 
164  } else if(model == 5) { //cloning
165 
167 
168  } else if(model == 6) { //random mating among hermaphrodites (selfing = 1/N)
169 
171 
172  }
173 
174  //check dispersal model:
175  model = this->getDispersalModel();
176 
177  if(model == 2) //propagule-pool island model
179  else
181 
182  //growth model
183  if(_paramSet->isSet("breed_disperse_growth_model"))
184  model = get_parameter_value("breed_disperse_growth_model");
185  else
186  model = 1;
187 
188  switch (model) {
189  case 1:
191  break;
192  case 2:
194  break;
195  case 3:
197  break;
198  case 4:
200  break;
201  case 5:
203  break;
204  case 6:
206  break;
207  case 7:
209  break;
210  case 8:
212  break;
213  default:
215  break;
216  }
217  //mean fecundity
218  if(_mean_fecundity.get(0,0) == -1) //wasn't set
219  if(model > 3 && model < 8) //4 - 7: conditional logistic growth, fecundity growth
220  return error("parameter \"mean_fecundity\" is needed with growth models 4 to 7 in LCE breed_disperse\n");
221 
222  //growth rate ---------------------------------------------------------------
223 
225 
226  if ((model > 1 && model < 6) || model == 8) {
227 
228  if(!_paramSet->isSet("breed_disperse_growth_rate")) {
229 
230  return error("parameter \"breed_disperse_growth_rate\" needs to be set\n");
231 
232  }
233 
235 
236  if(_paramSet->isMatrix("breed_disperse_growth_rate")) {
237 
238  TMatrix tmp;
239 
240  _paramSet->getMatrix("breed_disperse_growth_rate", &tmp);
241 
242  if(tmp.ncols() > _popPtr->getPatchNbr()){
243  return error("breed_disperse_growth_rate::number of elements in array must be < or = to the number of patches.\n");
244  }
245 
247 
248  } else { //not a matrix
249 
250  _growthRates.set_row(0, get_parameter_value("breed_disperse_growth_rate"));
251 
252  }
253 
254  if(model == 8) { //exponential growth
255  // reset counters
258  }
259  }
260 
261  return true;
262 }
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:577
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:565
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:479
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:538
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:524
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:511
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:471
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:303
bool isMatrix(string name)
Check if the parameter "name" is of matrix type.
Definition: param.h:295
bool isSet()
Accessor to the status flag.
Definition: param.h:287
string getArg()
Definition: param.h:137
void getMatrix(TMatrix *mat)
Sets the matrix from the argument string if the parameter is set and of matrix type.
Definition: param.cc:377
bool isSet()
Definition: param.h:139
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.0 by  doxygen 1.9.1 -- Nemo is hosted on  Download Nemo

Locations of visitors to this page
Catalogued on GSR