Nemo  2.4.0b
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 ()
 
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...
 
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

int _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 )()
 
double * _growthRates
 Patch-specific growth rates. More...
 
TMatrix _NatT0
 Recorder of original patch sizes used to compute future sizes depending on growth rate model. 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 ( )
45  : LifeCycleEvent("breed_disperse",""),_breed_disperse(0),
48 {
50 
51  LCE_Disperse_base::addParameters("breed_disperse", updater);
52 
53  add_parameter("breed_disperse_dispersing_sex", STR, false, false, 0, 0, updater);
54  add_parameter("breed_disperse_colonizers", INT,false,false,0,0, updater);
55  add_parameter("breed_disperse_growth_model", INT, false, true, 1, 8, updater);
56  add_parameter("breed_disperse_growth_rate", DBL, false, false, 0, 0, updater);
57 }
unsigned int(LCE_Breed_Disperse::* _get_numMalOffspring)(Patch *patch)
Definition: LCEcomposite.h:71
sex_t _dispersing_sex
Which part of the population is dispersing its gametes.
Definition: LCEcomposite.h:66
unsigned int(LCE_Breed_Disperse::* _get_patchFecundity)(Patch *patch, sex_t SEX)
Definition: LCEcomposite.h:72
double * _growthRates
Patch-specific growth rates.
Definition: LCEcomposite.h:55
void(LCE_Breed_Disperse::* _breed_disperse)()
Definition: LCEcomposite.h:51
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:68
int _num_colonizers
Maximum size of a patch after colonisation.
Definition: LCEcomposite.h:63
virtual bool setParameters()
Definition: LCEcomposite.cc:61
unsigned int(LCE_Breed_Disperse::* _get_numFemOffspring)(Patch *patch)
Definition: LCEcomposite.h:70
void addParameters(string prefix, ParamUpdaterBase *updater)
Definition: LCEdisperse.cc:62
LifeCycleEvent(const char *name, const char *trait_link)
Cstor.
Definition: lifecycleevent.h:98
Implementation of the ParamUpdaterBase interface.
Definition: param.h:363
virtual void add_parameter(Param *param)
Interface to add a parameter to the set.
Definition: simcomponent.h:112
@ FEM
Definition: types.h:37
@ DBL
Definition: types.h:78
@ STR
Definition: types.h:78
@ INT
Definition: types.h:78

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

Referenced by clone().

◆ ~LCE_Breed_Disperse()

virtual LCE_Breed_Disperse::~LCE_Breed_Disperse ( )
inlinevirtual
78 {if(_growthRates) delete [] _growthRates;}

References _growthRates.

Member Function Documentation

◆ addAgeClass()

virtual age_t LCE_Breed_Disperse::addAgeClass ( )
inlinevirtual

Reimplemented from LCE_Disperse_base.

Reimplemented in LCE_Breed_Selection_Disperse.

227 {return OFFSPRG;}
#define OFFSPRG
Offspring age class flag.
Definition: types.h:50

References OFFSPRG.

◆ clone()

virtual LifeCycleEvent* LCE_Breed_Disperse::clone ( )
inlinevirtual

Implements LifeCycleEvent.

Reimplemented in LCE_Breed_Selection_Disperse.

222 {return new LCE_Breed_Disperse();}
LCE_Breed_Disperse()
Definition: LCEcomposite.cc:45

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.

161  {
162  if (patch->size(SEX, ADLTx) < patch->get_K(SEX)/2) {
163  return fixedFecundityGrowth(patch, SEX);
164  } else {
165  return logisticGrowth(patch, SEX);
166  }
167  }
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:180
unsigned int logisticGrowth(Patch *patch, sex_t SEX)
The number of offspring produced is given by the logistic growth function.
Definition: LCEcomposite.h:143
unsigned int get_K()
Definition: metapop.h:482
unsigned int size(age_t AGE)
Returns the size of the container of the appropriate age class(es) for both sexes.
Definition: metapop.h:498
@ ADLTx
Definition: types.h:42

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

Referenced by setParameters().

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

171  {
172  if (patch->size(SEX, ADLTx) < patch->get_K(SEX)/2) {
173  return stochasticFecundityGrowth(patch, SEX);
174  } else {
175  return stochasticLogisticGrowth(patch, SEX);
176  }
177  }
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:186
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:154

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

