Nemo  2.3.46
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)
 
double getmeanOFD ()
 
double getmeanOMD ()
 
double getmeanFD ()
 
double getmeanMD ()
 
double getMeanDispRate ()
 
double getOffsprgMeanDispRate ()
 
double getMeanDispRate (bool)
 
double getOffsprgMeanDispRate (bool)
 
double getMeanFemDispRate ()
 
double getMeanMalDispRate ()
 
- 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(TTDispersalSH::*getStatNoArg)(void), double(TTDispersalSH::*getStatOneArg)(unsigned int), double(TTDispersalSH::*getStatTwoArg)(unsigned int, unsigned int), void(TTDispersalSH::*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 ( TProtoDispersal TT)
inline
int _mdispIdx
Definition: ttdispersal.h:179
double _meanMalDisp
Definition: ttdispersal.h:177
double _meanOffMalDisp
Definition: ttdispersal.h:177
double _meanFemDisp
Definition: ttdispersal.h:177
double _meanOffFemDisp
Definition: ttdispersal.h:177
int _fdispIdx
Definition: ttdispersal.h:179
TProtoDispersal * _trait
Definition: ttdispersal.h:175
virtual TTDispersalSH::~TTDispersalSH ( )
inlinevirtual
186 { }

Member Function Documentation

double TTDispersalSH::getMeanDispRate ( )

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

41 {
42  double meanDisp = 0;
43  unsigned int fem = 0, mal = 0, tot = 0,i,j;
44  Patch* crnt_patch;
45 
46  _meanFemDisp = 0;
47  _meanMalDisp = 0;
48 
49  for( i = 0; i < _pop->getPatchNbr(); ++i) {
50  crnt_patch = _pop->getPatch(i);
51  for( j = 0; j < crnt_patch->size(FEM, ADLTx); ++j) {
52  _meanFemDisp += *(double*)crnt_patch->get(FEM, ADLTx, j)->getTraitValue(_fdispIdx);
53  fem++;
54  }
55  for( j = 0; j < crnt_patch->size(MAL, ADLTx);++j) {
56  _meanMalDisp += *(double*)crnt_patch->get(MAL, ADLTx, j)->getTraitValue(_mdispIdx);
57  mal++;
58  }
59  }
60  meanDisp = _meanFemDisp + _meanMalDisp;
61  tot = fem + mal;
62  _meanFemDisp = (fem != 0 ? _meanFemDisp/fem : 0.0);
63  _meanMalDisp = (mal != 0 ? _meanMalDisp/mal : 0.0);
64 
65  return (tot != 0 ? meanDisp/tot : nanf("NULL"));
66 }
int _mdispIdx
Definition: ttdispersal.h:179
double _meanMalDisp
Definition: ttdispersal.h:177
void * getTraitValue(IDX T)
Accessor to the value (phenotype) of a particular trait.
Definition: individual.h:271
unsigned int size(age_t AGE)
Returns the size of the container of the appropriate age class(es) for both sexes.
Definition: metapop.h:487
double _meanFemDisp
Definition: ttdispersal.h:177
Second class in the metapopulation design structure, between the Metapop and Individual classes...
Definition: metapop.h:421
Patch * getPatch(unsigned int i)
Patch accessor, return the ith+1 patch in the metapop.
Definition: metapop.h:251
unsigned int getPatchNbr()
Definition: metapop.h:270
Definition: types.h:42
int _fdispIdx
Definition: ttdispersal.h:179
Definition: types.h:37
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:523
Metapop * _pop
Link to the current population, set through the link to the StatService.
Definition: stathandler.h:61
Definition: types.h:37
double TTDispersalSH::getMeanDispRate ( bool  sex)

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

71 {
72  double meanDispRate = 0;
73  unsigned int i,j,indnbr = 0;
74  Patch* crnt_patch;
75 
76  if(sex) {
77  for( i=0;i<_pop->getPatchNbr();++i) {
78  crnt_patch = _pop->getPatch(i);
79  for( j=0;j<crnt_patch->size(FEM, ADLTx);++j) {
80  meanDispRate += *(double*)crnt_patch->get(FEM, ADLTx, j)->getTraitValue( _fdispIdx);
81  indnbr++;
82  }
83  }
84  } else {
85  for( i=0;i<_pop->getPatchNbr();++i) {
86  crnt_patch = _pop->getPatch(i);
87  for( j=0;j<crnt_patch->size(MAL, ADLTx);++j) {
88  meanDispRate += *(double*)crnt_patch->get(MAL, ADLTx, j)->getTraitValue(_mdispIdx);
89  indnbr++;
90  }
91  }
92  }
93 
94  return (indnbr != 0 ? meanDispRate/indnbr : nanf("NULL"));
95 }
int _mdispIdx
Definition: ttdispersal.h:179
void * getTraitValue(IDX T)
Accessor to the value (phenotype) of a particular trait.
Definition: individual.h:271
unsigned int size(age_t AGE)
Returns the size of the container of the appropriate age class(es) for both sexes.
Definition: metapop.h:487
Second class in the metapopulation design structure, between the Metapop and Individual classes...
Definition: metapop.h:421
Patch * getPatch(unsigned int i)
Patch accessor, return the ith+1 patch in the metapop.
Definition: metapop.h:251
unsigned int getPatchNbr()
Definition: metapop.h:270
Definition: types.h:42
int _fdispIdx
Definition: ttdispersal.h:179
Definition: types.h:37
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:523
Metapop * _pop
Link to the current population, set through the link to the StatService.
Definition: stathandler.h:61
Definition: types.h:37
double TTDispersalSH::getmeanFD ( )
inline

References _meanFemDisp.

199 {return _meanFemDisp;}
double _meanFemDisp
Definition: ttdispersal.h:177
double TTDispersalSH::getMeanFemDispRate ( )

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

165 {
166  double meanDispRate = 0;
167  unsigned int indnbr = 0;
168  Patch* crnt_patch;
169 
170  for(unsigned int i = 0; i < _pop->getPatchNbr(); ++i) {
171 
172  crnt_patch = _pop->getPatch(i);
173 
174  for(unsigned int j = 0, size = crnt_patch->size(FEM, ADLTx); j < size; ++j)
175  meanDispRate += *(double*)crnt_patch->get(FEM, ADLTx, j)->getTraitValue(_fdispIdx);
176  }
177  indnbr = _pop->size(FEM, ADULTS);
178  return (indnbr != 0 ? meanDispRate/indnbr : nanf("NULL"));
179 }
#define ADULTS
Adults age class flag (breeders).
Definition: types.h:54
void * getTraitValue(IDX T)
Accessor to the value (phenotype) of a particular trait.
Definition: individual.h:271
unsigned int size(age_t AGE)
Returns the size of the container of the appropriate age class(es) for both sexes.
Definition: metapop.h:487
Second class in the metapopulation design structure, between the Metapop and Individual classes...
Definition: metapop.h:421
Patch * getPatch(unsigned int i)
Patch accessor, return the ith+1 patch in the metapop.
Definition: metapop.h:251
unsigned int getPatchNbr()
Definition: metapop.h:270
Definition: types.h:42
int _fdispIdx
Definition: ttdispersal.h:179
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:523
Metapop * _pop
Link to the current population, set through the link to the StatService.
Definition: stathandler.h:61
unsigned int size()
Get the total number of individuals present in the population, all sex and age classes together...
Definition: metapop.h:302
Definition: types.h:37
double TTDispersalSH::getMeanMalDispRate ( )

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

184 {
185  double meanDispRate = 0;
186  unsigned int indnbr = 0;
187  Patch* crnt_patch;
188 
189  for(unsigned int i = 0; i < _pop->getPatchNbr(); ++i) {
190 
191  crnt_patch = _pop->getPatch(i);
192 
193  for(unsigned int j = 0, size = crnt_patch->size(MAL, ADLTx); j < size; ++j)
194  meanDispRate += *(double*)crnt_patch->get(MAL, ADLTx, j)->getTraitValue(_mdispIdx);
195  }
196  indnbr = _pop->size(MAL, ADULTS);
197  return (indnbr != 0 ? meanDispRate/indnbr : nanf("NULL"));
198 }
int _mdispIdx
Definition: ttdispersal.h:179
#define ADULTS
Adults age class flag (breeders).
Definition: types.h:54
void * getTraitValue(IDX T)
Accessor to the value (phenotype) of a particular trait.
Definition: individual.h:271
unsigned int size(age_t AGE)
Returns the size of the container of the appropriate age class(es) for both sexes.
Definition: metapop.h:487
Second class in the metapopulation design structure, between the Metapop and Individual classes...
Definition: metapop.h:421
Patch * getPatch(unsigned int i)
Patch accessor, return the ith+1 patch in the metapop.
Definition: metapop.h:251
unsigned int getPatchNbr()
Definition: metapop.h:270
Definition: types.h:42
Definition: types.h:37
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:523
Metapop * _pop
Link to the current population, set through the link to the StatService.
Definition: stathandler.h:61
unsigned int size()
Get the total number of individuals present in the population, all sex and age classes together...
Definition: metapop.h:302
double TTDispersalSH::getmeanMD ( )
inline

References _meanMalDisp.

200 {return _meanMalDisp;}
double _meanMalDisp
Definition: ttdispersal.h:177
double TTDispersalSH::getmeanOFD ( )
inline

References _meanOffFemDisp.

197 {return _meanOffFemDisp;}
double _meanOffFemDisp
Definition: ttdispersal.h:177
double TTDispersalSH::getmeanOMD ( )
inline

References _meanOffMalDisp.

198 {return _meanOffMalDisp;}
double _meanOffMalDisp
Definition: ttdispersal.h:177
double TTDispersalSH::getOffsprgMeanDispRate ( )

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

100 {
101  double meanDisp = 0;
102  unsigned int fem = 0, mal = 0, tot = 0;
103  Patch* crnt_patch;
104 
105  _meanOffFemDisp = 0;
106  _meanOffMalDisp = 0;
107 
108  for(unsigned int i = 0; i < _pop->getPatchNbr(); ++i) {
109 
110  crnt_patch = _pop->getPatch(i);
111 
112  for(unsigned int j = 0, size = crnt_patch->size(FEM, OFFSx); j < size; ++j)
113  _meanOffFemDisp += *(double*)crnt_patch->get( FEM, OFFSx, j )->getTraitValue( _fdispIdx );
114 
115  for(unsigned int j = 0, size = crnt_patch->size(MAL, OFFSx); j < size; ++j)
116  _meanOffMalDisp += *(double*)crnt_patch->get( MAL, OFFSx, j )->getTraitValue( _mdispIdx );
117 
118  }
119 
120  meanDisp = _meanOffFemDisp + _meanOffMalDisp;
121  _meanOffFemDisp = ( (fem = _pop->size(FEM, OFFSPRG)) != 0 ? _meanOffFemDisp/fem : 0.0);
122  _meanOffMalDisp = ( (mal = _pop->size(MAL, OFFSPRG)) != 0 ? _meanOffMalDisp/mal : 0.0);
123 
124  return ( (tot = _pop->size(OFFSPRG)) != 0 ? meanDisp/tot : nanf("NULL"));
125 }
int _mdispIdx
Definition: ttdispersal.h:179
double _meanOffMalDisp
Definition: ttdispersal.h:177
void * getTraitValue(IDX T)
Accessor to the value (phenotype) of a particular trait.
Definition: individual.h:271
unsigned int size(age_t AGE)
Returns the size of the container of the appropriate age class(es) for both sexes.
Definition: metapop.h:487
Second class in the metapopulation design structure, between the Metapop and Individual classes...
Definition: metapop.h:421
Patch * getPatch(unsigned int i)
Patch accessor, return the ith+1 patch in the metapop.
Definition: metapop.h:251
unsigned int getPatchNbr()
Definition: metapop.h:270
double _meanOffFemDisp
Definition: ttdispersal.h:177
int _fdispIdx
Definition: ttdispersal.h:179
Definition: types.h:37
Definition: types.h:42
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:523
Metapop * _pop
Link to the current population, set through the link to the StatService.
Definition: stathandler.h:61
#define OFFSPRG
Offspring age class flag.
Definition: types.h:50
unsigned int size()
Get the total number of individuals present in the population, all sex and age classes together...
Definition: metapop.h:302
Definition: types.h:37
double TTDispersalSH::getOffsprgMeanDispRate ( bool  sex)

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

130 {
131  double meanDispRate = 0;
132  unsigned int indnbr = 0;
133  int TType = (sex ? _fdispIdx : _mdispIdx);
134  Patch* crnt_patch;
135 
136  if(sex) {
137 
138  for(unsigned int i = 0; i < _pop->getPatchNbr(); ++i){
139 
140  crnt_patch = _pop->getPatch(i);
141 
142  for(unsigned int j = 0, size = crnt_patch->size(FEM, OFFSx); j < size; ++j)
143  meanDispRate += *(double*)crnt_patch->get( FEM, OFFSx, j )->getTraitValue(TType);
144  }
145  indnbr = _pop->size(FEM, OFFSPRG);
146 
147  } else {
148 
149  for(unsigned int i = 0; i < _pop->getPatchNbr(); ++i){
150 
151  crnt_patch = _pop->getPatch(i);
152 
153  for(unsigned int j = 0, size = crnt_patch->size(MAL, OFFSx); j < size; ++j)
154  meanDispRate += *(double*)crnt_patch->get( MAL, OFFSx, j )->getTraitValue(TType);
155  }
156  indnbr = _pop->size(MAL, OFFSPRG);
157  }
158 
159  return (indnbr != 0 ? meanDispRate/indnbr : nanf("NULL"));
160 }
int _mdispIdx
Definition: ttdispersal.h:179
void * getTraitValue(IDX T)
Accessor to the value (phenotype) of a particular trait.
Definition: individual.h:271
unsigned int size(age_t AGE)
Returns the size of the container of the appropriate age class(es) for both sexes.
Definition: metapop.h:487
Second class in the metapopulation design structure, between the Metapop and Individual classes...
Definition: metapop.h:421
Patch * getPatch(unsigned int i)
Patch accessor, return the ith+1 patch in the metapop.
Definition: metapop.h:251
unsigned int getPatchNbr()
Definition: metapop.h:270
int _fdispIdx
Definition: ttdispersal.h:179
Definition: types.h:37
Definition: types.h:42
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:523
Metapop * _pop
Link to the current population, set through the link to the StatService.
Definition: stathandler.h:61
#define OFFSPRG
Offspring age class flag.
Definition: types.h:50
unsigned int size()
Get the total number of individuals present in the population, all sex and age classes together...
Definition: metapop.h:302
Definition: types.h:37
virtual void TTDispersalSH::init ( )
inlinevirtual

Reimplemented from StatHandlerBase.

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

188  {
192  }
int _mdispIdx
Definition: ttdispersal.h:179
#define MDISP
Definition: types.h:69
virtual void init()
Definition: stathandler.cc:39
int _fdispIdx
Definition: ttdispersal.h:179
int getTraitIndex(trait_t type)
Gives the index of trait with type.
Definition: indfactory.cc:128
Metapop * _pop
Link to the current population, set through the link to the StatService.
Definition: stathandler.h:61
#define FDISP
Definition: types.h:68
bool TTDispersalSH::setStatRecorders ( std::string &  token)
virtual

Implements StatHandlerBase.

360 {
361 #ifdef _DEBUG_
362  message("-TTDispersalSH::setStatRecorders ");
363 #endif
364  if(token.compare("disp") == 0) {
365 
366  add("Dispersal rate (offspring) ","off.disp",OFFSPRG,0,0,&TTDispersalSH::getOffsprgMeanDispRate,0,0,0);
367  add("Dispersal rate (offspring females)","off.fdisp",OFFSPRG,0,0,&TTDispersalSH::getmeanOFD,0,0,0);
368  add("Dispersal rate (offspring males) ","off.mdisp",OFFSPRG,0,0,&TTDispersalSH::getmeanOMD,0,0,0);
369 
370  add("Dispersal rate (adults) ","adlt.disp",ADULTS,0,0,&TTDispersalSH::getMeanDispRate,0,0,0);
371  add("Dispersal rate (adult females)","adlt.fdisp",ADULTS,0,0,&TTDispersalSH::getmeanFD,0,0,0);
372  add("Dispersal rate (adult males) ","adlt.mdisp",ADULTS,0,0,&TTDispersalSH::getmeanMD,0,0,0);
373 
374  } else if(token.compare("adlt.disp") == 0) {
375 
376  add("Dispersal rate (adults) ","adlt.disp",ADULTS,0,0,&TTDispersalSH::getMeanDispRate,0,0,0);
377  add("Dispersal rate (adult females)","adlt.fdisp",ADULTS,0,0,&TTDispersalSH::getmeanFD,0,0,0);
378  add("Dispersal rate (adult males) ","adlt.mdisp",ADULTS,0,0,&TTDispersalSH::getmeanMD,0,0,0);
379 
380  } else if(token.compare("off.disp") == 0) {
381 
382  add("Dispersal rate (offspring) ","off.disp",OFFSPRG,0,0,&TTDispersalSH::getOffsprgMeanDispRate,0,0,0);
383  add("Dispersal rate (offspring females)","off.fdisp",OFFSPRG,0,0,&TTDispersalSH::getmeanOFD,0,0,0);
384  add("Dispersal rate (offspring males) ","off.mdisp",OFFSPRG,0,0,&TTDispersalSH::getmeanOMD,0,0,0);
385 
386  } else
387  return false;
388 
389  return true;
390 }
void message(const char *message,...)
Definition: output.cc:40
double getmeanOMD()
Definition: ttdispersal.h:198
#define ADULTS
Adults age class flag (breeders).
Definition: types.h:54
double getmeanMD()
Definition: ttdispersal.h:200
double getOffsprgMeanDispRate()
Definition: stats_disp.cc:99
double getmeanFD()
Definition: ttdispersal.h:199
double getmeanOFD()
Definition: ttdispersal.h:197
virtual StatRecorder< TTDispersalSH > * add(std::string Title, std::string Name, age_t AGE, unsigned int ARG1, unsigned int ARG2, double(TTDispersalSH::*getStatNoArg)(void), double(TTDispersalSH::*getStatOneArg)(unsigned int), double(TTDispersalSH::*getStatTwoArg)(unsigned int, unsigned int), void(TTDispersalSH::*setStat)(void))
Adds a StatRecorder to the list, it is also added to the StatHandlerBase::_stats list.
Definition: stathandler.h:144
#define OFFSPRG
Offspring age class flag.
Definition: types.h:50
double getMeanDispRate()
Definition: stats_disp.cc:40

Member Data Documentation

int TTDispersalSH::_fdispIdx
private
int TTDispersalSH::_mdispIdx
private
double TTDispersalSH::_meanFemDisp
private

Referenced by getMeanDispRate(), and getmeanFD().

double TTDispersalSH::_meanMalDisp
private

Referenced by getMeanDispRate(), and getmeanMD().

double TTDispersalSH::_meanOffFemDisp
private
double TTDispersalSH::_meanOffMalDisp
private
TProtoDispersal* TTDispersalSH::_trait
private

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

Generated for Nemo v2.3.0 by  doxygen 1.8.8 --
Catalogued on GSR