ga/include/evaluations/multitrials.h

00001 /********************************************************************************
00002  *  FARSA Genetic Algorithm Library                                             *
00003  *  Copyright (C) 2007-2008 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 MULTITRIALS_H
00021 #define MULTITRIALS_H
00022 
00023 #include "gaconfig.h"
00024 #include "core/evaluation.h"
00025 
00026 namespace farsa {
00027 
00037 class FARSA_GA_API MultiTrials : public Evaluation {
00038 public:
00040     MultiTrials( int steps = 1, int trials = 1 );
00042     virtual ~MultiTrials();
00044     void setTrials( int t );
00046     int trials() const;
00048     int currentTrial() const;
00050     void setSteps( int s );
00052     int steps() const;
00054     int currentStep() const;
00055 
00062     virtual void configure( ConfigurationParameters& params, QString prefix );
00069     virtual void save( ConfigurationParameters& params, QString prefix );
00071     static void describe( QString type );
00072 
00074     virtual MultiTrials* clone() const = 0;
00075 
00076 protected:
00078     virtual void mainInit() = 0;
00085     virtual bool trialInit( int trial ) = 0;
00090     virtual void trialStep( int step, int trial ) = 0;
00092     virtual void trialFini( int trial ) = 0;
00094     virtual void mainFini() = 0;
00095 
00100     void trialDone();
00101 
00109     void remainInCurrentStep(bool remain);
00110 
00115     bool remainingInCurrentStep() const;
00116 
00117 private:
00119     void init();
00121     void step();
00123     void fini();
00124 
00126     int currStep;
00128     int currTrial;
00130     int numTrials;
00132     int numSteps;
00134     bool incrementStep;
00136     bool trialInited;
00137 };
00138 
00139 } // end namespace farsa
00140 
00141 #endif