Referenced by setParameters().

◆ do_breed_disperse()

void LCE_Breed_Disperse::do_breed_disperse ( )
252 {
253  Patch* patch;
254  unsigned int nfem, nmal;
255 
256  for(unsigned int i = 0; i < _popPtr->getPatchNbr(); i++) {
257 
258  patch = _popPtr->getPatch(i);
259 
260  if(patch->size(OFFSx) != 0) patch->flush(OFFSx, _popPtr);
261 
262  nfem = (this->* _get_numFemOffspring)(patch);
263  nmal = (this->* _get_numMalOffspring)(patch);
264 
265  // we want the catch the cases with empty (extinct) patches to avoid hanging time
266  if(patch->size(FEM, ADLTx) == 0) {
267 
268  do_breed_disperse_in_empty_patch(FEM, patch, i, nfem);
269  do_breed_disperse_in_empty_patch(MAL, patch, i, nmal);
270 
271  } else if (patch->size(MAL, ADLTx) == 0 && this->getMatingSystem() == 1) {
272 
273  do_breed_disperse_in_empty_patch(FEM, patch, i, nfem);
274  do_breed_disperse_in_empty_patch(MAL, patch, i, nmal);
275 
276  } else {
277 
278  do_breed_disperse_in_patch(FEM, patch, i, nfem);
279  do_breed_disperse_in_patch(MAL, patch, i, nmal);
280 
281  }
282  }
283 }
void do_breed_disperse_in_empty_patch(sex_t SEX, Patch *patch, unsigned int ID, unsigned int num_offsprg)
Definition: LCEcomposite.cc:326
void do_breed_disperse_in_patch(sex_t SEX, Patch *patch, unsigned int ID, unsigned int num_offsprg)
Definition: LCEcomposite.cc:287
Metapop * _popPtr
The ptr to the current Metapop.
Definition: lifecycleevent.h:81
unsigned int getPatchNbr()
Definition: metapop.h:276
Patch * getPatch(unsigned int i)
Patch accessor, return the ith+1 patch in the metapop.
Definition: metapop.h:257
Second class in the metapopulation design structure, between the Metapop and Individual classes.
Definition: metapop.h:432
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:37
@ OFFSx
Definition: types.h:42

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().

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

