*/
vector<_Chromosome> chromosomes;
+ template<typename> friend class Generation;
public:
/**
* Default constructor
/** Copy constructor */
Generation(const Generation& generation)
- : chromosomes(generation.get()) {
- }
-
- /**
- * Allows read-only access to Generation Chromosomes
- */
- vector<_Chromosome> get() const {
- return this->chromosomes;
+ : chromosomes(generation.chromosomes) {
}
/**
* @return Generation instance containing copied Chromosomes
*/
Generation& operator=(const Generation& generation){
- this->chromosomes = generation.get();
+ this->chromosomes = generation.chromosomes;
return *this;
}
Generation<_Chromosome> generation) {
vector<FitnessValueType> generationFitness;
- for (unsigned int i = 0; i < generation.get().size(); i++) {
- generationFitness.push_back(this->checkChromosomeFitness(generation.get()[i]));
+ for (unsigned int i = 0; i < generation.size(); i++) {
+ generationFitness.push_back(this->checkChromosomeFitness(generation[i]));
}
return generationFitness;
offset = (max - min) / (chromosomeSize - 1) - min;
for (unsigned int i = 0; i < generationFitness.size(); i++) {
- normalizedFitness.insert(std::make_pair(generationFitness[i] + offset, this->generation.get()[i]));
+ normalizedFitness.insert(std::make_pair(generationFitness[i] + offset, this->generation[i]));
}
return normalizedFitness;