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

The StatHandler for the evolving dispersal traits. More...

#include <ttdispersal.h>

+ Inheritance diagram for TTDispersalSH:
+ Collaboration diagram for TTDispersalSH:

Public Member Functions

 TTDispersalSH (TProtoDispersal *TT)
 
virtual ~TTDispersalSH ()
 
virtual void init ()
 
virtual bool setStatRecorders (std::string &token)
 
void addDispPerPatch (sex_t SEX, age_t AGE)
 
double getmeanOFD ()
 
double getmeanOMD ()
 
double getmeanFD ()
 
double getmeanMD ()
 
double getMeanDispRate ()
 
double getOffsprgMeanDispRate ()
 
double getMeanDispRate (sex_t sex)
 
double getOffsprgMeanDispRate (sex_t sex)
 
double getMeanFemDispRate ()
 
double getMeanMalDispRate ()
 
double getMeanDispRateInPatch (sex_t SEX, age_idx age, unsigned int traitidx, unsigned int i)
 
double getPatchDisp_OF (unsigned int patch)
 
double getPatchDisp_OM (unsigned int patch)
 
double getPatchDisp_AF (unsigned int patch)
 
double getPatchDisp_AM (unsigned int patch)
 
- Public Member Functions inherited from StatHandler< TTDispersalSH >
 StatHandler ()
 
virtual ~StatHandler ()
 
virtual void clear ()
 Empties the _recorders list, they are destroyed in StatHandlerBase::reset(). More...
 
virtual StatRecorder< TTDispersalSH > * 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 update ()
 This function is left empty as the StatServices calls StatRecorder::setVal directly. More...
 
- Public Member Functions inherited from Handler
virtual ~Handler ()
 

Private Attributes

TProtoDispersal_trait
 
double _meanFemDisp
 
double _meanMalDisp
 
double _meanOffFemDisp
 
double _meanOffMalDisp
 
int _fdispIdx
 
int _mdispIdx
 

Additional Inherited Members

- Protected Types inherited from StatHandler< TTDispersalSH >
typedef std::list< StatRecorder< TTDispersalSH > * >::iterator REC_IT
 
- Protected Attributes inherited from StatHandler< TTDispersalSH >
std::list< StatRecorder< TTDispersalSH > * > _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

The StatHandler for the evolving dispersal traits.

Constructor & Destructor Documentation

◆ TTDispersalSH()

TTDispersalSH::TTDispersalSH ( TProtoDispersal TT)
inline
int _mdispIdx
Definition: ttdispersal.h:202
int _fdispIdx
Definition: ttdispersal.h:202
double _meanOffMalDisp
Definition: ttdispersal.h:200
TProtoDispersal * _trait
Definition: ttdispersal.h:198
double _meanMalDisp
Definition: ttdispersal.h:200
double _meanOffFemDisp
Definition: ttdispersal.h:200
double _meanFemDisp
Definition: ttdispersal.h:200

◆ ~TTDispersalSH()

virtual TTDispersalSH::~TTDispersalSH ( )
inlinevirtual
209 { }

Member Function Documentation

◆ addDispPerPatch()

void TTDispersalSH::addDispPerPatch ( sex_t  SEX,
age_t  AGE 
)
419 {
420  string sextag = (SEX == FEM ? "fem." : "mal.");
421  string agetag = (AGE == OFFSPRG ? "off." : "adlt.");
422 
423  string statname;
424 
425  double (TTDispersalSH::* getter) (unsigned int);
426 
427  if(AGE == ADULTS) {
428 
429  if(SEX == FEM) getter = &TTDispersalSH::getPatchDisp_AF;
430  else getter = &TTDispersalSH::getPatchDisp_AM;
431 
432  } else {
433 
434  if(SEX == FEM) getter = &TTDispersalSH::getPatchDisp_OF;
435  else getter = &TTDispersalSH::getPatchDisp_OM;
436 
437  }
438 
439  for(unsigned int p = 0; p < _pop->getPatchNbr(); ++p) {
440 
441  statname = agetag + sextag + "disp.p" + tstring::int2str(p+1);
442 
443  add("", statname, AGE, p, 0, 0, getter, 0, 0);
444  }
445 
446 }
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< TTDispersalSH > * 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
The StatHandler for the evolving dispersal traits.
Definition: ttdispersal.h:196
double getPatchDisp_AF(unsigned int patch)
Definition: ttdispersal.h:243
double getPatchDisp_OF(unsigned int patch)
Definition: ttdispersal.h:233
double getPatchDisp_AM(unsigned int patch)
Definition: ttdispersal.h:248
double getPatchDisp_OM(unsigned int patch)
Definition: ttdispersal.h:238
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< TTDispersalSH >::add(), ADULTS, FEM, getPatchDisp_AF(), getPatchDisp_AM(), getPatchDisp_OF(), getPatchDisp_OM(), Metapop::getPatchNbr(), tstring::int2str(), and OFFSPRG.