327 {
328  Individual* newind;
329 
330 // cout<<"---- do_breed_disperse_in_empty_patch ----\n";
331 //
332 // cout<<" ---- patch "<<ID<<" ----\n";
333  // check that the connected patches are not also empty
334  vector<double> disp_rate_connected_fem = LCE_Disperse_base::getConnectedRates(FEM, ID);
335  vector<double> disp_rate_connected_mal = LCE_Disperse_base::getConnectedRates(MAL, ID);
336 
337  // set local patch disp rate (philopatry) to zero, it is empty
338 // disp_rate_connected_fem[0] = 0;
339 // disp_rate_connected_mal[0] = 0;
340 
341  double disp_table_fem[disp_rate_connected_fem.size()];
342  double disp_table_mal[disp_rate_connected_mal.size()];
343 
344  unsigned int size, c_size_fem = 0;
345  vector< double > connected_patches = LCE_Disperse_base::getConnectedPatches(FEM, ID);
346 
347 // cout<<"\t - female dispersal:\n";
348  // copy vector into table, and count size of connected patches
349  for(unsigned int i = 0; i < disp_rate_connected_fem.size(); ++i){
350  size = _popPtr->size(FEM, ADLTx, (unsigned int)connected_patches[i]);
351  if( size )
352  disp_table_fem[i] = disp_rate_connected_fem[i];
353  else
354  disp_table_fem[i] = 0;
355 
356 // cout<<"\t > "<<(unsigned int)connected_patches[i]<<": "
357 // <<size<<" adlt female ("<<disp_table_fem[i]<<")"<<endl;
358 
359  c_size_fem += size;
360  }
361 
363  unsigned int c_size_mal = 0;
364 
365  // use the dispersal matrices for the dispersing sex
367 
368 // cout<<"\t - male dispersal:\n";
369  // the sex patch size to check depends on the mating system; male for random mating, fem otherwise
370  sex_t sex2check = (this->getMatingSystem() == 1 ? MAL : FEM);
371 
372  for(unsigned int i = 0; i < disp_rate_connected_mal.size(); ++i){
373  size = _popPtr->size(sex2check, ADLTx, (unsigned int)connected_patches[i]);
374 
375  if(size)
376  disp_table_mal[i] = disp_rate_connected_mal[i];
377  else
378  disp_table_mal[i] = 0;
379 
380 // cout<<"\t > "<<(unsigned int)connected_patches[i]<<": "
381 // <<size<<" adlt "<<(sex2check == MAL? "male" :"female")
382 // <<"("<<disp_table_mal[i]<<")"<<endl;
383 
384  c_size_mal += size;
385  }
386 
387 // cout<<"\t - size of connected patch; fem = "<<c_size_fem<<", mal = "<<c_size_mal<<endl;
388  // no reproduction can happen if all connected patches are empty as well
389  if( c_size_fem == 0 ) return;
390 
391  // check for the dispersing sex, which is male under random mating
392  if( c_size_mal == 0 ) return;
393 
394  gsl_ran_discrete_t* gsltable_fem = gsl_ran_discrete_preproc(disp_rate_connected_fem.size(), disp_table_fem);
395  gsl_ran_discrete_t* gsltable_mal = gsl_ran_discrete_preproc(disp_rate_connected_mal.size(), disp_table_mal);
396 
397 // cout<<"\t generating "<<num_offsprg<<" offspring: ";
398  for(unsigned int j = 0; j < num_offsprg; j++) {
399 
400  newind = (this->*_make_offspring)(SEX, patch, ID, gsltable_fem, gsltable_mal);
401 
402  // it is possible that a null pointer is returned when patches are extinct and no migration is possible
403  if(!newind) continue;
404 
405 // cout<<j+1<<" ";
406 
407  patch->add(SEX, OFFSx, LCE_Breed_base::makeOffspring( newind ));
408  patch->nbKolonisers++;
409 
410  }
411 
412 // cout<< "\n\t - num colonizers: "<<patch->nbKolonisers<<endl;
413 
414  gsl_ran_discrete_free(gsltable_fem);
415  gsl_ran_discrete_free(gsltable_mal);
416 }
This class contains traits along with other individual information (sex, pedigree,...
Definition: individual.h:49
int getMatingSystem()
Definition: LCEbreed.h:102
Individual * makeOffspring(Individual *ind)
Last step of the breeding process, does inheritance and mutation of the parents' genes.
Definition: LCEbreed.cc:341
vector< double > getConnectedPatches(sex_t SEX, unsigned int local_patch)
Definition: LCEdisperse.cc:1301
vector< double > getConnectedRates(sex_t SEX, unsigned int local_patch)
Definition: LCEdisperse.cc:1312
unsigned int size()
Get the total number of individuals present in the population, all sex and age classes together.
Definition: metapop.h:312
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:551
short nbKolonisers
Definition: metapop.h:455
sex_t
Sex types, males are always 0 and females 1!!
Definition: types.h:36

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().

◆ 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 
)
288 {
289  Individual* newind;
290 
291  vector<double> disp_rate_connected_fem = LCE_Disperse_base::getConnectedRates(FEM, ID);
292  vector<double> disp_rate_connected_mal = LCE_Disperse_base::getConnectedRates(MAL, ID);
293 
294  double disp_table_fem[disp_rate_connected_fem.size()];
295  double disp_table_mal[disp_rate_connected_mal.size()];
296 
297  for(unsigned int i = 0; i < disp_rate_connected_fem.size(); ++i){
298  disp_table_fem[i] = disp_rate_connected_fem[i];
299  }
300 
301  for(unsigned int i = 0; i < disp_rate_connected_mal.size(); ++i){
302  disp_table_mal[i] = disp_rate_connected_mal[i];
303  }
304 
305  gsl_ran_discrete_t* gsltable_fem = gsl_ran_discrete_preproc(disp_rate_connected_fem.size(), disp_table_fem);
306  gsl_ran_discrete_t* gsltable_mal = gsl_ran_discrete_preproc(disp_rate_connected_mal.size(), disp_table_mal);
307 
308 
309  for(unsigned int j = 0; j < num_offsprg; j++) {
310 
311  newind = (this->*_make_offspring)(SEX, patch, ID, gsltable_fem, gsltable_mal);
312 
313  // it is possible that a null pointer is returned when connected patches are extinct and no migration is possible
314  if(!newind) continue;
315 
316  patch->add(SEX, OFFSx, LCE_Breed_base::makeOffspring( newind ));
317 
318  }
319 
320  gsl_ran_discrete_free(gsltable_fem);
321  gsl_ran_discrete_free(gsltable_mal);
322 }

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

