Nemo  2.4.2
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
47 { }

◆ ~MPStatHandler()

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

Member Function Documentation

◆ addIndNumPerPatch()

void MPStatHandler::addIndNumPerPatch ( sex_t  SEX,
age_t  AGE 
)
169 {
170  double (MPStatHandler::* setter) (unsigned int) = 0;
171 
172  if (SEX) {
173 
174  if (AGE == ADULTS) {
175  setter = &MPStatHandler::getFemNumber;
176  } else if (AGE == OFFSPRG) {
178  }
179 
180  } else {
181 
182  if (AGE == ADULTS) {
183  setter = &MPStatHandler::getMalNumber;
184  } else if (AGE == OFFSPRG) {
186  }
187 
188  }
189 
190  string suffix = (AGE == ADULTS ? "adlt.":"off.");
191  string name = (SEX == FEM ? suffix + "fem." : suffix + "mal.");
192  string patch = "p1";
193 
194  add("", name + patch, AGE, 0, 0, 0, setter, 0, 0);
195  for(unsigned int i = 1; i < _pop->getPatchNbr(); i++) {
196  patch = "p" + tstring::int2str(i+1);
197  add("", name + patch, AGE, i, 0, 0, setter, 0, 0);
198  }
199 }
A StatHandler for the Metapop SimComponent.
Definition: MPStatHandler.h:38
double getOffMalNumber(unsigned int i)
Definition: stats_demo.cc:561
double getOffFemNumber(unsigned int i)
Definition: stats_demo.cc:560
double getFemNumber(unsigned int i)
Definition: stats_demo.cc:562
double getMalNumber(unsigned int i)
Definition: stats_demo.cc:563
unsigned int getPatchNbr()
Definition: metapop.h:274
Metapop * _pop
Link to the current population, set through the link to the StatService.
Definition: stathandler.h:59
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:142
static string int2str(const int i)
Writes an integer value into a string.
Definition: tstring.h:93
@ FEM
Definition: types.h:35
#define ADULTS
Adults age class flag (breeders).
Definition: types.h:52
#define OFFSPRG
Offspring age class flag.
Definition: types.h:48

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 ( )
202 {
203 
204  std::ostringstream name, sub_name;
205 
206  add("Patch 1 age","age.patch1",ALL,0,0,0,&MPStatHandler::getPatchAge,0,0);
207  for(unsigned int i = 1; i < _pop->getPatchNbr(); i++) {
208  name<<"Patch "<<i+1<<" age";
209  sub_name<<"age.patch"<<i+1;
210  add(name.str(),sub_name.str(),ALL,i,0,0,&MPStatHandler::getPatchAge,0,0);
211  name.str("");
212  sub_name.str("");
213  }
214 
215  add("Mean patch age","patch.avg.age",ALL,0,0,&MPStatHandler::getMeanPatchAge,0,0,0);
216  add("Extinction rate","extrate",ALL,0,0,&MPStatHandler::getObsrvdExtinctionRate,0,0,
218 }
double getObsrvdExtinctionRate()
Definition: MPStatHandler.h:76
double getMeanPatchAge()
Definition: stats_demo.cc:176
double getPatchAge(unsigned int i)
Definition: stats_demo.cc:170
void setObsrvdExtinctionRate()
Definition: stats_demo.cc:160
#define ALL
All ages age class flag.
Definition: types.h:54

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 ( )
555 {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:310
@ MAL
Definition: types.h:35

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)
127 {
128  Patch* patch = _pop->getPatch(i);
129  return (patch != 0 ? patch->nbEmigrant : 0);
130 }
Patch * getPatch(unsigned int i)
Patch accessor, return the ith+1 patch in the metapop.
Definition: metapop.h:255
Second class in the metapopulation design structure, between the Metapop and Individual classes.
Definition: metapop.h:430
unsigned short nbEmigrant
Definition: metapop.h:452

References Patch::nbEmigrant.

Referenced by setStatsForMigrantsPerPatch().

+ Here is the caller graph for this function:

◆ getFemNumber()

double MPStatHandler::getFemNumber ( unsigned int  i)
562 {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)
139 {
140  Patch* patch = _pop->getPatch(i);
141  return (patch != 0 ? (double)patch->nbImigrant/(double)(patch->nbImigrant + patch->nbPhilopat)
142  : nanf("NULL"));
143 }
unsigned short nbPhilopat
Definition: metapop.h:452
unsigned short nbImigrant
Definition: metapop.h:452

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

Referenced by setStatsForMigrantsPerPatch().

+ Here is the caller graph for this function:

◆ getKolonisersInPatch()

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

References Patch::nbKolonisers.

Referenced by setStatsForMigrantsPerPatch().

+ Here is the caller graph for this function:

◆ getMalNumber()

double MPStatHandler::getMalNumber ( unsigned int  i)
563 {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)
266 {
267  double mean = 0, sum = 0;
268  unsigned int nbpatch = 0;
269  Patch* crnt_patch;
270 
271  if((bool)sex) {
272  for(unsigned int i = 0; i < _pop->getPatchNbr(); ++i) {
273  crnt_patch = _pop->getPatch(i);
274  if(crnt_patch->size(FEM, ADLTx) != 0) {
275  nbpatch++;
276  sum = 0;
277  for(unsigned int j = 0; j < crnt_patch->size(FEM, ADLTx);++j)
278  sum += crnt_patch->get(FEM, ADLTx, j)->getFecundity();
279  mean += sum/crnt_patch->size(FEM, ADLTx);
280  }
281  }
282  } else {
283  for(unsigned int i = 0; i < _pop->getPatchNbr(); ++i) {
284  crnt_patch = _pop->getPatch(i);
285  if(crnt_patch->size(MAL, ADLTx) != 0) {
286  nbpatch++;
287  sum = 0;
288  for(unsigned int j = 0; j < crnt_patch->size(MAL, ADLTx);++j)
289  sum += crnt_patch->get(MAL, ADLTx, j)->getFecundity();
290  mean += sum/crnt_patch->size(MAL, ADLTx);
291  }
292  }
293  }
294  return (nbpatch != 0 ? mean/nbpatch : nanf("NULL"));
295 }
double getFecundity()
Definition: individual.h:131
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
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
@ ADLTx
Definition: types.h:40

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

◆ getMeanEmigrantPerPatch()

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

Referenced by setStatsForMigrants().

+ Here is the caller graph for this function:

◆ getMeanImigrantPerPatch()

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

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

Referenced by setStatsForMigrants().

+ Here is the caller graph for this function:

◆ getMeanKolonisersPerPatch()

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

References Patch::nbKolonisers.

Referenced by setStatsForMigrants().

+ Here is the caller graph for this function:

◆ getMeanKolonisersProportion()

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

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

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 ( )
71 {
73 }
double meanResidant
Definition: MPStatHandler.h:40

Referenced by setStatsForMigrants().

+ Here is the caller graph for this function:

◆ getMeanPatchAge()

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

Referenced by addPatchAge().

+ Here is the caller graph for this function:

◆ getMeanPatchDensity()

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

References ADLTx, ADULTS, and OFFSx.

Referenced by setStatsForDemography().

+ Here is the caller graph for this function:

◆ getMeanPatchDensityVariance()

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

References ADLTx, ADULTS, and OFFSx.

Referenced by setStatsForDemography().

+ Here is the caller graph for this function:

◆ getMeanPatchSize()

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

◆ getMeanPatchSizePerSex()

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

Referenced by setStatsForDemography().

+ Here is the caller graph for this function:

◆ getMeanResidantPerPatch()

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

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

Referenced by setStatsForMigrants().

+ Here is the caller graph for this function:

◆ getObsrvdExtinctionRate()

double MPStatHandler::getObsrvdExtinctionRate ( )
inline
76 {return ObservedExtinctionRate;}
double ObservedExtinctionRate
Definition: MPStatHandler.h:41

References ObservedExtinctionRate.

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

+ Here is the caller graph for this function:

◆ getOffFemNumber()

double MPStatHandler::getOffFemNumber ( unsigned int  i)
560 {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)
561 {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 ( )
554 {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)
171 {
172  Patch* patch = _pop->getPatch(i);
173  return (patch != 0 ? patch->get_age() : 0);
174 }

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 
)
557 {return _pop->size(age_t(age), patch);}

◆ getPedProportion()

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

References _ped_prop.

Referenced by setStatRecorders().

+ Here is the caller graph for this function:

◆ getPopulationSize()

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

Referenced by setStatsForDemography().

+ Here is the caller graph for this function:

◆ getReproductiveVar()

double MPStatHandler::getReproductiveVar ( )
inline
99 {return _var_reprod_success;}
double _var_reprod_success
Definition: MPStatHandler.h:43

References _var_reprod_success.

Referenced by setStatRecorders().

+ Here is the caller graph for this function:

◆ getResidantInPatch()

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

References Patch::nbPhilopat.

Referenced by setStatsForMigrantsPerPatch().

+ Here is the caller graph for this function:

◆ getSibProportion()

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

References _sib_prop.

Referenced by setStatRecorders().

+ Here is the caller graph for this function:

◆ setKinClassCounter()

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

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

◆ setKinship()

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

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 ( )
161 {
163 
164  for(unsigned int i = 0; i < _pop->getPatchNbr(); ++i)
166 
168 }
bool isEmpty()
Definition: metapop.h:486

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

+ Here is the caller graph for this function:

◆ setPedegreeCount()

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

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

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.

41 {
42 #ifdef _DEBUG_
43  message("-MPStatHandler::setStatRecorders ");
44 #endif
45 
46  if(token.compare("extrate") == 0) {
47 
48  add("Extinction rate","extrate",ALL,0,0,&MPStatHandler::getObsrvdExtinctionRate,0,0,
50 
51  } else if(token.compare("pop") == 0) {
52 
54 
55  } else if(token.compare("pop.patch") == 0) {
56 
58 
59  } else if(token.compare("off.fem.patch") == 0) {
60 
62 
63  } else if(token.compare("off.mal.patch") == 0) {
64 
66 
67  } else if(token.compare("adlt.fem.patch") == 0) {
68 
70 
71  } else if(token.compare("adlt.mal.patch") == 0) {
72 
74 
75  } else if(token.compare("adlt.sexratio") == 0) {
76 
77  add("Adults sex ratio","adlt.sexratio",ADULTS,0,0,&MPStatHandler::getAdultSexRatio,0,0,0);
78 
79  } else if(token.compare("off.sexratio") == 0) {
80 
81  add("Offspring Sex Ratio","off.sexratio",OFFSPRG,0,0,&MPStatHandler::getOffsprgSexRatio,0,0,0);
82 
83  } else if(token.compare("migrants") == 0) {
84 
86 
87  } else if(token.compare("migrants.patch") == 0) {
88 
90 
91  } else if(token.compare("demography") == 0) {
92 
95 
96  } else if(token.compare("off.demography") == 0) {
97 
99 
100  } else if(token.compare("adlt.demography") == 0) {
101 
103 
104  } else if(token.compare("fecundity") == 0) {
105 
106  add("Females assigned fecundity","adlt.femfec",ADULTS,1,0,0,&MPStatHandler::getMeanMatings,0,0);
107  add("Females realized fecundity","adlt.femrealfec",ADULTS,1,0,0,&MPStatHandler::setReproductiveStats,0,0);
108  add("Females reproductive var ","adlt.femvarfec",ADULTS,0,0,&MPStatHandler::getReproductiveVar,0,0,0);
109  add("Males realized fecundity ","adlt.malrealfec",ADULTS,0,0,0,&MPStatHandler::setReproductiveStats,0,0);
110  add("Males reproductive var ","adlt.malvarfec",ADULTS,0,0,&MPStatHandler::getReproductiveVar,0,0,0);
111 
112  } else if(token.compare("kinship") == 0) {
113 
114  add("Proportion of full-sib offspring","off.fsib",OFFSPRG,3,0,0,&MPStatHandler::getSibProportion,0,&MPStatHandler::setKinship);
115  add("Proportion of paternal half-sib ","off.phsib",OFFSPRG,2,0,0,&MPStatHandler::getSibProportion,0,0);
116  add("Proportion of maternal half-sib ","off.mhsib",OFFSPRG,1,0,0, &MPStatHandler::getSibProportion,0,0);
117  add("Proportion of non-sib offspring ","off.nsib",OFFSPRG,0,0,0,&MPStatHandler::getSibProportion,0,0);
118  add("Proportion of selfed offspring ","off.self",OFFSPRG,4,0,0,&MPStatHandler::getSibProportion,0,0);
119 
120  } else if(token == "pedigree") {
121 
122  add("Proportion of other deme mated","ped.outb",OFFSPRG,0,0,0,&MPStatHandler::getPedProportion,0,&MPStatHandler::setPedegreeCount);
123  add("Proportion of same deme mated ","ped.outw",OFFSPRG,1,0,0,&MPStatHandler::getPedProportion,0,0);
124  add("Proportion of half-sib mated ","ped.hsib",OFFSPRG,2,0,0, &MPStatHandler::getPedProportion,0,0);
125  add("Proportion of full-sib mated ","ped.fsib",OFFSPRG,3,0,0,&MPStatHandler::getPedProportion,0,0);
126  add("Proportion of selfed mated ","ped.self",OFFSPRG,4,0,0,&MPStatHandler::getPedProportion,0,0);
127 
128  } else
129  return false;
130 
131  return true;
132 }
void setStatsForDemography(age_t AGE)
Definition: MPStatHandler.cc:146
void setStatsForPop()
Definition: MPStatHandler.cc:134
double getAdultSexRatio()
Definition: stats_demo.cc:555
void addIndNumPerPatch(sex_t SEX, age_t AGE)
Definition: MPStatHandler.cc:168
double getSibProportion(unsigned int i)
Definition: MPStatHandler.h:105
double getReproductiveVar()
Definition: MPStatHandler.h:99
void setStatsForMigrantsPerPatch()
Definition: MPStatHandler.cc:231
void setPedegreeCount()
Definition: stats_demo.cc:516
double getPedProportion(unsigned int i)
Definition: MPStatHandler.h:110
void setStatsForMigrants()
Definition: MPStatHandler.cc:221
double getOffsprgSexRatio()
Definition: stats_demo.cc:554
void setStatsForPopPerPatch()
Definition: MPStatHandler.cc:159
double getMeanMatings(unsigned int sex)
Definition: stats_demo.cc:299
double setReproductiveStats(unsigned int sex)
Definition: stats_demo.cc:333
void setKinship()
Definition: stats_demo.cc:405
void message(const char *message,...)
Definition: output.cc:38

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)
147 {
148  string suffix = (AGE == ADULTS ? "adlt.":"off.");
149  string name = (AGE == ADULTS ? "Adults ":"Offspring ");
150 
151  add(name + "number", suffix + "nbr", AGE, AGE, 0, 0, &MPStatHandler::getPopulationSize,0,0);
152  add(name + "fem nbr", suffix + "nbfem", AGE, FEM, AGE, 0, 0, &MPStatHandler::getMeanPatchSizePerSex,0);
153  add(name + "mal nbr", suffix + "nbmal", AGE, MAL, AGE, 0, 0, &MPStatHandler::getMeanPatchSizePerSex,0);
154  add(name + "density", suffix + "density", AGE, AGE, 0, 0, &MPStatHandler::getMeanPatchDensity,0,0);
155  add(name + "density var", suffix + "dvar", AGE, AGE, 0, 0, &MPStatHandler::getMeanPatchDensityVariance,0,0);
156 
157 }
double getMeanPatchDensity(age_t AGE)
Definition: stats_demo.cc:220
double getMeanPatchSizePerSex(unsigned int sex, unsigned int age)
Definition: stats_demo.cc:205
double getMeanPatchDensityVariance(age_t AGE)
Definition: stats_demo.cc:236
double getPopulationSize(unsigned int age)
Definition: stats_demo.cc:558

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 ( )
222 {
223  add("Emigrant nbr","emigrants",ALL,0,0,&MPStatHandler::getMeanEmigrantPerPatch,0,0,0);
224  add("Imigrant nbr","imigrants",ALL,0,0,&MPStatHandler::getMeanImigrantPerPatch,0,0,0);
225  add("Residant nbr","residents",ALL,0,0,&MPStatHandler::getMeanResidantPerPatch,0,0,0);
226  add("Imigration rate","imigrate",ALL,0,0,&MPStatHandler::getMeanMigrantRatio,0,0,0);
227  add("Coloniser nbr","colonisers",ALL,0,0,&MPStatHandler::getMeanKolonisersPerPatch,0,0,0);
228  add("Colonisation rate","colonrate",ALL,0,0,&MPStatHandler::getMeanKolonisersProportion,0,0,0);
229 }
double getMeanResidantPerPatch()
Definition: stats_demo.cc:77
double getMeanKolonisersProportion()
Definition: stats_demo.cc:94
double getMeanMigrantRatio()
Definition: stats_demo.cc:70
double getMeanImigrantPerPatch()
Definition: stats_demo.cc:53
double getMeanKolonisersPerPatch()
Definition: stats_demo.cc:111
double getMeanEmigrantPerPatch()
Definition: stats_demo.cc:41

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

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 ( )
135 {
137  add("Offspring Sex Ratio","off.sexratio",OFFSPRG,0,0,&MPStatHandler::getOffsprgSexRatio,0,0,0);
138 
140  add("Adults sex ratio","adlt.sexratio",ADULTS,0,0,&MPStatHandler::getAdultSexRatio,0,0,0);
141 
142  add("Extinction rate","extrate",ALL,0,0,&MPStatHandler::getObsrvdExtinctionRate,0,0,
144 }

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 ( )
160 {
165  addPatchAge();
166 }
void addPatchAge()
Definition: MPStatHandler.cc:201

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.2 by  doxygen 1.9.1

Catalogued on GSR