Referenced by setStatRecorders().

+ Here is the caller graph for this function:

◆ getMeanDispRate() [1/2]

double TTDispersalSH::getMeanDispRate ( )
56 {
57  double meanDisp = 0;
58  unsigned int fem = 0, mal = 0, tot = 0,i,j;
59  Patch* crnt_patch;
60 
61  _meanFemDisp = 0;
62  _meanMalDisp = 0;
63 
64  for( i = 0; i < _pop->getPatchNbr(); ++i) {
65  crnt_patch = _pop->getPatch(i);
66  for( j = 0; j < crnt_patch->size(FEM, ADLTx); ++j) {
67  _meanFemDisp += *(double*)crnt_patch->get(FEM, ADLTx, j)->getTraitValue(_fdispIdx);
68  fem++;
69  }
70  for( j = 0; j < crnt_patch->size(MAL, ADLTx);++j) {
71  _meanMalDisp += *(double*)crnt_patch->get(MAL, ADLTx, j)->getTraitValue(_mdispIdx);
72  mal++;
73  }
74  }
75  meanDisp = _meanFemDisp + _meanMalDisp;
76  tot = fem + mal;
77  _meanFemDisp = (fem != 0 ? _meanFemDisp/fem : 0.0);
78  _meanMalDisp = (mal != 0 ? _meanMalDisp/mal : 0.0);
79 
80  return (tot != 0 ? meanDisp/tot : nanf("NULL"));
81 }
void * getTraitValue(IDX T)
Accessor to the value (phenotype) of a particular trait.
Definition: individual.h:270
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 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
@ MAL
Definition: types.h:36
@ ADLTx
Definition: types.h:41

References _fdispIdx, _mdispIdx, _meanFemDisp, _meanMalDisp, StatHandlerBase::_pop, ADLTx, FEM, Patch::get(), Metapop::getPatch(), Metapop::getPatchNbr(), Individual::getTraitValue(), MAL, and Patch::size().

Referenced by setStatRecorders().

+ Here is the caller graph for this function:

◆ getMeanDispRate() [2/2]

double TTDispersalSH::getMeanDispRate ( sex_t  sex)
86 {
87  double meanDispRate = 0;
88  unsigned int i,j,indnbr = 0, traitidx = (sex == FEM ? _fdispIdx : _mdispIdx);
89  Patch* crnt_patch;
90 
91  for( i=0;i<_pop->getPatchNbr();++i) {
92  crnt_patch = _pop->getPatch(i);
93  for( j=0;j<crnt_patch->size(sex, ADLTx);++j) {
94  meanDispRate += *(double*)crnt_patch->get(sex, ADLTx, j)->getTraitValue( traitidx );
95  indnbr++;
96  }
97  }
98 
99  return (indnbr != 0 ? meanDispRate/indnbr : nanf("NULL"));
100 }

References _fdispIdx, _mdispIdx, StatHandlerBase::_pop, ADLTx, FEM, Patch::get(), Metapop::getPatch(), Metapop::getPatchNbr(), Individual::getTraitValue(), and Patch::size().

◆ getMeanDispRateInPatch()

double TTDispersalSH::getMeanDispRateInPatch ( sex_t  SEX,
age_idx  age,
unsigned int  traitidx,
unsigned int  i 
)
39 {
40  double meanDisp = 0;
41  unsigned int tot = 0;
42 
43  Patch* crnt_patch = _pop->getPatchPtr(i);
44 
45  for(unsigned int j = 0; j < crnt_patch->size(SEX, age); ++j) {
46  meanDisp += *(double*)crnt_patch->get(SEX, age, j)->getTraitValue(traitidx);
47  tot++;
48  }
49 
50  return (tot != 0 ? meanDisp/tot : nanf("NULL"));
51 }
Patch * getPatchPtr(unsigned int patch)
A secure version of the getPatch() method.
Definition: metapop.h:259

References StatHandlerBase::_pop, Patch::get(), Metapop::getPatchPtr(), Individual::getTraitValue(), and Patch::size().

Referenced by getPatchDisp_AF(), getPatchDisp_AM(), getPatchDisp_OF(), and getPatchDisp_OM().

