Nemo  2.3.56
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 void init ()=0
 Inits state. More...
 
virtual void update ()=0
 Updates the handler state. More...
 
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:180
int _fdispIdx
Definition: ttdispersal.h:180
double _meanOffMalDisp
Definition: ttdispersal.h:178
TProtoDispersal * _trait
Definition: ttdispersal.h:176
double _meanMalDisp
Definition: ttdispersal.h:178
double _meanOffFemDisp
Definition: ttdispersal.h:178
double _meanFemDisp
Definition: ttdispersal.h:178

◆ ~TTDispersalSH()

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

Member Function Documentation

◆ addDispPerPatch()

void TTDispersalSH::addDispPerPatch ( sex_t  SEX,
age_t  AGE 
)
420{
421 string sextag = (SEX == FEM ? "fem." : "mal.");
422 string agetag = (AGE == OFFSPRG ? "off." : "adlt.");
423
424 string statname;
425
426 double (TTDispersalSH::* getter) (unsigned int);
427
428 if(AGE == ADULTS) {
429
430 if(SEX == FEM) getter = &TTDispersalSH::getPatchDisp_AF;
431 else getter = &TTDispersalSH::getPatchDisp_AM;
432
433 } else {
434
435 if(SEX == FEM) getter = &TTDispersalSH::getPatchDisp_OF;
436 else getter = &TTDispersalSH::getPatchDisp_OM;
437
438 }
439
440 for(unsigned int p = 0; p < _pop->getPatchNbr(); ++p) {
441
442 statname = agetag + sextag + "disp.p" + tstring::int2str(p+1);
443
444 add("", statname, AGE, p, 0, 0, getter, 0, 0);
445 }
446
447}
unsigned int getPatchNbr()
Definition: metapop.h:276
Metapop * _pop
Link to the current population, set through the link to the StatService.
Definition: stathandler.h:61
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:144
The StatHandler for the evolving dispersal traits.
Definition: ttdispersal.h:174
double getPatchDisp_AF(unsigned int patch)
Definition: ttdispersal.h:221
double getPatchDisp_OF(unsigned int patch)
Definition: ttdispersal.h:211
double getPatchDisp_AM(unsigned int patch)
Definition: ttdispersal.h:226
double getPatchDisp_OM(unsigned int patch)
Definition: ttdispersal.h:216
static string int2str(const int i)
Writes an integer value into a string.
Definition: tstring.h:95
@ FEM
Definition: types.h:37
#define ADULTS
Adults age class flag (breeders).
Definition: types.h:54
#define OFFSPRG
Offspring age class flag.
Definition: types.h:50

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 ( )
57{
58 double meanDisp = 0;
59 unsigned int fem = 0, mal = 0, tot = 0,i,j;
60 Patch* crnt_patch;
61
62 _meanFemDisp = 0;
63 _meanMalDisp = 0;
64
65 for( i = 0; i < _pop->getPatchNbr(); ++i) {
66 crnt_patch = _pop->getPatch(i);
67 for( j = 0; j < crnt_patch->size(FEM, ADLTx); ++j) {
68 _meanFemDisp += *(double*)crnt_patch->get(FEM, ADLTx, j)->getTraitValue(_fdispIdx);
69 fem++;
70 }
71 for( j = 0; j < crnt_patch->size(MAL, ADLTx);++j) {
72 _meanMalDisp += *(double*)crnt_patch->get(MAL, ADLTx, j)->getTraitValue(_mdispIdx);
73 mal++;
74 }
75 }
76 meanDisp = _meanFemDisp + _meanMalDisp;
77 tot = fem + mal;
78 _meanFemDisp = (fem != 0 ? _meanFemDisp/fem : 0.0);
79 _meanMalDisp = (mal != 0 ? _meanMalDisp/mal : 0.0);
80
81 return (tot != 0 ? meanDisp/tot : nanf("NULL"));
82}
void * getTraitValue(IDX T)
Accessor to the value (phenotype) of a particular trait.
Definition: individual.h:271
Patch * getPatch(unsigned int i)
Patch accessor, return the ith+1 patch in the metapop.
Definition: metapop.h:257
Second class in the metapopulation design structure, between the Metapop and Individual classes.
Definition: metapop.h:430
unsigned int size(age_t AGE)
Returns the size of the container of the appropriate age class(es) for both sexes.
Definition: metapop.h:496
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
@ MAL
Definition: types.h:37
@ ADLTx
Definition: types.h:42

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

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

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
201{return _meanFemDisp;}

References _meanFemDisp.

Referenced by setStatRecorders().

+ Here is the caller graph for this function:

◆ getMeanFemDispRate()

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

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

◆ getMeanMalDispRate()

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

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
202{return _meanMalDisp;}

References _meanMalDisp.