Referenced by do_breed_disperse().

◆ do_breed_disperse_propagule()

void LCE_Breed_Disperse::do_breed_disperse_propagule ( )
421 {
424 }
void do_breed_disperse()
Definition: LCEcomposite.cc:251
bool setIsland_PropagulePool_Matrix()
Definition: LCEdisperse.cc:581

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

Referenced by setParameters().

◆ execute()

void LCE_Breed_Disperse::execute ( )
virtual

Implements LifeCycleEvent.

Reimplemented in LCE_Breed_Selection_Disperse.

223 {
224 #ifdef _DEBUG_
225  message("LCE_Breed_Disperse::execute (Patch nb: %i offsprg nb: %i adlt nb: %i "
227 #endif
228 
229  if(_npatch != _popPtr->getPatchNbr()) {
231  if(!updateDispMatrix()) fatal("bailing out\n");
232  }
233 
235 
236  (this->*_breed_disperse)();
237 
238 #ifdef _DEBUG_
239  unsigned int a = 0, b = 0, c = 0;
240  for(unsigned int i = 0; i < _popPtr->getPatchNbr(); i++){
241  a += _popPtr->getPatch(i)->nbEmigrant;
242  b += _popPtr->getPatch(i)->nbImigrant;
243  c += _popPtr->getPatch(i)->nbPhilopat;
244  }
245  message("immigrate: %f, emigrants: %i, imigrants: %i)\n",(double)b/(b+c), a, b);
246 #endif
247 }
void reset_counters()
Definition: LCEdisperse.cc:390
bool updateDispMatrix()
Definition: LCEdisperse.cc:365
unsigned int _npatch
Number of patches in the population.
Definition: LCEdisperse.h:64
unsigned short nbEmigrant
Definition: metapop.h:454
unsigned short nbPhilopat
Definition: metapop.h:454
unsigned short nbImigrant
Definition: metapop.h:454
void fatal(const char *str,...)
Definition: output.cc:96
void message(const char *message,...)
Definition: output.cc:40
#define ADULTS
Adults age class flag (breeders).
Definition: types.h:54

References _breed_disperse, LCE_Disperse_base::_npatch, LifeCycleEvent::_popPtr, ADULTS, fatal(), Metapop::getPatch(), Metapop::getPatchNbr(), 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.

429 {
430  static unsigned int t0 = 0;
431  unsigned int idx = patch->getID();
432  unsigned int cGen = _popPtr->getCurrentGeneration();
433  unsigned int nGen;
434  unsigned int N;
435 
436  if(t0 == 0) { //mark starting generation of growth model, when first call (in first patch)
437  t0 = cGen; //cGen can be zero
438  }
439 
440  if(t0 == cGen) { // that means we have just set t0, in some other patch probably
441  _NatT0.set(0, idx, patch->size(SEX, ADULTS)); //record initial patch size
442  }
443 
444  if(patch->size(SEX, ADULTS) < patch->get_K(SEX)) {
445 
446  nGen = cGen - t0 + 1; //we're calculating the size at time = t+1
447 
448  N = _NatT0.get(0, idx)*exp(_growthRates[idx]*nGen);
449 
450  } else {
451  N = patch->get_K(SEX);
452  }
453 
454  return N;
455 }
TMatrix _NatT0
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:296
unsigned int getID()
Definition: metapop.h:481
void set(unsigned int i, unsigned int j, double val)
Sets element at row i and column j to value val.
Definition: tmatrix.h:103
double get(unsigned int i, unsigned int j) const
Accessor to element at row i and column j.
Definition: tmatrix.h:193

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

Referenced by setParameters().

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

181  {
182  return patch->size(SEX,ADULTS)*LCE_Breed_base::getMeanFecundity(patch->getID());
183  }
double getMeanFecundity(unsigned int patch)
Definition: LCEbreed.h:101

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

Referenced by conditionalLogisticGrowth(), and setParameters().

◆ get_parent()

Individual * LCE_Breed_Disperse::get_parent ( sex_t  SEX,
sex_t  DispSex,
Patch LocalPatch,
unsigned int  patchID,
gsl_ran_discrete_t *  rates 
)
539 {
540  unsigned int SourcePatch = 0;
541  Patch* src_patch;
542 
543  //first check if individuals are available in other patches:
544  if(local_patch->size(SEX, ADLTx) == _popPtr->size(SEX, ADLTx)) {
545 
546  //other patches are empty, force philopatry:
547  SourcePatch = LocalPatch;
548  src_patch = local_patch;
549 
550  } else {
551 
552  // find immigrants from the connected patches
553 
554  unsigned int index;
555 
556  do {
557 
558  index = getMigrationIndexGSLdiscrete(rates);
559 
560  SourcePatch = LCE_Disperse_base::getReducedDispersalPatchID(DispSex, LocalPatch, index);
561 
562  src_patch = _popPtr->getPatchPtr(SourcePatch); // checked version of getPatch, safe to use if SourcePatch if outside range
563 
564  } while (src_patch->size( SEX, ADLTx ) == 0);
565 
566  }
567 
568  //set migrant counters for the stats
569  if(LocalPatch != SourcePatch) {
570  src_patch->nbEmigrant++;
571 
572  if( local_patch->size(ADLTx) != 0 ) // only count immigrants, not colonizers
573  local_patch->nbImigrant++;
574 
575  } else
576  src_patch->nbPhilopat++;
577 
578  //return a pointer to an individual randomly chosen from the source patch:
579  return src_patch->get(SEX, ADLTx, RAND::Uniform( src_patch->size( SEX, ADLTx ) ) );
580 }
unsigned int getReducedDispersalPatchID(sex_t SEX, unsigned int row, unsigned int col)
Definition: LCEdisperse.cc:1333
unsigned int getMigrationIndexGSLdiscrete(gsl_ran_discrete_t *rates)
Definition: LCEdisperse.cc:1294
Patch * getPatchPtr(unsigned int patch)
A secure version of the getPatch() method.
Definition: metapop.h:260
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:534
static double Uniform()
Generates a random number from [0.0, 1.0[ uniformly distributed.
Definition: Uniform.h:124

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().

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

139  {
140  return patch->get_K(SEX);
141  }

References Patch::get_K().

Referenced by setParameters().

◆ loadFileServices()

virtual void LCE_Breed_Disperse::loadFileServices ( FileServices loader)
inlinevirtual

Reimplemented from LCE_Disperse_base.

Reimplemented in LCE_Breed_Selection_Disperse.

223 {}

◆ loadStatServices()

virtual void LCE_Breed_Disperse::loadStatServices ( StatServices loader)
inlinevirtual

Reimplemented from LCE_Disperse_base.

Reimplemented in LCE_Breed_Selection_Disperse.

224 {}

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

144  {
145  double K = (double)patch->get_K(SEX);
146  double r = _growthRates[ patch->getID() ];
147  double N = (double)patch->size(ADLTx);
148  if( K <= N )
149  return K;
150  else
151  return (unsigned int)ceil(N + r*N*((K-N)/K));
152  }

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

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

◆ 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 
)
527 {
528  Individual *mom = get_parent(FEM, FEM, patch, LocalPatch, rate_fem);
529 
530  if(!mom) return NULL;
531 
532  return LCE_Breed_base::breed_cloning(mom, mom, LocalPatch);
533 }
Individual * get_parent(sex_t SEX, sex_t DispSex, Patch *LocalPatch, unsigned int patchID, gsl_ran_discrete_t *rates)
Definition: LCEcomposite.cc:537
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:360

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

Referenced by setParameters().

◆ 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 
)
515 {
516  Individual *mom = get_parent(FEM, FEM, patch, LocalPatch, rate_fem);
517 
518  if(!mom) return NULL;
519 
520  return _popPtr->makeNewIndividual(mom, mom, FEM, LocalPatch);
521 }
Individual * makeNewIndividual(Individual *mother, Individual *father, sex_t sex, unsigned short homepatch)
Creates an individual with pointers to parents, sex and home ID set but no genetic data.
Definition: indfactory.cc:152

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

Referenced by setParameters().

◆ 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 
)
461 {
462  Individual* p1 = get_parent(FEM, FEM, patch, LocalPatch, rate_fem);
463  Individual* p2 = get_parent(MAL, MAL, patch, LocalPatch, rate_mal);
464 
465  if(! (p1 && p2)) return NULL;
466 
467  return _popPtr->makeNewIndividual(p1, p2, SEX, LocalPatch);
468 }

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

