Nemo  2.4.0
Simulate forward-in-time genetic evolution in a spatially explicit, individual-based stochastic simulator
MPStatHandler Class Reference

A StatHandler for the Metapop SimComponent. More...

#include <MPStatHandler.h>

+ Inheritance diagram for MPStatHandler:
+ Collaboration diagram for MPStatHandler:

Public Member Functions

 MPStatHandler ()
 
virtual ~MPStatHandler ()
 
virtual bool setStatRecorders (std::string &token)
 
void setStatsForDemography (age_t AGE)
 
void setStatsForPop ()
 
void setStatsForPopPerPatch ()
 
void setStatsForMigrants ()
 
void setStatsForMigrantsPerPatch ()
 
void addIndNumPerPatch (sex_t SEX, age_t AGE)
 
void addPatchAge ()
 
Migration
double getMeanEmigrantPerPatch ()
 
double getMeanImigrantPerPatch ()
 
double getMeanMigrantRatio ()
 
double getMeanResidantPerPatch ()
 
double getMeanKolonisersProportion ()
 
double getMeanKolonisersPerPatch ()
 
double getEmigrantInPatch (unsigned int i)
 
double getResidantInPatch (unsigned int i)
 
double getImigrateInPatch (unsigned int i)
 
double getKolonisersInPatch (unsigned int i)
 
Patch extinction
void setObsrvdExtinctionRate ()
 
double getObsrvdExtinctionRate ()
 
double get_isAlive ()
 
double getPatchAge (unsigned int i)
 
double getMeanPatchAge ()
 
Demography
double getAdultSexRatio ()
 
double getOffsprgSexRatio ()
 
double getPatchSize (unsigned int age, unsigned int patch)
 
double getPopulationSize (unsigned int age)
 
double getMeanPatchSize (unsigned int age)
 
double getMeanPatchSizePerSex (unsigned int sex, unsigned int age)
 
double getMeanPatchDensity (age_t AGE)
 
double getMeanPatchDensityVariance (age_t AGE)
 
double getFemNumber (unsigned int i)
 
double getMalNumber (unsigned int i)
 
double getOffFemNumber (unsigned int i)
 
double getOffMalNumber (unsigned int i)
 
double getMeanAssignedFecundity (unsigned int sex)
 
double getMeanMatings (unsigned int sex)
 
double setReproductiveStats (unsigned int sex)
 
double getReproductiveVar ()
 
Kinship
void setKinship ()
 
void setKinClassCounter (Individual *I1, Individual *I2)
 
double getSibProportion (unsigned int i)
 
Pedegree
void setPedegreeCount ()
 
double getPedProportion (unsigned int i)
 
- Public Member Functions inherited from StatHandler< MPStatHandler >
 StatHandler ()
 
virtual ~StatHandler ()
 
virtual void clear ()
 Empties the _recorders list, they are destroyed in StatHandlerBase::reset(). More...
 
virtual StatRecorder< MPStatHandler > * add (std::string Title, std::string Name, age_t AGE, unsigned int ARG1, unsigned int ARG2, double(SH::*getStatNoArg)(void), double(SH::*getStatOneArg)(unsigned int), double(SH::*getStatTwoArg)(unsigned int, unsigned int), void(SH::*setStat)(void))
 Adds a StatRecorder to the list, it is also added to the StatHandlerBase::_stats list. More...
 
- Public Member Functions inherited from StatHandlerBase
 StatHandlerBase ()
 
virtual ~StatHandlerBase ()
 
virtual void reset ()
 Empties the _stats list and calls clear() (defined in the derived class). More...
 
Metapopget_pop_ptr ()
 
void set_service (StatServices *srv)
 
StatServicesget_service ()
 
unsigned int getOccurrence ()
 
unsigned int getNumOccurrences ()
 
unsigned int getCurrentOccurrence ()
 
unsigned int getNbRecorders ()
 
std::list< StatRecBase * > & getStats ()
 
virtual void add (StatRecBase *rec)
 
virtual void init ()
 
virtual void update ()
 This function is left empty as the StatServices calls StatRecorder::setVal directly. More...
 
- Public Member Functions inherited from Handler
virtual ~Handler ()
 

Private Attributes

double meanEmigrant
 
double meanImigrant
 
double meanResidant
 
double meanKolonisers
 
double meanDeadDisp
 
double ObservedExtinctionRate
 
double _sib_prop [5]
 
double _ped_prop [5]
 
double _var_reprod_success
 

Additional Inherited Members

- Protected Types inherited from StatHandler< MPStatHandler >
typedef std::list< StatRecorder< MPStatHandler > * >::iterator REC_IT
 
- Protected Attributes inherited from StatHandler< MPStatHandler >
std::list< StatRecorder< MPStatHandler > * > _recorders
 The list of stat recorders. More...
 
- Protected Attributes inherited from StatHandlerBase
Metapop_pop
 Link to the current population, set through the link to the StatService. More...
 

Detailed Description

Constructor & Destructor Documentation

◆ MPStatHandler()

MPStatHandler::MPStatHandler ( )
inline
48 { }

◆ ~MPStatHandler()

virtual MPStatHandler::~MPStatHandler ( )
inlinevirtual
50 {}

Member Function Documentation

◆ addIndNumPerPatch()

