Nemo  2.3.56
Simulate forward-in-time genetic evolution in a spatially explicit, individual-based stochastic simulator
LCEmisc.h
Go to the documentation of this file.
1
30#ifndef LCEMISC_H
31#define LCEMISC_H
32
33#include <iostream>
34#include <string>
35#include <map>
36#include "types.h"
37#include "lifecycleevent.h"
38#include "fileservices.h"
39#include "statservices.h"
40#include "filehandler.h"
41#include "stathandler.h"
42#include "Uniform.h"
43
44// LCE_Regulation
45//
51{
52public:
53
54 LCE_Regulation( ) : LifeCycleEvent("regulation","") {}
55
56 virtual ~LCE_Regulation( ) { }
57
58 void regulatePatch (Patch* patch, age_idx age, sex_t sex);
59
60 //implementations:
61 virtual bool setParameters () {return true;}
62 virtual void execute ();
63 virtual LCE_Regulation* clone ( ) {return new LCE_Regulation();}
64 virtual void loadFileServices ( FileServices* loader ) {}
65 virtual void loadStatServices ( StatServices* loader ) {}
66 virtual bool resetParameterFromSource (std::string param, SimComponent* cmpt) {return false;}
67 virtual age_t removeAgeClass ( ) {return NONE;}
68 virtual age_t addAgeClass ( ) {return NONE;}
69 virtual age_t requiredAgeClass () {return NONE;}
70};
71
72// LCE_Aging
73//
80{
81public:
82
83 LCE_Aging( ) : LifeCycleEvent("aging","") {}
84
85 virtual ~LCE_Aging( ) { }
86
87 //implementations:
88 virtual bool setParameters () {return true;}
89 virtual void execute ();
90 virtual LCE_Aging* clone ( ) {return new LCE_Aging();}
91 virtual void loadFileServices ( FileServices* loader ) {}
92 virtual void loadStatServices ( StatServices* loader ) {}
93 virtual bool resetParameterFromSource (std::string param, SimComponent* cmpt) {return false;}
94 virtual age_t removeAgeClass ( ) {return OFFSPRG;}
95 virtual age_t addAgeClass ( ) {return ADULTS;}
96 virtual age_t requiredAgeClass () {return OFFSPRG;}
97};
98
99// LCE_Patch_Extinction
100//
104{
121
123
124 unsigned int rand_uniform (double max) {return RAND::Uniform((unsigned int)max);}
125 unsigned int rand_poisson (double mean){return (unsigned int)RAND::Poisson(mean);}
126 unsigned int rand_gaussian (double mean){return (unsigned int)abs(mean + RAND::Gaussian(_harvest_dist_stdev));}
127 unsigned int rand_exp (double mean){return (unsigned int)(-1.0 * mean * log(1.0-RAND::Uniform()));}
128 unsigned int rand_lognormal (double mean){return (unsigned int)RAND::LogNormal(mean, _harvest_dist_stdev);}
129
130public:
131
134 {
135 if(_Xtion_rate) delete _Xtion_rate;
136 if(_harvest_size) delete _harvest_size;
138 }
139
140 bool set_matrix_param (TMatrix* mat, string name);
141 void do_flush (Patch *patch);
142 void do_remove (age_idx AGE, Patch *patch);
143 unsigned int get_harvest_size (age_idx AGE, Patch *patch);
144
145 //LifeCycleEvent interface:
146 virtual bool setParameters ();
147 virtual void execute ();
148 virtual LifeCycleEvent* clone ( ) {return new LCE_Patch_Extinction();}
149
150 //SimComponent interface:
151 virtual void loadFileServices ( FileServices* loader ) {}
152 virtual void loadStatServices ( StatServices* loader ) {}
153 virtual bool resetParameterFromSource (std::string param, SimComponent* cmpt) {return false;}
154 virtual age_t removeAgeClass ( ) {return 0;}
155 virtual age_t addAgeClass ( ) {return 0;}
156 virtual age_t requiredAgeClass () {return 0;}
157};
158
159class FHPedigreeReader;
160
161//CROSSING
162//
165{
166 unsigned int _nSire, _nDam;
167 unsigned int _nOffspring;
168 unsigned int _atGeneration;
170
173 map<unsigned long, Individual* > _pedigree_pop;
174
175public:
176
177 LCE_Cross( );
178 virtual ~LCE_Cross( ) { }
179
180 void sampleAmongPop(Patch* patch, deque<Individual*>& males, unsigned int nsire);
181 void sampleWithinPop(Patch* patch, deque<Individual*>& males, deque<Individual*>& females, unsigned int nsire);
182 void generatePedigree ();
184
185 //LifeCycleEvent interface:
186 virtual bool setParameters ();
187 virtual void execute ();
188 virtual LifeCycleEvent* clone ( ) {return new LCE_Cross();}
189
190 //SimComponent interface:
191 virtual void loadFileServices ( FileServices* loader );
192 virtual void loadStatServices ( StatServices* loader ) {}
193 virtual bool resetParameterFromSource (std::string param, SimComponent* cmpt) {return false;}
194 virtual age_t removeAgeClass ( ) {return 0;}
195 virtual age_t addAgeClass ( ) {return OFFSPRG;}
196 virtual age_t requiredAgeClass () {return ADULTS;}
197
198};
199
200//CROSSING FILE READER
201//
203class FHPedigreeReader : public EventFileHandler<LCE_Cross> {
204public:
205 FHPedigreeReader(LCE_Cross* event); // : EventFileHandler< LCE_Cross > (event, ".ped");
207
208 virtual void FHwrite () {}
209 virtual void FHread (string& filename);
210
211 vector< unsigned long * >& getPedigree() {return _pedigree;}
212
213private:
214 vector< unsigned long * > _pedigree;
215};
216
217
218//RESIZE POP
219//
222{
223 list< int >::const_iterator _genITER;
225 list< int > _generations;
230public:
231
232 LCE_Resize( );
233 virtual ~LCE_Resize( ) { if(_patchBackup) delete _patchBackup;}
234
237 void removeDesignatedPatch(bool do_backup);
239 void fillPop ( void (LCE_Resize:: *fillFuncPtr) (unsigned int p, age_idx age));
240 void fillPatchNoBackup(unsigned int p, age_idx age);
241 void fillPatchWithBackup(unsigned int p, age_idx age);
242 void regulate( void (LCE_Resize::* regFuncPtr) (Patch *patch, age_idx age));
243 void regulateAgeClassWithBackup(Patch *patch, age_idx age);
244 void regulateAgeClassNoBackup(Patch *patch, age_idx age);
245
246 //LifeCycleEvent interface:
247 virtual bool setParameters ();
248 bool updateParameters ();
249 virtual void execute ();
250 virtual LifeCycleEvent* clone ( ) {return new LCE_Resize();}
251
252 //SimComponent interface:
253 virtual void loadFileServices ( FileServices* loader ) {}
254 virtual void loadStatServices ( StatServices* loader ) {}
255 virtual bool resetParameterFromSource (std::string param, SimComponent* cmpt) {return false;}
256 virtual age_t removeAgeClass ( ) {return 0;}
257 virtual age_t addAgeClass ( ) {return 0;}
258 virtual age_t requiredAgeClass () {return 0;}
259
260};
261
262
263#endif //LCEMISC_H
Template class for the LCEs StatHandler classes.
Definition: filehandler.h:247
A class to read a pedigree from a file.
Definition: LCEmisc.h:203
virtual void FHwrite()
Definition: LCEmisc.h:208
virtual ~FHPedigreeReader()
Definition: LCEmisc.h:206
vector< unsigned long * > _pedigree
Definition: LCEmisc.h:214
vector< unsigned long * > & getPedigree()
Definition: LCEmisc.h:211
virtual void FHread(string &filename)
Definition: LCEmisc.cc:728
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
Removes all adults from the patches and randomly moves the offspring to the adults age class.
Definition: LCEmisc.h:80
virtual ~LCE_Aging()
Definition: LCEmisc.h:85
virtual LCE_Aging * clone()
Definition: LCEmisc.h:90
virtual bool setParameters()
Definition: LCEmisc.h:88
virtual age_t requiredAgeClass()
Definition: LCEmisc.h:96
virtual void loadFileServices(FileServices *loader)
Definition: LCEmisc.h:91
LCE_Aging()
Definition: LCEmisc.h:83
virtual age_t addAgeClass()
Definition: LCEmisc.h:95
virtual age_t removeAgeClass()
Definition: LCEmisc.h:94
virtual void execute()
Definition: LCEmisc.cc:45
virtual void loadStatServices(StatServices *loader)
Definition: LCEmisc.h:92
virtual bool resetParameterFromSource(std::string param, SimComponent *cmpt)
Definition: LCEmisc.h:93
A class to perform crosses within patches, implements the NC1 mating design.
Definition: LCEmisc.h:165
void sampleAmongPop(Patch *patch, deque< Individual * > &males, unsigned int nsire)
Definition: LCEmisc.cc:641
void sampleWithinPop(Patch *patch, deque< Individual * > &males, deque< Individual * > &females, unsigned int nsire)
Definition: LCEmisc.cc:680
virtual void loadStatServices(StatServices *loader)
Definition: LCEmisc.h:192
virtual void loadFileServices(FileServices *loader)
Definition: LCEmisc.cc:434
virtual bool resetParameterFromSource(std::string param, SimComponent *cmpt)
Definition: LCEmisc.h:193
unsigned int _nDam
Definition: LCEmisc.h:166
bool _doWithinPop
Definition: LCEmisc.h:169
FHPedigreeReader * _reader
Definition: LCEmisc.h:171
bool _doAmongPop
Definition: LCEmisc.h:169
virtual ~LCE_Cross()
Definition: LCEmisc.h:178
virtual age_t requiredAgeClass()
Definition: LCEmisc.h:196
virtual LifeCycleEvent * clone()
Definition: LCEmisc.h:188
virtual age_t removeAgeClass()
Definition: LCEmisc.h:194
map< unsigned long, Individual * > _pedigree_pop
Definition: LCEmisc.h:173
unsigned int _atGeneration
Definition: LCEmisc.h:168
unsigned int _nSire
Definition: LCEmisc.h:166
bool _doReplace
Definition: LCEmisc.h:169
unsigned int _nOffspring
Definition: LCEmisc.h:167
virtual void execute()
Definition: LCEmisc.cc:453
bool create_individual_ancestors(Individual *ind)
Definition: LCEmisc.cc:575
LCE_Cross()
Definition: LCEmisc.cc:382
virtual age_t addAgeClass()
Definition: LCEmisc.h:195
string _pedigree_file
Definition: LCEmisc.h:172
virtual bool setParameters()
Definition: LCEmisc.cc:400
void generatePedigree()
Definition: LCEmisc.cc:510
Randomly removes individuals from the patches according to the extinction rate parameter.
Definition: LCEmisc.h:104
TMatrix * _harvest_proportion
Proportion of the patch size to remove.
Definition: LCEmisc.h:110
unsigned int(LCE_Patch_Extinction::* _rand_size_fct)(double)
Definition: LCEmisc.h:122
LCE_Patch_Extinction()
Definition: LCEmisc.cc:132
void do_remove(age_idx AGE, Patch *patch)
Definition: LCEmisc.cc:328
void do_flush(Patch *patch)
Definition: LCEmisc.cc:319
virtual void loadFileServices(FileServices *loader)
Definition: LCEmisc.h:151
virtual LifeCycleEvent * clone()
Definition: LCEmisc.h:148
bool _by_proportion
Definition: LCEmisc.h:114
unsigned int rand_exp(double mean)
Definition: LCEmisc.h:127
double _harvest_dist_shape
shape variable to use with the gamma dist.
Definition: LCEmisc.h:118
virtual ~LCE_Patch_Extinction()
Definition: LCEmisc.h:133
double _harvest_dist_stdev
Standard deviate to use with the Gaussian dist.
Definition: LCEmisc.h:116
virtual age_t addAgeClass()
Definition: LCEmisc.h:155
unsigned int rand_lognormal(double mean)
Definition: LCEmisc.h:128
unsigned int rand_uniform(double max)
Definition: LCEmisc.h:124
virtual bool setParameters()
Definition: LCEmisc.cc:150
string _harvest_distribution
Name of the distribution to use.
Definition: LCEmisc.h:112
virtual age_t requiredAgeClass()
Definition: LCEmisc.h:156
virtual age_t removeAgeClass()
Definition: LCEmisc.h:154
unsigned int rand_poisson(double mean)
Definition: LCEmisc.h:125
bool set_matrix_param(TMatrix *mat, string name)
Definition: LCEmisc.cc:255
unsigned int get_harvest_size(age_idx AGE, Patch *patch)
Definition: LCEmisc.cc:357
unsigned int rand_gaussian(double mean)
Definition: LCEmisc.h:126
double _extinction_threshold
Patch extinction threshold in % of total size of the patch.
Definition: LCEmisc.h:120
virtual bool resetParameterFromSource(std::string param, SimComponent *cmpt)
Definition: LCEmisc.h:153
bool _harvest_size_varies
Flags.
Definition: LCEmisc.h:114
bool _by_size
Definition: LCEmisc.h:114
TMatrix * _harvest_size
Number of individual to remove per patch.
Definition: LCEmisc.h:108
virtual void execute()
Definition: LCEmisc.cc:284
TMatrix * _Xtion_rate
Patch extinction probability.
Definition: LCEmisc.h:106
virtual void loadStatServices(StatServices *loader)
Definition: LCEmisc.h:152
Regulates the patches to their carrying capacity, acts on each age class separately.
Definition: LCEmisc.h:51
virtual bool resetParameterFromSource(std::string param, SimComponent *cmpt)
Definition: LCEmisc.h:66
virtual age_t requiredAgeClass()
Definition: LCEmisc.h:69
virtual void loadFileServices(FileServices *loader)
Definition: LCEmisc.h:64
virtual age_t removeAgeClass()
Definition: LCEmisc.h:67
virtual bool setParameters()
Definition: LCEmisc.h:61
virtual LCE_Regulation * clone()
Definition: LCEmisc.h:63
LCE_Regulation()
Definition: LCEmisc.h:54
void regulatePatch(Patch *patch, age_idx age, sex_t sex)
Definition: LCEmisc.cc:118
virtual void execute()
Definition: LCEmisc.cc:91
virtual void loadStatServices(StatServices *loader)
Definition: LCEmisc.h:65
virtual ~LCE_Regulation()
Definition: LCEmisc.h:56
virtual age_t addAgeClass()
Definition: LCEmisc.h:68
A class to change the size of the population/patches during a simulation.
Definition: LCEmisc.h:222
virtual age_t addAgeClass()
Definition: LCEmisc.h:257
age_t _setAge
Definition: LCEmisc.h:228
void fillPatchWithBackup(unsigned int p, age_idx age)
Definition: LCEmisc.cc:1104
void fillPatchNoBackup(unsigned int p, age_idx age)
Definition: LCEmisc.cc:1091
void fillPop(void(LCE_Resize::*fillFuncPtr)(unsigned int p, age_idx age))
Definition: LCEmisc.cc:1074
Patch * _patchBackup
Definition: LCEmisc.h:229
void regulateAgeClassNoBackup(Patch *patch, age_idx age)
Definition: LCEmisc.cc:1151
virtual void loadStatServices(StatServices *loader)
Definition: LCEmisc.h:254
virtual bool resetParameterFromSource(std::string param, SimComponent *cmpt)
Definition: LCEmisc.h:255
TMatrix _patch2keep
Definition: LCEmisc.h:227
int _atGeneration
Definition: LCEmisc.h:224
bool _do_fill
Definition: LCEmisc.h:226
bool _do_regulate
Definition: LCEmisc.h:226
bool updateParameters()
Definition: LCEmisc.cc:837
virtual LifeCycleEvent * clone()
Definition: LCEmisc.h:250
void regulate(void(LCE_Resize::*regFuncPtr)(Patch *patch, age_idx age))
Definition: LCEmisc.cc:1119
void buildNewPatchArrayNoBackup()
Definition: LCEmisc.cc:1000
virtual void execute()
Definition: LCEmisc.cc:882
void updatePatchCapacities()
Definition: LCEmisc.cc:985
list< int > _generations
Definition: LCEmisc.h:225
LCE_Resize()
Definition: LCEmisc.cc:793
void regulateAgeClassWithBackup(Patch *patch, age_idx age)
Definition: LCEmisc.cc:1131
void buildNewPatchArrayWithBackup()
Definition: LCEmisc.cc:1013
virtual bool setParameters()
Definition: LCEmisc.cc:812
void removeDesignatedPatch(bool do_backup)
Definition: LCEmisc.cc:1036
virtual age_t requiredAgeClass()
Definition: LCEmisc.h:258
virtual void loadFileServices(FileServices *loader)
Definition: LCEmisc.h:253
virtual age_t removeAgeClass()
Definition: LCEmisc.h:256
virtual ~LCE_Resize()
Definition: LCEmisc.h:233
list< int >::const_iterator _genITER
Definition: LCEmisc.h:223
bool _do_flush
Definition: LCEmisc.h:226
Base class of the Life Cycle Events, declares the LCE interface.
Definition: lifecycleevent.h:73
Second class in the metapopulation design structure, between the Metapop and Individual classes.
Definition: metapop.h:430
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 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
sex_t
Sex types, males are always 0 and females 1!!
Definition: types.h:36
#define NONE
No age flag.
Definition: types.h:48
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
age_idx
Array index of the age classes in the patch sizes and containers arrays.
Definition: types.h:41

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