+ Here is the caller graph for this function:

◆ getmeanFD()

double TTDispersalSH::getmeanFD ( )
inline
223 {return _meanFemDisp;}

References _meanFemDisp.

Referenced by setStatRecorders().

+ Here is the caller graph for this function:

◆ getMeanFemDispRate()

double TTDispersalSH::getMeanFemDispRate ( )
170 {
171  double meanDispRate = 0;
172  unsigned int indnbr = 0;
173  Patch* crnt_patch;
174 
175  for(unsigned int i = 0; i < _pop->getPatchNbr(); ++i) {
176 
177  crnt_patch = _pop->getPatch(i);
178 
179  for(unsigned int j = 0, size = crnt_patch->size(FEM, ADLTx); j < size; ++j)
180  meanDispRate += *(double*)crnt_patch->get(FEM, ADLTx, j)->getTraitValue(_fdispIdx);
181  }
182  indnbr = _pop->size(FEM, ADULTS);
183  return (indnbr != 0 ? meanDispRate/indnbr : nanf("NULL"));
184 }
unsigned int size()
Get the total number of individuals present in the population, all sex and age classes together.
Definition: metapop.h:311

References _fdispIdx, StatHandlerBase::_pop, ADLTx, ADULTS, FEM, Patch::get(), Metapop::getPatch(), Metapop::getPatchNbr(), Individual::getTraitValue(), Metapop::size(), and Patch::size().

◆ getMeanMalDispRate()

double TTDispersalSH::getMeanMalDispRate ( )
189 {
190  double meanDispRate = 0;
191  unsigned int indnbr = 0;
192  Patch* crnt_patch;
193 
194  for(unsigned int i = 0; i < _pop->getPatchNbr(); ++i) {
195 
196  crnt_patch = _pop->getPatch(i);
197 
198  for(unsigned int j = 0, size = crnt_patch->size(MAL, ADLTx); j < size; ++j)
199  meanDispRate += *(double*)crnt_patch->get(MAL, ADLTx, j)->getTraitValue(_mdispIdx);
200  }
201  indnbr = _pop->size(MAL, ADULTS);
202  return (indnbr != 0 ? meanDispRate/indnbr : nanf("NULL"));
203 }

References _mdispIdx, StatHandlerBase::_pop, ADLTx, ADULTS, Patch::get(), Metapop::getPatch(), Metapop::getPatchNbr(), Individual::getTraitValue(), MAL, Metapop::size(), and Patch::size().

◆ getmeanMD()

double TTDispersalSH::getmeanMD ( )
inline
224 {return _meanMalDisp;}

References _meanMalDisp.

Referenced by setStatRecorders().

+ Here is the caller graph for this function:

◆ getmeanOFD()

double TTDispersalSH::getmeanOFD ( )
inline
221 {return _meanOffFemDisp;}

References _meanOffFemDisp.

Referenced by setStatRecorders().

+ Here is the caller graph for this function:

◆ getmeanOMD()

double TTDispersalSH::getmeanOMD ( )
inline
222 {return _meanOffMalDisp;}

References _meanOffMalDisp.

Referenced by setStatRecorders().

+ Here is the caller graph for this function:

◆ getOffsprgMeanDispRate() [1/2]

double TTDispersalSH::getOffsprgMeanDispRate ( )
105 {
106  double meanDisp = 0;
107  unsigned int fem = 0, mal = 0, tot = 0;
108  Patch* crnt_patch;
109 
110  _meanOffFemDisp = 0;
111  _meanOffMalDisp = 0;
112 
113  for(unsigned int i = 0; i < _pop->getPatchNbr(); ++i) {
114 
115  crnt_patch = _pop->getPatch(i);
116 
117  for(unsigned int j = 0, size = crnt_patch->size(FEM, OFFSx); j < size; ++j)
118  _meanOffFemDisp += *(double*)crnt_patch->get( FEM, OFFSx, j )->getTraitValue( _fdispIdx );
119 
120  for(unsigned int j = 0, size = crnt_patch->size(MAL, OFFSx); j < size; ++j)
121  _meanOffMalDisp += *(double*)crnt_patch->get( MAL, OFFSx, j )->getTraitValue( _mdispIdx );
122 
123  }
124 
125  meanDisp = _meanOffFemDisp + _meanOffMalDisp;
126  _meanOffFemDisp = ( (fem = _pop->size(FEM, OFFSPRG)) != 0 ? _meanOffFemDisp/fem : 0.0);
127  _meanOffMalDisp = ( (mal = _pop->size(MAL, OFFSPRG)) != 0 ? _meanOffMalDisp/mal : 0.0);
128 
129  return ( (tot = _pop->size(OFFSPRG)) != 0 ? meanDisp/tot : nanf("NULL"));
130 }
@ OFFSx
Definition: types.h:41