void MPStatHandler::addIndNumPerPatch ( sex_t  SEX,
age_t  AGE 
)
170 {
171  double (MPStatHandler::* setter) (unsigned int) = 0;
172 
173  if (SEX) {
174 
175  if (AGE == ADULTS) {
176  setter = &MPStatHandler::getFemNumber;
177  } else if (AGE == OFFSPRG) {
179  }
180 
181  } else {
182 
183  if (AGE == ADULTS) {
184  setter = &MPStatHandler::getMalNumber;
185  } else if (AGE == OFFSPRG) {
187  }
188 
189  }
190 
191  string suffix = (AGE == ADULTS ? "adlt.":"off.");
192  string name = (SEX == FEM ? suffix + "fem." : suffix + "mal.");
193  string patch = "p1";
194 
195  add("", name + patch, AGE, 0, 0, 0, setter, 0, 0);
196  for(unsigned int i = 1; i < _pop->getPatchNbr(); i++) {
197  patch = "p" + tstring::int2str(i+1);
198  add("", name + patch, AGE, i, 0, 0, setter, 0, 0);
199  }
200 }
A StatHandler for the Metapop SimComponent.
Definition: MPStatHandler.h:39
double getOffMalNumber(unsigned int i)
Definition: stats_demo.cc:562
double getOffFemNumber(unsigned int i)
Definition: stats_demo.cc:561
double getFemNumber(unsigned int i)
Definition: stats_demo.cc:563
double getMalNumber(unsigned int i)
Definition: stats_demo.cc:564
unsigned int getPatchNbr()
Definition: metapop.h:275
Metapop * _pop
Link to the current population, set through the link to the StatService.
Definition: stathandler.h:60
virtual StatRecorder< MPStatHandler > * add(std::string Title, std::string Name, age_t AGE, unsigned int ARG1, unsigned int ARG2, double(SH::*getStatNoArg)(void), double(SH::*getStatOneArg)(unsigned int), double(SH::*getStatTwoArg)(unsigned int, unsigned int), void(SH::*setStat)(void))
Adds a StatRecorder to the list, it is also added to the StatHandlerBase::_stats list.
Definition: stathandler.h:143
static string int2str(const int i)
Writes an integer value into a string.
Definition: tstring.h:94
@ FEM
Definition: types.h:36
#define ADULTS
Adults age class flag (breeders).
Definition: types.h:53
#define OFFSPRG
Offspring age class flag.
Definition: types.h:49

References StatHandlerBase::_pop, StatHandler< MPStatHandler >::add(), ADULTS, FEM, getFemNumber(), getMalNumber(), getOffFemNumber(), getOffMalNumber(), Metapop::getPatchNbr(), tstring::int2str(), and OFFSPRG.

Referenced by setStatRecorders(), and setStatsForPopPerPatch().

+ Here is the caller graph for this function:

◆ addPatchAge()