Referenced by setParameters().

◆ 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 
)
474 {
475  Individual* p1 = get_parent(FEM, FEM, patch, LocalPatch, rate_fem);
476  Individual* p2 = get_parent(FEM, _dispersing_sex, patch, LocalPatch,
477  (_dispersing_sex == MAL ? rate_mal : rate_fem));
478 
479  if(! (p1 && p2)) return NULL;
480 
481  return _popPtr->makeNewIndividual(p1, p2, FEM, LocalPatch);
482 }

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

Referenced by setParameters().

◆ 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 
)
488 {
489  Individual *mom, *dad;
490  // cout << "--- choosing mum in patch "<<LocalPatch<<" ("<<patch->size(FEM, ADLTx)<<")\n";
491  mom = get_parent(FEM, FEM, patch, LocalPatch, rate_fem);
492 
493  // cout << "--- choosing dad \n";
494 
495  if( RAND::Uniform() > this->getMatingProportion() ) {
496  //random mating
497  do{
498  dad = get_parent(FEM, _dispersing_sex, patch, LocalPatch,
499  (_dispersing_sex == MAL ? rate_mal : rate_fem));
500  }while(dad == mom && _popPtr->getPatchNbr() != 1 && patch->size(FEM, ADLTx) > 1);
501  } else
502  dad = mom;
503 
504  // cout << "--- make offspring by crossing "<<mom->getID()<<" with "<<dad->getID()<<endl;
505 
506  if(! (mom && dad)) return NULL;
507 
508  return _popPtr->makeNewIndividual(mom, dad, FEM, LocalPatch);
509 }
double getMatingProportion()
Definition: LCEbreed.h:100

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().

