Nemo  2.3.46
TProtoDispersal Class Reference

Prototype of the evolving dispersal trait, defines the sex-specific trait type. More...

#include <ttdispersal.h>

+ Inheritance diagram for TProtoDispersal:
+ Collaboration diagram for TProtoDispersal:

Public Member Functions

 TProtoDispersal (sex_t sex)
 
 TProtoDispersal (const TProtoDispersal &TP)
 
 ~TProtoDispersal ()
 
virtual void init ()
 
virtual void reset ()
 
virtual TTDispersalhatch ()
 
virtual TProtoDispersalclone ()
 
virtual trait_t get_type () const
 
virtual void store_data (BinaryStorageBuffer *saver)
 
virtual bool retrieve_data (BinaryStorageBuffer *reader)
 
virtual bool setParameters ()
 
virtual void loadFileServices (FileServices *loader)
 
virtual void loadStatServices (StatServices *loader)
 
bool setNonRandom ()
 
bool setRandom ()
 
bool get_init_mode ()
 
TMatrixget_init_dist_params ()
 
string get_init_dist ()
 
- Public Member Functions inherited from TraitPrototype
virtual void set_index (int idx)
 Sets the traits index. More...
 
virtual int get_index ()
 Index getter. More...
 
- Public Member Functions inherited from StorableComponent
virtual ~StorableComponent ()
 
- Public Member Functions inherited from SimComponent
 SimComponent ()
 
virtual ~SimComponent ()
 
virtual void loadUpdaters (UpdaterServices *loader)
 Loads the parameters and component updater onto the updater manager. More...
 
virtual void set_paramset (ParamSet *paramset)
 Sets the ParamSet member. More...
 
virtual void set_paramset (std::string name, bool required, SimComponent *owner)
 Sets a new ParamSet and name it. More...
 
virtual void set_paramsetFromCopy (const ParamSet &PSet)
 Reset the set of parameters from a another set. More...
 
virtual ParamSetget_paramset ()
 ParamSet accessor. More...
 
virtual void add_parameter (Param *param)
 Interface to add a parameter to the set. More...
 
virtual void add_parameter (std::string Name, param_t Type, bool isRequired, bool isBounded, double low_bnd, double up_bnd)
 Interface to add a parameter to the set. More...
 
virtual void add_parameter (std::string Name, param_t Type, bool isRequired, bool isBounded, double low_bnd, double up_bnd, ParamUpdaterBase *updater)
 Interface to add a parameter and its updater to the set. More...
 
virtual Paramget_parameter (std::string name)
 Param getter. More...
 
virtual double get_parameter_value (std::string name)
 Param value getter. More...
 
virtual string get_name ()
 Returnd the name of the ParamSet, i.e. More...
 

Private Attributes

double _mut_rate
 The allelic mutation rate. More...
 
double _mut_mean
 Mean mutation step. More...
 
double _init_rate_fem
 Initial allele for female dispersal. More...
 
double _init_rate_mal
 Initial allele for male dispersal. More...
 
string _init_dist
 
TMatrix _init_dist_param
 
bool _init_random
 
sex_t _gender
 The gender of the trait, will determine its type. More...
 
trait_t _type
 The trait's type. More...
 
TTDispersalSH_stats
 The trait's StatHandler. More...
 

Additional Inherited Members

- Protected Attributes inherited from TraitPrototype
int _index
 The trait index in the Individual traits table. More...
 
- Protected Attributes inherited from SimComponent
ParamSet_paramSet
 The parameters container. More...
 

Detailed Description

Prototype of the evolving dispersal trait, defines the sex-specific trait type.

Constructor & Destructor Documentation

TProtoDispersal::TProtoDispersal ( sex_t  sex)

Referenced by clone().

