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

#include <LCEphenoexpression.h>

+ Inheritance diagram for LCE_PhenotypeExpression:
+ Collaboration diagram for LCE_PhenotypeExpression:

Public Member Functions

 LCE_PhenotypeExpression ()
 
virtual ~LCE_PhenotypeExpression ()
 
bool set_g_value_matrix (Param *param, TMatrix &mat)
 
bool check_g_index_matrix (Param *param, TMatrix &mat)
 
bool set_env_cue ()
 
void set_phenot_no_evol (unsigned int patch, TTQuanti *trait)
 
void set_phenot_g1_evol (unsigned int patch, TTQuanti *trait)
 
void set_phenot_g2_evol (unsigned int patch, TTQuanti *trait)
 
void set_phenot_g1_g2_evol (unsigned int patch, TTQuanti *trait)
 
double get_env_cue_no_noise (unsigned int patch, unsigned int trait)
 
double get_env_cue_noise (unsigned int patch, unsigned int trait)
 
virtual void execute ()
 
void setIndPhenotype (Patch *patch, sex_t SEX, age_idx AGE)
 
virtual LifeCycleEventclone ()
 
virtual bool setParameters ()
 
virtual void loadFileServices (FileServices *loader)
 
virtual void loadStatServices (StatServices *loader)
 
virtual bool resetParameterFromSource (std::string param, SimComponent *cmpt)
 
virtual age_t removeAgeClass ()
 
virtual age_t addAgeClass ()
 
virtual age_t requiredAgeClass ()
 
- Public Member Functions inherited from LifeCycleEvent
 LifeCycleEvent (const char *name, const char *trait_link)
 Cstor. More...
 
virtual ~LifeCycleEvent ()
 
virtual void init (Metapop *popPtr)
 Sets the pointer to the current Metapop and the trait link if applicable. More...
 
virtual bool attach_trait (string trait)
 
virtual void set_paramset (std::string name, bool required, SimComponent *owner)
 
virtual void set_event_name (std::string &name)
 Set the name of the event (name of the ParamSet) and add the corresponding parameter to the set. More...
 
virtual void set_event_name (const char *name)
 
virtual string & get_event_name ()
 Accessor to the LCE's name. More...
 
virtual int get_rank ()
 Accessor to the LCE rank in the life cycle. More...
 
virtual void set_pop_ptr (Metapop *popPtr)
 Accessors for the population pointer. More...
 
virtual Metapopget_pop_ptr ()
 
- 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_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...
 
virtual bool has_parameter (std::string name)
 Param getter. More...
 

Private Attributes

unsigned int _num_trait
 Number of plastic phenotypes. More...
 
TMatrix _env_cue
 A matrix to hold the environmental cues (e value). More...
 
TMatrix _e_noise
 A matrix to hold the environmental noise (e reliability). More...
 
TMatrix _e_rate
 A matrix to hold the per generation rate of change of the environmental cues. More...
 
bool _e_copy_trait_optimum_value
 A flag to set whether environmental cue values are equal to and copied from the trait local optimum values from LCE_selection. More...
 
TMatrix _g0_linked_index
 
TMatrix _g1_linked_index
 
TMatrix _g2_linked_index
 
TMatrix _g1_values
 
TMatrix _g2_values
 
TMatrix _e_values
 
bool _g1_evolves
 
bool _g2_evolves
 
bool _do_change_cue
 
bool _is_labile
 
void(LCE_PhenotypeExpression::* _set_phenotype_func )(unsigned int, TTQuanti *)
 
double(LCE_PhenotypeExpression::* _get_env_cue_func )(unsigned int, unsigned int)
 
TProtoQuanti_QuantiProto
 A pointer to the plastic trait prototype. More...
 

Additional Inherited Members

- Protected Attributes inherited from LifeCycleEvent
std::string _event_name
 The param name to be read in the init file. More...
 
Metapop_popPtr
 The ptr to the current Metapop. More...
 
std::string _LCELinkedTraitType
 The name of the linked trait. More...
 
int _LCELinkedTraitIndex
 The index in the individual's trait table of the linked trait. More...
 
- Protected Attributes inherited from SimComponent
ParamSet_paramSet
 The parameters container. More...
 

Constructor & Destructor Documentation

◆ LCE_PhenotypeExpression()

