1 #ifndef __FITNESS_WSTI_H
2 #define __FITNESS_WSTI_H
14 * Just an example Fitness function based on WSTI version.
16 template <typename _Chromosome, typename _Value = double>
17 class WSTI : public Fitness<_Chromosome, _Value> {
20 * Value of the begining of the Fitness function domain
25 * Value of the end of the Fitness function domain
30 * Calculates fenotype of the current Chromosome
35 for (unsigned int i = 0; i < this->chromosome.get().size(); i++) {
36 _fenotype = _fenotype + this->chromosome.get()[i].get() * ratio;
39 // cout << "Fenotyp: " << _fenotype << "\n";
44 * Calculates fenotype of the current Chromosome
46 _Value calculateFenotype() {
47 const unsigned int power2N = 1 << this->chromosome.get().size();
48 return span_start + (span_end - span_start) * this->fenotype() / power2N;
52 * Calculates fitness value of the current Chromosome
54 _Value do_calculate() {
55 _Value fenotype = this->calculateFenotype();
56 return (exp(fenotype) * sin(3.1415 * fenotype) + 1) / fenotype;
60 * Class constructor. Initializes class with requied values.
62 * @param start begining of the Fitness function domain
63 * @param end end of the Fitness function domain
65 WSTI(float start, float end)
66 : span_start(start), span_end(end) {
70 * Class constructor. Initializes class with requied values.
72 * @param _chromosome Chromosome, for which value will be calculated
73 * @param start begining of the Fitness function domain
74 * @param end end of the Fitness function domain
76 WSTI(_Chromosome& _chromosome, float start, float end)
77 : Fitness<_Chromosome>(_chromosome), span_start(start), span_end(end) {
82 #endif /* __FITNESS_WSTI_H */