Nemo  2.2.0
Public Member Functions | Private Attributes
LCE_QuantiInit Class Reference

Set patch-specifiec initial genotypes values. More...

#include <LCEquanti.h>

+ Inheritance diagram for LCE_QuantiInit:
+ Collaboration diagram for LCE_QuantiInit:

List of all members.

Public Member Functions

 LCE_QuantiInit ()
virtual ~LCE_QuantiInit ()
virtual void execute ()
 Execute the event on the pop.
void init_value (sex_t SEX, age_idx age, unsigned int size, unsigned int deme, double *values)
virtual LifeCycleEventclone ()
 Cloning interface.
virtual bool setParameters ()
 Default interface needed to initialize the component's variables from its input parameters value.
virtual void loadFileServices (FileServices *loader)
 Loads the component's FileHandler onto the FileServices.
virtual void loadStatServices (StatServices *loader)
 Loads the component's StatHandler onto the StatServices.
virtual age_t removeAgeClass ()
 Removes the returned age-class flag(s) from the current Metapop age-class flags.
virtual age_t addAgeClass ()
 Adds the returned age-class flag(s) to the current Metapop age-class flags.
virtual age_t requiredAgeClass ()
 Specifies what age-classes are required by the LCE to execute.

Private Attributes

TMatrix _init_values
unsigned int _nTraits

Detailed Description

Set patch-specifiec initial genotypes values.

Definition at line 39 of file LCEquanti.h.


Constructor & Destructor Documentation

LCE_QuantiInit::LCE_QuantiInit ( ) [inline]

Definition at line 46 of file LCEquanti.h.

References SimComponent::add_parameter(), and MAT.

Referenced by clone().

: LifeCycleEvent("quanti_init","quant") {add_parameter("quanti_init_values",MAT,1,0,0,0);}
virtual LCE_QuantiInit::~LCE_QuantiInit ( ) [inline, virtual]

Definition at line 48 of file LCEquanti.h.

{ }

Member Function Documentation

virtual age_t LCE_QuantiInit::addAgeClass ( ) [inline, virtual]

Adds the returned age-class flag(s) to the current Metapop age-class flags.

Implements LifeCycleEvent.

Definition at line 61 of file LCEquanti.h.

{return 0;}
virtual LifeCycleEvent* LCE_QuantiInit::clone ( ) [inline, virtual]

Cloning interface.

Implements LifeCycleEvent.

Definition at line 53 of file LCEquanti.h.

References LCE_QuantiInit().

{return new LCE_QuantiInit();}
void LCE_QuantiInit::execute ( ) [virtual]

Execute the event on the pop.

Implements LifeCycleEvent.

Definition at line 96 of file LCEquanti.cc.

{
  if(!(_popPtr->getCurrentGeneration() == 1)) return;
  
  unsigned int patchNbr = _popPtr->getPatchNbr();
  double *values = new double[_nTraits];
  
  for (unsigned int i = 0; i < patchNbr ; i++) { 
    
    _init_values.getRowView(i, _nTraits, values);
    
    init_value(FEM, OFFSx, _popPtr->size(FEM, OFFSPRG, i), i, values);
    init_value(MAL, OFFSx, _popPtr->size(MAL, OFFSPRG, i), i, values);
    init_value(FEM, ADLTx, _popPtr->size(FEM, ADULTS, i), i, values);
    init_value(MAL, ADLTx, _popPtr->size(MAL, ADULTS, i), i, values);
    
  }
  
  delete [] values;
}
void LCE_QuantiInit::init_value ( sex_t  SEX,
age_idx  age,
unsigned int  size,
unsigned int  deme,
double *  values 
)

Definition at line 119 of file LCEquanti.cc.

{ 
  Individual* ind;
  TTQuanti* trait;
  for(unsigned h = 0; h < _nTraits; h++)
    
    for (unsigned int i = 0; i < size ; i++) {
      ind = _popPtr->get(SEX, age, i, deme);
      trait = dynamic_cast<TTQuanti*> ( ind->getTrait(_LCELinkedTraitIndex) );
      trait->set_init_value(values);
      trait->init_sequence();
      trait->set_value();
    }
  
}
virtual void LCE_QuantiInit::loadFileServices ( FileServices loader) [inline, virtual]

