}
/** Copy constructor */
- Chromosome(const Chromosome& chromosome) : genes(chromosome.get()) {}
+ Chromosome(const Chromosome& chromosome)
+ : genes(chromosome.get()) {
+ }
Chromosome& operator=(const Chromosome&){
return *this;
return span_start + (span_end - span_start) * this->fenotype() / power2N;
}
public:
- WSTI(_Chromosome& chromosome, float start, float end) {
- this->chromosome = chromosome;
- this->span_start = start;
- this->span_end = end;
+ WSTI(_Chromosome& _chromosome, float start, float end)
+ : chromosome(_chromosome.get()), span_start(start), span_end(end) {
}
double calculate() {
vector<_Gene> genes;
- for (int i = 0; i < 20; i++) {
+ for (int i = 0; i < 11; i++) {
_Gene gene(rand() % 2);
cout << "Generated gene: " << (int)gene.get() << "\n";
genes.push_back(gene);
_Chromosome chromosome(genes);
cout << "Entire chromosome: ";
- for (int i = 0; i < 20; i++) {
+ for (unsigned int i = 0; i < chromosome.get().size(); i++) {
cout << chromosome.get()[i].get();
}
cout << endl;
WSTI<_Chromosome> fitness(chromosome, 0.5, 2.5);
- cout << "Fitness is equal to: " << (double)fitness.calculate() << "\n";
+ cout << "Fitness is equal to: " << fitness.calculate() << "\n";
return 0;
}