Main Page | Namespace List | Class List | File List | Class Members | File Members

Indiv.h

Go to the documentation of this file.
00001 //
00002 // $Id: Indiv.h,v 1.4 2004/11/29 14:37:10 min Exp min $
00003 //
00004 
00005 #ifndef __Indiv_h
00006 #define __Indiv_h
00007 
00008 #include <vector>
00009 
00010 using namespace std;
00011 
00012 //
00013 // individual representation
00014 //
00015 // transformation parameters
00016 //   variances, number of variances nv is [1, n]
00017 //   covariances, number is 0, n(n-1)/2 if # variances is n,
00018 //     or (n - nv/2)(nv - 1) for other values of nv
00019 //
00020 // to mutate, sample from normal distribution
00021 //   variances and covariances are also adjusted (if present), from different distributions
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 };  // Indiv class
00071 
00072 
00073 #endif
00074 
00075 

Generated on Tue Jun 14 11:37:51 2005 for evofunc by doxygen 1.3.6