Nemo  2.3.46
LCEcomposite.h
Go to the documentation of this file.
1 
30 #ifndef LCE_COMPOSITE_H
31 #define LCE_COMPOSITE_H
32 
33 #include <cmath>
34 #include "LCEbreed.h"
35 #include "LCEdisperse.h"
36 #include "LCEselection.h"
37 #include "lifecycleevent.h"
38 
39 //CLASS LCE_Breed_Disperse
40 //
45 class LCE_Breed_Disperse : public virtual LCE_Breed_base, public virtual LCE_Disperse_base
46 {
48 
51 
54 
56  double *_growthRates;
57 
58 protected: //so that the derived class can use these function pointers
59  Individual* (LCE_Breed_Disperse::* _make_offspring)(sex_t SEX, Patch* patch, unsigned int LocalPatch);
62  unsigned int (LCE_Breed_Disperse::* _get_patchFecundity )(Patch* patch, sex_t SEX);
63 
64 public:
65 
67 
68  virtual ~LCE_Breed_Disperse (){if(_growthRates) delete [] _growthRates;}
69 
70  void do_breed_disperse ();
72 
73 
74  unsigned int numFemOffspring (Patch *patch)
75  {
76  if (patch->size(FEM, ADLTx) == 0 && _dispersing_sex != FEM)//to avoid choosing a local female when there is none
77  return 0;
78  else
79  return (this->*_get_patchFecundity)(patch, FEM);
80  }
81 
83  unsigned int numFemOffspring_colonizers (Patch *patch)
84  {
85  if(patch->get_isExtinct()) {
86  //check if only one sex sends gametes around, capturing the case of pollen dispersal
87  if(_dispersing_sex != FEM)
88  return 0;
89  else
90  return _num_colonizers;
91  } else
92  return (this->*_get_patchFecundity)(patch, FEM);
93  }
94 
96  unsigned int numMalOffspring_notrandom (Patch *patch)
97  {
98  return 0;
99  }
100 
101  unsigned int numMalOffspring_random (Patch *patch)
102  { //return 0 if only males gametes migrate and there is no females in the patch
103  //to avoid choosing a local female when there is none
104  //(we assume it doesn't make sense to have only female gametes migrating)
105  if (patch->size(FEM, ADLTx) == 0 && _dispersing_sex != FEM)
106  return 0;
107  else
108  return (this->*_get_patchFecundity)(patch, MAL);
109  }
110 
112  {
113  if(patch->get_isExtinct()) {
114  //check if only one sex sends gametes around, capturing the case of pollen dispersal
115  if(_dispersing_sex != FEM)
116  return 0;
117  else
118  return _num_colonizers;
119  } else
120  return (this->*_get_patchFecundity)(patch, MAL);
121  }
122 
125 
126  unsigned int instantGrowth (Patch* patch, sex_t SEX)
127  {
128  return patch->get_K(SEX);
129  }
131  unsigned int logisticGrowth (Patch* patch, sex_t SEX)
132  {
133  double K = (double)patch->get_K(SEX);
134  double r = _growthRates[ patch->getID() ];
135  double N = (double)patch->size(ADLTx);
136  return (unsigned int)ceil(N + r*N*((K-N)/K));
137  }
139  unsigned int stochasticLogisticGrowth (Patch* patch, sex_t SEX)
140  {
141  return (unsigned int)RAND::Poisson((double)logisticGrowth(patch, SEX));
142  }
145  unsigned int conditionalLogisticGrowth (Patch* patch, sex_t SEX)
146  {
147  if (patch->size(SEX, ADLTx) < patch->get_K(SEX)/2) {
148  return fixedFecundityGrowth(patch, SEX);
149  } else {
150  return logisticGrowth(patch, SEX);
151  }
152  }
156  {
157  if (patch->size(SEX, ADLTx) < patch->get_K(SEX)/2) {
158  return stochasticFecundityGrowth(patch, SEX);
159  } else {
160  return stochasticLogisticGrowth(patch, SEX);
161  }
162  }
165  unsigned int fixedFecundityGrowth (Patch* patch, sex_t SEX)
166  {
167  return patch->get_K(SEX)*LCE_Breed_base::getMeanFecundity(patch->getID());
168  }
171  unsigned int stochasticFecundityGrowth (Patch* patch, sex_t SEX)
172  {
173  return RAND::Uniform(patch->get_K(SEX)*LCE_Breed_base::getMeanFecundity(patch->getID()));
174  }
176 
179  Individual* mate_random (sex_t SEX, Patch *patch, unsigned int LocalPatch);
180  Individual* mate_random_hermaphrodite (sex_t SEX, Patch *patch, unsigned int LocalPatch);
181  Individual* mate_selfing (sex_t SEX, Patch *patch, unsigned int LocalPatch);
182  Individual* mate_full_selfing (sex_t SEX, Patch *patch, unsigned int LocalPatch);
183  Individual* mate_cloning (sex_t SEX, Patch *patch, unsigned int LocalPatch);
185  void breed_disperse(sex_t SEX, Patch *patch, unsigned int LocalPatch, unsigned int size);
186 
187  Individual* get_parent (sex_t SEX, sex_t DispSex, Patch* LocalPatch, unsigned int patchNbr);
189 
192 // virtual void init(Metapop* popPtr);
193  virtual bool setParameters ();
194  virtual void execute ();
195  virtual LifeCycleEvent* clone () {return new LCE_Breed_Disperse();}
196  virtual void loadFileServices ( FileServices* loader ) {}
197  virtual void loadStatServices ( StatServices* loader ) {}
198  virtual age_t removeAgeClass ( ) {return NONE;}
199  virtual age_t addAgeClass ( ) {return OFFSPRG;}
200  virtual age_t requiredAgeClass () {return ADULTS;}
202 
203 };
204 
205 // Class LCE_Breed_Selection
206 //
209 class LCE_Breed_Selection : public virtual LCE_Breed_base, public virtual LCE_Selection_base
210 {
211 
212  void (LCE_Breed_Selection::* _breed_selection) (Patch* patch, unsigned int patchID, unsigned int *cntr);
213 
214  unsigned int _nb_trait;
215 
216  vector< unsigned int > _nonSelectedTraitIndices;
217 
218 public:
219 
220  LCE_Breed_Selection ( ); // : LifeCycleEvent("breed_selection","") {}
221  virtual ~LCE_Breed_Selection ( ) {}
222 
224  bool setNonSelectedTraitTable ();
225 
232  Individual* makeOffspringWithSelection (Individual* ind, unsigned int natalpatch);
233 
234  void do_breed_selection_FecFitness (Patch* patch, unsigned int patchID, unsigned int *cntr);
235  void do_breed_selection_OffSurvival (Patch* patch, unsigned int patchID, unsigned int *cntr);
236 
239 // virtual void init (Metapop* popPtr);
240  virtual bool setParameters ();
241  virtual void execute ();
242  virtual LifeCycleEvent* clone ( ){ return new LCE_Breed_Selection(); }
243  virtual void loadFileServices ( FileServices* loader ) {}
244  virtual void loadStatServices ( StatServices* loader );
245  virtual age_t removeAgeClass ( ) {return NONE;}
246  virtual age_t addAgeClass ( ) {return OFFSPRG;}
247  virtual age_t requiredAgeClass () {return ADULTS;}
249 };
250 
251 //CLASS LCE_Breed_Selection_Disperse
252 //
260 {
261 // int _max_try;
262 
264 
265 public:
266 
268 
270 
271  void breed_selection_disperse(int* counter);
272  void breed_selection_disperse_propagule(int* counter);
273 
274  void do_breed (sex_t SEX, unsigned int size, int* counter, Patch* patch, unsigned int patchNbr);
275 
278 // virtual void init(Metapop* popPtr);
279  virtual bool setParameters ();
280  virtual void execute ();
282  virtual void loadFileServices ( FileServices* loader ) {}
283  virtual void loadStatServices ( StatServices* loader );
284  virtual age_t removeAgeClass ( ) {return NONE;}
285  virtual age_t addAgeClass ( ) {return OFFSPRG;}
286  virtual age_t requiredAgeClass () {return ADULTS;}
288 };
289 #endif
virtual ~LCE_Breed_Selection()
Definition: LCEcomposite.h:221
virtual LifeCycleEvent * clone()
Definition: LCEcomposite.h:195
Individual * mate_full_selfing(sex_t SEX, Patch *patch, unsigned int LocalPatch)
Definition: LCEcomposite.cc:312
unsigned int numMalOffspring_random(Patch *patch)
Definition: LCEcomposite.h:101
Performs breeding and migration in one, migration rates are backward rates.
Definition: LCEcomposite.h:45
The Service class used to manage the StatHandler objects.
Definition: statservices.h:50
void do_breed_disperse()
Definition: LCEcomposite.cc:233
void breed_selection_disperse_propagule(int *counter)
Definition: LCEcomposite.cc:469
#define ADULTS
Adults age class flag (breeders).
Definition: types.h:54
LCE_Breed_Disperse()
Definition: LCEcomposite.cc:39
LCE_Breed_Selection_Disperse()
Definition: LCEcomposite.cc:368
virtual void loadFileServices(FileServices *loader)
Definition: LCEcomposite.h:282
virtual age_t removeAgeClass()
Definition: LCEcomposite.h:284
virtual void loadFileServices(FileServices *loader)
Definition: LCEcomposite.h:196
unsigned int size(age_t AGE)
Returns the size of the container of the appropriate age class(es) for both sexes.
Definition: metapop.h:487
virtual ~LCE_Breed_Selection_Disperse()
Definition: LCEcomposite.h:269
unsigned int age_t
Age class flags.
Definition: types.h:46
unsigned int conditionalLogisticGrowth(Patch *patch, sex_t SEX)
The number of offspring produced depends on the adult density.
Definition: LCEcomposite.h:145
unsigned int(LCE_Breed_Disperse::* _get_patchFecundity)(Patch *patch, sex_t SEX)
Definition: LCEcomposite.h:62
unsigned int getID()
Definition: metapop.h:469
void(LCE_Breed_Disperse::* _breed_disperse)()
Definition: LCEcomposite.h:47
unsigned int numFemOffspring_colonizers(Patch *patch)
The number of females produced in case a max number of colonizers was specified.
Definition: LCEcomposite.h:83
unsigned int instantGrowth(Patch *patch, sex_t SEX)
The number of offspring produced corresponds to the carrying capacity of the patch.
Definition: LCEcomposite.h:126
unsigned int _nb_trait
Definition: LCEcomposite.h:214
unsigned int(LCE_Breed_Disperse::* _get_numMalOffspring)(Patch *patch)
Definition: LCEcomposite.h:61
virtual LifeCycleEvent * clone()
Definition: LCEcomposite.h:281
Second class in the metapopulation design structure, between the Metapop and Individual classes...
Definition: metapop.h:421
#define NONE
No age flag.
Definition: types.h:48
static double Poisson(double mean)
From the Numerical Recieps.
Definition: Uniform.h:196
vector< unsigned int > _nonSelectedTraitIndices
Definition: LCEcomposite.h:216
bool get_isExtinct()
Definition: metapop.h:475
virtual age_t addAgeClass()
Definition: LCEcomposite.h:199
Composite LCE implementing breeding and viability selection on a given trait type.
Definition: LCEcomposite.h:209
Base class for the breeding (and mating) life cycle events.
Definition: LCEbreed.h:43
Individual * makeOffspringWithSelection(Individual *ind, unsigned int natalpatch)
Performs viability selection and breeding at the same time.
Definition: LCEcomposite.cc:690
Individual * mate_cloning(sex_t SEX, Patch *patch, unsigned int LocalPatch)
Definition: LCEcomposite.cc:321
virtual void execute()
Definition: LCEcomposite.cc:406
sex_t
Sex types, males are always 0 and females 1!!
Definition: types.h:36
virtual age_t addAgeClass()
Definition: LCEcomposite.h:285
Definition: types.h:42
double getMeanFecundity(unsigned int patch)
Definition: LCEbreed.h:94
unsigned int(LCE_Breed_Disperse::* _get_numFemOffspring)(Patch *patch)
Definition: LCEcomposite.h:60
virtual age_t removeAgeClass()
Definition: LCEcomposite.h:198
Individual * mate_random(sex_t SEX, Patch *patch, unsigned int LocalPatch)
Definition: LCEcomposite.cc:269
unsigned int get_K()
Definition: metapop.h:470
void do_breed_disperse_propagule()
Definition: LCEcomposite.cc:261
Individual *(LCE_Breed_Disperse::* _make_offspring)(sex_t SEX, Patch *patch, unsigned int LocalPatch)
Definition: LCEcomposite.h:59
bool setNonSelectedTraitTable()
Builds the vector of traits not under selection.
Definition: LCEcomposite.cc:531
Base class performing (viability) selection on an arbitrary trait.
Definition: LCEselection.h:50
virtual void loadStatServices(StatServices *loader)
Definition: LCEcomposite.h:197
The base class of the dispersal LCEs, all events move offspring to the post-dispersal patch container...
Definition: LCEdisperse.h:39
unsigned int conditionalStochasticLogisticGrowth(Patch *patch, sex_t SEX)
The number of offspring produced depends on the adult density, similar to 'conditionalLogisticGrowth'...
Definition: LCEcomposite.h:155
static double Uniform()
Generates a random number from [0.0, 1.0[ uniformly distributed.
Definition: Uniform.h:101
virtual bool setParameters()
Definition: LCEcomposite.cc:55
void do_breed_selection_FecFitness(Patch *patch, unsigned int patchID, unsigned int *cntr)
Definition: LCEcomposite.cc:644
virtual age_t removeAgeClass()
Definition: LCEcomposite.h:245
virtual age_t requiredAgeClass()
Definition: LCEcomposite.h:247
virtual void execute()
Definition: LCEcomposite.cc:204
double * _growthRates
Patch-specific growth rates.
Definition: LCEcomposite.h:56
void(LCE_Breed_Selection::* _breed_selection)(Patch *patch, unsigned int patchID, unsigned int *cntr)
Definition: LCEcomposite.h:212
unsigned int numFemOffspring(Patch *patch)
Definition: LCEcomposite.h:74
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:139
Individual * makeOffspring(Individual *ind)
Individual * mate_random_hermaphrodite(sex_t SEX, Patch *patch, unsigned int LocalPatch)
Definition: LCEcomposite.cc:278
Composite LCE performing breeding, migration and viability selection all in one.
Definition: LCEcomposite.h:259
Definition: types.h:37
Individual * get_parent(sex_t SEX, sex_t DispSex, Patch *LocalPatch, unsigned int patchNbr)
Definition: LCEcomposite.cc:328
void breed_disperse(sex_t SEX, Patch *patch, unsigned int LocalPatch, unsigned int size)
sex_t _dispersing_sex
Which part of the population is dispersing its gametes.
Definition: LCEcomposite.h:53
virtual bool setParameters()
Definition: LCEcomposite.cc:510
#define OFFSPRG
Offspring age class flag.
Definition: types.h:50
virtual void loadStatServices(StatServices *loader)
Definition: LCEcomposite.cc:560
unsigned int logisticGrowth(Patch *patch, sex_t SEX)
The number of offspring produced is given by the logistic growth function.
Definition: LCEcomposite.h:131
int _num_colonizers
Maximum size of a patch after colonisation.
Definition: LCEcomposite.h:50
virtual age_t addAgeClass()
Definition: LCEcomposite.h:246
virtual ~LCE_Breed_Disperse()
Definition: LCEcomposite.h:68
virtual LifeCycleEvent * clone()
Definition: LCEcomposite.h:242
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:96
virtual void execute()
Definition: LCEcomposite.cc:567
void(LCE_Breed_Selection_Disperse::* _breed_selection_disperse)(int *counter)
Definition: LCEcomposite.h:263
LCE_Breed_Selection()
Definition: LCEcomposite.cc:502
unsigned int numMalOffspring_random_colonizers(Patch *patch)
Definition: LCEcomposite.h:111
A class to manage the files associated with each components of the simulation.
Definition: fileservices.h:51
void do_breed_selection_OffSurvival(Patch *patch, unsigned int patchID, unsigned int *cntr)
Definition: LCEcomposite.cc:608
This class contains traits along with other individual information (sex, pedigree, etc. ).
Definition: individual.h:49
Definition: types.h:37
unsigned int fixedFecundityGrowth(Patch *patch, sex_t SEX)
The number of offspring produced is equal to the carrying capacity multiplied by the mean fecundity o...
Definition: LCEcomposite.h:165
virtual age_t requiredAgeClass()
Definition: LCEcomposite.h:286
Individual * mate_selfing(sex_t SEX, Patch *patch, unsigned int LocalPatch)
Definition: LCEcomposite.cc:288
virtual age_t requiredAgeClass()
Definition: LCEcomposite.h:200
Base class of the Life Cycle Events, declares the LCE interface.
Definition: lifecycleevent.h:72
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:171
void do_breed(sex_t SEX, unsigned int size, int *counter, Patch *patch, unsigned int patchNbr)
Definition: LCEcomposite.cc:477
virtual void loadStatServices(StatServices *loader)
Definition: LCEcomposite.cc:399
virtual void loadFileServices(FileServices *loader)
Definition: LCEcomposite.h:243
void breed_selection_disperse(int *counter)
Definition: LCEcomposite.cc:443
virtual bool setParameters()
Definition: LCEcomposite.cc:377

Generated for Nemo v2.3.0 by  doxygen 1.8.8 --
Catalogued on GSR