59 lines
2.1 KiB
C++
59 lines
2.1 KiB
C++
#pragma once
|
|
/*
|
|
|
|
|
|
*/
|
|
#include "../environment/AbstractEnvironment.h"
|
|
#include "genome/AbstractGenome.h"
|
|
#include "InnerSubstratesPool.h"
|
|
#include "genome/strategies/PhenotypeToFitnessStrategy.h"
|
|
class Phenotype;
|
|
class GenotypeToPhenotypeStrategy;
|
|
class Individual {
|
|
public:
|
|
enum Gender { male, female, hermaphrodite };
|
|
friend class GenotypeToPhenotypeStrategy;
|
|
friend class InOutBreedingGenotypeToPhenotypeStrategy;
|
|
friend class KolchShindyalGenotypeToPhenotypeStrategy;
|
|
friend class BisexualPopulation; // À íàäî áû MutationStrategy !!!
|
|
protected:
|
|
// Ñòðàòåãèè
|
|
GenotypeToPhenotypeStrategy* genToPhenStrategy;
|
|
PhenotypeToFitnessStrategy* phenToFitStrategy;
|
|
ChromosomeRearrangementStrategy* recombinationStrategy;
|
|
|
|
////
|
|
//Environment* currentEnvironment;
|
|
Region* region;
|
|
|
|
unsigned int age;
|
|
Gender gender;
|
|
Genotype* genotype;
|
|
|
|
InnerSubstratesPool* substrateCache ; // Çàïàñû ñóáñòðàòîâ
|
|
|
|
Phenotype* phenotype;
|
|
|
|
double fitness;
|
|
|
|
/////////////////
|
|
public:
|
|
Individual(const Individual& father, const Individual& mother); // Â àáñòðàêòíîì âàðèàíòå - âåêòîð ðîäèòåëåé
|
|
Individual(Genotype* gType, Phenotype* pType, InnerSubstratesPool* sub, Gender _gender = hermaphrodite, Region* reg = 0);
|
|
virtual ~Individual();
|
|
virtual const Genotype& getGenotype() const { return *genotype;}
|
|
virtual const Phenotype& getPhenotype() const {return *phenotype;}
|
|
//virtual void setEnvironment(Environment* env) { currentEnvironment = env; }
|
|
virtual void setRegion(Region* _region) {};
|
|
virtual void setGenToPhenStrategy(GenotypeToPhenotypeStrategy* s){ genToPhenStrategy = s;}
|
|
virtual void setPhenToFitnessStrategy(PhenotypeToFitnessStrategy* p) { if(phenToFitStrategy != 0) {delete phenToFitStrategy;} phenToFitStrategy = p;}
|
|
virtual void calculateFitness();
|
|
virtual void calculatePhenotype();
|
|
virtual double getFitness() const { return fitness; }
|
|
|
|
Gender getGender() const { return gender; }
|
|
virtual bool operator<(const Individual* _ind) const { return this->fitness < _ind->fitness;}
|
|
};
|
|
|
|
//bool compareOnFitness(const Individual& a, const Individual& b);
|
|
bool compareOnFitness(const Individual* a, const Individual* b); |