LCE_PhenotypeExpression::LCE_PhenotypeExpression ( )
40  : LifeCycleEvent("phenotype_expression","quant"),
41  _num_trait(0),
43  _QuantiProto(0),
44  _g1_evolves(0),
45  _g2_evolves(0),
46  _do_change_cue(0),
47  _is_labile(0),
50  {
51 
53 
54  // mandatory parameter
56  add_parameter("pheno_plastic_e_value", MAT, true, false, 0, 0, updater); // environmental cue for phenotype expression
57 
59  add_parameter("pheno_plastic_g0_quanti_trait", INT, true, false, 0, 0, updater); // link to quantitative trait (trait index)
60 
61  // non-mandatory parameters
62  add_parameter("pheno_plastic_e_is_selection_optimum_value", BOOL, false, false, 0, 0, updater);
63  add_parameter("pheno_plastic_e_rate_change", MAT, false, false,0,0,updater);
64  add_parameter("pheno_plastic_e_noise",MAT, false, false,0,0,updater);
65  add_parameter("pheno_plastic_is_labile", BOOL, false, false, 0, 0, 0); // FALSE - developmental plasticity
66 
67  // NOR - QUANTITATIVE TRAITS ----------------------------------------------------
68  add_parameter("pheno_plastic_g1_value", DBL, false, false, 0, 0, updater); // only with constant plasticity
69  add_parameter("pheno_plastic_g1_quanti_trait", INT, false, false, 0, 0, updater); // link to quantitative trait (trait index)
70  add_parameter("pheno_plastic_g2_value", DBL, false, false, 0, 0, updater); // only with evolving plasticity
71  add_parameter("pheno_plastic_g2_quanti_trait", INT, false, false, 0, 0, updater); // link to quantitative trait (trait index)
72 
73  }
unsigned int _num_trait
Number of plastic phenotypes.
Definition: LCEphenoexpression.h:39
bool _do_change_cue
Definition: LCEphenoexpression.h:62
void(LCE_PhenotypeExpression::* _set_phenotype_func)(unsigned int, TTQuanti *)
Definition: LCEphenoexpression.h:65
double(LCE_PhenotypeExpression::* _get_env_cue_func)(unsigned int, unsigned int)
Definition: LCEphenoexpression.h:66
bool _e_copy_trait_optimum_value
A flag to set whether environmental cue values are equal to and copied from the trait local optimum v...
Definition: LCEphenoexpression.h:51
bool set_env_cue()
Definition: LCEphenoexpression.cc:313
TProtoQuanti * _QuantiProto
A pointer to the plastic trait prototype.
Definition: LCEphenoexpression.h:69
bool _g2_evolves
Definition: LCEphenoexpression.h:61
virtual bool setParameters()
Definition: LCEphenoexpression.cc:81
bool _is_labile
Definition: LCEphenoexpression.h:63
bool _g1_evolves
Definition: LCEphenoexpression.h:60
LifeCycleEvent(const char *name, const char *trait_link)
Cstor.
Definition: lifecycleevent.h:98
Implementation of the ParamUpdaterBase interface.
Definition: param.h:363
virtual void add_parameter(Param *param)
Interface to add a parameter to the set.
Definition: simcomponent.h:112
@ DBL
Definition: types.h:78
@ MAT
Definition: types.h:78
@ BOOL
Definition: types.h:78
@ INT
Definition: types.h:78

References SimComponent::add_parameter(), BOOL, DBL, INT, MAT, set_env_cue(), and setParameters().

Referenced by clone().

◆ ~LCE_PhenotypeExpression()

virtual LCE_PhenotypeExpression::~LCE_PhenotypeExpression ( )
inlinevirtual
76 { }

Member Function Documentation

◆ addAgeClass()

virtual age_t LCE_PhenotypeExpression::addAgeClass ( )
inlinevirtual

Implements LifeCycleEvent.

107 {return 0;}

◆ check_g_index_matrix()

bool LCE_PhenotypeExpression::check_g_index_matrix ( Param param,
TMatrix mat 
)
299 {
300 
301  for(unsigned int t = 0; t < mat.length(); ++t) {
302  if( mat.get(0,t) > _QuantiProto->get_num_traits() || mat.get(0,t) < 1)
303  return error("phenotype_expression::quanti trait index %i provided in \"%s\" is not valid. It must be > 0 and not higher than the number of \"quanti_traits\".\n",
304  (unsigned int)mat.get(0,t), param->getName().c_str());
305  // the index must be zero-based => deduce 1 from input index values:
306  mat.minus(0, t, 1.0);
307  }
308  return true;
309 }
string getName()
Definition: param.h:137
double get(unsigned int i, unsigned int j) const
Accessor to element at row i and column j.
Definition: tmatrix.h:193
void minus(unsigned int i, unsigned int j, double value)
Substracts a value from an element of the matrix.
Definition: tmatrix.h:273
unsigned int length() const
Returns the number of elements in the matrix.
Definition: tmatrix.h:218
unsigned int get_num_traits()
Definition: ttquanti.h:417
int error(const char *str,...)
Definition: output.cc:77