◆ numFemOffspring()

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

References _dispersing_sex, _get_patchFecundity, ADLTx, FEM, and Patch::size().

Referenced by setParameters().

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

96  {
97  if(patch->get_isExtinct()) {
98 // //check if only one sex sends gametes around, capturing the case of pollen dispersal
99 // if(_dispersing_sex != FEM)
100 // return 0;
101 // else
102  return _num_colonizers;
103  } else
104  return (this->*_get_patchFecundity)(patch, FEM);
105  }
bool get_isExtinct()
Definition: metapop.h:486

References _get_patchFecundity, _num_colonizers, FEM, and Patch::get_isExtinct().

Referenced by setParameters().

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

109  {
110  return 0;
111  }

Referenced by setParameters().

◆ numMalOffspring_random()

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

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

Referenced by setParameters().

◆ numMalOffspring_random_colonizers()

unsigned int LCE_Breed_Disperse::numMalOffspring_random_colonizers ( Patch patch)
inline
124  {
125  if(patch->get_isExtinct()) {
126 // //check if only one sex sends gametes around, capturing the case of pollen dispersal
127 // if(_dispersing_sex != FEM)
128 // return 0;
129 // else
130  return _num_colonizers;
131  } else
132  return (this->*_get_patchFecundity)(patch, MAL);
133  }

References _get_patchFecundity, _num_colonizers, Patch::get_isExtinct(), and MAL.

Referenced by setParameters().

◆ removeAgeClass()

virtual age_t LCE_Breed_Disperse::removeAgeClass ( )
inlinevirtual

Reimplemented from LCE_Disperse_base.

Reimplemented in LCE_Breed_Selection_Disperse.

226 {return NONE;}
#define NONE
No age flag.
Definition: types.h:48

References NONE.

◆ requiredAgeClass()

virtual age_t LCE_Breed_Disperse::requiredAgeClass ( )
inlinevirtual

Reimplemented from LCE_Disperse_base.

Reimplemented in LCE_Breed_Selection_Disperse.

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

225 {return false;}

◆ setParameters()

bool LCE_Breed_Disperse::setParameters ( )
virtual

Reimplemented from LCE_Breed_base.

Reimplemented in LCE_Breed_Selection_Disperse.

