LCE_Breed_Selection Class Reference

Composite LCE implementing breeding and viability selection on a given trait type. More...

#include <LCEcomposite.h>

Inheritance diagram for LCE_Breed_Selection:

Inheritance graph
[legend]
Collaboration diagram for LCE_Breed_Selection:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 LCE_Breed_Selection ()
virtual ~LCE_Breed_Selection ()
IndividualmakeOffspringWithSelection (Individual *ind, unsigned int natalpatch)
 Performs viability selection and breeding at the same time.
Implementations
virtual bool setParameters ()
 Default interface needed to initialize the component's variables from its input parameters value.
virtual void execute ()
 Execute the event on the pop.
virtual LifeCycleEventclone ()
 Cloning interface.
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.


Detailed Description

Composite LCE implementing breeding and viability selection on a given trait type.

Inherits from LCE_Breed_base and LCE_Selection_base.

Definition at line 124 of file LCEcomposite.h.


Constructor & Destructor Documentation

LCE_Breed_Selection::LCE_Breed_Selection (  )  [inline]

Definition at line 129 of file LCEcomposite.h.

Referenced by clone().

00129 : LifeCycleEvent("breed_selection","") {}

virtual LCE_Breed_Selection::~LCE_Breed_Selection (  )  [inline, virtual]

Definition at line 130 of file LCEcomposite.h.

00130 {}


Member Function Documentation

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

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

Reimplemented from LCE_Selection_base.

Reimplemented in LCE_Breed_Selection_Disperse.

Definition at line 149 of file LCEcomposite.h.

00149 {return OFFSPRG;}

virtual LifeCycleEvent* LCE_Breed_Selection::clone (  )  [inline, virtual]

Cloning interface.

Reimplemented from LCE_Selection_base.

Reimplemented in LCE_Breed_Selection_Disperse.

Definition at line 145 of file LCEcomposite.h.

00145 { return new LCE_Breed_Selection(); }

void LCE_Breed_Selection::execute (  )  [virtual]

Execute the event on the pop.

Reimplemented from LCE_Selection_base.

Reimplemented in LCE_Breed_Selection_Disperse.

Definition at line 393 of file LCEcomposite.cc.

00394 {
00395   Patch* current_patch;
00396   unsigned int nbBaby, ind_count = 0;
00397   //double mean_fec;
00398   Individual* FatherPtr;
00399   Individual* MotherPtr;
00400   Individual* NewOffsprg;
00401   
00402   if(_popPtr->size(OFFSPRG) != 0) {
00403     warning("offspring containers not empty at time of breeding, flushing.\n");
00404     _popPtr->flush(OFFSx);
00405   }
00406   
00407 #ifdef _DEBUG_
00408   message("LCE_Breed_Selection::execute, ");
00409 #endif
00410   
00411   _scaling_factor = 1;
00412   _mean_fitness = 0;
00413 
00414   LCE_Selection_base::resetCounters();
00415   
00416   for(unsigned int home = 0; home < _popPtr->getPatchNbr(); home++) {
00417     
00418     current_patch = _popPtr->getPatch(home);
00419     
00420     if( !checkMatingCondition(current_patch) ) continue;
00421     
00422     for(unsigned int size = current_patch->size(FEM, ADLTx), indexOfMother = 0;
00423         indexOfMother < size;
00424         indexOfMother++) {
00425       
00426       MotherPtr = current_patch->get(FEM, ADLTx, indexOfMother);
00427       
00428       nbBaby = (unsigned int)MotherPtr->setFecundity( getFecundity() );
00429       
00430       ind_count += nbBaby;
00431       //-----------------------------------------------------------------------
00432       while(nbBaby != 0) {
00433         
00434         FatherPtr = this->getFatherPtr(current_patch, MotherPtr, indexOfMother);
00435         
00436         NewOffsprg = makeOffspringWithSelection( LCE_Breed_base::do_breed(MotherPtr, FatherPtr, home), home );
00437         
00438         if(NewOffsprg != NULL)
00439           current_patch->add(NewOffsprg->getSex(), OFFSx, NewOffsprg);
00440         
00441         nbBaby--;
00442         
00443       }//_END__WHILE;
00444     }//end_for
00445   }//end_for
00446   
00447   LCE_Selection_base::setMeans(ind_count);
00448   
00449 #ifdef _DEBUG_
00450   message("(offsprg nb: %i adults nb: %i, mean fitness: %f)\n",_popPtr->size(OFFSPRG),
00451           _popPtr->size(ADULTS), _mean_fitness);
00452 #endif
00453   
00454 }