References _QuantiProto, error(), TMatrix::get(), TProtoQuanti::get_num_traits(), Param::getName(), TMatrix::length(), and TMatrix::minus().

Referenced by setParameters().

◆ clone()

virtual LifeCycleEvent* LCE_PhenotypeExpression::clone ( )
inlinevirtual

Implements LifeCycleEvent.

93 {return new LCE_PhenotypeExpression();}
LCE_PhenotypeExpression()
Definition: LCEphenoexpression.cc:40

References LCE_PhenotypeExpression().

◆ execute()

void LCE_PhenotypeExpression::execute ( )
virtual

Implements LifeCycleEvent.

332 {
333 
334  unsigned int stage_nb = _popPtr->getNumAgeClasses();
335 
336  age_idx age;
337 
338  Patch *patch;
339 
340  if(_popPtr->getCurrentGeneration() == 1){
341 
342  // reset the e values to their original values for a new replicate
343  set_env_cue();
344 
345  }
346 
348 
349  // set the cue _e_ equal to the local trait optima, which may change over time
350 
351  const TMatrix& trait_optima = dynamic_cast<LCE_Selection_base*>(SIMenv::MainSim->get_LCE("viability_selection"))->getLocalOptima();
352 
353  _env_cue.copy(trait_optima);
354 
355  } else
356 
357  if(_do_change_cue) {
358  // apply rate of change to the e values
359  for(unsigned int p = 0; p < _popPtr->getPatchNbr(); ++p) {
360  for(unsigned int t = 0; t < _num_trait; ++t) {
361  _env_cue.plus(p, t,_e_rate.get(p,t));
362  }
363  }
364  }
365 
366  if(_is_labile) {
367 
368  // (re)set the individuals' phenotypes in all age classes
369  for(unsigned int p = 0; p < _popPtr->getPatchNbr(); ++p)
370  {
371  patch = _popPtr->getPatch(p);
372 
373  for(unsigned int s = 0; s < stage_nb; ++s)
374  {
375  age = age_idx(s);
376 
377  setIndPhenotype (patch, FEM, age);
378 
379  setIndPhenotype (patch, MAL, age);
380 
381  }
382  }
383  } else {
384  // Developmnental plasticity
385  // set the phenotypes in the offspring only
386  for(unsigned int p = 0; p < _popPtr->getPatchNbr(); ++p)
387  {
388  patch = _popPtr->getPatch(p);
389 
390  setIndPhenotype (patch, FEM, OFFSx);
391 
392  setIndPhenotype (patch, MAL, OFFSx);
393 
394  }
395  }
396 }
LifeCycleEvent * get_LCE(string name)
Search for component with "name" in the life cycle events list.
Definition: basicsimulation.cc:76
TMatrix _env_cue
A matrix to hold the environmental cues (e value).
Definition: LCEphenoexpression.h:42
void setIndPhenotype(Patch *patch, sex_t SEX, age_idx AGE)
Definition: LCEphenoexpression.cc:400
TMatrix _e_rate
A matrix to hold the per generation rate of change of the environmental cues.
Definition: LCEphenoexpression.h:48
Base class performing (viability) selection on an arbitrary trait.
Definition: LCEselection.h:51
Metapop * _popPtr
The ptr to the current Metapop.
Definition: lifecycleevent.h:81
unsigned int getNumAgeClasses()
Definition: metapop.h:290
unsigned int getPatchNbr()
Definition: metapop.h:276
Patch * getPatch(unsigned int i)
Patch accessor, return the ith+1 patch in the metapop.
Definition: metapop.h:257
unsigned int getCurrentGeneration()
Definition: metapop.h:296
Second class in the metapopulation design structure, between the Metapop and Individual classes.
Definition: metapop.h:432
static SimRunner * MainSim
Definition: simenv.h:42
A class to handle matrix in params, coerces matrix into a vector of same total size.
Definition: tmatrix.h:50
void copy(const TMatrix &mat)
Copy a matrix.
Definition: tmatrix.h:78
void plus(unsigned int i, unsigned int j, double value)
Adds a value to an element of the matrix.
Definition: tmatrix.h:256
@ FEM
Definition: types.h:37
@ MAL
Definition: types.h:37
age_idx
Array index of the age classes in the patch sizes and containers arrays.
Definition: types.h:41
@ OFFSx
Definition: types.h:42

