Init version
This commit is contained in:
68
individual/Individual.cpp
Normal file
68
individual/Individual.cpp
Normal file
@@ -0,0 +1,68 @@
|
||||
#include "AbstractIndividual.h"
|
||||
#include "genome/strategies/GenotypeToPhenotypeStrategy.h"
|
||||
#include <iostream>
|
||||
|
||||
Individual::Individual(const Individual& father, const Individual& mother)
|
||||
{
|
||||
this->genToPhenStrategy = GenotypeToPhenotypeStrategies::getInstance("inoutbreeding");
|
||||
this->phenToFitStrategy = PhenotypeToFitnessStrategy::getInstance("inoutbreeding");
|
||||
this->recombinationStrategy = RecombinationStrategies::getInstance("Simple recombination");
|
||||
|
||||
genotype = new Genotype(
|
||||
father.getGenotype().recombinantHaploidGenotype(recombinationStrategy),
|
||||
mother.getGenotype().recombinantHaploidGenotype(recombinationStrategy));
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
this->substrateCache = new InnerSubstratesPool();
|
||||
|
||||
phenotype= new Phenotype(father.getPhenotype());
|
||||
this->age = 0;
|
||||
this->calculateFitness();
|
||||
|
||||
}
|
||||
|
||||
Individual::Individual(Genotype* gType, Phenotype* pType, InnerSubstratesPool* sub, Gender _gender, Region* _reg):
|
||||
genotype(gType), phenotype(pType), substrateCache(sub),
|
||||
gender(_gender), region(_reg)
|
||||
{
|
||||
this->genToPhenStrategy = GenotypeToPhenotypeStrategies::getInstance("inoutbreeding");
|
||||
this->phenToFitStrategy = PhenotypeToFitnessStrategy::getInstance("inoutbreeding");
|
||||
this->recombinationStrategy = RecombinationStrategies::getInstance("Simple recombination");
|
||||
|
||||
this->age = 0;
|
||||
|
||||
//this->calculateFitness();
|
||||
//this->phenotype
|
||||
}
|
||||
|
||||
|
||||
Individual::~Individual(){
|
||||
// std::cerr<<"Destructor works"<<std::endl;
|
||||
delete this->genotype;
|
||||
delete this->phenotype;
|
||||
|
||||
//delete this->genToPhenStrategy;
|
||||
//delete this->phenToFitStrategy;
|
||||
//delete this->recombinationStrategy;
|
||||
|
||||
if(this->substrateCache != 0)
|
||||
delete this->substrateCache;
|
||||
}
|
||||
|
||||
/*bool compareOnFitness(const Individual& a, const Individual& b){
|
||||
return a.getFitness() < b.getFitness();
|
||||
}*/
|
||||
|
||||
bool compareOnFitness(const Individual* a, const Individual* b){
|
||||
return a->getFitness() < b->getFitness();
|
||||
}
|
||||
|
||||
void Individual::calculateFitness(){
|
||||
this->genToPhenStrategy->calculatePhenotype(this);
|
||||
this->fitness = this->phenToFitStrategy->calculateFitness(this->phenotype);
|
||||
}
|
||||
|
||||
void Individual::calculatePhenotype(){
|
||||
this->genToPhenStrategy->calculatePhenotype(this);
|
||||
}
|
||||
Reference in New Issue
Block a user