40 lines
1.3 KiB
C++
40 lines
1.3 KiB
C++
#pragma once
|
|
#include <vector>
|
|
|
|
class Individ {
|
|
protected:
|
|
float E;
|
|
public:
|
|
static std::vector<float> c;
|
|
static float Xopt, sigmaX, sigmaE, sigmaC1, sigmaC2, sigmaC3, sigmaC4, sigmaC5;
|
|
static void initConstants();
|
|
static void initConstantsFromGUI(float c1, float c2, float c3, float c4, float c5, float Xoptim, float sigX, float sigE, float sigC1, float sigC2,
|
|
float sigC3, float sigC4, float sigC5);
|
|
|
|
Individ(float _E);
|
|
//virtual Individ~();
|
|
float getE() const { return E;}
|
|
virtual float getFitness() const;
|
|
virtual bool hasFeedBack() const {return false;}
|
|
virtual void mutate (float deltaE) { E += deltaE;}
|
|
virtual void mutateC2(float deltaC2) {}
|
|
virtual void setC2(float v){}
|
|
virtual float getC2() const { return c[1];}
|
|
static float getOptimalE() { return Xopt*c[2]/c[0] - c[3];}
|
|
};
|
|
|
|
class IndividFeedBack : public Individ {
|
|
float C2;
|
|
public:
|
|
IndividFeedBack(float _E);
|
|
IndividFeedBack(const IndividFeedBack& parent);
|
|
virtual float getFitness() const;
|
|
virtual bool hasFeedBack() const {return true;}
|
|
virtual void mutateC2(float deltaC2) { this->C2 += deltaC2;}
|
|
static float getOptimalE();
|
|
virtual void setC2(float v){ this->C2 = v;}
|
|
virtual float getC2() const { return this->C2;}
|
|
};
|
|
|
|
bool compareOnFitness(const Individ* a, const Individ* b);
|