References _do_change_cue, _e_copy_trait_optimum_value, _e_rate, _env_cue, _is_labile, _num_trait, LifeCycleEvent::_popPtr, TMatrix::copy(), FEM, TMatrix::get(), ComponentManager::get_LCE(), Metapop::getCurrentGeneration(), Metapop::getNumAgeClasses(), Metapop::getPatch(), Metapop::getPatchNbr(), SIMenv::MainSim, MAL, OFFSx, TMatrix::plus(), set_env_cue(), and setIndPhenotype().

◆ get_env_cue_no_noise()

double LCE_PhenotypeExpression::get_env_cue_no_noise ( unsigned int  patch,
unsigned int  trait 
)
417 {
418  return _env_cue.get(patch, trait);
419 }

References _env_cue, and TMatrix::get().

Referenced by setParameters().

◆ get_env_cue_noise()

double LCE_PhenotypeExpression::get_env_cue_noise ( unsigned int  patch,
unsigned int  trait 
)
424 {
425  return _env_cue.get(patch, trait) + RAND::Gaussian(_e_noise.get(patch, trait));
426 }
TMatrix _e_noise
A matrix to hold the environmental noise (e reliability).
Definition: LCEphenoexpression.h:45
static double Gaussian(double sigma)
Definition: Uniform.h:261

References _e_noise, _env_cue, RAND::Gaussian(), and TMatrix::get().

Referenced by setParameters().

◆ loadFileServices()

virtual void LCE_PhenotypeExpression::loadFileServices ( FileServices loader)
inlinevirtual

Implements SimComponent.

99 {}

◆ loadStatServices()

virtual void LCE_PhenotypeExpression::loadStatServices ( StatServices loader)
inlinevirtual

Implements SimComponent.

101 {}

◆ removeAgeClass()

virtual age_t LCE_PhenotypeExpression::removeAgeClass ( )
inlinevirtual

Implements LifeCycleEvent.

105 {return 0;}

◆ requiredAgeClass()

virtual age_t LCE_PhenotypeExpression::requiredAgeClass ( )
inlinevirtual

Implements LifeCycleEvent.

109 {return 0;}

◆ resetParameterFromSource()

virtual bool LCE_PhenotypeExpression::resetParameterFromSource ( std::string  param,
SimComponent cmpt 
)
inlinevirtual

Implements SimComponent.

103 {return false;}

◆ set_env_cue()

bool LCE_PhenotypeExpression::set_env_cue ( )
314 {
315  TMatrix tmp_mat;
316 
318 
319  _paramSet->getMatrix("pheno_plastic_e_value", &tmp_mat);
320 
321  if( !setSpatialMatrix("pheno_plastic_e_value", "\"pheno_plastic_traits\"", &tmp_mat, &_env_cue,
322  (unsigned)_num_trait, _popPtr->getPatchNbr(), false) )
323  return false;
324 
325  return true;
326 }
void getMatrix(string name, TMatrix *mat)
Accessor to the parameters matrix.
Definition: param.h:304
ParamSet * _paramSet
The parameters container.
Definition: simcomponent.h:48
void reset(unsigned int rows, unsigned int cols)
Re-allocate the existing matrix with assigned rows and cols dimensions and all elements to 0.
Definition: tmatrix.h:161
bool setSpatialMatrix(string param, string numColCondition, TMatrix *inMat, TMatrix *outMat, unsigned int nVal, unsigned int patchNbr, bool doRandomize)
Definition: utils.cc:115

References _env_cue, _num_trait, SimComponent::_paramSet, LifeCycleEvent::_popPtr, ParamSet::getMatrix(), Metapop::getPatchNbr(), TMatrix::reset(), and setSpatialMatrix().

Referenced by execute(), LCE_PhenotypeExpression(), and setParameters().

◆ set_g_value_matrix()

bool LCE_PhenotypeExpression::set_g_value_matrix ( Param param,
TMatrix mat 
)
277 {
278  if( param->isMatrix() ) {
279 
280  param->getMatrix(&mat);
281 
282  if(mat.nrows() > 1)
283  return error("phenotype_expression::the array of trait indices for the n-o-r parameters should have one row only\n.");
284 
285  if(mat.ncols() > _QuantiProto->get_num_traits())
286  return error("phenotype_expression::the number of trait indices in \"%s\" is larger than the number of quantitative traits.\n", param->getName().c_str());
287  }
288  else
289  {
290  mat.reset(1,1, param->getValue());
291  }
292 
293  return true;
294 }
double getValue()
Returns the argument value according to its type.
Definition: param.cc:368
bool isMatrix()
Checks if the argument is of matrix type.
Definition: param.h:172
void getMatrix(TMatrix *mat)
Sets the matrix from the argument string if the parameter is set and of matrix type.
Definition: param.cc:378
unsigned int ncols() const
Definition: tmatrix.h:216
unsigned int nrows() const
Definition: tmatrix.h:213