void MPStatHandler::addPatchAge ( )
203 {
204 
205  std::ostringstream name, sub_name;
206 
207  add("Patch 1 age","age.patch1",ALL,0,0,0,&MPStatHandler::getPatchAge,0,0);
208  for(unsigned int i = 1; i < _pop->getPatchNbr(); i++) {
209  name<<"Patch "<<i+1<<" age";
210  sub_name<<"age.patch"<<i+1;
211  add(name.str(),sub_name.str(),ALL,i,0,0,&MPStatHandler::getPatchAge,0,0);
212  name.str("");
213  sub_name.str("");
214  }
215 
216  add("Mean patch age","patch.avg.age",ALL,0,0,&MPStatHandler::getMeanPatchAge,0,0,0);
217  add("Extinction rate","extrate",ALL,0,0,&MPStatHandler::getObsrvdExtinctionRate,0,0,
219 }
double getObsrvdExtinctionRate()
Definition: MPStatHandler.h:77
double getMeanPatchAge()
Definition: stats_demo.cc:177
double getPatchAge(unsigned int i)
Definition: stats_demo.cc:171
void setObsrvdExtinctionRate()
Definition: stats_demo.cc:161
#define ALL
All ages age class flag.
Definition: types.h:55

References StatHandlerBase::_pop, StatHandler< MPStatHandler >::add(), ALL, getMeanPatchAge(), getObsrvdExtinctionRate(), getPatchAge(), Metapop::getPatchNbr(), and setObsrvdExtinctionRate().

Referenced by setStatsForPopPerPatch().

+ Here is the caller graph for this function:

◆ get_isAlive()

double MPStatHandler::get_isAlive ( )

◆ getAdultSexRatio()

double MPStatHandler::getAdultSexRatio ( )
556 {return (_pop->size(MAL, ADULTS) != 0 ? (double)_pop->size(FEM, ADULTS)/_pop->size(MAL, ADULTS) : 0);}
unsigned int size()
Get the total number of individuals present in the population, all sex and age classes together.
Definition: metapop.h:311
@ MAL
Definition: types.h:36

References ADULTS, FEM, and MAL.

Referenced by setStatRecorders(), and setStatsForPop().

+ Here is the caller graph for this function:

◆ getEmigrantInPatch()

double MPStatHandler::getEmigrantInPatch ( unsigned int  i)
128 {
129  Patch* patch = _pop->getPatch(i);
130  return (patch != 0 ? patch->nbEmigrant : 0);
131 }
Patch * getPatch(unsigned int i)
Patch accessor, return the ith+1 patch in the metapop.
Definition: metapop.h:256
Second class in the metapopulation design structure, between the Metapop and Individual classes.
Definition: metapop.h:431
unsigned short nbEmigrant
Definition: metapop.h:453

References Patch::nbEmigrant.

Referenced by setStatsForMigrantsPerPatch().

+ Here is the caller graph for this function:

◆ getFemNumber()

double MPStatHandler::getFemNumber ( unsigned int  i)
563 {return _pop->size(FEM, ADULTS, i);}

References ADULTS, and FEM.

Referenced by addIndNumPerPatch().

+ Here is the caller graph for this function:

◆ getImigrateInPatch()

double MPStatHandler::getImigrateInPatch ( unsigned int  i)
140 {
141  Patch* patch = _pop->getPatch(i);
142  return (patch != 0 ? (double)patch->nbImigrant/(double)(patch->nbImigrant + patch->nbPhilopat)
143  : nanf("NULL"));
144 }
unsigned short nbPhilopat
Definition: metapop.h:453
unsigned short nbImigrant
Definition: metapop.h:453

References Patch::nbImigrant, and Patch::nbPhilopat.

Referenced by setStatsForMigrantsPerPatch().

+ Here is the caller graph for this function:

◆ getKolonisersInPatch()

double MPStatHandler::getKolonisersInPatch ( unsigned int  i)
148 {
149  Patch* patch = _pop->getPatch(i);
150  int colon = (patch != 0 ? patch->nbKolonisers : 0);
151  return (colon != -1 ? colon : nanf("NULL"));
152 }
short nbKolonisers
Definition: metapop.h:454

References Patch::nbKolonisers.

Referenced by setStatsForMigrantsPerPatch().

+ Here is the caller graph for this function:

◆ getMalNumber()

double MPStatHandler::getMalNumber ( unsigned int  i)
564 {return _pop->size(MAL, ADULTS, i);}

References ADULTS, and MAL.

Referenced by addIndNumPerPatch().

+ Here is the caller graph for this function:

◆ getMeanAssignedFecundity()

double MPStatHandler::getMeanAssignedFecundity ( unsigned int  sex)
267 {
268  double mean = 0, sum = 0;
269  unsigned int nbpatch = 0;
270  Patch* crnt_patch;
271 
272  if((bool)sex) {
273  for(unsigned int i = 0; i < _pop->getPatchNbr(); ++i) {
274  crnt_patch = _pop->getPatch(i);
275  if(crnt_patch->size(FEM, ADLTx) != 0) {
276  nbpatch++;
277  sum = 0;
278  for(unsigned int j = 0; j < crnt_patch->size(FEM, ADLTx);++j)
279  sum += crnt_patch->get(FEM, ADLTx, j)->getFecundity();
280  mean += sum/crnt_patch->size(FEM, ADLTx);
281  }
282  }
283  } else {
284  for(unsigned int i = 0; i < _pop->getPatchNbr(); ++i) {
285  crnt_patch = _pop->getPatch(i);
286  if(crnt_patch->size(MAL, ADLTx) != 0) {
287  nbpatch++;
288  sum = 0;
289  for(unsigned int j = 0; j < crnt_patch->size(MAL, ADLTx);++j)
290  sum += crnt_patch->get(MAL, ADLTx, j)->getFecundity();
291  mean += sum/crnt_patch->size(MAL, ADLTx);
292  }
293  }
294  }
295  return (nbpatch != 0 ? mean/nbpatch : nanf("NULL"));
296 }
double getFecundity()
Definition: individual.h:132
unsigned int size(age_t AGE)
Returns the size of the container of the appropriate age class(es) for both sexes.
Definition: metapop.h:497
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:533
@ ADLTx
Definition: types.h:41

References ADLTx, FEM, Patch::get(), Individual::getFecundity(), MAL, and Patch::size().

◆ getMeanEmigrantPerPatch()

double MPStatHandler::getMeanEmigrantPerPatch ( )
43 {
44  unsigned int meanM = 0;
45 
46  for(unsigned int i = 0; i < _pop->getPatchNbr(); i++)
47  meanM += _pop->getPatch(i)->nbEmigrant;
48  meanEmigrant = (double)meanM/_pop->getPatchNbr();
49  return meanEmigrant;
50 }
double meanEmigrant
Definition: MPStatHandler.h:41

Referenced by setStatsForMigrants().

+ Here is the caller graph for this function:

◆ getMeanImigrantPerPatch()

double MPStatHandler::getMeanImigrantPerPatch ( )
55 {
56  double meanM = 0,nbpatch = 0;
57  Patch* current_patch;
58  for(unsigned int i = 0; i < _pop->getPatchNbr(); i++) {
59  current_patch = _pop->getPatch(i);
60  if(!current_patch->get_isExtinct()){
61  meanM += current_patch->nbImigrant;
62  nbpatch++;
63  }
64  }
65  meanImigrant = (nbpatch != 0 ? meanM/nbpatch : nanf("NULL"));
66  return meanImigrant;
67 }
double meanImigrant
Definition: MPStatHandler.h:41
bool get_isExtinct()
Definition: metapop.h:485

References Patch::get_isExtinct(), and Patch::nbImigrant.

Referenced by setStatsForMigrants().

+ Here is the caller graph for this function:

◆ getMeanKolonisersPerPatch()

double MPStatHandler::getMeanKolonisersPerPatch ( )
113 {
114  double mean = 0,nbpatch = 0;
115  Patch* current_patch;
116  for(unsigned int i = 0; i < _pop->getPatchNbr(); i++){
117  current_patch = _pop->getPatch(i);
118  if(current_patch->nbKolonisers >= 0) {
119  mean += current_patch->nbKolonisers;
120  nbpatch++;
121  }
122  }
123  meanKolonisers = (nbpatch != 0 ? mean/nbpatch : nanf("NULL"));
124  return meanKolonisers;
125 }
double meanKolonisers
Definition: MPStatHandler.h:41

References Patch::nbKolonisers.

Referenced by setStatsForMigrants().

+ Here is the caller graph for this function:

◆ getMeanKolonisersProportion()

double MPStatHandler::getMeanKolonisersProportion ( )
96 {
97  double nbpatch = 0, mean = 0;
98  Patch* current_patch;
99  for(unsigned int i = 0; i < _pop->getPatchNbr(); i++){
100  current_patch = _pop->getPatch(i);
101  if(current_patch->nbKolonisers >= 0) {
102  mean += fmin((double)current_patch->nbKolonisers / current_patch->get_K(), 1.0);
103  nbpatch++;
104  }
105  }
106 
107  return (nbpatch != 0 ? mean/nbpatch : nanf("NULL"));
108 }
unsigned int get_K()
Definition: metapop.h:481

References Patch::get_K(), and Patch::nbKolonisers.

Referenced by setStatsForMigrants().

+ Here is the caller graph for this function:

◆ getMeanMatings()

double MPStatHandler::getMeanMatings ( unsigned int  sex)
301 {
302  double mean = 0, sum = 0;
303  unsigned int nbpatch = 0;
304  Patch* crnt_patch;
305 
306  if((bool)sex) {
307  for(unsigned int i = 0; i < _pop->getPatchNbr(); ++i) {
308  crnt_patch = _pop->getPatch(i);
309  if(crnt_patch->size(FEM, ADLTx) != 0) {
310  nbpatch++;
311  sum = 0;
312  for(unsigned int j = 0; j < crnt_patch->size(FEM, ADLTx);++j)
313  sum += crnt_patch->get(FEM, ADLTx, j)->getTotMatings();
314  mean += sum/crnt_patch->size(FEM, ADLTx);
315  }
316  }
317  } else {
318  for(unsigned int i = 0; i < _pop->getPatchNbr(); ++i) {
319  crnt_patch = _pop->getPatch(i);
320  if(crnt_patch->size(MAL, ADLTx) != 0) {
321  nbpatch++;
322  sum = 0;
323  for(unsigned int j = 0; j < crnt_patch->size(MAL, ADLTx);++j)
324  sum += crnt_patch->get(MAL, ADLTx, j)->getTotMatings();
325  mean += sum/crnt_patch->size(MAL, ADLTx);
326  }
327  }
328  }
329  return (nbpatch != 0 ? mean/nbpatch : nanf("NULL"));
330 }
unsigned int getTotMatings()
Gives the total number of matings of an individual.
Definition: individual.h:151

References ADLTx, FEM, Patch::get(), Individual::getTotMatings(), MAL, and Patch::size().

Referenced by setStatRecorders().

+ Here is the caller graph for this function:

◆ getMeanMigrantRatio()

double MPStatHandler::getMeanMigrantRatio ( )
72 {
74 }
double meanResidant
Definition: MPStatHandler.h:41

Referenced by setStatsForMigrants().

+ Here is the caller graph for this function:

◆ getMeanPatchAge()

double MPStatHandler::getMeanPatchAge ( )
178 {
179  int mean = 0;
180  for(unsigned int i = 0; i < _pop->getPatchNbr(); ++i)
181  mean += _pop->getPatch(i)->get_age();
182  return mean/_pop->getPatchNbr();
183 }
unsigned int get_age()
Definition: metapop.h:486

Referenced by addPatchAge().

+ Here is the caller graph for this function:

◆ getMeanPatchDensity()

double MPStatHandler::getMeanPatchDensity ( age_t  AGE)
222 {
223  double mean = 0;
224  unsigned int nb_patch = 0;
225  age_idx age = (AGE == ADULTS ? ADLTx : OFFSx);
226 
227  for(unsigned int i = 0; i < _pop->getPatchNbr(); i++) {
228  nb_patch += (_pop->size(AGE, i) != 0);
229  mean += _pop->getPatch(i)->getDensity(age);
230  }
231 
232  return (nb_patch != 0 ? mean/nb_patch : nanf("NULL"));
233 }
double getDensity(age_idx age)
Definition: metapop.h:489
age_idx
Array index of the age classes in the patch sizes and containers arrays.
Definition: types.h:40
@ OFFSx
Definition: types.h:41

References ADLTx, ADULTS, and OFFSx.

Referenced by setStatsForDemography().

+ Here is the caller graph for this function:

◆ getMeanPatchDensityVariance()

double MPStatHandler::getMeanPatchDensityVariance ( age_t  AGE)
238 {
239  unsigned int i,nb_patch;
240  vector<double> stat;
241  double var = 0, mean = 0, val;
242  age_idx age = (AGE == ADULTS ? ADLTx : OFFSx);
243 
244  for(i = 0; i < _pop->getPatchNbr(); i++) {
245  if(_pop->size(AGE,i) != 0){
246  val = _pop->getPatch(i)->getDensity(age);
247  stat.push_back(val);
248  mean += val;
249  }
250  }
251  nb_patch = stat.size();
252  mean = (nb_patch != 0 ? mean/nb_patch : 0);
253 
254  for(i = 0; i < nb_patch; i++)
255  var += pow((stat[i]-mean),2);
256 
257  return (nb_patch != 0 ? var/nb_patch : nanf("NULL"));
258 }

References ADLTx, ADULTS, and OFFSx.

Referenced by setStatsForDemography().

+ Here is the caller graph for this function:

◆ getMeanPatchSize()

double MPStatHandler::getMeanPatchSize ( unsigned int  age)
192 {
193  double mean = 0;
194  unsigned int nb_patch = 0;
195 
196  for(unsigned int i = 0; i < _pop->getPatchNbr(); i++) {
197  nb_patch += (_pop->size(age_t(age),i) != 0);
198  mean += _pop->size(age_t(age),i);
199  }
200 
201  return (nb_patch != 0 ? mean/nb_patch : nanf("NULL"));
202 }
unsigned int age_t
Age class flags.
Definition: types.h:45

◆ getMeanPatchSizePerSex()

double MPStatHandler::getMeanPatchSizePerSex ( unsigned int  sex,
unsigned int  age 
)
207 {
208  double mean = 0;
209  unsigned int nb_patch = 0;
210 
211  for(unsigned int i = 0; i < _pop->getPatchNbr(); i++) {
212  nb_patch += (_pop->size(sex_t(sex),age_t(age),i) != 0);
213  mean += _pop->size(sex_t(sex),age_t(age),i);
214  }
215 
216  return (nb_patch != 0 ? mean/nb_patch : nanf("NULL"));
217 }
sex_t
Sex types, males are always 0 and females 1!!
Definition: types.h:35

Referenced by setStatsForDemography().

+ Here is the caller graph for this function:

◆ getMeanResidantPerPatch()

double MPStatHandler::getMeanResidantPerPatch ( )
79 {
80  double meanR = 0,nbpatch = 0;
81  Patch* current_patch;
82  for(unsigned int i = 0; i < _pop->getPatchNbr(); i++){
83  current_patch = _pop->getPatch(i);
84  if(!current_patch->get_isExtinct()){
85  meanR += current_patch->nbPhilopat;
86  nbpatch++;
87  }
88  }
89  meanResidant = (nbpatch != 0 ? meanR/nbpatch : nanf("NULL"));
90  return meanResidant;
91 }

References Patch::get_isExtinct(), and Patch::nbPhilopat.

Referenced by setStatsForMigrants().

+ Here is the caller graph for this function:

◆ getObsrvdExtinctionRate()

double MPStatHandler::getObsrvdExtinctionRate ( )
inline
77 {return ObservedExtinctionRate;}
double ObservedExtinctionRate
Definition: MPStatHandler.h:42

References ObservedExtinctionRate.

Referenced by addPatchAge(), setStatRecorders(), and setStatsForPop().

+ Here is the caller graph for this function:

◆ getOffFemNumber()

double MPStatHandler::getOffFemNumber ( unsigned int  i)
561 {return _pop->size(FEM, OFFSPRG,i);}

References FEM, and OFFSPRG.

Referenced by addIndNumPerPatch().

+ Here is the caller graph for this function:

◆ getOffMalNumber()

double MPStatHandler::getOffMalNumber ( unsigned int  i)
562 {return _pop->size(MAL, OFFSPRG,i);}

References MAL, and OFFSPRG.

Referenced by addIndNumPerPatch().

+ Here is the caller graph for this function:

◆ getOffsprgSexRatio()

double MPStatHandler::getOffsprgSexRatio ( )
555 {return (_pop->size(MAL, OFFSPRG)!= 0 ? (double)_pop->size(FEM, OFFSPRG)/_pop->size(MAL, OFFSPRG) : 0);}

References FEM, MAL, and OFFSPRG.

Referenced by setStatRecorders(), and setStatsForPop().

+ Here is the caller graph for this function:

◆ getPatchAge()

double MPStatHandler::getPatchAge ( unsigned int  i)
172 {
173  Patch* patch = _pop->getPatch(i);
174  return (patch != 0 ? patch->get_age() : 0);
175 }

References Patch::get_age().

Referenced by addPatchAge().

+ Here is the caller graph for this function:

◆ getPatchSize()

double MPStatHandler::getPatchSize ( unsigned int  age,
unsigned int  patch 
)
558 {return _pop->size(age_t(age), patch);}

◆ getPedProportion()

double MPStatHandler::getPedProportion ( unsigned int  i)
inline
111 {return _ped_prop[i];}
double _ped_prop[5]
Definition: MPStatHandler.h:43

References _ped_prop.

Referenced by setStatRecorders().

+ Here is the caller graph for this function:

◆ getPopulationSize()

double MPStatHandler::getPopulationSize ( unsigned int  age)
559 {return _pop->size(age_t(age));}

Referenced by setStatsForDemography().

+ Here is the caller graph for this function:

◆ getReproductiveVar()

double MPStatHandler::getReproductiveVar ( )
inline
100 {return _var_reprod_success;}
double _var_reprod_success
Definition: MPStatHandler.h:44

References _var_reprod_success.

Referenced by setStatRecorders().

+ Here is the caller graph for this function:

◆ getResidantInPatch()

double MPStatHandler::getResidantInPatch ( unsigned int  i)
134 {
135  Patch* patch = _pop->getPatch(i);
136  return (patch != 0 ? patch->nbPhilopat : 0);
137 }

References Patch::nbPhilopat.

Referenced by setStatsForMigrantsPerPatch().

+ Here is the caller graph for this function:

◆ getSibProportion()

double MPStatHandler::getSibProportion ( unsigned int  i)
inline
106 {return _sib_prop[i];}
double _sib_prop[5]
Definition: MPStatHandler.h:43

References _sib_prop.

Referenced by setStatRecorders().

+ Here is the caller graph for this function:

◆ setKinClassCounter()

void MPStatHandler::setKinClassCounter ( Individual I1,
Individual I2 
)
496 {
497  //non sibs
498  if((I1->getMotherID() != I2->getMotherID()) && (I1->getFatherID() != I2->getFatherID()))
499  _sib_prop[0]++;
500 
501  //maternal half sibs
502  else if((I1->getMotherID() == I2->getMotherID()) && (I1->getFatherID() != I2->getFatherID()))
503  _sib_prop[1]++;
504 
505  //paternal half sibs
506  else if((I1->getMotherID() != I2->getMotherID()) && (I1->getFatherID() == I2->getFatherID()))
507  _sib_prop[2]++;
508 
509  //full sibs
510  else if((I1->getMotherID() == I2->getMotherID()) && (I1->getFatherID() == I2->getFatherID()))
511  _sib_prop[3]++;
512 }
unsigned long getMotherID()
Definition: individual.h:124
unsigned long getFatherID()
Definition: individual.h:123

References Individual::getFatherID(), and Individual::getMotherID().

◆ setKinship()

void MPStatHandler::setKinship ( )
407 {
408  unsigned int i,j,k;
409  unsigned int patchNbr = this->_pop->getPatchNbr(), Msize=0, Fsize=0;
410  Patch* current_patch;
411  Individual *I1,*I2;
412 
413  //counters initialization
414  for(i = 0; i < 5; ++i) _sib_prop[i] = 0.0;
415 
416  for( i = 0; i < patchNbr; ++i) {
417 
418  current_patch = _pop->getPatch(i);
419 
420  //male-male
421  if ( (Msize = current_patch->size(MAL, OFFSx)) != 0) {
422 
423  for(j = 0; j < Msize -1; ++j) {
424 
425  I1 = current_patch->get(MAL, OFFSx, j);
426 
427  for(k = j+1; k < Msize; ++k) {
428 
429  I2 = current_patch->get(MAL, OFFSx, k);
430 
431  setKinClassCounter(I1, I2);
432 
433  } //end for k < size
434 
435  //selfed offspring counter:
436  if(I1->getIsSelfed()) _sib_prop[4]++;
437 
438  } //end for j < size-1
439 
440  //don't forget the last one!
441  if(current_patch->get(MAL, OFFSx, Msize -1)->getIsSelfed()) _sib_prop[4]++;
442 
443  }//endif
444 
445  //female-female
446  if ( (Fsize = current_patch->size(FEM, OFFSx)) != 0) {
447 
448  for(j = 0; j < Fsize -1; ++j) {
449 
450  I1 = current_patch->get(FEM, OFFSx, j);
451 
452  for(k = j+1; k < Fsize; ++k) {
453 
454  I2 = current_patch->get(FEM, OFFSx, k);
455 
456  setKinClassCounter(I1, I2);
457 
458  } //end for k < size
459 
460  //selfed offspring counter:
461  if(I1->getIsSelfed()) _sib_prop[4]++;
462 
463  } //end for j < size-1
464 
465  //don't forget the last one!
466  if(current_patch->get(FEM, OFFSx, Fsize -1)->getIsSelfed()) _sib_prop[4]++;
467 
468  }//endif
469 
470  //male-female
471  for(j = 0; j < Msize; ++j) {
472 
473  I1 = current_patch->get(MAL, OFFSx, j);
474 
475  for(k = 0; k < Fsize; ++k) {
476 
477  I2 = current_patch->get(FEM, OFFSx, k);
478 
479  setKinClassCounter(I1, I2);
480  } //end for k
481  } //end for j
482 
483  } //end for i < patchNbr
484 
485  //total number of pairwise comparisons:
486  double tot = _sib_prop[0] + _sib_prop[1] + _sib_prop[2] + _sib_prop[3];
487 
488  for(i = 0 ; i < 4; ++i) _sib_prop[i] /= tot;
489 
490  _sib_prop[4] /= _pop->size(OFFSPRG);
491 }
This class contains traits along with other individual information (sex, pedigree,...
Definition: individual.h:48
bool getIsSelfed()
Definition: individual.h:130
void setKinClassCounter(Individual *I1, Individual *I2)
Definition: stats_demo.cc:495

References FEM, Patch::get(), Individual::getIsSelfed(), MAL, OFFSPRG, OFFSx, and Patch::size().

Referenced by setStatRecorders().

+ Here is the caller graph for this function:

◆ setObsrvdExtinctionRate()

void MPStatHandler::setObsrvdExtinctionRate ( )
162 {
164 
165  for(unsigned int i = 0; i < _pop->getPatchNbr(); ++i)
167 
169 }
bool isEmpty()
Definition: metapop.h:487

Referenced by addPatchAge(), setStatRecorders(), and setStatsForPop().

+ Here is the caller graph for this function:

◆ setPedegreeCount()

void MPStatHandler::setPedegreeCount ( )
518 {
519 
520  unsigned int i,j;
521  unsigned int patchNbr = _pop->getPatchNbr();
522  Patch* patch;
523 
524  //counters initialization
525  for(i = 0; i < 5; ++i) _ped_prop[i] = 0.0;
526 
527  for(i = 0; i < patchNbr; ++i) {
528 
529  patch = _pop->getPatch(i);
530 
531  //males
532  for(j = 0; j < patch->size(MAL, OFFSx); ++j) {
533 
534  _ped_prop[ patch->get(MAL, OFFSx, j)->getPedigreeClass() ]++;
535 
536  }
537 
538  //females
539  for(j = 0; j < patch->size(FEM, OFFSx); ++j) {
540 
541  _ped_prop[ patch->get(FEM, OFFSx, j)->getPedigreeClass() ]++;
542 
543  }
544 
545 
546  } //end for i < patchNbr
547 
548  //total:
549  double tot = _ped_prop[0] + _ped_prop[1] + _ped_prop[2] + _ped_prop[3] + _ped_prop[4];
550 
551  for(i = 0 ; i < 5; ++i) _ped_prop[i] /= tot;
552 
553 }
unsigned int getPedigreeClass()
Returns the pedigree class of the individual, as set during offspring creation.
Definition: individual.h:178

References FEM, Patch::get(), Individual::getPedigreeClass(), MAL, OFFSx, and Patch::size().

Referenced by setStatRecorders().

+ Here is the caller graph for this function:

◆ setReproductiveStats()

double MPStatHandler::setReproductiveStats ( unsigned int  sex)
335 {
336  double var = 0, mean = 0;
337  unsigned int tot_size = _pop->size( (sex_t)sex, ADULTS ), v = 0;
338  double *stat;
339  Patch *crnt_patch;
340 
341  if(tot_size == 0) {
342  _var_reprod_success = nanf("NULL");
343  return nanf("NULL");
344  }
345 
346  stat = new double [tot_size];
347 
348  //females
349  if((bool)sex) {
350 
351  for(unsigned int i = 0; i < _pop->getPatchNbr(); ++i) {
352  crnt_patch = _pop->getPatch(i);
353  for(unsigned int j = 0, size = crnt_patch->size(FEM, ADLTx);
354  j < size;
355  ++j)
356  {
357  stat[v] = crnt_patch->get(FEM, ADLTx, j)->getTotRealizedFecundity();
358  mean += stat[v];
359  v++;
360  }
361  }
362 
363  mean /= tot_size;
364 
365  for(unsigned int i = 0; i < tot_size; ++i)
366  var += pow( (stat[i] - mean), 2);
367 
368  var /= tot_size;
369  //males
370  } else {
371 
372  for(unsigned int i = 0; i < _pop->getPatchNbr(); ++i) {
373  crnt_patch = _pop->getPatch(i);
374  for(unsigned int j = 0, size = crnt_patch->size(MAL, ADLTx);
375  j < size;
376  ++j)
377  {
378  stat[v] = crnt_patch->get(MAL, ADLTx, j)->getTotRealizedFecundity();
379  mean += stat[v];
380  v++;
381  }
382  }
383 
384  mean /= tot_size;
385 
386  for(unsigned int i = 0; i < tot_size; ++i)
387  var += pow( (stat[i] - mean), 2);
388 
389  var /= tot_size;
390 
391  }
392 
393  _var_reprod_success = var;
394 
395  delete [] stat;
396 
397  return mean;
398 }
unsigned int getTotRealizedFecundity()
Gives the total number of surviving offspring for all categories of mating.
Definition: individual.h:175

References ADLTx, ADULTS, FEM, Patch::get(), Individual::getTotRealizedFecundity(), MAL, and Patch::size().

Referenced by setStatRecorders().

+ Here is the caller graph for this function:

◆ setStatRecorders()

bool MPStatHandler::setStatRecorders ( std::string &  token)
virtual

Implements StatHandlerBase.

42 {
43 #ifdef _DEBUG_
44  message("-MPStatHandler::setStatRecorders ");
45 #endif
46 
47  if(token.compare("extrate") == 0) {
48 
49  add("Extinction rate","extrate",ALL,0,0,&MPStatHandler::getObsrvdExtinctionRate,0,0,
51 
52  } else if(token.compare("pop") == 0) {
53 
55 
56  } else if(token.compare("pop.patch") == 0) {
57 
59 
60  } else if(token.compare("off.fem.patch") == 0) {
61 
63 
64  } else if(token.compare("off.mal.patch") == 0) {
65 
67 
68  } else if(token.compare("adlt.fem.patch") == 0) {
69 
71 
72  } else if(token.compare("adlt.mal.patch") == 0) {
73 
75 
76  } else if(token.compare("adlt.sexratio") == 0) {
77 
78  add("Adults sex ratio","adlt.sexratio",ADULTS,0,0,&MPStatHandler::getAdultSexRatio,0,0,0);
79 
80  } else if(token.compare("off.sexratio") == 0) {
81 
82  add("Offspring Sex Ratio","off.sexratio",OFFSPRG,0,0,&MPStatHandler::getOffsprgSexRatio,0,0,0);
83 
84  } else if(token.compare("migrants") == 0) {
85 
87 
88  } else if(token.compare("migrants.patch") == 0) {
89 
91 
92  } else if(token.compare("demography") == 0) {
93 
96 
97  } else if(token.compare("off.demography") == 0) {
98 
100 
101  } else if(token.compare("adlt.demography") == 0) {
102 
104 
105  } else if(token.compare("fecundity") == 0) {
106 
107  add("Females assigned fecundity","adlt.femfec",ADULTS,1,0,0,&MPStatHandler::getMeanMatings,0,0);
108  add("Females realized fecundity","adlt.femrealfec",ADULTS,1,0,0,&MPStatHandler::setReproductiveStats,0,0);
109  add("Females reproductive var ","adlt.femvarfec",ADULTS,0,0,&MPStatHandler::getReproductiveVar,0,0,0);
110  add("Males realized fecundity ","adlt.malrealfec",ADULTS,0,0,0,&MPStatHandler::setReproductiveStats,0,0);
111  add("Males reproductive var ","adlt.malvarfec",ADULTS,0,0,&MPStatHandler::getReproductiveVar,0,0,0);
112 
113  } else if(token.compare("kinship") == 0) {
114 
115  add("Proportion of full-sib offspring","off.fsib",OFFSPRG,3,0,0,&MPStatHandler::getSibProportion,0,&MPStatHandler::setKinship);
116  add("Proportion of paternal half-sib ","off.phsib",OFFSPRG,2,0,0,&MPStatHandler::getSibProportion,0,0);
117  add("Proportion of maternal half-sib ","off.mhsib",OFFSPRG,1,0,0, &MPStatHandler::getSibProportion,0,0);
118  add("Proportion of non-sib offspring ","off.nsib",OFFSPRG,0,0,0,&MPStatHandler::getSibProportion,0,0);
119  add("Proportion of selfed offspring ","off.self",OFFSPRG,4,0,0,&MPStatHandler::getSibProportion,0,0);
120 
121  } else if(token == "pedigree") {
122 
123  add("Proportion of other deme mated","ped.outb",OFFSPRG,0,0,0,&MPStatHandler::getPedProportion,0,&MPStatHandler::setPedegreeCount);
124  add("Proportion of same deme mated ","ped.outw",OFFSPRG,1,0,0,&MPStatHandler::getPedProportion,0,0);
125  add("Proportion of half-sib mated ","ped.hsib",OFFSPRG,2,0,0, &MPStatHandler::getPedProportion,0,0);
126  add("Proportion of full-sib mated ","ped.fsib",OFFSPRG,3,0,0,&MPStatHandler::getPedProportion,0,0);
127  add("Proportion of selfed mated ","ped.self",OFFSPRG,4,0,0,&MPStatHandler::getPedProportion,0,0);
128 
129  } else
130  return false;
131 
132  return true;
133 }
void setStatsForDemography(age_t AGE)
Definition: MPStatHandler.cc:147
void setStatsForPop()
Definition: MPStatHandler.cc:135
double getAdultSexRatio()
Definition: stats_demo.cc:556
void addIndNumPerPatch(sex_t SEX, age_t AGE)
Definition: MPStatHandler.cc:169
double getSibProportion(unsigned int i)
Definition: MPStatHandler.h:106
double getReproductiveVar()
Definition: MPStatHandler.h:100
void setStatsForMigrantsPerPatch()
Definition: MPStatHandler.cc:232
void setPedegreeCount()
Definition: stats_demo.cc:517
double getPedProportion(unsigned int i)
Definition: MPStatHandler.h:111
void setStatsForMigrants()
Definition: MPStatHandler.cc:222
double getOffsprgSexRatio()
Definition: stats_demo.cc:555
void setStatsForPopPerPatch()
Definition: MPStatHandler.cc:160
double getMeanMatings(unsigned int sex)
Definition: stats_demo.cc:300
double setReproductiveStats(unsigned int sex)
Definition: stats_demo.cc:334
void setKinship()
Definition: stats_demo.cc:406
void message(const char *message,...)
Definition: output.cc:39

References StatHandler< MPStatHandler >::add(), addIndNumPerPatch(), ADULTS, ALL, FEM, getAdultSexRatio(), getMeanMatings(), getObsrvdExtinctionRate(), getOffsprgSexRatio(), getPedProportion(), getReproductiveVar(), getSibProportion(), MAL, message(), OFFSPRG, setKinship(), setObsrvdExtinctionRate(), setPedegreeCount(), setReproductiveStats(), setStatsForDemography(), setStatsForMigrants(), setStatsForMigrantsPerPatch(), setStatsForPop(), and setStatsForPopPerPatch().

◆ setStatsForDemography()

void MPStatHandler::setStatsForDemography ( age_t  AGE)
148 {
149  string suffix = (AGE == ADULTS ? "adlt.":"off.");
150  string name = (AGE == ADULTS ? "Adults ":"Offspring ");
151 
152  add(name + "number", suffix + "nbr", AGE, AGE, 0, 0, &MPStatHandler::getPopulationSize,0,0);
153  add(name + "fem nbr", suffix + "nbfem", AGE, FEM, AGE, 0, 0, &MPStatHandler::getMeanPatchSizePerSex,0);
154  add(name + "mal nbr", suffix + "nbmal", AGE, MAL, AGE, 0, 0, &MPStatHandler::getMeanPatchSizePerSex,0);
155  add(name + "density", suffix + "density", AGE, AGE, 0, 0, &MPStatHandler::getMeanPatchDensity,0,0);
156  add(name + "density var", suffix + "dvar", AGE, AGE, 0, 0, &MPStatHandler::getMeanPatchDensityVariance,0,0);
157 
158 }
double getMeanPatchDensity(age_t AGE)
Definition: stats_demo.cc:221
double getMeanPatchSizePerSex(unsigned int sex, unsigned int age)
Definition: stats_demo.cc:206
double getMeanPatchDensityVariance(age_t AGE)
Definition: stats_demo.cc:237
double getPopulationSize(unsigned int age)
Definition: stats_demo.cc:559

References StatHandler< MPStatHandler >::add(), ADULTS, FEM, getMeanPatchDensity(), getMeanPatchDensityVariance(), getMeanPatchSizePerSex(), getPopulationSize(), and MAL.

Referenced by setStatRecorders(), and setStatsForPop().

+ Here is the caller graph for this function:

◆ setStatsForMigrants()

void MPStatHandler::setStatsForMigrants ( )
223 {
224  add("Emigrant nbr","emigrants",ALL,0,0,&MPStatHandler::getMeanEmigrantPerPatch,0,0,0);
225  add("Imigrant nbr","imigrants",ALL,0,0,&MPStatHandler::getMeanImigrantPerPatch,0,0,0);
226  add("Residant nbr","residents",ALL,0,0,&MPStatHandler::getMeanResidantPerPatch,0,0,0);
227  add("Imigration rate","imigrate",ALL,0,0,&MPStatHandler::getMeanMigrantRatio,0,0,0);
228  add("Coloniser nbr","colonisers",ALL,0,0,&MPStatHandler::getMeanKolonisersPerPatch,0,0,0);
229  add("Colonisation rate","colonrate",ALL,0,0,&MPStatHandler::getMeanKolonisersProportion,0,0,0);
230 }
double getMeanResidantPerPatch()
Definition: stats_demo.cc:78
double getMeanKolonisersProportion()
Definition: stats_demo.cc:95
double getMeanMigrantRatio()
Definition: stats_demo.cc:71
double getMeanImigrantPerPatch()
Definition: stats_demo.cc:54
double getMeanKolonisersPerPatch()
Definition: stats_demo.cc:112
double getMeanEmigrantPerPatch()
Definition: stats_demo.cc:42

References StatHandler< MPStatHandler >::add(), ALL, getMeanEmigrantPerPatch(), getMeanImigrantPerPatch(), getMeanKolonisersPerPatch(), getMeanKolonisersProportion(), getMeanMigrantRatio(), and getMeanResidantPerPatch().

Referenced by setStatRecorders().

+ Here is the caller graph for this function:

◆ setStatsForMigrantsPerPatch()

void MPStatHandler::setStatsForMigrantsPerPatch ( )
233 { std::ostringstream name, sub_name;
234 
235  add("Emigrants patch 1","emigr.p1", ALL,0,0,0,&MPStatHandler::getEmigrantInPatch,0,0);
236  for(unsigned int i = 1; i < _pop->getPatchNbr(); i++) {
237  name<<"Emigrants patch "<<i+1;
238  sub_name<<"emigr.p"<<i+1;
239  add(name.str(),sub_name.str(),ALL,i,0,0,&MPStatHandler::getEmigrantInPatch,0,0);
240  name.str("");
241  sub_name.str("");
242  }
243 
244  add("Residants patch 1","resid.p1", ALL,0,0,0,&MPStatHandler::getResidantInPatch,0,0);
245  for(unsigned int i = 1; i < _pop->getPatchNbr(); i++) {
246  name<<"Residants patch "<<i+1;
247  sub_name<<"resid.p"<<i+1;
248  add(name.str(),sub_name.str(),ALL,i,0,0,&MPStatHandler::getResidantInPatch,0,0);
249  name.str("");
250  sub_name.str("");
251  }
252 
253  add("Imig. rate patch 1","imrate.p1", ALL,0,0,0,&MPStatHandler::getImigrateInPatch,0,0);
254  for(unsigned int i = 1; i < _pop->getPatchNbr(); i++) {
255  name<<"Imig. rate patch "<<i+1;
256  sub_name<<"imrate.p"<<i+1;
257  add(name.str(),sub_name.str(),ALL,i,0,0,&MPStatHandler::getImigrateInPatch,0,0);
258  name.str("");
259  sub_name.str("");
260  }
261 
262  add("Colons patch 1","colo.p1", ALL,0,0,0,&MPStatHandler::getKolonisersInPatch,0,0);
263  for(unsigned int i = 1; i < _pop->getPatchNbr(); i++) {
264  name<<"Colons patch "<<i+1;
265  sub_name<<"colo.p"<<i+1;
266  add(name.str(),sub_name.str(),ALL,i,0,0,&MPStatHandler::getKolonisersInPatch,0,0);
267  name.str("");
268  sub_name.str("");
269  }
270 }
double getEmigrantInPatch(unsigned int i)
Definition: stats_demo.cc:127
double getKolonisersInPatch(unsigned int i)
Definition: stats_demo.cc:147
double getImigrateInPatch(unsigned int i)
Definition: stats_demo.cc:139
double getResidantInPatch(unsigned int i)
Definition: stats_demo.cc:133

References StatHandlerBase::_pop, StatHandler< MPStatHandler >::add(), ALL, getEmigrantInPatch(), getImigrateInPatch(), getKolonisersInPatch(), Metapop::getPatchNbr(), and getResidantInPatch().

Referenced by setStatRecorders().

+ Here is the caller graph for this function:

◆ setStatsForPop()

void MPStatHandler::setStatsForPop ( )
136 {
138  add("Offspring Sex Ratio","off.sexratio",OFFSPRG,0,0,&MPStatHandler::getOffsprgSexRatio,0,0,0);
139 
141  add("Adults sex ratio","adlt.sexratio",ADULTS,0,0,&MPStatHandler::getAdultSexRatio,0,0,0);
142 
143  add("Extinction rate","extrate",ALL,0,0,&MPStatHandler::getObsrvdExtinctionRate,0,0,
145 }

References StatHandler< MPStatHandler >::add(), ADULTS, ALL, getAdultSexRatio(), getObsrvdExtinctionRate(), getOffsprgSexRatio(), OFFSPRG, setObsrvdExtinctionRate(), and setStatsForDemography().

Referenced by setStatRecorders().

+ Here is the caller graph for this function:

◆ setStatsForPopPerPatch()

void MPStatHandler::setStatsForPopPerPatch ( )
161 {
166  addPatchAge();
167 }
void addPatchAge()
Definition: MPStatHandler.cc:202

References addIndNumPerPatch(), addPatchAge(), ADULTS, FEM, MAL, and OFFSPRG.

Referenced by setStatRecorders().

+ Here is the caller graph for this function:

Member Data Documentation

◆ _ped_prop

double MPStatHandler::_ped_prop[5]
private

Referenced by getPedProportion().

◆ _sib_prop

double MPStatHandler::_sib_prop[5]
private

Referenced by getSibProportion().

◆ _var_reprod_success

double MPStatHandler::_var_reprod_success
private

Referenced by getReproductiveVar().

◆ meanDeadDisp

double MPStatHandler::meanDeadDisp
private

◆ meanEmigrant

double MPStatHandler::meanEmigrant
private

◆ meanImigrant

double MPStatHandler::meanImigrant
private

◆ meanKolonisers

double MPStatHandler::meanKolonisers
private

◆ meanResidant

double MPStatHandler::meanResidant
private

◆ ObservedExtinctionRate

double MPStatHandler::ObservedExtinctionRate
private

Referenced by getObsrvdExtinctionRate().


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

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

Locations of visitors to this page
Catalogued on GSR