44 : _mut_rate(0), _mut_mean(0.2), _init_rate_fem(-1.0), _init_rate_mal(-1.0), _gender(sex), _stats(0)
45 {
46  _type = (_gender == FEM ? FDISP : MDISP);
47 
48  set_paramset("dispersal", false, this);
49 
50  add_parameter("disp_mutation_rate",DBL,true,true,0,1);
51  add_parameter("disp_mutation_mean",DBL,true,true,0,1);
52  add_parameter("disp_init_rate",DBL,false,true,0,1);
53  add_parameter("disp_init_rate_fem",DBL,false,true,0,1);
54  add_parameter("disp_init_rate_mal",DBL,false,true,0,1);
55  add_parameter("disp_init_distribution", STR, false, false, 0, 0);
56  add_parameter("disp_init_dist_params", MAT, false, false, 0, 0);
57 }
#define MDISP
Definition: types.h:69
sex_t _gender
The gender of the trait, will determine its type.
Definition: ttdispersal.h:160
virtual void set_paramset(ParamSet *paramset)
Sets the ParamSet member.
Definition: simcomponent.h:86
Definition: types.h:78
virtual void add_parameter(Param *param)
Interface to add a parameter to the set.
Definition: simcomponent.h:112
double _mut_rate
The allelic mutation rate.
Definition: ttdispersal.h:147
TTDispersalSH * _stats
The trait's StatHandler.
Definition: ttdispersal.h:164
Definition: types.h:78
trait_t _type
The trait's type.
Definition: ttdispersal.h:162
double _init_rate_mal
Initial allele for male dispersal.
Definition: ttdispersal.h:153
double _init_rate_fem
Initial allele for female dispersal.
Definition: ttdispersal.h:151
#define FDISP
Definition: types.h:68
double _mut_mean
Mean mutation step.
Definition: ttdispersal.h:149
Definition: types.h:37
Definition: types.h:78
TProtoDispersal::TProtoDispersal ( const TProtoDispersal TP)
64 {
65  _paramSet = new ParamSet( *(TP._paramSet) ) ;
66 }
sex_t _gender
The gender of the trait, will determine its type.
Definition: ttdispersal.h:160
double _mut_rate
The allelic mutation rate.
Definition: ttdispersal.h:147
TTDispersalSH * _stats
The trait's StatHandler.
Definition: ttdispersal.h:164
trait_t _type
The trait's type.
Definition: ttdispersal.h:162
ParamSet * _paramSet
The parameters container.
Definition: simcomponent.h:48
double _init_rate_mal
Initial allele for male dispersal.
Definition: ttdispersal.h:153
double _init_rate_fem
Initial allele for female dispersal.
Definition: ttdispersal.h:151
double _mut_mean
Mean mutation step.
Definition: ttdispersal.h:149
Parameters container, implemented in each SimComponent.
Definition: param.h:203
TProtoDispersal::~TProtoDispersal ( )
71 {
72  if(_stats != NULL) delete _stats;
73 }
TTDispersalSH * _stats
The trait's StatHandler.
Definition: ttdispersal.h:164

Member Function Documentation

virtual TProtoDispersal* TProtoDispersal::clone ( )
inlinevirtual

Implements TraitPrototype.

References TProtoDispersal().

128 {return new TProtoDispersal(*this);}
TProtoDispersal(sex_t sex)
Definition: ttdispersal.cc:43
string TProtoDispersal::get_init_dist ( )
inline

References _init_dist.

143 {return _init_dist;}
string _init_dist
Definition: ttdispersal.h:155
TMatrix* TProtoDispersal::get_init_dist_params ( )
inline

References _init_dist_param.

142 {return &_init_dist_param;}
TMatrix _init_dist_param
Definition: ttdispersal.h:156
bool TProtoDispersal::get_init_mode ( )
inline

References _init_random.

141 {return _init_random;}
bool _init_random
Definition: ttdispersal.h:157
virtual trait_t TProtoDispersal::get_type ( ) const
inlinevirtual

Implements TraitPrototype.

References _type.

129 {return _type;}
trait_t _type
The trait's type.
Definition: ttdispersal.h:162
TTDispersal * TProtoDispersal::hatch ( )
virtual

Implements TraitPrototype.

190 {
191  TTDispersal* new_trait = new TTDispersal(_gender);
192 
193  new_trait->set_mut_rate(_mut_rate);
194  new_trait->set_mut_mean(_mut_mean);
195  new_trait->set_init_rate_fem(_init_rate_fem);
196  new_trait->set_init_rate_mal(_init_rate_mal);
197  new_trait->set_gender(_gender);
198  new_trait->set_type(_type);
199  new_trait->set_proto(this);
200 
201  return new_trait;
202 }
void set_init_rate_fem(double val)
Definition: ttdispersal.h:78
void set_mut_mean(double val)
Definition: ttdispersal.h:77
void set_init_rate_mal(double val)
Definition: ttdispersal.h:79
sex_t _gender
The gender of the trait, will determine its type.
Definition: ttdispersal.h:160
void set_mut_rate(double val)
Definition: ttdispersal.h:76
double _mut_rate
The allelic mutation rate.
Definition: ttdispersal.h:147
trait_t _type
The trait's type.
Definition: ttdispersal.h:162
void set_gender(sex_t val)
Definition: ttdispersal.h:80
Evolving dispersal trait, codes for female (_type = FDISP) or male (_type = MDISP) sex-specific dispe...
Definition: ttdispersal.h:43
void set_type(trait_t val)
Definition: ttdispersal.h:81
void set_proto(TProtoDispersal *P)
Definition: ttdispersal.h:82
double _init_rate_mal
Initial allele for male dispersal.
Definition: ttdispersal.h:153
double _init_rate_fem
Initial allele for female dispersal.
Definition: ttdispersal.h:151
double _mut_mean
Mean mutation step.
Definition: ttdispersal.h:149
virtual void TProtoDispersal::init ( )
inlinevirtual
125 {}
virtual void TProtoDispersal::loadFileServices ( FileServices loader)
inlinevirtual

