evaluation.h
1 /********************************************************************************
2  * FARSA Genetic Algorithm Library *
3  * Copyright (C) 2007-2009 Gianluca Massera <emmegian@yahoo.it> *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the Free Software *
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
18  ********************************************************************************/
19 
20 #ifndef EVALUATION_H
21 #define EVALUATION_H
22 
23 #include "gaconfig.h"
24 #include "parametersettable.h"
25 
26 namespace farsa {
27 
28 class Genotype;
29 class Genome;
30 class GeneticAlgo;
31 
46 public:
48  Evaluation();
50  virtual ~Evaluation();
54  void initialize( Genotype* genotypeToEvaluate );
59  void evaluateStep();
63  void evaluate();
68  virtual void initGeneration(int generation) { };
73  virtual void endGeneration(int generation) { };
75  void finalize();
77  bool isEvaluationDone();
80  return genotypev;
81  };
83  unsigned int genotypeID() {
84  return genotypeid;
85  };
87  void setGenome( Genome* g ) {
88  genomev = g;
89  };
92  return genomev;
93  };
95  void setGA( GeneticAlgo* g ) {
96  ga = g;
97  };
100  return ga;
101  };
103  const GeneticAlgo* GA() const {
104  return ga;
105  };
106 
108  virtual Evaluation* clone() const = 0;
109 
110 protected:
112  virtual void init() = 0;
114  virtual void step() = 0;
116  virtual void fini() = 0;
117 
121  void evaluationDone();
122 
123 private:
125  bool isDone;
127  bool isInitialized;
129  bool isFinalized;
131  Genotype* genotypev;
133  unsigned int genotypeid;
135  Genome* genomev;
137  GeneticAlgo* ga;
138 };
139 
140 } // end namespace farsa
141 
142 #endif