References _fdispIdx, _mdispIdx, _meanOffFemDisp, _meanOffMalDisp, StatHandlerBase::_pop, FEM, Patch::get(), Metapop::getPatch(), Metapop::getPatchNbr(), Individual::getTraitValue(), MAL, OFFSPRG, OFFSx, Metapop::size(), and Patch::size().

Referenced by setStatRecorders().

+ Here is the caller graph for this function:

◆ getOffsprgMeanDispRate() [2/2]

double TTDispersalSH::getOffsprgMeanDispRate ( sex_t  sex)
135 {
136  double meanDispRate = 0;
137  unsigned int indnbr = 0;
138  int TType = (sex == FEM ? _fdispIdx : _mdispIdx);
139  Patch* crnt_patch;
140 
141  if(sex) {
142 
143  for(unsigned int i = 0; i < _pop->getPatchNbr(); ++i){
144 
145  crnt_patch = _pop->getPatch(i);
146 
147  for(unsigned int j = 0, size = crnt_patch->size(FEM, OFFSx); j < size; ++j)
148  meanDispRate += *(double*)crnt_patch->get( FEM, OFFSx, j )->getTraitValue(TType);
149  }
150  indnbr = _pop->size(FEM, OFFSPRG);
151 
152  } else {
153 
154  for(unsigned int i = 0; i < _pop->getPatchNbr(); ++i){
155 
156  crnt_patch = _pop->getPatch(i);
157 
158  for(unsigned int j = 0, size = crnt_patch->size(MAL, OFFSx); j < size; ++j)
159  meanDispRate += *(double*)crnt_patch->get( MAL, OFFSx, j )->getTraitValue(TType);
160  }
161  indnbr = _pop->size(MAL, OFFSPRG);
162  }
163 
164  return (indnbr != 0 ? meanDispRate/indnbr : nanf("NULL"));
165 }

References _fdispIdx, _mdispIdx, StatHandlerBase::_pop, FEM, Patch::get(), Metapop::getPatch(), Metapop::getPatchNbr(), Individual::getTraitValue(), MAL, OFFSPRG, OFFSx, Metapop::size(), and Patch::size().

◆ getPatchDisp_AF()

double TTDispersalSH::getPatchDisp_AF ( unsigned int  patch)
inline
244  {
245  return getMeanDispRateInPatch(FEM, ADLTx, _fdispIdx, patch);
246  }
double getMeanDispRateInPatch(sex_t SEX, age_idx age, unsigned int traitidx, unsigned int i)
Definition: stats_disp.cc:38

References _fdispIdx, ADLTx, FEM, and getMeanDispRateInPatch().

Referenced by addDispPerPatch().

+ Here is the caller graph for this function:

◆ getPatchDisp_AM()

double TTDispersalSH::getPatchDisp_AM ( unsigned int  patch)
inline
249  {
250  return getMeanDispRateInPatch(MAL, ADLTx, _mdispIdx, patch);
251  }

References _mdispIdx, ADLTx, getMeanDispRateInPatch(), and MAL.

Referenced by addDispPerPatch().

+ Here is the caller graph for this function:

◆ getPatchDisp_OF()

double TTDispersalSH::getPatchDisp_OF ( unsigned int  patch)
inline
234  {
235  return getMeanDispRateInPatch(FEM, OFFSx, _fdispIdx, patch);
236  }

References _fdispIdx, FEM, getMeanDispRateInPatch(), and OFFSx.

Referenced by addDispPerPatch().

+ Here is the caller graph for this function:

◆ getPatchDisp_OM()

double TTDispersalSH::getPatchDisp_OM ( unsigned int  patch)
inline
239  {
240  return getMeanDispRateInPatch(MAL, OFFSx, _mdispIdx, patch);
241  }

References _mdispIdx, getMeanDispRateInPatch(), MAL, and OFFSx.

Referenced by addDispPerPatch().

+ Here is the caller graph for this function:

◆ init()

virtual void TTDispersalSH::init ( )
inlinevirtual

Reimplemented from StatHandlerBase.

211  {
215  }
int getTraitIndex(trait_t type)
Gives the index of trait with type.
Definition: indfactory.cc:127
virtual void init()
Definition: stathandler.cc:38
#define MDISP
Definition: types.h:68
#define FDISP
Definition: types.h:67