References _QuantiProto, error(), TProtoQuanti::get_num_traits(), Param::getMatrix(), Param::getName(), Param::getValue(), Param::isMatrix(), TMatrix::ncols(), TMatrix::nrows(), and TMatrix::reset().

Referenced by setParameters().

◆ set_phenot_g1_evol()

void LCE_PhenotypeExpression::set_phenot_g1_evol ( unsigned int  patch,
TTQuanti trait 
)
444 {
445  double pheno = 0;
446  for(unsigned int t = 0, ID0, ID1; t < _num_trait; ++t) {
447  ID0 = _g0_linked_index.get(0,t);
448  ID1 = _g1_linked_index.get(0,t);
449  pheno = trait->get_phenotype(ID0) + trait->get_phenotype(ID1) *
450  ( (this->*_get_env_cue_func)(patch, t) - _g2_values.get(0, t) );
451  trait->set_phenotype(ID0, pheno);
452  }
453 }
TMatrix _g1_linked_index
Definition: LCEphenoexpression.h:54
TMatrix _g2_values
Definition: LCEphenoexpression.h:58
TMatrix _g0_linked_index
Definition: LCEphenoexpression.h:53
void set_phenotype(unsigned int trait, double value)
Definition: ttquanti.cc:3111
double get_phenotype(unsigned int trai)
Definition: ttquanti.cc:3102

References _g0_linked_index, _g1_linked_index, _g2_values, _get_env_cue_func, _num_trait, TMatrix::get(), TTQuanti::get_phenotype(), and TTQuanti::set_phenotype().

Referenced by setParameters().

◆ set_phenot_g1_g2_evol()

void LCE_PhenotypeExpression::set_phenot_g1_g2_evol ( unsigned int  patch,
TTQuanti trait 
)
472 {
473  double pheno = 0;
474  for(unsigned int t = 0, ID0, ID1, ID2; t < _num_trait; ++t) {
475  ID0 = _g0_linked_index.get(0,t);
476  ID1 = _g1_linked_index.get(0,t);
477  ID2 = _g2_linked_index.get(0,t);
478  pheno = trait->get_phenotype(ID0) + trait->get_phenotype(ID1) *
479  ( (this->*_get_env_cue_func)(patch, t) - trait->get_phenotype(ID2) );
480  trait->set_phenotype(ID0, pheno);
481  }
482 }
TMatrix _g2_linked_index
Definition: LCEphenoexpression.h:55

References _g0_linked_index, _g1_linked_index, _g2_linked_index, _get_env_cue_func, _num_trait, TMatrix::get(), TTQuanti::get_phenotype(), and TTQuanti::set_phenotype().

Referenced by setParameters().

◆ set_phenot_g2_evol()

void LCE_PhenotypeExpression::set_phenot_g2_evol ( unsigned int  patch,
TTQuanti trait 
)
458 {
459  double pheno = 0;
460  for(unsigned int t = 0, ID0, ID2; t < _num_trait; ++t) {
461  ID0 = _g0_linked_index.get(0,t);
462  ID2 = _g2_linked_index.get(0,t);
463  pheno = trait->get_phenotype(ID0) + _g1_values.get(0, t) *
464  ( (this->*_get_env_cue_func)(patch, t) - trait->get_phenotype(ID2) );
465  trait->set_phenotype(ID0, pheno);
466  }
467 }
TMatrix _g1_values
Definition: LCEphenoexpression.h:57

References _g0_linked_index, _g1_values, _g2_linked_index, _get_env_cue_func, _num_trait, TMatrix::get(), TTQuanti::get_phenotype(), and TTQuanti::set_phenotype().

Referenced by setParameters().

◆ set_phenot_no_evol()

void LCE_PhenotypeExpression::set_phenot_no_evol ( unsigned int  patch,
TTQuanti trait 
)
431 {
432  double pheno = 0;
433  for(unsigned int t = 0, ID0; t < _num_trait; ++t) {
434  ID0 = _g0_linked_index.get(0,t);
435  pheno = trait->get_phenotype(ID0) + _g1_values.get(0, t) *
436  ( (this->*_get_env_cue_func)(patch, t) - _g2_values.get(0, t) );
437  trait->set_phenotype(ID0, pheno);
438  }
439 }

