Nemo  2.3.56
Simulate forward-in-time genetic evolution in a spatially explicit, individual-based stochastic simulator
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//
43class 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
59protected:
60
63
64public:
65
67
68 virtual ~LCE_Breed_base ( ) {}
69
76 virtual Individual* getFatherPtr (Patch* thePatch, Individual* mother, unsigned int motherIndex)
77 {
78 return (this->*MatingFuncPtr)(thePatch, mother, motherIndex);
79 }
83 virtual bool setParameters();
85
88 bool setMatingSystem ();
89 bool setFecundity ();
90 bool setSexRatio ();
95 double getMeanFecundity (unsigned int patch) {return _mean_fecundity.get(0, patch);}
97 bool doInheritance () {return _do_inherit;}
98 double getPoissonFecundity (double mean) {return RAND::Poisson(mean);}
99 double getFixedFecundity (double mean) {return (mean < 0) ? 0 : mean;}
100 double getGaussianFecundity(double mean) {
101 double fec; do{fec = mean + RAND::Gaussian(_sd_fecundity);}while(fec < 0);
102 return fec;}
103 double getLogNormalFecundity(double mean) {
104 double fec; do{fec = mean + RAND::LogNormal(mean, _sd_fecundity);}while(fec < 0);
105 return fec;}
106 double getFecundity (unsigned int patch) {return (this->* FecundityFuncPtr)(_mean_fecundity.get(0, patch));}
107 double getFecundity (double mean) {return (this->* FecundityFuncPtr)(mean);}
108 sex_t getOffsprgSex () {return (this->* GetOffsprgSex) ();}
113
116
118
126 Individual* breed (Individual* mother, Individual* father, unsigned int LocalPatch);
127
134 Individual* breed_cloning (Individual* mother, Individual* father, unsigned int LocalPatch);
135
152
156 Individual* do_breed (Individual* mother, Individual* father, unsigned int LocalPatch)
157 {
158 return (this->* DoBreedFuncPtr)(mother, father, LocalPatch);
159 }
160
166 {
167 return (this->* CheckMatingConditionFuncPtr) (thePatch);
168 }
173 bool checkNoSelfing (Patch* thePatch)
174 {
175 return (thePatch->size(FEM, ADLTx) != 0 && thePatch->size(MAL, ADLTx) != 0);
176 }
177
182 bool checkPolygyny (Patch* thePatch)
183 {
184 if(thePatch->size(FEM, ADLTx) == 0 || thePatch->size(MAL, ADLTx) == 0) return false;
185
186// if(thePatch->size(MAL, ADLTx) < _mating_males) _mating_males = thePatch->size(MAL, ADLTx);
187
188 _alpha_male = (unsigned int)RAND::Uniform(thePatch->size(MAL, ADLTx));
189
190 return true;
191 }
192
197 bool checkSelfing (Patch* thePatch)
198 {
199 if(thePatch->size(MAL, ADLTx) != 0) thePatch->flush(MAL, ADLTx, this->_popPtr);
200 return (thePatch->size(FEM, ADLTx) != 0);
201 }
202
207 bool checkCloning (Patch* thePatch)
208 {
209 if(thePatch->size(MAL, ADLTx) != 0) thePatch->flush(MAL, ADLTx, this->_popPtr);
210
211 return (thePatch->size(FEM, ADLTx) != 0);
212 }
213
214
217
222 Individual* RandomMating (Patch* thePatch, Individual* mother, unsigned int motherIndex)
223 { return thePatch->get(MAL, ADLTx, RAND::Uniform(thePatch->size(MAL, ADLTx)) ); }
224
231 Individual* fullPolyginy (Patch* thePatch, Individual* mother, unsigned int motherIndex)
232 { return thePatch->get(MAL, ADLTx, _alpha_male); }
233
239 Individual* fullPolyginy_manyMales (Patch* thePatch, Individual* mother, unsigned int motherIndex)
240 {
241 if(thePatch->size(MAL,ADLTx) < _mating_males)
242 return thePatch->get(MAL, ADLTx, RAND::Uniform( thePatch->size(MAL, ADLTx) ) );
243 else
244 return thePatch->get(MAL, ADLTx, RAND::Uniform( _mating_males ) );
245 }
246
252 Individual* partialPolyginy (Patch* thePatch, Individual* mother, unsigned int motherIndex)
253 {
255 return RandomMating(thePatch, mother, 0);
256 else
257 return fullPolyginy(thePatch, 0, 0);
258 }
259
266 Individual* partialPolyginy_manyMales (Patch* thePatch, Individual* mother, unsigned int motherIndex)
267 {
269 return RandomMating(thePatch, mother, 0);
270 else
271 return fullPolyginy_manyMales(thePatch, mother, 0);
272 }
273
280 Individual* fullMonoginy (Patch* thePatch, Individual* mother, unsigned int motherIndex)
281 {
282 if(thePatch->size(MAL, ADLTx) < motherIndex+1)
283 return RandomMating(thePatch, mother, motherIndex);
284 else
285 return thePatch->get(MAL, ADLTx, motherIndex);
286 }
287
294 Individual* partialMonoginy (Patch* thePatch, Individual* mother, unsigned int motherIndex)
295 {
296 if(RAND::Uniform() > _mating_proportion || thePatch->size(MAL, ADLTx) < motherIndex+1)
297 return RandomMating(thePatch, mother, motherIndex);
298 else
299 return thePatch->get(MAL, ADLTx, motherIndex);
300 }
301
307 Individual* fullSelfing (Patch* thePatch, Individual* mother, unsigned int motherIndex)
308 {
309 return mother;
310 }
311
317 Individual* partialSelfing (Patch* thePatch, Individual* mother, unsigned int motherIndex)
318 {
319 unsigned int fem;
321 do {
322 fem = RAND::Uniform(thePatch->size(FEM, ADLTx));
323 } while(fem == motherIndex && thePatch->size(FEM, ADLTx) != 1);
324 return thePatch->get(FEM, ADLTx, fem);
325 }else
326 return mother;
327 }
328
334 Individual* random_hermaphrodite (Patch* thePatch, Individual* mother, unsigned int motherIndex)
335 {
336 return thePatch->get(FEM, ADLTx, RAND::Uniform(thePatch->size(FEM, ADLTx)) );
337 }
339
340};
341
342// Class LCE_Breed
343//
354class LCE_Breed : public virtual LCE_Breed_base
355{
356
357public:
358
359 LCE_Breed ( ) : LifeCycleEvent("breed","") { }
360
361 virtual ~LCE_Breed ( ) { }
362
365 virtual bool setParameters ();
366 virtual void execute ();
367
368 virtual LifeCycleEvent* clone ( ) {return new LCE_Breed();}
369
370 virtual void loadFileServices ( FileServices* loader ) {}
371 virtual void loadStatServices ( StatServices* loader ) {}
372 virtual bool resetParameterFromSource (std::string param, SimComponent* cmpt) {return false;}
373 virtual age_t removeAgeClass ( ) {return 0;}
374 virtual age_t addAgeClass ( ) {return OFFSPRG;}
375 virtual age_t requiredAgeClass () {return ADULTS;}
377};
378
379#endif //LCEBREED_H
A class to manage the files associated with each components of the simulation.
Definition: fileservices.h:52
This class contains traits along with other individual information (sex, pedigree,...
Definition: individual.h:49
Base class for the breeding (and mating) life cycle events.
Definition: LCEbreed.h:44
bool checkPolygyny(Patch *thePatch)
Checks whether mating will take place in the current patch when mating is polygynous.
Definition: LCEbreed.h:182
sex_t getOffsprgSex()
Definition: LCEbreed.h:108
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:294
void NonWrightFisherPopulation()
Definition: LCEbreed.cc:454
unsigned int _alpha_male
Definition: LCEbreed.h:49
void WrightFisherPopulation()
Definition: LCEbreed.cc:502
Individual *(LCE_Breed_base::* MatingFuncPtr)(Patch *, Individual *, unsigned int)
Definition: LCEbreed.h:53
Individual * do_breed(Individual *mother, Individual *father, unsigned int LocalPatch)
Calls the breeding function unsing its pointer.
Definition: LCEbreed.h:156
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:334
virtual ~LCE_Breed_base()
Definition: LCEbreed.h:68
double getFixedFecundity(double mean)
Definition: LCEbreed.h:99
sex_t getOffsprgSexSelfing()
Definition: LCEbreed.h:111
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:252
Individual * breed(Individual *mother, Individual *father, unsigned int LocalPatch)
Makes a new individual with the right parents.
Definition: LCEbreed.cc:419
Individual * partialSelfing(Patch *thePatch, Individual *mother, unsigned int motherIndex)
Returns the mother pointer or a random female if _mating_proportion != 1.
Definition: LCEbreed.h:317
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:266
int getMatingSystem()
Definition: LCEbreed.h:96
virtual Individual * getFatherPtr(Patch *thePatch, Individual *mother, unsigned int motherIndex)
Calls the mating function according to the model chosen using the function pointer,...
Definition: LCEbreed.h:76
double getFecundity(double mean)
Definition: LCEbreed.h:107
bool _do_inherit
Definition: LCEbreed.h:51
double getGaussianFecundity(double mean)
Definition: LCEbreed.h:100
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:239
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:280
Individual * makeOffspring(Individual *ind)
Last step of the breeding process, does inheritance and mutation of the parents' genes.
Definition: LCEbreed.cc:407
double _sd_fecundity
Definition: LCEbreed.h:50
sex_t(LCE_Breed_base::* GetOffsprgSex)()
Definition: LCEbreed.h:57
double(LCE_Breed_base::* FecundityFuncPtr)(double mean)
Definition: LCEbreed.h:55
Individual * fullPolyginy(Patch *thePatch, Individual *mother, unsigned int motherIndex)
Returns a pointer to the alpha male of the patch.
Definition: LCEbreed.h:231
double getMatingProportion()
Definition: LCEbreed.h:94
void(LCE_Breed_base::* PopModelFuncPtr)(void)
Definition: LCEbreed.h:61
double getLogNormalFecundity(double mean)
Definition: LCEbreed.h:103
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:426
double _mating_proportion
Definition: LCEbreed.h:50
bool setMatingSystem()
Definition: LCEbreed.cc:82
bool checkCloning(Patch *thePatch)
Checks whether mating will take place in the current patch when mating is cloning.
Definition: LCEbreed.h:207
bool checkNoSelfing(Patch *thePatch)
Checks whether mating will take place in the current patch when mating is not selfing or cloning.
Definition: LCEbreed.h:173
bool setFecundity()
Definition: LCEbreed.cc:319
sex_t getOffsprgSexRandom()
Definition: LCEbreed.h:109
Individual *(LCE_Breed_base::* DoBreedFuncPtr)(Individual *mother, Individual *father, unsigned int LocalPatch)
Definition: LCEbreed.h:54
bool doInheritance()
Definition: LCEbreed.h:97
bool checkMatingCondition(Patch *thePatch)
Checks if any mating will take place in the patch passed as argument.
Definition: LCEbreed.h:165
Individual * RandomMating(Patch *thePatch, Individual *mother, unsigned int motherIndex)
Returns a pointer to a male drawn randomly from a patch.
Definition: LCEbreed.h:222
bool(LCE_Breed_base::* CheckMatingConditionFuncPtr)(Patch *thePatch)
Definition: LCEbreed.h:56
double getPoissonFecundity(double mean)
Definition: LCEbreed.h:98
sex_t getOffsprgSexFixed()
Definition: LCEbreed.cc:397
unsigned int _mating_males
Definition: LCEbreed.h:48
LCE_Breed_base()
Definition: LCEbreed.cc:44
sex_t getOffsprgSexCloning()
Definition: LCEbreed.h:112
Individual * fullSelfing(Patch *thePatch, Individual *mother, unsigned int motherIndex)
Returns the mother pointer.
Definition: LCEbreed.h:307
TMatrix _mean_fecundity
Definition: LCEbreed.h:62
bool checkSelfing(Patch *thePatch)
Checks whether mating will take place in the current patch when mating is selfing.
Definition: LCEbreed.h:197
int _mating_system
Definition: LCEbreed.h:47
bool setSexRatio()
Definition: LCEbreed.cc:279
double getMeanFecundity(unsigned int patch)
Definition: LCEbreed.h:95
double getFecundity(unsigned int patch)
Definition: LCEbreed.h:106
virtual bool setParameters()
Definition: LCEbreed.cc:75
Implementation of the basic breeding and mating procedures, does not link to any trait.
Definition: LCEbreed.h:355
virtual age_t requiredAgeClass()
Definition: LCEbreed.h:375
virtual bool setParameters()
Definition: LCEbreed.cc:554
virtual void loadFileServices(FileServices *loader)
Definition: LCEbreed.h:370
virtual bool resetParameterFromSource(std::string param, SimComponent *cmpt)
Definition: LCEbreed.h:372
virtual void execute()
Definition: LCEbreed.cc:561
virtual void loadStatServices(StatServices *loader)
Definition: LCEbreed.h:371
virtual ~LCE_Breed()
Definition: LCEbreed.h:361
virtual LifeCycleEvent * clone()
Definition: LCEbreed.h:368
virtual age_t addAgeClass()
Definition: LCEbreed.h:374
LCE_Breed()
Definition: LCEbreed.h:359
virtual age_t removeAgeClass()
Definition: LCEbreed.h:373
Base class of the Life Cycle Events, declares the LCE interface.
Definition: lifecycleevent.h:73
Metapop * _popPtr
The ptr to the current Metapop.
Definition: lifecycleevent.h:81
Second class in the metapopulation design structure, between the Metapop and Individual classes.
Definition: metapop.h:430
unsigned int size(age_t AGE)
Returns the size of the container of the appropriate age class(es) for both sexes.
Definition: metapop.h:496
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:643
Individual * get(sex_t SEX, age_idx AGE, unsigned int at)
Returns a pointer to the individual sitting at the index passed.
Definition: metapop.h:532
static double Poisson(double mean)
From the Numerical Recieps.
Definition: Uniform.h:220
static double Gaussian(double sigma)
Definition: Uniform.h:262
static double Uniform()
Generates a random number from [0.0, 1.0[ uniformly distributed.
Definition: Uniform.h:125
static bool RandBool()
Returns a random boolean.
Definition: Uniform.h:163
static double LogNormal(double zeta, double sigma)
Definition: Uniform.h:358
Interface to all basic components of a simulation (traits, life cycle events, pop,...
Definition: simcomponent.h:45
The Service class used to manage the StatHandler objects.
Definition: statservices.h:50
A class to handle matrix in params, coerces matrix into a vector of same total size.
Definition: tmatrix.h:49
double get(unsigned int i, unsigned int j)
Accessor to element at row i and column j.
Definition: tmatrix.h:147
sex_t
Sex types, males are always 0 and females 1!!
Definition: types.h:36
@ FEM
Definition: types.h:37
@ MAL
Definition: types.h:37
unsigned int age_t
Age class flags.
Definition: types.h:46
#define ADULTS
Adults age class flag (breeders).
Definition: types.h:54
#define OFFSPRG
Offspring age class flag.
Definition: types.h:50
@ ADLTx
Definition: types.h:42

Generated for Nemo v2.3.56 by  doxygen 1.9.0 -- Nemo is hosted on  Download Nemo

Locations of visitors to this page
Catalogued on GSR