virtual void LCE_Breed_Selection::loadFileServices ( FileServices loader  )  [inline, virtual]

Loads the component's FileHandler onto the FileServices.

Parameters:
loader the file service

Reimplemented from LCE_Selection_base.

Reimplemented in LCE_Breed_Selection_Disperse.

Definition at line 146 of file LCEcomposite.h.

00146 {}

void LCE_Breed_Selection::loadStatServices ( StatServices loader  )  [virtual]

Loads the component's StatHandler onto the StatServices.

Parameters:
loader the stat service

Reimplemented from LCE_Selection_base.

Reimplemented in LCE_Breed_Selection_Disperse.

Definition at line 386 of file LCEcomposite.cc.

00387 {
00388   LCE_Selection_base::loadStatServices(loader);
00389 }

Individual * LCE_Breed_Selection::makeOffspringWithSelection ( Individual ind,
unsigned int  natalpatch 
)

Performs viability selection and breeding at the same time.

The selected trait is first inherited (with recombination and mutations) and survival checked before the remaining traits are inherited. This helps save some computing time. The function returns a null pointer in case of selective death.

Parameters:
ind the newborn, its new traits have not been computed yet
natalpatch the index of the natal patch of the offfspring where selectin takes palce

Definition at line 458 of file LCEcomposite.cc.

Referenced by LCE_Breed_Selection_Disperse::do_breed(), and execute().

00460 {
00461   
00462   if(_LCELinkedTraitIndex != -1)
00463     ind->createTrait(_LCELinkedTraitIndex, LCE_Breed_base::doInheritance(), true);
00464   
00465   register double fitness = getFitness(ind, natalpatch);
00466   register unsigned int cat = ind->getPedigreeClass();
00467   
00468   _fitness[cat] += fitness;
00469   _ind_cntr[cat]++;
00470   
00471   if(RAND::Uniform() > fitness * _scaling_factor ) {
00472     //this one dies
00473         _popPtr->recycle(ind);
00474     
00475     ind->getMother()->addMating(cat);
00476     if(cat!=4) ind->getFather()->addMating(cat);
00477     
00478     return NULL;
00479     
00480   } else {
00481     
00482     //update counters
00483     _survival[cat]++;
00484     
00485     ind->getMother()->DidHaveABaby(cat);
00486     if(cat!=4) ind->getFather()->DidHaveABaby(cat);
00487   }
00488   
00489   //compute inheritance and mutation of the other traits:
00490   for(int i = 0; i < (int)_nb_trait; i++)
00491         if(i != _LCELinkedTraitIndex)
00492           ind->createTrait(i, LCE_Breed_base::doInheritance(), true);
00493   
00494   return ind;
00495 }

virtual age_t LCE_Breed_Selection::removeAgeClass (  )  [inline, virtual]

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

Reimplemented from LCE_Selection_base.

Reimplemented in LCE_Breed_Selection_Disperse.

Definition at line 148 of file LCEcomposite.h.

00148 {return NONE;}

virtual age_t LCE_Breed_Selection::requiredAgeClass (  )  [inline, virtual]

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

Reimplemented from LCE_Selection_base.

Reimplemented in LCE_Breed_Selection_Disperse.

Definition at line 150 of file LCEcomposite.h.

00150 {return ADULTS;}

bool LCE_Breed_Selection::setParameters (  )  [virtual]

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

Formerly called 'init'.

Reimplemented from LCE_Breed_base.

Reimplemented in LCE_Breed_Selection_Disperse.

Definition at line 372 of file LCEcomposite.cc.

00373 {
00374   if( !LCE_Breed_base::setParameters( ) ||  !LCE_Selection_base::setParameters( ) )
00375     return false;
00376   
00377   if(getMeanFecundity() <= 0) {
00378     error("\"mean_fecundity\" is not set!\n");
00379     return false;
00380   }
00381   return true;
00382 }


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

Generated for Nemo v2.1.2 by  doxygen 1.5.8 -- Nemo is hosted by  SourceForge.net Logo