References _g0_linked_index, _g1_values, _g2_values, _get_env_cue_func, _num_trait, TMatrix::get(), TTQuanti::get_phenotype(), and TTQuanti::set_phenotype().

Referenced by setParameters().

◆ setIndPhenotype()

void LCE_PhenotypeExpression::setIndPhenotype ( Patch patch,
sex_t  SEX,
age_idx  AGE 
)
401 {
402  TTQuanti *trait;
403 
404  for(unsigned int i = 0; i < patch->size(SEX, AGE); ++i)
405  {
406 
407  trait = dynamic_cast<TTQuanti*> (patch->get(SEX, AGE, i)->getTrait(_LCELinkedTraitIndex));
408 
409  (this->*_set_phenotype_func)(patch->getID(), trait);
410 
411  }
412 }
TTrait * getTrait(IDX T)
Trait accessor.
Definition: individual.h:277
int _LCELinkedTraitIndex
The index in the individual's trait table of the linked trait.
Definition: lifecycleevent.h:89
unsigned int size(age_t AGE)
Returns the size of the container of the appropriate age class(es) for both sexes.
Definition: metapop.h:498
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:534
unsigned int getID()
Definition: metapop.h:481
TTQuanti.
Definition: ttquanti.h:59

References LifeCycleEvent::_LCELinkedTraitIndex, _set_phenotype_func, Patch::get(), Patch::getID(), Individual::getTrait(), and Patch::size().

Referenced by execute().

◆ setParameters()

bool LCE_PhenotypeExpression::setParameters ( )
virtual

Implements SimComponent.

