Nemo  2.3.46
LCEbreed.h
Go to the documentation of this file.
1 
30 #ifndef LCEBREED_H
31 #define LCEBREED_H
32 #include "lifecycleevent.h"
33 #include "Uniform.h"
34 
35 
36 // Class LCE_Breed_base
37 //
43 class LCE_Breed_base : public virtual LifeCycleEvent
44 {
48  unsigned int _mating_males;
49  unsigned int _alpha_male;
54  Individual* (LCE_Breed_base::* DoBreedFuncPtr) (Individual* mother, Individual* father, unsigned int LocalPatch);
55  double (LCE_Breed_base::* FecundityFuncPtr) (double mean);
58 
59 protected:
60 
62 
63 public:
64 
65  LCE_Breed_base ();
66 
67  virtual ~LCE_Breed_base ( ) {if(_mean_fecundity) delete _mean_fecundity;}
68 
75  virtual Individual* getFatherPtr (Patch* thePatch, Individual* mother, unsigned int motherIndex)
76  {
77  return (this->*MatingFuncPtr)(thePatch, mother, motherIndex);
78  }
82  virtual bool setParameters();
84 
87  bool setMatingSystem ();
88  bool setFecundity ();
89  bool setSexRatio ();
94  double getMeanFecundity (unsigned int patch) {return _mean_fecundity->get(0, patch);}
96  bool doInheritance () {return _do_inherit;}
97  double getPoissonFecundity (double mean) {return RAND::Poisson(mean);}
98  double getFixedFecundity (double mean) {return mean;}
99  double getGaussianFecundity(double mean) {
100  double fec; do{fec = mean + RAND::Gaussian(_sd_fecundity);}while(fec < 0);
101  return fec;}
102  double getFecundity (unsigned int patch) {return (this->* FecundityFuncPtr)(_mean_fecundity->get(0, patch));}
103  double getFecundity (double mean) {return (this->* FecundityFuncPtr)(mean);}
104  sex_t getOffsprgSex () {return (this->* GetOffsprgSex) ();}
109 
111 
118  Individual* breed (Individual* mother, Individual* father, unsigned int LocalPatch);
119 
126  Individual* breed_cloning (Individual* mother, Individual* father, unsigned int LocalPatch);
127 
144 
148  Individual* do_breed (Individual* mother, Individual* father, unsigned int LocalPatch)
149  {
150  return (this->* DoBreedFuncPtr)(mother, father, LocalPatch);
151  }
152 
157  bool checkMatingCondition (Patch* thePatch)
158  {
159  return (this->* CheckMatingConditionFuncPtr) (thePatch);
160  }
165  bool checkNoSelfing (Patch* thePatch)
166  {
167  return (thePatch->size(FEM, ADLTx) != 0 && thePatch->size(MAL, ADLTx) != 0);
168  }
169 
174  bool checkPolygyny (Patch* thePatch)
175  {
176  if(thePatch->size(FEM, ADLTx) == 0 || thePatch->size(MAL, ADLTx) == 0) return false;
177 
178 // if(thePatch->size(MAL, ADLTx) < _mating_males) _mating_males = thePatch->size(MAL, ADLTx);
179 
180  _alpha_male = (unsigned int)RAND::Uniform(thePatch->size(MAL, ADLTx));
181 
182  return true;
183  }
184 
189  bool checkSelfing (Patch* thePatch)
190  {
191  if(thePatch->size(MAL, ADLTx) != 0) thePatch->flush(MAL, ADLTx, this->_popPtr);
192  return (thePatch->size(FEM, ADLTx) != 0);
193  }
194 
199  bool checkCloning (Patch* thePatch)
200  {
201  if(thePatch->size(MAL, ADLTx) != 0) thePatch->flush(MAL, ADLTx, this->_popPtr);
202 
203  return (thePatch->size(FEM, ADLTx) != 0);
204  }
205 
206 
209 
214  Individual* RandomMating (Patch* thePatch, Individual* mother, unsigned int motherIndex)
215  { return thePatch->get(MAL, ADLTx, RAND::Uniform(thePatch->size(MAL, ADLTx)) ); }
216 
223  Individual* fullPolyginy (Patch* thePatch, Individual* mother, unsigned int motherIndex)
224  { return thePatch->get(MAL, ADLTx, _alpha_male); }
225 
231  Individual* fullPolyginy_manyMales (Patch* thePatch, Individual* mother, unsigned int motherIndex)
232  {
233  if(thePatch->size(MAL,ADLTx) < _mating_males)
234  return thePatch->get(MAL, ADLTx, RAND::Uniform( thePatch->size(MAL, ADLTx) ) );
235  else
236  return thePatch->get(MAL, ADLTx, RAND::Uniform( _mating_males ) );
237  }
238 
244  Individual* partialPolyginy (Patch* thePatch, Individual* mother, unsigned int motherIndex)
245  {
246  if(RAND::Uniform() > _mating_proportion)
247  return RandomMating(thePatch, mother, 0);
248  else
249  return fullPolyginy(thePatch, 0, 0);
250  }
251 
258  Individual* partialPolyginy_manyMales (Patch* thePatch, Individual* mother, unsigned int motherIndex)
259  {
260  if(RAND::Uniform() > _mating_proportion)
261  return RandomMating(thePatch, mother, 0);
262  else
263  return fullPolyginy_manyMales(thePatch, mother, 0);
264  }
265 
272  Individual* fullMonoginy (Patch* thePatch, Individual* mother, unsigned int motherIndex)
273  {
274  if(thePatch->size(MAL, ADLTx) < motherIndex+1)
275  return RandomMating(thePatch, mother, motherIndex);
276  else
277  return thePatch->get(MAL, ADLTx, motherIndex);
278  }
279 
286  Individual* partialMonoginy (Patch* thePatch, Individual* mother, unsigned int motherIndex)
287  {
288  if(RAND::Uniform() > _mating_proportion || thePatch->size(MAL, ADLTx) < motherIndex+1)
289  return RandomMating(thePatch, mother, motherIndex);
290  else
291  return thePatch->get(MAL, ADLTx, motherIndex);
292  }
293 
299  Individual* fullSelfing (Patch* thePatch, Individual* mother, unsigned int motherIndex)
300  {
301  return mother;
302  }
303 
309  Individual* partialSelfing (Patch* thePatch, Individual* mother, unsigned int motherIndex)
310  {
311  unsigned int fem;
312  if(RAND::Uniform() > _mating_proportion) {
313  do {
314  fem = RAND::Uniform(thePatch->size(FEM, ADLTx));
315  } while(fem == motherIndex && thePatch->size(FEM, ADLTx) != 1);
316  return thePatch->get(FEM, ADLTx, fem);
317  }else
318  return mother;
319  }
320 
326  Individual* random_hermaphrodite (Patch* thePatch, Individual* mother, unsigned int motherIndex)
327  {
328  return thePatch->get(FEM, ADLTx, RAND::Uniform(thePatch->size(FEM, ADLTx)) );
329  }
331 
332 };
333 
334 // Class LCE_Breed
335 //
346 class LCE_Breed : public virtual LCE_Breed_base
347 {
348 
349 public:
350 
351  LCE_Breed ( ) : LifeCycleEvent("breed","") { }
352 
353  virtual ~LCE_Breed ( ) { }
354 
357  virtual bool setParameters ();
358  virtual void execute ();
359 
360  virtual LifeCycleEvent* clone ( ) {return new LCE_Breed();}
361 
362  virtual void loadFileServices ( FileServices* loader ) {}
363  virtual void loadStatServices ( StatServices* loader ) {}
364  virtual age_t removeAgeClass ( ) {return 0;}
365  virtual age_t addAgeClass ( ) {return OFFSPRG;}
366  virtual age_t requiredAgeClass () {return ADULTS;}
368 };
369 
370 #endif //LCEBREED_H
double getPoissonFecundity(double mean)
Definition: LCEbreed.h:97
virtual age_t removeAgeClass()
Definition: LCEbreed.h:364
Individual *(LCE_Breed_base::* MatingFuncPtr)(Patch *, Individual *, unsigned int)
Definition: LCEbreed.h:53
int _mating_system
Definition: LCEbreed.h:47
bool checkPolygyny(Patch *thePatch)
Checks whether mating will take place in the current patch when mating is polygynous.
Definition: LCEbreed.h:174
double getFixedFecundity(double mean)
Definition: LCEbreed.h:98
Individual * partialPolyginy_manyMales(Patch *thePatch, Individual *mother, unsigned int motherIndex)
Returns a pointer to a male from a patch chosen at random if _mating_proportion != 1...
Definition: LCEbreed.h:258
virtual void loadStatServices(StatServices *loader)
Definition: LCEbreed.h:363
The Service class used to manage the StatHandler objects.
Definition: statservices.h:50
#define ADULTS
Adults age class flag (breeders).
Definition: types.h:54
double _sd_fecundity
Definition: LCEbreed.h:50
sex_t getOffsprgSexCloning()
Definition: LCEbreed.h:108
Individual * partialSelfing(Patch *thePatch, Individual *mother, unsigned int motherIndex)
Returns the mother pointer or a random female if _mating_proportion != 1.
Definition: LCEbreed.h:309
bool(LCE_Breed_base::* CheckMatingConditionFuncPtr)(Patch *thePatch)
Definition: LCEbreed.h:56
LCE_Breed()
Definition: LCEbreed.h:351
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:634
virtual ~LCE_Breed()
Definition: LCEbreed.h:353
double getFecundity(unsigned int patch)
Definition: LCEbreed.h:102
bool checkSelfing(Patch *thePatch)
Checks whether mating will take place in the current patch when mating is selfing.
Definition: LCEbreed.h:189
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
Individual * fullPolyginy(Patch *thePatch, Individual *mother, unsigned int motherIndex)
Returns a pointer to the alpha male of the patch.
Definition: LCEbreed.h:223
unsigned int age_t
Age class flags.
Definition: types.h:46
Individual * breed(Individual *mother, Individual *father, unsigned int LocalPatch)
Makes a new individual with the right parents.
Definition: LCEbreed.cc:374
sex_t getOffsprgSex()
Definition: LCEbreed.h:104
sex_t getOffsprgSexSelfing()
Definition: LCEbreed.h:107
virtual ~LCE_Breed_base()
Definition: LCEbreed.h:67
Individual *(LCE_Breed_base::* DoBreedFuncPtr)(Individual *mother, Individual *father, unsigned int LocalPatch)
Definition: LCEbreed.h:54
virtual Individual * getFatherPtr(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.
Definition: LCEbreed.h:75
double get(unsigned int i, unsigned int j)
Accessor to element at row i and column j.
Definition: tmatrix.h:120
Individual * fullSelfing(Patch *thePatch, Individual *mother, unsigned int motherIndex)
Returns the mother pointer.
Definition: LCEbreed.h:299
bool checkCloning(Patch *thePatch)
Checks whether mating will take place in the current patch when mating is cloning.
Definition: LCEbreed.h:199
virtual bool setParameters()
Definition: LCEbreed.cc:71
bool doInheritance()
Definition: LCEbreed.h:96
Second class in the metapopulation design structure, between the Metapop and Individual classes...
Definition: metapop.h:421
virtual LifeCycleEvent * clone()
Definition: LCEbreed.h:360
static double Poisson(double mean)
From the Numerical Recieps.
Definition: Uniform.h:196
virtual void loadFileServices(FileServices *loader)
Definition: LCEbreed.h:362
virtual age_t requiredAgeClass()
Definition: LCEbreed.h:366
Individual * RandomMating(Patch *thePatch, Individual *mother, unsigned int motherIndex)
Returns a pointer to a male drawn randomly from a patch.
Definition: LCEbreed.h:214
virtual age_t addAgeClass()
Definition: LCEbreed.h:365
Base class for the breeding (and mating) life cycle events.
Definition: LCEbreed.h:43
Implementation of the basic breeding and mating procedures, does not link to any trait.
Definition: LCEbreed.h:346
bool _do_inherit
Definition: LCEbreed.h:51
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:381
virtual void execute()
Definition: LCEbreed.cc:420
double getFecundity(double mean)
Definition: LCEbreed.h:103
TMatrix * _mean_fecundity
Definition: LCEbreed.h:61
Individual * do_breed(Individual *mother, Individual *father, unsigned int LocalPatch)
Calls the breeding function unsing its pointer.
Definition: LCEbreed.h:148
sex_t getOffsprgSexFixed()
Definition: LCEbreed.cc:352
sex_t
Sex types, males are always 0 and females 1!!
Definition: types.h:36
Definition: types.h:42
double getMeanFecundity(unsigned int patch)
Definition: LCEbreed.h:94
unsigned int _alpha_male
Definition: LCEbreed.h:49
Individual * fullMonoginy(Patch *thePatch, Individual *mother, unsigned int motherIndex)
Returns a pointer to a male with same index as mother (if available) from the focal patch...
Definition: LCEbreed.h:272
double(LCE_Breed_base::* FecundityFuncPtr)(double mean)
Definition: LCEbreed.h:55
bool checkMatingCondition(Patch *thePatch)
Checks if any mating will take place in the patch passed as argument.
Definition: LCEbreed.h:157
bool setFecundity()
Definition: LCEbreed.cc:277
Individual * random_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 m...
Definition: LCEbreed.h:326
A class to handle matrix in params, coerces matrix into a vector of same total size.
Definition: tmatrix.h:49
static double Gaussian(double sigma)
Definition: Uniform.h:238
static double Uniform()
Generates a random number from [0.0, 1.0[ uniformly distributed.
Definition: Uniform.h:101
double getMatingProportion()
Definition: LCEbreed.h:93
Individual * partialPolyginy(Patch *thePatch, Individual *mother, unsigned int motherIndex)
Returns a pointer to a male from a patch chosen at random if _mating_proportion != 1...
Definition: LCEbreed.h:244
sex_t getOffsprgSexRandom()
Definition: LCEbreed.h:105
double getGaussianFecundity(double mean)
Definition: LCEbreed.h:99
Definition: types.h:37
bool setMatingSystem()
Definition: LCEbreed.cc:78
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:523
#define OFFSPRG
Offspring age class flag.
Definition: types.h:50
bool setSexRatio()
Definition: LCEbreed.cc:244
A class to manage the files associated with each components of the simulation.
Definition: fileservices.h:51
unsigned int _mating_males
Definition: LCEbreed.h:48
static bool RandBool()
Returns a random boolean.
Definition: Uniform.h:139
int getMatingSystem()
Definition: LCEbreed.h:95
Individual * fullPolyginy_manyMales(Patch *thePatch, Individual *mother, unsigned int motherIndex)
Returns a pointer to one of the first _mating_males males of the patch.
Definition: LCEbreed.h:231
This class contains traits along with other individual information (sex, pedigree, etc. ).
Definition: individual.h:49
Definition: types.h:37
Individual * partialMonoginy(Patch *thePatch, Individual *mother, unsigned int motherIndex)
Returns a pointer to a male with same index as mother (if available) from the focal patch...
Definition: LCEbreed.h:286
Individual * makeOffspring(Individual *ind)
Last step of the breeding process, does inheritance and mutation of the parents' genes.
Definition: LCEbreed.cc:362
Base class of the Life Cycle Events, declares the LCE interface.
Definition: lifecycleevent.h:72
virtual bool setParameters()
Definition: LCEbreed.cc:413
double _mating_proportion
Definition: LCEbreed.h:50
LCE_Breed_base()
Definition: LCEbreed.cc:44
sex_t(LCE_Breed_base::* GetOffsprgSex)()
Definition: LCEbreed.h:57
bool checkNoSelfing(Patch *thePatch)
Checks whether mating will take place in the current patch when mating is not selfing or cloning...
Definition: LCEbreed.h:165

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