ga/include/core/evaluation.h

00001 /********************************************************************************
00002  *  FARSA Genetic Algorithm Library                                             *
00003  *  Copyright (C) 2007-2009 Gianluca Massera <emmegian@yahoo.it>                *
00004  *                                                                              *
00005  *  This program is free software; you can redistribute it and/or modify        *
00006  *  it under the terms of the GNU General Public License as published by        *
00007  *  the Free Software Foundation; either version 2 of the License, or           *
00008  *  (at your option) any later version.                                         *
00009  *                                                                              *
00010  *  This program is distributed in the hope that it will be useful,             *
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of              *
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               *
00013  *  GNU General Public License for more details.                                *
00014  *                                                                              *
00015  *  You should have received a copy of the GNU General Public License           *
00016  *  along with this program; if not, write to the Free Software                 *
00017  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA  *
00018  ********************************************************************************/
00019 
00020 #ifndef EVALUATION_H
00021 #define EVALUATION_H
00022 
00023 #include "gaconfig.h"
00024 #include "parametersettable.h"
00025 
00026 namespace farsa {
00027 
00028 class Genotype;
00029 class Genome;
00030 class GeneticAlgo;
00031 
00047 class FARSA_GA_API Evaluation : public ParameterSettableWithConfigureFunction {
00048 public:
00050     Evaluation();
00052     virtual ~Evaluation();
00056     void initialize( Genotype* genotypeToEvaluate );
00061     void evaluateStep();
00065     void evaluate();
00067     void finalize();
00069     bool isEvaluationDone();
00071     Genotype* genotype() {
00072         return genotypev;
00073     };
00075     unsigned int genotypeID() {
00076         return genotypeid;
00077     };
00079     void setGenome( Genome* g ) {
00080         genomev = g;
00081     };
00083     Genome* genome() {
00084         return genomev;
00085     };
00087     void setGA( GeneticAlgo* g ) {
00088         ga = g;
00089     };
00091     GeneticAlgo* GA() {
00092         return ga;
00093     };
00095     const GeneticAlgo* GA() const {
00096         return ga;
00097     };
00098 
00100     virtual Evaluation* clone() const = 0;
00101 
00102 protected:
00104     virtual void init() = 0;
00106     virtual void step() = 0;
00108     virtual void fini() = 0;
00109 
00113     void evaluationDone();
00114 
00115 private:
00117     bool isDone;
00119     bool isInitialized;
00121     bool isFinalized;
00123     Genotype* genotypev;
00125     unsigned int genotypeid;
00127     Genome* genomev;
00129     GeneticAlgo* ga;
00130 };
00131 
00132 } // end namespace farsa
00133 
00134 #endif