#include <indfactory.h>


Public Member Functions | |
| IndFactory () | |
| virtual | ~IndFactory () |
| void | recycle (Individual *ind) |
| Put an individual in the recycling pool. | |
| void | purgeRecyclingPOOL () |
| Empty the recycling pool. | |
| void | makePrototype (map< trait_t, TraitPrototype * > TTlist) |
| Creates the individuals prototype from the selected trait prototypes. | |
| Individual * | getNewIndividual () |
| Creates a blank individual which has to be "decorated" later. | |
| Individual * | makeNewIndividual (Individual *mother, Individual *father, sex_t sex, unsigned short homepatch) |
| Creates an individual with pointers to parents, sex and home ID set but no genetic data. | |
| Individual * | makeOffsprg (Individual *mother, Individual *father, sex_t sex, unsigned short homepatch) |
| Completely creates an individual with inheritance and mutations on all traits. | |
| Individual * | getIndividualProtoype () |
| Individual prototype accessor. | |
| TraitPrototype * | getTraitPrototype (trait_t type) |
| Accessor to a TraitPrototype. | |
| std::map< trait_t, TraitPrototype * > & | getTraitPrototypes () |
| Accessor to the list of TraitPrototype's. | |
| int | getTraitIndex (trait_t type) |
| Gives the index of trait with type. | |
Protected Attributes | |
| std::map< trait_t, TraitPrototype * > | _protoTraits |
| Map of the trait prototypes. | |
| std::map< trait_t, int > | _TraitsIndex |
| Table containing the index of each trait. | |
| Individual | _protoIndividual |
| The individuals prototype used to create any new individual in a simulation. | |
| std::deque< Individual * > | RecyclingPOOL |
| Garbage collector for unused Individual's. | |
Provides methods to generate new individuals within the Metapop. Each new individual is created by cloning a prototype itself created at the simulation setup. New individuals are decorated with the appropriate traits as set by the trait prototypes and receives a unique ID (unique within a simulation).
Definition at line 43 of file indfactory.h.
| IndFactory::IndFactory | ( | ) | [inline] |
| IndFactory::~IndFactory | ( | ) | [virtual] |
Definition at line 36 of file indfactory.cc.
00037 { 00038 purgeRecyclingPOOL(); 00039 00040 _protoIndividual.clearTraits(); 00041 00042 // for(map< trait_t, TraitPrototype* >::iterator trait = _protoTraits.begin(); trait != _protoTraits.end(); 00043 // trait++) 00044 // delete trait->second; 00045 00046 _protoTraits.clear(); 00047 00048 _TraitsIndex.clear(); 00049 00050 }
| Individual* IndFactory::getIndividualProtoype | ( | ) | [inline] |
Individual prototype accessor.
Definition at line 99 of file indfactory.h.
Referenced by LCE_Selection_base::setParameters().
00099 {return &_protoIndividual;}
| Individual* IndFactory::getNewIndividual | ( | ) | [inline] |
Creates a blank individual which has to be "decorated" later.
ID is set and new traits are allocated but no genetic data is created (i.e. TTrait::init_sequence() is not called). Sex has to be set later too.
Definition at line 78 of file indfactory.h.
Referenced by LCE_Breed_base::breed_cloning(), Metapop::fillPatchFromSource(), Metapop::fillPopulationFromSource(), Metapop::loadPopFromBinarySource(), and Metapop::retrieve_data().
00078 {return makeNewIndividual(NULL,NULL,MAL,0);}
| int IndFactory::getTraitIndex | ( | trait_t | type | ) |
Gives the index of trait with type.
| type | the type of the trait (i.e. its "name") |
Definition at line 91 of file indfactory.cc.
Referenced by LifeCycleEvent::attach_trait(), TTDispersalSH::init(), and LCE_Disperse_EvolDisp::setParameters().
00092 { 00093 map< trait_t, int >::iterator trait = _TraitsIndex.find(type); 00094 00095 if(trait == _TraitsIndex.end()) 00096 return -1; 00097 00098 return trait->second; 00099 }
| TraitPrototype * IndFactory::getTraitPrototype | ( | trait_t | type | ) |
Accessor to a TraitPrototype.
| type | the trait name |
Definition at line 103 of file indfactory.cc.
00104 { 00105 map< trait_t, TraitPrototype* >::iterator trait = _protoTraits.find(type); 00106 00107 if(trait == _protoTraits.end()) 00108 return NULL; 00109 00110 return trait->second; 00111 00112 }
| std::map< trait_t,TraitPrototype* >& IndFactory::getTraitPrototypes | ( | ) | [inline] |
Accessor to the list of TraitPrototype's.
Definition at line 105 of file indfactory.h.
Referenced by Metapop::loadPopFromTraitFile(), and Metapop::store_data().
00105 {return _protoTraits;}
| Individual * IndFactory::makeNewIndividual | ( | Individual * | mother, | |
| Individual * | father, | |||
| sex_t | sex, | |||
| unsigned short | homepatch | |||
| ) |
Creates an individual with pointers to parents, sex and home ID set but no genetic data.
No inheritance or mutations on the trait sequences are done. Sets the pedigree class of the individual. Calls Individual::init() to allocate traits' sequences memory if individual is cloned from the prototype. Otherwise, calls Individual::reset() if the new individual is coming from the recycling pool.
| mother | ptr to the mother | |
| father | ptr to the father | |
| sex | gender of the individual | |
| homepatch | ID of the Patch where this individual is born, usually the current position in the Metapop::vPatch array. |
Definition at line 116 of file indfactory.cc.
Referenced by LCE_Breed_base::breed(), LCE_Breed_base::breed_cloning(), TTNeutralGenesFH::FHread(), TTDeletMutBitstrFH::FHread(), LCE_Resize::fillPatchNoBackup(), getNewIndividual(), makeOffsprg(), LCE_Breed_Disperse::mate_full_selfing(), LCE_Breed_Disperse::mate_random(), LCE_Breed_Disperse::mate_random_hermaphrodite(), LCE_Breed_Disperse::mate_selfing(), and Patch::setNewGeneration().
00117 { 00118 Individual* newind; 00119 00120 if(RecyclingPOOL.empty()) { 00121 //create new Individual by cloning the proto-individual 00122 newind = _protoIndividual.clone(); 00123 //allocate memory for the traits' sequences: 00124 newind->init(); 00125 } else { 00126 //recycle an Individual from the POOL 00127 newind = RecyclingPOOL[0]; 00128 RecyclingPOOL.pop_front(); 00129 newind->reset(); 00130 newind->setID(Individual::currentID++); 00131 } 00132 00133 newind->setSex(sex); 00134 newind->setHome(homepatch); 00135 if(mother != NULL && father != NULL) { 00136 newind->setFatherID(father->getID()); 00137 newind->setMotherID(mother->getID()); 00138 newind->setFather(father); 00139 newind->setMother(mother); 00140 newind->setPedigreeClass(mother, father); 00141 } 00142 00143 return newind; 00144 }
| Individual * IndFactory::makeOffsprg | ( | Individual * | mother, | |
| Individual * | father, | |||
| sex_t | sex, | |||
| unsigned short | homepatch | |||
| ) |
Completely creates an individual with inheritance and mutations on all traits.
Calls makeNewIndividual() to get the new offspring.
| mother | ptr to the mother | |
| father | ptr to the father | |
| sex | gender of the individual | |
| homepatch | ID of the Patch where this individual is born, usually the current position in the Patch array |
Definition at line 148 of file indfactory.cc.
Referenced by LCE_Cross::execute(), and LCE_Breed_Wolbachia::execute().
00149 { 00150 Individual* offspring = makeNewIndividual(mother,father,sex,homepatch); 00151 unsigned int cat = offspring->getPedigreeClass(); 00152 mother->DidHaveABaby(cat); 00153 if(cat!=4) father->DidHaveABaby(cat); 00154 return offspring->create(mother, father); 00155 }
| void IndFactory::makePrototype | ( | map< trait_t, TraitPrototype * > | TTlist | ) |
Creates the individuals prototype from the selected trait prototypes.
Resets the individual's ID counter to 0 and sets the traits index table.
| TTlist | the list of the current trait prototype selected from the current simulation parameters. |
Definition at line 54 of file indfactory.cc.
Referenced by BinaryDataLoader::extractPop(), SimRunner::init_components(), and Metapop::loadPopFromTraitFile().
00055 { 00056 #ifdef _DEBUG_ 00057 message("IndFactory::makePrototype\n"); 00058 #endif 00059 //first, reset the ID counter: 00060 _protoIndividual.setCurrentID(0); 00061 //and clear the ttraits: 00062 _protoIndividual.clearTraits(); 00063 //store the traits list for future use: 00064 _protoTraits = TTlist; 00065 //then add the traits from the trait prototypes: 00066 map< trait_t, TraitPrototype* >::iterator trait = TTlist.begin(); 00067 00068 _TraitsIndex.clear(); 00069 int i = 0; 00070 00071 while(trait != TTlist.end()) { 00072 #ifdef _DEBUG_ 00073 message("IndFactory::makePrototype::addTrait: %s\n",trait->first.c_str()); 00074 #endif 00075 //init the trait prototype, set attribute from input file parameters value 00076 // trait->second->init(); 00077 if(!trait->second->setParameters()) fatal("bailing out from trait initialization\n"); 00078 //set the prototype's index value 00079 trait->second->set_index(i); 00080 //create the trait and add it to the proto-individual 00081 _protoIndividual.addTrait(trait->second->hatch(),i); 00082 //store the trait's index into the index map 00083 _TraitsIndex[trait->first] = i++; 00084 trait++; 00085 } 00086 00087 }
| void IndFactory::purgeRecyclingPOOL | ( | ) | [inline] |
Empty the recycling pool.
Definition at line 66 of file indfactory.h.
Referenced by Metapop::init(), Metapop::setPopulation(), and ~IndFactory().
00067 { for(unsigned int i=0; i < RecyclingPOOL.size(); ++i) delete RecyclingPOOL[i]; RecyclingPOOL.clear(); }
| void IndFactory::recycle | ( | Individual * | ind | ) | [inline] |
Put an individual in the recycling pool.
Definition at line 62 of file indfactory.h.
Referenced by LCE_Selection_base::doViabilitySelection(), LCE_Disperse_EvolDisp::evoldisp(), LCE_Breed_Wolbachia::execute(), LCE_Disperse_EvolDisp::fixdisp(), Patch::flush(), LCE_Breed_Selection::makeOffspringWithSelection(), LCE_Disperse_ConstDisp::MigratePatch_AbsorbingBorder(), LCE_Resize::regulateAgeClassNoBackup(), and LCE_Regulation::regulatePatch().
00063 { if(ind == NULL) error("IndFactory::recycle:ind is NULL!!\n"); else RecyclingPOOL.push_back(ind); }
Individual IndFactory::_protoIndividual [protected] |
The individuals prototype used to create any new individual in a simulation.
Definition at line 51 of file indfactory.h.
Referenced by getIndividualProtoype(), makeNewIndividual(), makePrototype(), and ~IndFactory().
std::map< trait_t,TraitPrototype* > IndFactory::_protoTraits [protected] |
Map of the trait prototypes.
Definition at line 46 of file indfactory.h.
Referenced by getTraitPrototype(), getTraitPrototypes(), makePrototype(), Metapop::retrieve_data(), and ~IndFactory().
std::map< trait_t, int > IndFactory::_TraitsIndex [protected] |
Table containing the index of each trait.
Definition at line 48 of file indfactory.h.
Referenced by getTraitIndex(), makePrototype(), and ~IndFactory().
std::deque<Individual*> IndFactory::RecyclingPOOL [protected] |
Garbage collector for unused Individual's.
Definition at line 54 of file indfactory.h.
Referenced by makeNewIndividual(), purgeRecyclingPOOL(), and recycle().
1.5.8 -- Nemo is hosted by