Implements SimComponent.

135 {}
void TProtoDispersal::loadStatServices ( StatServices loader)
virtual

Implements SimComponent.

180 {
181  //allocate the stat handler
182  if(_stats == NULL)
183  _stats = new TTDispersalSH(this);
184  if(_stats != NULL) loader->attach(_stats);
185 }
TTDispersalSH * _stats
The trait's StatHandler.
Definition: ttdispersal.h:164
The StatHandler for the evolving dispersal traits.
Definition: ttdispersal.h:173
virtual void attach(Handler *H)
attach the StatHandler to the current list (_statHandlers) of the StatServices
Definition: statservices.cc:177
virtual void TProtoDispersal::reset ( )
inlinevirtual

Implements TraitPrototype.

126 {}
virtual bool TProtoDispersal::retrieve_data ( BinaryStorageBuffer reader)
inlinevirtual

Implements StorableComponent.

References _gender, _type, and BinaryStorageBuffer::read().

132 {reader->read(&_type, sizeof(trait_t));reader->read(&_gender, sizeof(sex_t));return true;}
std::string trait_t
Trait types.
Definition: types.h:63
sex_t _gender
The gender of the trait, will determine its type.
Definition: ttdispersal.h:160
trait_t _type
The trait's type.
Definition: ttdispersal.h:162
sex_t
Sex types, males are always 0 and females 1!!
Definition: types.h:36
void read(void *out, unsigned int nb_bytes)
Definition: binarystoragebuffer.h:147
bool TProtoDispersal::setNonRandom ( )
120 {
121 
122  Param* init_param = get_parameter("disp_init_rate");
123 
124  if(init_param->isSet()) {
125 
126  _init_rate_fem = init_param->getValue();
127 
128  _init_rate_mal = init_param->getValue();
129 
130  } else if (get_parameter("disp_init_rate_fem")->isSet() &&
131  get_parameter("disp_init_rate_mal")->isSet()) {
132 
133  _init_rate_fem = get_parameter_value("disp_init_rate_fem");
134 
135  _init_rate_mal = get_parameter_value("disp_init_rate_mal");
136 
137  } else {
138  error("dispersal trait init parameters not correctly set\n");
139  error("note that \"disp_init_rate_fem\" and \"disp_init_rate_mal\" must be set together\n");
140  return false;
141  }
142 
143  _init_random = false;
144 
145  return true;
146 }
virtual double get_parameter_value(std::string name)
Param value getter.
Definition: simcomponent.h:143
double getValue()
Returns the argument value according to its type.
Definition: param.cc:319
int error(const char *str,...)
Definition: output.cc:73
This structure stores one parameter, its definition and its string argument.
Definition: param.h:53
virtual Param * get_parameter(std::string name)
Param getter.
Definition: simcomponent.h:139
double _init_rate_mal
Initial allele for male dispersal.
Definition: ttdispersal.h:153
double _init_rate_fem
Initial allele for female dispersal.
Definition: ttdispersal.h:151
bool _init_random
Definition: ttdispersal.h:157
bool isSet()
Definition: param.h:138
bool TProtoDispersal::setParameters ( )
virtual

Implements SimComponent.

