finish the handling of gnuplot completely at build-time.
No gnuplot-ifs in headers anymore.
This commit is contained in:
parent
4eb298ac73
commit
afc0659e35
12 changed files with 219 additions and 192 deletions
|
|
@ -3,16 +3,16 @@
|
|||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
|
||||
jeggermo@liacs.nl
|
||||
*/
|
||||
|
|
@ -26,8 +26,8 @@
|
|||
#endif
|
||||
|
||||
#include <iostream>
|
||||
#include <gp/eoParseTree.h>
|
||||
#include <eo>
|
||||
#include "gp/eoParseTree.h"
|
||||
#include "eo"
|
||||
|
||||
using namespace gp_parse_tree;
|
||||
using namespace std;
|
||||
|
|
@ -43,7 +43,7 @@ using namespace std;
|
|||
|
||||
|
||||
typedef eoParseTree<FitnessType, Node > EoType;
|
||||
typedef eoPop<EoType> Pop;
|
||||
typedef eoPop<EoType> Pop;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -52,23 +52,23 @@ int main(int argc, char *argv[])
|
|||
|
||||
// the vector containing the possible nodes
|
||||
vector<Node> initSequence;
|
||||
|
||||
// initialise parameters
|
||||
Parameters parameter(argc, argv);
|
||||
|
||||
|
||||
// initialise parameters
|
||||
Parameters parameter(argc, argv);
|
||||
|
||||
// set the randomseed
|
||||
rng.reseed(parameter.randomseed);
|
||||
|
||||
|
||||
// Create a generation counter
|
||||
eoValueParam<unsigned> generationCounter(0, "Gen.");
|
||||
|
||||
// Create an incrementor (sub-class of eoUpdater). Note that the
|
||||
// parameter's value is passed by reference,
|
||||
|
||||
// Create an incrementor (sub-class of eoUpdater). Note that the
|
||||
// parameter's value is passed by reference,
|
||||
// so every time the incrementer is updated (every generation),
|
||||
// the data in generationCounter will change.
|
||||
eoIncrementor<unsigned> increment(generationCounter.value());
|
||||
|
||||
|
||||
|
||||
|
||||
// create an instantiation of the fitness/evaluation function
|
||||
// it initializes the initSequence vector
|
||||
// the parameters are passed on as well
|
||||
|
|
@ -76,44 +76,44 @@ int main(int argc, char *argv[])
|
|||
|
||||
// Depth Initializor, set for Ramped Half and Half Initialization
|
||||
eoParseTreeDepthInit<FitnessType, Node> initializer(parameter.InitMaxDepth, initSequence, true, true);
|
||||
|
||||
|
||||
// create the initial population
|
||||
Pop pop(parameter.population_size, initializer);
|
||||
|
||||
// and evaluate the individuals
|
||||
// and evaluate the individuals
|
||||
apply<EoType>(eval, pop);
|
||||
|
||||
|
||||
generationCounter.value()++; // set the generationCounter to 1
|
||||
|
||||
|
||||
|
||||
// define X-OVER
|
||||
|
||||
|
||||
eoSubtreeXOver<FitnessType, Node> xover(parameter.MaxSize);
|
||||
|
||||
|
||||
// define MUTATION
|
||||
eoBranchMutation<FitnessType, Node> mutation(initializer, parameter.MaxSize);
|
||||
// eoExpansionMutation<FitnessType, Node> mutation(initializer, parameter.MaxSize);
|
||||
// eoCollapseSubtreeMutation<FitnessType, Node> mutation(initializer, parameter.MaxSize);
|
||||
// eoPointMutation<FitnessType, Node> mutation(initSequence);
|
||||
// eoHoistMutation<FitnessType, Node> mutation;
|
||||
|
||||
// The operators are encapsulated into an eoTRansform object,
|
||||
|
||||
// The operators are encapsulated into an eoTRansform object,
|
||||
// that performs sequentially crossover and mutation
|
||||
eoSGATransform<EoType> transform(xover, parameter.xover_rate, mutation, parameter.mutation_rate);
|
||||
|
||||
|
||||
// The robust tournament selection
|
||||
// in our case 5-tournament selection
|
||||
eoDetTournamentSelect<EoType> selectOne(parameter.tournamentsize);
|
||||
// is now encapsulated in a eoSelectMany
|
||||
eoSelectMany<EoType> select(selectOne, parameter.offspring_size, eo_is_an_integer);
|
||||
|
||||
|
||||
// and the generational replacement
|
||||
//eoGenerationalReplacement<EoType> replace;
|
||||
// or the SteadtState replacment
|
||||
//eoSSGAWorseReplacement<EoType> replace;
|
||||
// or comma selection
|
||||
eoCommaReplacement<EoType> replace;
|
||||
|
||||
|
||||
// Terminators
|
||||
eoGenContinue<EoType> term(parameter.nGenerations);
|
||||
|
||||
|
|
@ -124,13 +124,13 @@ int main(int argc, char *argv[])
|
|||
eoBestFitnessStat<EoType> best;
|
||||
|
||||
|
||||
// Add it to the checkpoint,
|
||||
// Add it to the checkpoint,
|
||||
// so the counter is updated (here, incremented) every generation
|
||||
checkPoint.add(increment);
|
||||
checkPoint.add(avg);
|
||||
checkPoint.add(best);
|
||||
|
||||
#if !defined(NO_GNUPLOT)
|
||||
|
||||
#ifdef HAVE_GNUPLOT
|
||||
eoGnuplot1DMonitor gnuplotmonitor("gnuplotBestStats");
|
||||
gnuplotmonitor.add(generationCounter);
|
||||
gnuplotmonitor.add(best);
|
||||
|
|
@ -147,7 +147,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
checkPoint.add(gnuplotmonitor);
|
||||
checkPoint.add(gnuplotAvgmonitor);
|
||||
#endif
|
||||
#endif
|
||||
// GP Generation
|
||||
eoEasyEA<EoType> gp(checkPoint, eval, select, transform, replace);
|
||||
|
||||
|
|
|
|||
Reference in a new issue