83 {
84 
85  _QuantiProto = dynamic_cast<TProtoQuanti*> ( _popPtr->getTraitPrototype("quant"));
86 
87  // ...........................................................................
88  // dimension of the NOR, how many g0's?
89  if(!set_g_value_matrix(_paramSet->get_param("pheno_plastic_g0_quanti_trait") , _g0_linked_index))
90  return false;
91 
92  if(!check_g_index_matrix(_paramSet->get_param("pheno_plastic_g0_quanti_trait") , _g0_linked_index))
93  return false;
94 
96 
97  // check if g1 evolves:
98  if(_paramSet->isSet("pheno_plastic_g1_quanti_trait")) {
99 
100  if(!set_g_value_matrix(_paramSet->get_param("pheno_plastic_g1_quanti_trait") , _g1_linked_index)) {
101 
102  return false;
103 
104  } else {
105 
106  if(!check_g_index_matrix(_paramSet->get_param("pheno_plastic_g1_quanti_trait") , _g1_linked_index)) return false;
107 
108  _g1_evolves = true;
109  }
110 
112  return error("phenotype_expression::the number of evolving n-o-r (g1) should be equal to the number of g0 linked traits.\n");
113 
114  } else {
115  _g1_evolves = false;
116  }
117 
118  // check if g2 evolves;
119  if(_paramSet->isSet("pheno_plastic_g2_quanti_trait")) {
120  if(!set_g_value_matrix(_paramSet->get_param("pheno_plastic_g2_quanti_trait") , _g2_linked_index)) {
121 
122  return false;
123 
124  } else {
125 
126  if(!check_g_index_matrix(_paramSet->get_param("pheno_plastic_g2_quanti_trait") , _g2_linked_index)) return false;
127 
128  _g2_evolves = true;
129  }
130 
132  return error("phenotype_expression::the number of evolving g2-values should be equal to the number of g0 linked traits.\n");
133 
134  } else {
135  _g2_evolves = false;
136  }
137 
139  // G!
140  if(_paramSet->isSet("pheno_plastic_g1_value")) {
141 
142  if(_g1_evolves)
143 
144  warning("phenotype_expression::parameter \"pheno_plastic_g1_value\" is set but g1 evolves. Fixed g1 values will be ignored.\n");
145 
146  else {
147 
148  if(!set_g_value_matrix(_paramSet->get_param("pheno_plastic_g1_value"), _g1_values))
149  return false;
150 
151  if(_g1_values.length() != _num_trait)
152  return error("phenotype_expression::the number of slope values (g1) should be equal to the number of g0 linked traits.\n");
153  }
154  }
155  else
156  if(!_g1_evolves) {
157 
158  return error("phenotype_expression::the slope values (g1) of the modelled n-o-r are missing.\n");
159 
160  }
161 
162  // G2
163  if(_paramSet->isSet("pheno_plastic_g2_value")) {
164 
165  if(_g2_evolves)
166 
167  warning("phenotype_expression::parameter \"pheno_plastic_g2_value\" is set but g2 evolves. Fixed g2 values will be ignored.\n");
168 
169  else {
170 
171  if(!set_g_value_matrix(_paramSet->get_param("pheno_plastic_g2_value"), _g2_values))
172  return false;
173 
174  if(_g2_values.length() != _num_trait)
175  return error("phenotype_expression::the number of reference values (g2) should be equal to the number of g0 linked traits.\n");
176  }
177  }
178  else
179  if(!_g2_evolves) {
180 
181  warning("phenotype_expression::reference values (g2) of the n-o-r modeled are set to 0 by default.\n");
182 
183  _g2_values.reset(1, _num_trait, 0.0);
184  }
185 
186  if(_g1_evolves) {
187 
188  if(_g2_evolves)
190  else
192 
193  } else if(_g2_evolves) {
194 
196 
197  } else
199 
200 
201 
202  TMatrix tmp_mat;
203 
204  // ...........................................................................
205  // plastic_e_value - the environmental cue(s) "e" relevant for phenotype expression
206 
207  if(!set_env_cue()) return false;
208 
209  // ...........................................................................
210  // plastic_e_value_noise - the reliability of the environmental cue(s) "e"
211  if(get_parameter("pheno_plastic_e_noise")->isSet() ){
212 
214 
215  _paramSet->getMatrix("pheno_plastic_e_noise", &tmp_mat);
216 
217  if( !setSpatialMatrix("pheno_plastic_e_noise", "\"pheno_plastic_traits\"", &tmp_mat, &_e_noise,
218  (unsigned)_num_trait, _popPtr->getPatchNbr(), false) )
219  return false;
220 
222 
223  } else {
224 
226 
228  }
229 
230  // ...........................................................................
231  // plastic_e_value_change_rate - the rate of change for the environmental cue(s) "e"
232  if(get_parameter("pheno_plastic_e_rate_change")->isSet() ){
233 
234  _e_rate.reset(_popPtr->getPatchNbr(), (unsigned)_num_trait);
235 
236  _paramSet->getMatrix("pheno_plastic_e_rate_change", &tmp_mat);
237 
238  if( !setSpatialMatrix("pheno_plastic_e_rate_change", "\"pheno_plastic_traits\"", &tmp_mat, &_e_rate,
239  (unsigned)_num_trait, _popPtr->getPatchNbr(), false) )
240  return false;
241 
242  _do_change_cue = true;
243 
244  } else {
245 
246  _e_rate.reset(_popPtr->getPatchNbr(), (unsigned)_num_trait, 0.0);
247 
248  _do_change_cue = false;
249  }
250 
251  // set matrix of environmental gains ..................................................
252  // to keep track of the change of environmental cues
253 
254  if(get_parameter("pheno_plastic_e_is_selection_optimum_value")->isSet()) {
255 
256  _e_copy_trait_optimum_value = get_parameter_value("pheno_plastic_e_is_selection_optimum_value");
257 
258  } else {
260  }
261 
262  // labile plasticity ? ------------------------------------------------------------------
263  if(_paramSet->isSet("pheno_plastic_is_labile")) {
264  _is_labile = _paramSet->getValue("pheno_plastic_is_labile");
265  }
266  else {
267  _is_labile = false;
268  }
269 
270  return true;
271 
272 }
TraitPrototype * getTraitPrototype(trait_t type)
Accessor to a TraitPrototype.
Definition: indfactory.cc:140
double get_env_cue_noise(unsigned int patch, unsigned int trait)
Definition: LCEphenoexpression.cc:423
void set_phenot_g1_g2_evol(unsigned int patch, TTQuanti *trait)
Definition: LCEphenoexpression.cc:471
bool check_g_index_matrix(Param *param, TMatrix &mat)
Definition: LCEphenoexpression.cc:298
void set_phenot_g1_evol(unsigned int patch, TTQuanti *trait)
Definition: LCEphenoexpression.cc:443
bool set_g_value_matrix(Param *param, TMatrix &mat)
Definition: LCEphenoexpression.cc:276
void set_phenot_no_evol(unsigned int patch, TTQuanti *trait)
Definition: LCEphenoexpression.cc:430
double get_env_cue_no_noise(unsigned int patch, unsigned int trait)
Definition: LCEphenoexpression.cc:416
void set_phenot_g2_evol(unsigned int patch, TTQuanti *trait)
Definition: LCEphenoexpression.cc:457
double getValue(string name)
Accessor the parameters value.
Definition: param.h:302
Param * get_param(string name)
Look for a param "name" in its parameters list.
Definition: param.cc:658
bool isSet()
Accessor to the status flag.
Definition: param.h:288
virtual double get_parameter_value(std::string name)
Param value getter.
Definition: simcomponent.h:143
virtual Param * get_parameter(std::string name)
Param getter.
Definition: simcomponent.h:139
TProtoQuanti.
Definition: ttquanti.h:409
void warning(const char *str,...)
Definition: output.cc:58

