1 /*
2  *  Open BEAGLE
3  *  Copyright (C) 2001-2004 by Christian Gagne and Marc Parizeau
4  *
5  *  This library is free software; you can redistribute it and/or
6  *  modify it under the terms of the GNU Lesser General Public
7  *  License as published by the Free Software Foundation; either
8  *  version 2.1 of the License, or (at your option) any later version.
9  *
10  *  This library 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 GNU
13  *  Lesser General Public License for more details.
14  *
15  *  You should have received a copy of the GNU Lesser General Public
16  *  License along with this library; if not, write to the Free Software
17  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  *
19  *  Contact:
20  *  Laboratoire de Vision et Systemes Numeriques
21  *  Departement de genie electrique et de genie informatique
22  *  Universite Laval, Quebec, Canada, G1V 4J7
23  *  http://vision.gel.ulaval.ca
24  *
25  */
26 
27 /*!
28  *  \file   beagle/LinGP/src/Evolver.cpp
29  *  \brief  Source code of class LinGP::Evolver.
30  *  \author Christian Gagne <cgagne@gel.ulaval.ca>
31  *  \author Alain-Daniel Bourdage <adb@btc.bm>
32  *  $Revision: 1.1 $
33  *  $Date: 2005/10/06 15:43:44 $
34  */
35 
36 #include <string>
37 
38 #include "beagle/GP.hpp"
39 #include "beagle/LinGP/Evolver.hpp"
40 #include "beagle/LinGP/EvaluationOp.hpp"
41 #include "beagle/LinGP/CrossoverOnePointOp.hpp"
42 #include "beagle/LinGP/CrossoverTwoPointsOp.hpp"
43 #include "beagle/LinGP/CrossoverUniformOp.hpp"
44 #include "beagle/LinGP/MutationOp.hpp"
45 #include "beagle/LinGP/InitializationOp.hpp"
46 #include "beagle/IfThenElseOp.hpp"
47 
48 using namespace Beagle;
49 
50 
51 /*!
52  *  \brief Construct a linear GP evolver.
53  */
Evolver()54 LinGP::Evolver::Evolver()
55 {
56   addOperator(new LinGP::InitializationOp);
57   addOperator(new LinGP::CrossoverOnePointOp);
58   addOperator(new LinGP::CrossoverTwoPointsOp);
59   addOperator(new LinGP::CrossoverUniformOp);
60   addOperator(new LinGP::MutationOp);
61 }
62 
63 
64 /*!
65  *  \brief Construct a linear GP generational evolver.
66  *  \param inEvalOp Linear GP evaluation operator.
67  */
Evolver(Beagle::EvaluationOp::Handle inEvalOp)68 LinGP::Evolver::Evolver(Beagle::EvaluationOp::Handle inEvalOp)
69 {
70   addOperator(inEvalOp);
71   addOperator(new LinGP::InitializationOp);
72   addOperator(new LinGP::CrossoverOnePointOp);
73   addOperator(new LinGP::CrossoverTwoPointsOp);
74   addOperator(new LinGP::CrossoverUniformOp);
75   addOperator(new LinGP::MutationOp);
76 
77   addBootStrapOp("IfThenElseOp");
78   IfThenElseOp::Handle lITE = castHandleT<IfThenElseOp>(getBootStrapSet().back());
79   lITE->setConditionTag("ms.restart.file");
80   lITE->setConditionValue("");
81   lITE->insertPositiveOp("LinGP-InitializationOp", getOperatorMap());
82   lITE->insertPositiveOp(inEvalOp->getName(), getOperatorMap());
83   lITE->insertPositiveOp("StatsCalcFitnessSimpleOp", getOperatorMap());
84   lITE->insertNegativeOp("MilestoneReadOp", getOperatorMap());
85   addBootStrapOp("TermMaxGenOp");
86   addBootStrapOp("MilestoneWriteOp");
87 
88   addMainLoopOp("SelectTournamentOp");
89   addMainLoopOp("LinGP-CrossoverOnePointOp");
90   addMainLoopOp("LinGP-MutationOp");
91   addMainLoopOp(inEvalOp->getName());
92   addMainLoopOp("MigrationRandomRingOp");
93   addMainLoopOp("StatsCalcFitnessSimpleOp");
94   addMainLoopOp("TermMaxGenOp");
95   addMainLoopOp("MilestoneWriteOp");
96 }
97 
98