62 {
63  if(!LCE_Breed_base::setParameters()) return false;
64 
66 
67  if(!LCE_Disperse_base::setBaseParameters("breed_disperse")) return false;
68 
69  _num_colonizers = (int)get_parameter_value("breed_disperse_colonizers");
70 
71  //some default settings, reset below depending on mating system
76 
77  if(get_parameter("breed_disperse_dispersing_sex")->isSet()) {
78 
79  if (get_parameter("breed_disperse_dispersing_sex")->getArg() == "female") {
81  } else if (get_parameter("breed_disperse_dispersing_sex")->getArg() == "male") {
83  } else {
84  error("the \"breed_disperse_dispersing_sex\" parameter only takes \"female\" or \"male\" as argument\n");
85  }
86 
87  } else { //default depends on mating system
88  // males are the dispersing sex for random mating, female dispersal is always checked, male dispersal is optional
89  if(this->getMatingSystem() == 1)
91  else // all others use females only, since monogamy and polygyny are not allowed here
93  }
94 
95  //check mating system:
96  unsigned int model = this->getMatingSystem();
97 
98  if(model == 2 || model == 3) {
99 
100  return error("Polygyny and Monogamy are not implemented within the breed_disperse LCE.\n");
101 
102  } else if(model == 1) { //promiscuity/random mating
103 
105 
109 
110  } else if(model == 4) { //selfing
111 
112  if(this->getMatingProportion() != 1)
114  else
116 
117  } else if(model == 5) { //cloning
118 
120 
121  } else if(model == 6) { //random mating among hermaphrodites (selfing = 1/N)
122 
124 
125  }
126 
127  //check dispersal model:
128  model = this->getDispersalModel();
129 
130  if(model == 2) //propagule-pool island model
132  else
134 
135  //growth model
136  if(_paramSet->isSet("breed_disperse_growth_model"))
137  model = get_parameter_value("breed_disperse_growth_model");
138  else
139  model = 1;
140 
141  switch (model) {
142  case 1:
144  break;
145  case 2:
147  break;
148  case 3:
150  break;
151  case 4:
153  break;
154  case 5:
156  break;
157  case 6:
159  break;
160  case 7:
162  break;
163  case 8:
165  break;
166  default:
168  break;
169  }
170  //mean fecundity
171  if(_mean_fecundity.get(0,0) == -1) //wasn't set
172  if(model > 3 && model < 8) //4 - 7: conditional logistic growth, fecundity growth
173  return error("parameter \"mean_fecundity\" is needed with growth models 4 to 7 in LCE breed_disperse\n");
174 
175  //growth rate
176  if ((model > 1 && model < 6) || model == 8) {
177 
178  if(!_paramSet->isSet("breed_disperse_growth_rate")) {
179 
180  return error("parameter \"breed_disperse_growth_rate\" needs to be set\n");
181 
182  }
183 
184  if(_growthRates) delete [] _growthRates;
185  _growthRates = new double [ _popPtr->getPatchNbr() ];
186 
187  if(_paramSet->isMatrix("breed_disperse_growth_rate")) {
188 
189  TMatrix tmp;
190 
191  _paramSet->getMatrix("breed_disperse_growth_rate", &tmp);
192 
193  if(tmp.getNbCols() != _popPtr->getPatchNbr()){
194  return error("matrix argument to \"breed_disperse_growth_rate\" has wrong number of elements,\
195  must equal the number of patches.\n");
196  }
197 
198  for (unsigned int i = 0; i < _popPtr->getPatchNbr(); i++) {
199  _growthRates[i] = tmp.get(0, i);
200  }
201 
202 
203  } else { //not a matrix
204 
205  _growthRates[0] = get_parameter_value("breed_disperse_growth_rate");
206 
207  for (unsigned int i = 1; i < _popPtr->getPatchNbr(); i++) {
208  _growthRates[i] = _growthRates[0];
209  }
210  }
211 
212  if(model == 8) { //exponential growth
214  }
215  }
216 
217  return true;
218 }
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:525
unsigned int conditionalLogisticGrowth(Patch *patch, sex_t SEX)
The number of offspring produced depends on the adult density.
Definition: LCEcomposite.h:160
unsigned int numMalOffspring_random_colonizers(Patch *patch)
Definition: LCEcomposite.h:123
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:513
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:428
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:108
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:486
unsigned int conditionalStochasticLogisticGrowth(Patch *patch, sex_t SEX)
The number of offspring produced depends on the adult density, similar to 'conditionalLogisticGrowth'...
Definition: LCEcomposite.h:170
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:472
unsigned int numFemOffspring(Patch *patch)
Definition: LCEcomposite.h:86
unsigned int numFemOffspring_colonizers(Patch *patch)
The number of females produced in case a max number of colonizers was specified.
Definition: LCEcomposite.h:95
unsigned int numMalOffspring_random(Patch *patch)
Definition: LCEcomposite.h:113
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:459
unsigned int instantGrowth(Patch *patch, sex_t SEX)
The number of offspring produced corresponds to the carrying capacity of the patch.
Definition: LCEcomposite.h:138
void do_breed_disperse_propagule()
Definition: LCEcomposite.cc:420
TMatrix _mean_fecundity
Definition: LCEbreed.h:68
virtual bool setParameters()
Definition: LCEbreed.cc:77
bool setBaseParameters(string prefix)
Definition: LCEdisperse.cc:88
void set_isForward(bool val)
Definition: LCEdisperse.h:85
unsigned int getDispersalModel()
Definition: LCEdisperse.h:115
void getMatrix(string name, TMatrix *mat)
Accessor to the parameters matrix.
Definition: param.h:304
bool isMatrix(string name)
Check if the parameter "name" is of matrix type.
Definition: param.h:296
bool isSet()
Accessor to the status flag.
Definition: param.h:288
string getArg()
Definition: param.h:138
bool isSet()
Definition: param.h:140
virtual double get_parameter_value(std::string name)
Param value getter.
Definition: simcomponent.h:143
virtual Param * get_parameter(std::string name)
Param getter.
Definition: simcomponent.h:139
ParamSet * _paramSet
The parameters container.
Definition: simcomponent.h:48
A class to handle matrix in params, coerces matrix into a vector of same total size.
Definition: tmatrix.h:50
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:161
unsigned int getNbCols() const
Gives the number of columns.
Definition: tmatrix.h:215
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, _NatT0, _num_colonizers, SimComponent::_paramSet, LifeCycleEvent::_popPtr, conditionalLogisticGrowth(), conditionalStochasticLogisticGrowth(), do_breed_disperse(), do_breed_disperse_propagule(), error(), exponentialGrowth(), FEM, fixedFecundityGrowth(), TMatrix::get(), SimComponent::get_parameter(), SimComponent::get_parameter_value(), Param::getArg(), LCE_Disperse_base::getDispersalModel(), LCE_Breed_base::getMatingProportion(), LCE_Breed_base::getMatingSystem(), ParamSet::getMatrix(), TMatrix::getNbCols(), Metapop::getPatchNbr(), instantGrowth(), ParamSet::isMatrix(), Param::isSet(), ParamSet::isSet(), logisticGrowth(), MAL, mate_cloning(), mate_full_selfing(), mate_random(), mate_random_hermaphrodite(), mate_selfing(), numFemOffspring(), numFemOffspring_colonizers(), numMalOffspring_notrandom(), numMalOffspring_random(), numMalOffspring_random_colonizers(), TMatrix::reset(), LCE_Disperse_base::set_isForward(), LCE_Disperse_base::setBaseParameters(), LCE_Breed_base::setParameters(), stochasticFecundityGrowth(), and stochasticLogisticGrowth().

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

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

187  {
188  return RAND::Uniform(patch->size(SEX,ADULTS)*LCE_Breed_base::getMeanFecundity(patch->getID()));
189  }

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

Referenced by conditionalStochasticLogisticGrowth(), and setParameters().

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

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

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

Referenced by conditionalStochasticLogisticGrowth(), and setParameters().

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

double* LCE_Breed_Disperse::_growthRates
private

Patch-specific growth rates.

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

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

◆ _NatT0

TMatrix LCE_Breed_Disperse::_NatT0
private

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

Referenced by exponentialGrowth(), and setParameters().

◆ _num_colonizers

int LCE_Breed_Disperse::_num_colonizers
protected

Maximum size of a patch after colonisation.

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


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

Generated for Nemo v2.4.0b by  doxygen 1.9.1 -- Nemo is hosted on  Download Nemo

Locations of visitors to this page
Catalogued on GSR