X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=src%2Ffitness%2Fwsti.h;fp=src%2Ffitness%2Fwsti.h;h=d99dd18b8e6d58673a5f750d6e7ca8634fe7d55b;hb=1bef1f38888f19f83083d2f5bc1e1a90bb14291f;hp=eaa0538b77d58f46cab63a68efd648d448fd4750;hpb=58bf4fc9da0dfc4abb33bdc982214cbd2f186b44;p=genetic.git diff --git a/src/fitness/wsti.h b/src/fitness/wsti.h index eaa0538..d99dd18 100644 --- a/src/fitness/wsti.h +++ b/src/fitness/wsti.h @@ -16,9 +16,19 @@ namespace genetic { template class WSTI : public Fitness<_Chromosome, _Value> { protected: + /** + * Value of the begining of the Fitness function domain + */ float span_start; + + /** + * Value of the end of the Fitness function domain + */ float span_end; + /** + * Calculates fenotype of the current Chromosome + */ _Value fenotype() { int _fenotype = 0; int ratio = 1; @@ -30,19 +40,39 @@ namespace genetic { return _fenotype; } + /** + * Calculates fenotype of the current Chromosome + */ _Value calculateFenotype() { const unsigned int power2N = 1 << this->chromosome.get().size(); return span_start + (span_end - span_start) * this->fenotype() / power2N; } + /** + * Calculates fitness value of the current Chromosome + */ _Value do_calculate() { _Value fenotype = this->calculateFenotype(); return (exp(fenotype) * sin(3.1415 * fenotype) + 1) / fenotype; } public: + /** + * Class constructor. Initializes class with requied values. + * + * @param start begining of the Fitness function domain + * @param end end of the Fitness function domain + */ WSTI(float start, float end) : span_start(start), span_end(end) { } + + /** + * Class constructor. Initializes class with requied values. + * + * @param _chromosome Chromosome, for which value will be calculated + * @param start begining of the Fitness function domain + * @param end end of the Fitness function domain + */ WSTI(_Chromosome& _chromosome, float start, float end) : Fitness<_Chromosome>(_chromosome), span_start(start), span_end(end) { }