X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=src%2Ffitness%2Fwsti.h;h=b93439f204466028c6d6ba021a15d47ae2bcae7f;hb=1014b8296cc38f408212d385f036cc78e9c66cce;hp=068590d94c815868b0d2bf6c04401932a47ef566;hpb=971fed67ac2e5a01b5232853c08e03ed05bebbe0;p=genetic.git diff --git a/src/fitness/wsti.h b/src/fitness/wsti.h index 068590d..b93439f 100644 --- a/src/fitness/wsti.h +++ b/src/fitness/wsti.h @@ -20,13 +20,13 @@ namespace genetic { float span_end; double fenotype() { - int fen = 0; - int rat = 1; + int _fenotype = 0; + int ratio = 1; for (unsigned int i = 0; i < chromosome.get().size(); i++) { - fen = fen + chromosome.get()[i].get() * rat; - rat = rat * 2; + _fenotype = _fenotype + chromosome.get()[i].get() * ratio; + ratio = ratio * 2; } - return fen; + return _fenotype; } double calculateFenotype() { @@ -34,10 +34,8 @@ namespace genetic { 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() {