00001
00002
00003
00004
00005 #ifndef __Indiv_h
00006 #define __Indiv_h
00007
00008 #include <vector>
00009
00010 using namespace std;
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 class Indiv
00027 {
00028
00029 public:
00030
00031 Indiv(int nr_pars);
00032 ~Indiv();
00033
00034 void init(vector<double>& parameter_ranges);
00035
00036 int get_nr_pars() { return pars.size(); }
00037 std::vector<double>& get_pars() { return pars; }
00038 std::vector<double>& get_vars() { return vars; }
00039
00040 double operator[] (int index) const { return pars[index]; }
00041 double& operator[] (int index) { return pars[index]; }
00042
00043 int is_parent() { return parent; }
00044 void set_parent(int new_value) { parent = new_value; }
00045
00046 void set_fitness(double new_value) { fitness = new_value; }
00047 double get_fitness() { return fitness; }
00048
00049 void recombine(Indiv* parent1, Indiv* parent2);
00050
00051 void mutate();
00052
00053
00054 friend ostream& operator<<(ostream& out, const Indiv& ind);
00055
00056
00057 private:
00058
00059 int nr_parameters;
00060 std::vector<double> pars;
00061 std::vector<double> vars;
00062 std::vector<double> covars;
00063
00064 int parent;
00065
00066 double fitness;
00067 double tau, tau2;
00068
00069
00070 };
00071
00072
00073 #endif
00074
00075