Referenced by setStatRecorders().

+ Here is the caller graph for this function:

◆ getmeanOFD()

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

References _meanOffFemDisp.

Referenced by setStatRecorders().

+ Here is the caller graph for this function:

◆ getmeanOMD()

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

References _meanOffMalDisp.

Referenced by setStatRecorders().

+ Here is the caller graph for this function:

◆ getOffsprgMeanDispRate() [1/2]

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

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

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
222 {
223 return getMeanDispRateInPatch(FEM, ADLTx, _fdispIdx, patch);
224 }
double getMeanDispRateInPatch(sex_t SEX, age_idx age, unsigned int traitidx, unsigned int i)
Definition: stats_disp.cc:39

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
227 {
228 return getMeanDispRateInPatch(MAL, ADLTx, _mdispIdx, patch);
229 }

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
212 {
213 return getMeanDispRateInPatch(FEM, OFFSx, _fdispIdx, patch);
214 }

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
217 {
218 return getMeanDispRateInPatch(MAL, OFFSx, _mdispIdx, patch);
219 }

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.

189 {
193 }
int getTraitIndex(trait_t type)
Gives the index of trait with type.
Definition: indfactory.cc:128
virtual void init()
Definition: stathandler.cc:39
#define MDISP
Definition: types.h:69
#define FDISP
Definition: types.h:68

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

◆ setStatRecorders()

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

Implements StatHandlerBase.

359{
360#ifdef _DEBUG_
361 message("-TTDispersalSH::setStatRecorders ");
362#endif
363 if(token == "disp") {
364
365 add("Dispersal rate (offspring) ","off.disp",OFFSPRG,0,0,&TTDispersalSH::getOffsprgMeanDispRate,0,0,0);
366 add("Dispersal rate (offspring females)","off.fdisp",OFFSPRG,0,0,&TTDispersalSH::getmeanOFD,0,0,0);
367 add("Dispersal rate (offspring males) ","off.mdisp",OFFSPRG,0,0,&TTDispersalSH::getmeanOMD,0,0,0);
368
369 add("Dispersal rate (adults) ","adlt.disp",ADULTS,0,0,&TTDispersalSH::getMeanDispRate,0,0,0);
370 add("Dispersal rate (adult females)","adlt.fdisp",ADULTS,0,0,&TTDispersalSH::getmeanFD,0,0,0);
371 add("Dispersal rate (adult males) ","adlt.mdisp",ADULTS,0,0,&TTDispersalSH::getmeanMD,0,0,0);
372
373 } else if(token == "adlt.disp") {
374
375 add("Dispersal rate (adults) ","adlt.disp",ADULTS,0,0,&TTDispersalSH::getMeanDispRate,0,0,0);
376 add("Dispersal rate (adult females)","adlt.fdisp",ADULTS,0,0,&TTDispersalSH::getmeanFD,0,0,0);
377 add("Dispersal rate (adult males) ","adlt.mdisp",ADULTS,0,0,&TTDispersalSH::getmeanMD,0,0,0);
378
379 } else if(token== "off.disp") {
380
381 add("Dispersal rate (offspring) ","off.disp",OFFSPRG,0,0,&TTDispersalSH::getOffsprgMeanDispRate,0,0,0);
382 add("Dispersal rate (offspring females)","off.fdisp",OFFSPRG,0,0,&TTDispersalSH::getmeanOFD,0,0,0);
383 add("Dispersal rate (offspring males) ","off.mdisp",OFFSPRG,0,0,&TTDispersalSH::getmeanOMD,0,0,0);
384
385 } else if(token == "off.disp.patch") {
386
389
390 } else if(token == "adlt.disp.patch") {
391
394
395 } else if(token == "off.fem.disp.patch") {
396
398
399 } else if(token == "adlt.fem.disp.patch") {
400
402
403 } else if(token == "off.mal.disp.patch") {
404
406
407 } else if(token == "adlt.mal.disp.patch") {
408
410
411 } else
412 return false;
413
414 return true;
415}
double getMeanDispRate()
Definition: stats_disp.cc:56
void addDispPerPatch(sex_t SEX, age_t AGE)
Definition: ttdispersal.cc:419
double getOffsprgMeanDispRate()
Definition: stats_disp.cc:105
double getmeanOFD()
Definition: ttdispersal.h:199
double getmeanFD()
Definition: ttdispersal.h:201
double getmeanOMD()
Definition: ttdispersal.h:200
double getmeanMD()
Definition: ttdispersal.h:202
void message(const char *message,...)
Definition: output.cc:40

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

Member Data Documentation

◆ _fdispIdx

◆ _mdispIdx

◆ _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.3.56 by  doxygen 1.9.0 -- Nemo is hosted on  Download Nemo

Locations of visitors to this page
Catalogued on GSR