References _do_change_cue, _e_copy_trait_optimum_value, _e_noise, _e_rate, _g0_linked_index, _g1_evolves, _g1_linked_index, _g1_values, _g2_evolves, _g2_linked_index, _g2_values, _get_env_cue_func, _is_labile, _num_trait, SimComponent::_paramSet, LifeCycleEvent::_popPtr, _QuantiProto, _set_phenotype_func, check_g_index_matrix(), error(), get_env_cue_no_noise(), get_env_cue_noise(), ParamSet::get_param(), SimComponent::get_parameter(), SimComponent::get_parameter_value(), ParamSet::getMatrix(), Metapop::getPatchNbr(), IndFactory::getTraitPrototype(), ParamSet::getValue(), ParamSet::isSet(), TMatrix::length(), TMatrix::reset(), set_env_cue(), set_g_value_matrix(), set_phenot_g1_evol(), set_phenot_g1_g2_evol(), set_phenot_g2_evol(), set_phenot_no_evol(), setSpatialMatrix(), and warning().

Referenced by LCE_PhenotypeExpression().

Member Data Documentation

◆ _do_change_cue

bool LCE_PhenotypeExpression::_do_change_cue
private

Referenced by execute(), and setParameters().

◆ _e_copy_trait_optimum_value

bool LCE_PhenotypeExpression::_e_copy_trait_optimum_value
private

A flag to set whether environmental cue values are equal to and copied from the trait local optimum values from LCE_selection.

Referenced by execute(), and setParameters().

◆ _e_noise

TMatrix LCE_PhenotypeExpression::_e_noise
private

A matrix to hold the environmental noise (e reliability).

Referenced by get_env_cue_noise(), and setParameters().

◆ _e_rate

TMatrix LCE_PhenotypeExpression::_e_rate
private

A matrix to hold the per generation rate of change of the environmental cues.

Referenced by execute(), and setParameters().

◆ _e_values

TMatrix LCE_PhenotypeExpression::_e_values
private

◆ _env_cue

TMatrix LCE_PhenotypeExpression::_env_cue
private

A matrix to hold the environmental cues (e value).

Referenced by execute(), get_env_cue_no_noise(), get_env_cue_noise(), and set_env_cue().

◆ _g0_linked_index

TMatrix LCE_PhenotypeExpression::_g0_linked_index
private

◆ _g1_evolves

bool LCE_PhenotypeExpression::_g1_evolves
private

Referenced by setParameters().

◆ _g1_linked_index

TMatrix LCE_PhenotypeExpression::_g1_linked_index
private

◆ _g1_values

TMatrix LCE_PhenotypeExpression::_g1_values
private

◆ _g2_evolves

bool LCE_PhenotypeExpression::_g2_evolves
private

Referenced by setParameters().

◆ _g2_linked_index

TMatrix LCE_PhenotypeExpression::_g2_linked_index
private

◆ _g2_values

TMatrix LCE_PhenotypeExpression::_g2_values
private

◆ _get_env_cue_func

double(LCE_PhenotypeExpression::* LCE_PhenotypeExpression::_get_env_cue_func) (unsigned int, unsigned int)
private

◆ _is_labile

bool LCE_PhenotypeExpression::_is_labile
private

Referenced by execute(), and setParameters().

◆ _num_trait

unsigned int LCE_PhenotypeExpression::_num_trait
private

◆ _QuantiProto

TProtoQuanti* LCE_PhenotypeExpression::_QuantiProto
private

A pointer to the plastic trait prototype.

Referenced by check_g_index_matrix(), set_g_value_matrix(), and setParameters().

◆ _set_phenotype_func

void(LCE_PhenotypeExpression::* LCE_PhenotypeExpression::_set_phenotype_func) (unsigned int, TTQuanti *)
private

Referenced by setIndPhenotype(), and setParameters().


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

Generated for Nemo v2.4.0b by  doxygen 1.9.1 -- Nemo is hosted on  Download Nemo

Locations of visitors to this page
Catalogued on GSR