78 {
79  _mut_rate = get_parameter_value("disp_mutation_rate");
80  _mut_mean = get_parameter_value("disp_mutation_mean");
81 
82  if (( get_parameter("disp_init_rate")->isSet() ||
83  get_parameter("disp_init_rate_fem")->isSet() ||
84  get_parameter("disp_init_rate_mal")->isSet() ) )
85  {
86 
87  if(get_parameter("disp_init_distribution")->isSet()) {
88  warning("both \"disp_init_rate[...]\" and \"disp_init_distribution\" are set\n");
89  warning("discarding \"disp_init_rate[...]\" parameters\n");
90  return setRandom();
91  }
92 
93  return setNonRandom();
94 
95  } else if (get_parameter("disp_init_distribution")->isSet()) {
96 
97  return setRandom();
98 
99  } else { //no init parameter specified
100 
101  Param* init_param = get_parameter("disp_init_distribution");
102 
103  init_param->setArg("uniform");
104  init_param->setIsSet(true);
105 
106  init_param = get_parameter("disp_init_dist_params");
107 
108  init_param->setArg("{{0,0}}");
109  init_param->setIsSet(true);
110 
111  return setRandom();
112 
113  }
114  return true;
115 }
virtual double get_parameter_value(std::string name)
Param value getter.
Definition: simcomponent.h:143
void setArg(string value)
Sets the parameter's argument.
Definition: param.h:118
bool setNonRandom()
Definition: ttdispersal.cc:119
double _mut_rate
The allelic mutation rate.
Definition: ttdispersal.h:147
void warning(const char *str,...)
Definition: output.cc:56
This structure stores one parameter, its definition and its string argument.
Definition: param.h:53
void setIsSet(bool value)
Sets the _isSet flag.
Definition: param.h:122
virtual Param * get_parameter(std::string name)
Param getter.
Definition: simcomponent.h:139
double _mut_mean
Mean mutation step.
Definition: ttdispersal.h:149
bool setRandom()
Definition: ttdispersal.cc:150
bool TProtoDispersal::setRandom ( )
151 {
152 
153  Param *init_param = get_parameter("disp_init_distribution");
154 
155  if (init_param->isSet()) {
156 
157  if (!get_parameter("disp_init_dist_params")->isSet()) {
158  error("parameter \"disp_init_distribution\" requires \"disp_init_dist_params\" to be set as well.\n");
159  return false;
160  } else {
161  get_parameter("disp_init_dist_params")->getMatrix(&_init_dist_param);
162  }
163 
164  _init_dist = init_param->getArg();
165 
166 
167  } else { //this should not happen...
168  error("something got wrong with the dispersal trait init distribution parameters\n");
169  return false;
170  }
171 
172  _init_random = true;
173 
174  return true;
175 }
void getMatrix(TMatrix *mat)
Sets the matrix from the argument string if the parameter is set and of matrix type.
Definition: param.cc:329
TMatrix _init_dist_param
Definition: ttdispersal.h:156
int error(const char *str,...)
Definition: output.cc:73
string _init_dist
Definition: ttdispersal.h:155
This structure stores one parameter, its definition and its string argument.
Definition: param.h:53
string getArg()
Definition: param.h:136
virtual Param * get_parameter(std::string name)
Param getter.
Definition: simcomponent.h:139
bool _init_random
Definition: ttdispersal.h:157
bool isSet()
Definition: param.h:138
virtual void TProtoDispersal::store_data ( BinaryStorageBuffer saver)
inlinevirtual

Implements StorableComponent.

References _gender, _type, and BinaryStorageBuffer::store().

131 {saver->store(&_type, sizeof(trait_t));saver->store(&_gender, sizeof(sex_t));}
std::string trait_t
Trait types.
Definition: types.h:63
sex_t _gender
The gender of the trait, will determine its type.
Definition: ttdispersal.h:160
void store(void *stream, unsigned int nb_bytes)
Definition: binarystoragebuffer.h:130
trait_t _type
The trait's type.
Definition: ttdispersal.h:162
sex_t
Sex types, males are always 0 and females 1!!
Definition: types.h:36

Member Data Documentation

sex_t TProtoDispersal::_gender
private

The gender of the trait, will determine its type.

Referenced by retrieve_data(), and store_data().

string TProtoDispersal::_init_dist
private

Referenced by get_init_dist().

TMatrix TProtoDispersal::_init_dist_param
private

Referenced by get_init_dist_params().

bool TProtoDispersal::_init_random
private

Referenced by get_init_mode().

double TProtoDispersal::_init_rate_fem
private

Initial allele for female dispersal.

double TProtoDispersal::_init_rate_mal
private

Initial allele for male dispersal.

double TProtoDispersal::_mut_mean
private

Mean mutation step.

double TProtoDispersal::_mut_rate
private

The allelic mutation rate.

TTDispersalSH* TProtoDispersal::_stats
private

The trait's StatHandler.

trait_t TProtoDispersal::_type
private

The trait's type.

Referenced by get_type(), retrieve_data(), and store_data().


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