Loads the component's FileHandler onto the FileServices.

Parameters:
loaderthe file service

Implements SimComponent.

Definition at line 58 of file LCEquanti.h.

{}
virtual void LCE_QuantiInit::loadStatServices ( StatServices loader) [inline, virtual]

Loads the component's StatHandler onto the StatServices.

Parameters:
loaderthe stat service

Implements SimComponent.

Definition at line 59 of file LCEquanti.h.

{}
virtual age_t LCE_QuantiInit::removeAgeClass ( ) [inline, virtual]

Removes the returned age-class flag(s) from the current Metapop age-class flags.

Implements LifeCycleEvent.

Definition at line 60 of file LCEquanti.h.

{return 0;}
virtual age_t LCE_QuantiInit::requiredAgeClass ( ) [inline, virtual]

Specifies what age-classes are required by the LCE to execute.

Implements LifeCycleEvent.

Definition at line 62 of file LCEquanti.h.

{return 0;}
bool LCE_QuantiInit::setParameters ( ) [virtual]

Default interface needed to initialize the component's variables from its input parameters value.

Formerly called 'init'.

Implements SimComponent.

Definition at line 40 of file LCEquanti.cc.

{
  TMatrix pat_mat;
  unsigned int patchNbr = _popPtr->getPatchNbr();
  unsigned int nLocus;
  TProtoQuanti* proto = dynamic_cast<TProtoQuanti*> ( _popPtr->getTraitPrototype("quant") );
  
  _nTraits = proto -> get_nb_traits();
  nLocus = proto->get_nb_locus();
  
  _paramSet->getMatrix("quanti_init_values", &pat_mat);
  
  unsigned int ncol = pat_mat.getNbCols(); //nbr of local optima = nbr of traits = nbr of col
  unsigned int npat = pat_mat.getNbRows(); //nbr of diff. value / traits, may be <= patchNbr
  
  //we have two possible configurations:
  // 1. ncol == 1; same value for all 'traits' in a patch but varies among patches, with possible repetition of a pattern
  // 2. ncol == no traits && npat <= no patches; trait values change in each patch following a pattern (same if npat == 1)
  if(npat > patchNbr) {
    error("The number of rows in \"quanti_init_values\" is greater than the number of patches, must be at least equal to this.");
    return false;
  }  
  if(ncol != 1 && ncol != _nTraits) {
    error("The number of columns in \"quanti_init_values\" differs from its expected values.\n");
    error("It is expected to be either 1 or equal to no. of quanti traits (%i).\n", _nTraits);
    return false;
  }
  
  _init_values.reset(patchNbr, _nTraits);
  
  for(unsigned int i = 0; i < patchNbr; ++i) {
    
    if(npat < patchNbr) {//repetition of a pattern
      
      if(ncol == 1)
        for(unsigned int j = 0; j < _nTraits; j++) 
          _init_values.set(i, j, pat_mat.get(i % npat, 0) / (2*nLocus));
      else
        for(unsigned int j = 0; j < _nTraits; j++)
          _init_values.set(i, j, pat_mat.get(i % npat, j) / (2*nLocus));
      
    } else {//different values for each Patch
      
      if(ncol == 1)
        for(unsigned int j = 0; j < _nTraits; j++) 
          _init_values.set(i, j, pat_mat.get(i, 0) / (2*nLocus));
      else
        for(unsigned int j = 0; j < _nTraits; j++)
          _init_values.set(i, j, pat_mat.get(i, j) / (2*nLocus));
    }
  }
  return true;
}

Member Data Documentation

Definition at line 42 of file LCEquanti.h.

unsigned int LCE_QuantiInit::_nTraits [private]

Definition at line 43 of file LCEquanti.h.


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

Generated for Nemo v2.2.0 by  doxygen 1.7.5.1 -- Nemo is hosted by  SourceForge.net Logo