References _fdispIdx, _mdispIdx, StatHandlerBase::_pop, FDISP, IndFactory::getTraitIndex(), StatHandlerBase::init(), and MDISP.

◆ setStatRecorders()

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

Implements StatHandlerBase.

358 {
359 #ifdef _DEBUG_
360  message("-TTDispersalSH::setStatRecorders ");
361 #endif
362  if(token == "disp") {
363 
364  add("Dispersal rate (offspring) ","off.disp",OFFSPRG,0,0,&TTDispersalSH::getOffsprgMeanDispRate,0,0,0);
365  add("Dispersal rate (offspring females)","off.fdisp",OFFSPRG,0,0,&TTDispersalSH::getmeanOFD,0,0,0);
366  add("Dispersal rate (offspring males) ","off.mdisp",OFFSPRG,0,0,&TTDispersalSH::getmeanOMD,0,0,0);
367 
368  add("Dispersal rate (adults) ","adlt.disp",ADULTS,0,0,&TTDispersalSH::getMeanDispRate,0,0,0);
369  add("Dispersal rate (adult females)","adlt.fdisp",ADULTS,0,0,&TTDispersalSH::getmeanFD,0,0,0);
370  add("Dispersal rate (adult males) ","adlt.mdisp",ADULTS,0,0,&TTDispersalSH::getmeanMD,0,0,0);
371 
372  } else if(token == "adlt.disp") {
373 
374  add("Dispersal rate (adults) ","adlt.disp",ADULTS,0,0,&TTDispersalSH::getMeanDispRate,0,0,0);
375  add("Dispersal rate (adult females)","adlt.fdisp",ADULTS,0,0,&TTDispersalSH::getmeanFD,0,0,0);
376  add("Dispersal rate (adult males) ","adlt.mdisp",ADULTS,0,0,&TTDispersalSH::getmeanMD,0,0,0);
377 
378  } else if(token== "off.disp") {
379 
380  add("Dispersal rate (offspring) ","off.disp",OFFSPRG,0,0,&TTDispersalSH::getOffsprgMeanDispRate,0,0,0);
381  add("Dispersal rate (offspring females)","off.fdisp",OFFSPRG,0,0,&TTDispersalSH::getmeanOFD,0,0,0);
382  add("Dispersal rate (offspring males) ","off.mdisp",OFFSPRG,0,0,&TTDispersalSH::getmeanOMD,0,0,0);
383 
384  } else if(token == "off.disp.patch") {
385 
388 
389  } else if(token == "adlt.disp.patch") {
390 
393 
394  } else if(token == "off.fem.disp.patch") {
395 
397 
398  } else if(token == "adlt.fem.disp.patch") {
399 
401 
402  } else if(token == "off.mal.disp.patch") {
403 
405 
406  } else if(token == "adlt.mal.disp.patch") {
407 
409 
410  } else
411  return false;
412 
413  return true;
414 }
double getMeanDispRate()
Definition: stats_disp.cc:55
void addDispPerPatch(sex_t SEX, age_t AGE)
Definition: ttdispersal.cc:418
double getOffsprgMeanDispRate()
Definition: stats_disp.cc:104
double getmeanOFD()
Definition: ttdispersal.h:221
double getmeanFD()
Definition: ttdispersal.h:223
double getmeanOMD()
Definition: ttdispersal.h:222
double getmeanMD()
Definition: ttdispersal.h:224
void message(const char *message,...)
Definition: output.cc:39

References StatHandler< TTDispersalSH >::add(), addDispPerPatch(), ADULTS, FEM, getMeanDispRate(), getmeanFD(), getmeanMD(), getmeanOFD(), getmeanOMD(), getOffsprgMeanDispRate(), MAL, message(), and OFFSPRG.

Member Data Documentation

◆ _fdispIdx

int TTDispersalSH::_fdispIdx
private

◆ _mdispIdx

int TTDispersalSH::_mdispIdx
private

◆ _meanFemDisp

double TTDispersalSH::_meanFemDisp
private

Referenced by getMeanDispRate(), and getmeanFD().

◆ _meanMalDisp

double TTDispersalSH::_meanMalDisp
private

Referenced by getMeanDispRate(), and getmeanMD().

◆ _meanOffFemDisp

double TTDispersalSH::_meanOffFemDisp
private

◆ _meanOffMalDisp

double TTDispersalSH::_meanOffMalDisp
private

◆ _trait

TProtoDispersal* TTDispersalSH::_trait
private

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