* EO.tpl, MyStructEA.cpp, MyStructSEA.cpp, make_MyStruct.cpp: Use
correct names for includes. * README.manual: This is a copy of the old README. * README: Describe the new way and setup of creating a new EO project. * createEOproject.sh, Makefile.am.src-tmpl, Makefile.am.top-tmpl: * configure.ac.tmpl: New files to create a standalone EO project from templates.
This commit is contained in:
parent
b28f39af40
commit
301e29ac02
12 changed files with 445 additions and 265 deletions
19
eo/tutorial/Templates/ChangeLog
Normal file
19
eo/tutorial/Templates/ChangeLog
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
2006-12-16 Jochen Küpper <jochen@fhi-berlin.mpg.de>
|
||||
|
||||
* EO.tpl, MyStructEA.cpp, MyStructSEA.cpp, make_MyStruct.cpp: Use
|
||||
correct names for includes.
|
||||
|
||||
* README.manual: This is a copy of the old README.
|
||||
|
||||
* README: Describe the new way and setup of creating a new EO project.
|
||||
|
||||
* createEOproject.sh, Makefile.am.src-tmpl, Makefile.am.top-tmpl:
|
||||
* configure.ac.tmpl: New files to create a standalone EO project from
|
||||
templates.
|
||||
|
||||
|
||||
* Local Variables:
|
||||
* coding: iso-8859-1
|
||||
* mode: flyspell
|
||||
* fill-column: 80
|
||||
* End:
|
||||
|
|
@ -95,32 +95,32 @@ typedef EASEAGenome<MyFitT> Indi; // ***MUST*** derive from EO
|
|||
|
||||
// how to initialize the population
|
||||
// it IS representation independent if an eoInit is given
|
||||
#include <do/make_pop.h>
|
||||
#include <make_pop.h>
|
||||
eoPop<Indi >& make_pop(eoParser& _parser, eoState& _state, eoInit<Indi> & _init){
|
||||
return do_make_pop(_parser, _state, _init);
|
||||
}
|
||||
|
||||
// the stopping criterion
|
||||
#include "do/make_continue.h"
|
||||
#include "make_continue.h"
|
||||
eoContinue<Indi>& make_continue(eoParser& _parser, eoState& _state, eoEvalFuncCounter<Indi> & _eval){
|
||||
return do_make_continue(_parser, _state, _eval);
|
||||
}
|
||||
|
||||
// outputs (stats, population dumps, ...)
|
||||
#include <do/make_checkpoint.h>
|
||||
#include <make_checkpoint.h>
|
||||
eoCheckPoint<Indi>& make_checkpoint(eoParser& _parser, eoState& _state, eoEvalFuncCounter<Indi>& _eval, eoContinue<Indi>& _continue) {
|
||||
return do_make_checkpoint(_parser, _state, _eval, _continue);
|
||||
}
|
||||
|
||||
// evolution engine (selection and replacement)
|
||||
#include <do/make_algo_easea.h>
|
||||
#include <make_algo_easea.h>
|
||||
eoAlgo<Indi>& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc<Indi>& _eval, eoContinue<Indi>& _continue, eoGenOp<Indi>& _op){
|
||||
return do_make_algo_scalar(_parser, _state, _eval, _continue, _op);
|
||||
}
|
||||
|
||||
// simple call to the algo. stays there for consistency reasons
|
||||
// no template for that one
|
||||
#include <do/make_run.h>
|
||||
#include <make_run.h>
|
||||
// the instanciating fitnesses
|
||||
#include <eoScalarFitness.h>
|
||||
void run_ea(eoAlgo<Indi>& _ga, eoPop<Indi>& _pop){
|
||||
|
|
|
|||
16
eo/tutorial/Templates/Makefile.am.src-tmpl
Normal file
16
eo/tutorial/Templates/Makefile.am.src-tmpl
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
bin_PROGRAMS = MyStruct
|
||||
|
||||
MyStruct_SOURCES = MyStructEA.cpp \
|
||||
eoMyStruct.h \
|
||||
eoMyStructEvalFunc.h \
|
||||
eoMyStructInit.h \
|
||||
eoMyStructMutation.h \
|
||||
eoMyStructQuadCrossover.h
|
||||
|
||||
|
||||
|
||||
dnl Local Variables:
|
||||
dnl coding: iso-8859-1
|
||||
dnl mode: makefile-automake
|
||||
dnl fill-column: 80
|
||||
dnl End:
|
||||
8
eo/tutorial/Templates/Makefile.am.top-tmpl
Normal file
8
eo/tutorial/Templates/Makefile.am.top-tmpl
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
SUBDIRS = src
|
||||
|
||||
|
||||
dnl Local Variables:
|
||||
dnl coding: iso-8859-1
|
||||
dnl mode: makefile-automake
|
||||
dnl fill-column: 80
|
||||
dnl End:
|
||||
|
|
@ -77,28 +77,28 @@ eoGenOp<Indi>& make_op(eoParser& _parser, eoState& _state, eoInit<Indi>& _init)
|
|||
|
||||
// how to initialize the population
|
||||
// it IS representation independent if an eoInit is given
|
||||
#include <do/make_pop.h>
|
||||
#include <make_pop.h>
|
||||
eoPop<Indi >& make_pop(eoParser& _parser, eoState& _state, eoInit<Indi> & _init)
|
||||
{
|
||||
return do_make_pop(_parser, _state, _init);
|
||||
}
|
||||
|
||||
// the stopping criterion
|
||||
#include <do/make_continue.h>
|
||||
#include <make_continue.h>
|
||||
eoContinue<Indi>& make_continue(eoParser& _parser, eoState& _state, eoEvalFuncCounter<Indi> & _eval)
|
||||
{
|
||||
return do_make_continue(_parser, _state, _eval);
|
||||
}
|
||||
|
||||
// outputs (stats, population dumps, ...)
|
||||
#include <do/make_checkpoint.h>
|
||||
#include <make_checkpoint.h>
|
||||
eoCheckPoint<Indi>& make_checkpoint(eoParser& _parser, eoState& _state, eoEvalFuncCounter<Indi>& _eval, eoContinue<Indi>& _continue)
|
||||
{
|
||||
return do_make_checkpoint(_parser, _state, _eval, _continue);
|
||||
}
|
||||
|
||||
// evolution engine (selection and replacement)
|
||||
#include <do/make_algo_scalar.h>
|
||||
#include <make_algo_scalar.h>
|
||||
eoAlgo<Indi>& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc<Indi>& _eval, eoContinue<Indi>& _continue, eoGenOp<Indi>& _op)
|
||||
{
|
||||
return do_make_algo_scalar(_parser, _state, _eval, _continue, _op);
|
||||
|
|
@ -106,7 +106,7 @@ eoAlgo<Indi>& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc<I
|
|||
|
||||
// simple call to the algo. stays there for consistency reasons
|
||||
// no template for that one
|
||||
#include <do/make_run.h>
|
||||
#include <make_run.h>
|
||||
// the instanciating fitnesses
|
||||
#include <eoScalarFitness.h>
|
||||
void run_ea(eoAlgo<Indi>& _ga, eoPop<Indi>& _pop)
|
||||
|
|
|
|||
|
|
@ -73,28 +73,28 @@ typedef eoMyStruct<MyFitT> Indi; // ***MUST*** derive from EO
|
|||
|
||||
// how to initialize the population
|
||||
// it IS representation independent if an eoInit is given
|
||||
#include <do/make_pop.h>
|
||||
#include <make_pop.h>
|
||||
eoPop<Indi >& make_pop(eoParser& _parser, eoState& _state, eoInit<Indi> & _init)
|
||||
{
|
||||
return do_make_pop(_parser, _state, _init);
|
||||
}
|
||||
|
||||
// the stopping criterion
|
||||
#include <do/make_continue.h>
|
||||
#include <make_continue.h>
|
||||
eoContinue<Indi>& make_continue(eoParser& _parser, eoState& _state, eoEvalFuncCounter<Indi> & _eval)
|
||||
{
|
||||
return do_make_continue(_parser, _state, _eval);
|
||||
}
|
||||
|
||||
// outputs (stats, population dumps, ...)
|
||||
#include <do/make_checkpoint.h>
|
||||
#include <make_checkpoint.h>
|
||||
eoCheckPoint<Indi>& make_checkpoint(eoParser& _parser, eoState& _state, eoEvalFuncCounter<Indi>& _eval, eoContinue<Indi>& _continue)
|
||||
{
|
||||
return do_make_checkpoint(_parser, _state, _eval, _continue);
|
||||
}
|
||||
|
||||
// evolution engine (selection and replacement)
|
||||
#include <do/make_algo_scalar.h>
|
||||
#include <make_algo_scalar.h>
|
||||
eoAlgo<Indi>& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc<Indi>& _eval, eoContinue<Indi>& _continue, eoGenOp<Indi>& _op, eoDistance<Indi> *_dist = NULL)
|
||||
{
|
||||
return do_make_algo_scalar(_parser, _state, _eval, _continue, _op, _dist);
|
||||
|
|
@ -102,7 +102,7 @@ eoAlgo<Indi>& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc<I
|
|||
|
||||
// simple call to the algo. stays there for consistency reasons
|
||||
// no template for that one
|
||||
#include <do/make_run.h>
|
||||
#include <make_run.h>
|
||||
// the instanciating fitnesses
|
||||
#include <eoScalarFitness.h>
|
||||
void run_ea(eoAlgo<Indi>& _ga, eoPop<Indi>& _pop)
|
||||
|
|
|
|||
|
|
@ -1,149 +1,15 @@
|
|||
Quick NOTE: This version of README is obsolete (May 25, 2004)
|
||||
In particular, a simpler version of the algorithm can be generated
|
||||
using the script
|
||||
createSimple
|
||||
This Templates directory contains template files of an EO project and
|
||||
a script createEOproject.sh to create a complete new EO project.
|
||||
|
||||
with the same syntax. It is also more powerful, allowing for instance
|
||||
to create you own statistics on the population, saving it in a file
|
||||
and/or plotting on on-line during the run (see eoStat.tmpl).
|
||||
More details some day, when I have some time ...
|
||||
The template requires a complete installation of EO.
|
||||
|
||||
============= Old README (most is still accurate, though) ==========
|
||||
In particular, the C++ compiler must find the EO include files and the
|
||||
linker must find the EO libraries. Most probably, that means that you
|
||||
have to set the variables CPLUS_INCLUDE_PATH and LIBRARY_PATH, i.e.
|
||||
for a standard installation and using tcsh:
|
||||
|
||||
This directory contains sample files that should make it easy to
|
||||
create an EO algorithm to evolve any type of structure
|
||||
(EO comes with two examples, bitstrings and vector of real variables,
|
||||
so you'll need this as soon as you want to evolve something else).
|
||||
setenv CPLUS_INCLUDE_PATH /usr/local/include/eo:"$CPLUS_INCLUDE_PATH"
|
||||
setenv LIBRARY_PATH /usr/local/lib:"$LIBRARY_PATH"
|
||||
|
||||
At the moment, only algorithms involving a scalar fitness (double)
|
||||
are implemented (see test dir for Pareto optimization of multiple-
|
||||
objective fitness - or be patient :-)
|
||||
|
||||
This file will help you to build the same algorithm than the ones
|
||||
in the Lesson4 of the tutorial, but with YOUR genotype instead of
|
||||
bitstrings or vector<double>. More details in Lesson5 of the tutorial.
|
||||
|
||||
It is assumed in the following that you have read the first part of
|
||||
the tutorial (Lessons 1 to 4).
|
||||
|
||||
Creating the algorithm for your genotype
|
||||
----------------------------------------
|
||||
In what follows, we will suppose that you want to evolve some data
|
||||
structure, and that you have enough programming skills to be able to
|
||||
write C code for its random initilialization, its crossover, its
|
||||
mutation and the computation of its fitness.
|
||||
|
||||
The helper script * create.sh * will create for you the files you need
|
||||
from the samples in tutorial/Templates dir, and all you'll have to do
|
||||
is to include the actual code where indicated in those files (between
|
||||
keywords START and END).
|
||||
|
||||
First, let's choose a name: let's call the new EO class eoAppli.
|
||||
All newly created classes will be named eoAppliXXX (in the file
|
||||
eoAppliXXX)
|
||||
|
||||
1- cd to the tutorial dir
|
||||
|
||||
2- create the directory for your application (let's assume you call it
|
||||
APPLICATION): type in
|
||||
|
||||
mkdir APPLICATION
|
||||
|
||||
3- go to the Templates dir
|
||||
|
||||
cd Templates
|
||||
|
||||
and run the helper script create.sh with the following arguments
|
||||
|
||||
./create.sh Appli ../APPLICATION
|
||||
|
||||
4- cd to the APPLICATION dir (cd ../APPLICATION).
|
||||
You should see there the following files:
|
||||
AppliEA.cpp the main file, includes all other, to be compiled
|
||||
Makefile with default target eoAppliEA
|
||||
eoAppli.h class eoAppli<FitT>, FitT = template fitness
|
||||
eoAppliEvalFunc.h class for the computation of fotness
|
||||
eoAppliInit.h class for genotype initlialization
|
||||
eoAppliMutation.h class for mutation
|
||||
eoAppliQuadCrossover.h class for (quadratic) crossover
|
||||
make_genotype_Appli.h helper function that create the initializer
|
||||
make_op_Appli.h helper function that creates the variatin operators
|
||||
|
||||
Note: You can go directly to step 6 and 7: you'll get a lot of
|
||||
warnings, but will be able to run an EA that does nothing!
|
||||
|
||||
5- Edit those files to suit your needs. The minimal addition you'll need
|
||||
to make are
|
||||
in eoAppli.h define your genotype
|
||||
in eoAppliInit.h define the initialization of one genotype
|
||||
in eoAppliMutation.h define the mutation of one genotype
|
||||
in eoAppliQuadCrossover.h define the crossover of 2 genotypes
|
||||
|
||||
HINT: look for keywords START and END and modify code in between.
|
||||
|
||||
6- Compile eoAppliEA.cpp. If your APPLICATION dir is in the tutorial
|
||||
dir, you don't need to modify Makefile. Just type in
|
||||
|
||||
% make
|
||||
|
||||
7- Run the resulting program:
|
||||
|
||||
% eoAppliEA
|
||||
|
||||
The default output is one line per generation with the generation
|
||||
number, the number of evaluations performed, the best and average
|
||||
fitnesses in the population.
|
||||
The algorithm stops by default after 100 generations.
|
||||
|
||||
8- Customize the parameters: copy eoAppliEA.status into
|
||||
e.g. eoAppliEA.param, edit eoAppliEA.param (uncomment the lines you
|
||||
want to become active), and run
|
||||
|
||||
% eoAppliEA @eoAppliEA.param
|
||||
|
||||
(see the Lesson 5 of the tutorial for more details now).
|
||||
|
||||
HINTS
|
||||
-----
|
||||
|
||||
1- If some new classes you create require some user parameter, you can
|
||||
either read them in the file where they are created (e.g.
|
||||
make_op_Appli.h for variation operators), or pass the eoParser to the
|
||||
constructor of the class, and read the parameter from the parser.
|
||||
|
||||
2- If you stick to privacy for the data in your EO class, you will
|
||||
probably need to write accessors to those data, as well as some public
|
||||
methods to modify them, as soon as some other methods need them too.
|
||||
|
||||
3- The sample make_op_Appli.h supposes that you ony have one crossover
|
||||
and one mutation operator. However, the code for multiple operators is
|
||||
there: you can have for instance 2 crossover operators, and choose
|
||||
among them according to relative weights (proportional choice) - same
|
||||
for mutation. Look at the operator section in eoAppliEA.cpp In
|
||||
particular, the user parameters cross1Rate and mut1Rate are totally
|
||||
useless for a single operator.
|
||||
|
||||
To add another operator, you have to create another class by mimicking
|
||||
what has been done for the first operator.
|
||||
For instance, let's suppose you want to create another mutation.
|
||||
|
||||
* duplicate the code for eoAppliMutation class
|
||||
* in the second version, change the class name (eoAppliMutation) into
|
||||
another name (let's say eoAppliBetterMutation) - you must change the
|
||||
name in the class declaration, in the constructor and in the
|
||||
className() method.
|
||||
* in the new eoAppliBetterMutation class, change the code for the
|
||||
operator() - and eventually the code for the constructor.
|
||||
* in the make_op_Appli.h file, in the mutation section, uncomment the
|
||||
lines
|
||||
mut = new eoAppliSecondMutation<Indi>(varType _anyVariable);
|
||||
_state.storeFunctor(mut);
|
||||
double mut2Rate = _parser.createParam(1.0, "mut2Rate", "Relative rate for mutation 2", '2', "Variation Operators").value();
|
||||
propMutation.add(*mut, mut2Rate);
|
||||
|
||||
and change the name of the class from eoAppliSecondMutation to your
|
||||
name eoAppliBetterMutation (you can also change the keyword from
|
||||
mut2Rate to something more meaningful like BetterMutationRate).
|
||||
You're done!
|
||||
|
||||
In case of problem: Marc.Schoenauer@inria.fr
|
||||
See README.manual for more details.
|
||||
|
|
|
|||
143
eo/tutorial/Templates/README.manual
Normal file
143
eo/tutorial/Templates/README.manual
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
This is the old template-directory README. Most of this information is
|
||||
still accurate and it contains more details than the new README.
|
||||
However, see there first for the creation of new projects.
|
||||
|
||||
========================================================================
|
||||
|
||||
This directory contains sample files that should make it easy to
|
||||
create an EO algorithm to evolve any type of structure
|
||||
(EO comes with two examples, bitstrings and vector of real variables,
|
||||
so you'll need this as soon as you want to evolve something else).
|
||||
|
||||
At the moment, only algorithms involving a scalar fitness (double)
|
||||
are implemented (see test dir for Pareto optimization of multiple-
|
||||
objective fitness - or be patient :-)
|
||||
|
||||
This file will help you to build the same algorithm than the ones
|
||||
in the Lesson4 of the tutorial, but with YOUR genotype instead of
|
||||
bitstrings or vector<double>. More details in Lesson5 of the tutorial.
|
||||
|
||||
It is assumed in the following that you have read the first part of
|
||||
the tutorial (Lessons 1 to 4).
|
||||
|
||||
Creating the algorithm for your genotype
|
||||
----------------------------------------
|
||||
In what follows, we will suppose that you want to evolve some data
|
||||
structure, and that you have enough programming skills to be able to
|
||||
write C code for its random initilialization, its crossover, its
|
||||
mutation and the computation of its fitness.
|
||||
|
||||
The helper script * create.sh * will create for you the files you need
|
||||
from the samples in tutorial/Templates dir, and all you'll have to do
|
||||
is to include the actual code where indicated in those files (between
|
||||
keywords START and END).
|
||||
|
||||
First, let's choose a name: let's call the new EO class eoAppli.
|
||||
All newly created classes will be named eoAppliXXX (in the file
|
||||
eoAppliXXX)
|
||||
|
||||
1- cd to the tutorial dir
|
||||
|
||||
2- create the directory for your application (let's assume you call it
|
||||
APPLICATION): type in
|
||||
|
||||
mkdir APPLICATION
|
||||
|
||||
3- go to the Templates dir
|
||||
|
||||
cd Templates
|
||||
|
||||
and run the helper script create.sh with the following arguments
|
||||
|
||||
./create.sh Appli ../APPLICATION
|
||||
|
||||
4- cd to the APPLICATION dir (cd ../APPLICATION).
|
||||
You should see there the following files:
|
||||
AppliEA.cpp the main file, includes all other, to be compiled
|
||||
Makefile with default target eoAppliEA
|
||||
eoAppli.h class eoAppli<FitT>, FitT = template fitness
|
||||
eoAppliEvalFunc.h class for the computation of fotness
|
||||
eoAppliInit.h class for genotype initlialization
|
||||
eoAppliMutation.h class for mutation
|
||||
eoAppliQuadCrossover.h class for (quadratic) crossover
|
||||
make_genotype_Appli.h helper function that create the initializer
|
||||
make_op_Appli.h helper function that creates the variatin operators
|
||||
|
||||
Note: You can go directly to step 6 and 7: you'll get a lot of
|
||||
warnings, but will be able to run an EA that does nothing!
|
||||
|
||||
5- Edit those files to suit your needs. The minimal addition you'll need
|
||||
to make are
|
||||
in eoAppli.h define your genotype
|
||||
in eoAppliInit.h define the initialization of one genotype
|
||||
in eoAppliMutation.h define the mutation of one genotype
|
||||
in eoAppliQuadCrossover.h define the crossover of 2 genotypes
|
||||
|
||||
HINT: look for keywords START and END and modify code in between.
|
||||
|
||||
6- Compile eoAppliEA.cpp. If your APPLICATION dir is in the tutorial
|
||||
dir, you don't need to modify Makefile. Just type in
|
||||
|
||||
% make
|
||||
|
||||
7- Run the resulting program:
|
||||
|
||||
% eoAppliEA
|
||||
|
||||
The default output is one line per generation with the generation
|
||||
number, the number of evaluations performed, the best and average
|
||||
fitnesses in the population.
|
||||
The algorithm stops by default after 100 generations.
|
||||
|
||||
8- Customize the parameters: copy eoAppliEA.status into
|
||||
e.g. eoAppliEA.param, edit eoAppliEA.param (uncomment the lines you
|
||||
want to become active), and run
|
||||
|
||||
% eoAppliEA @eoAppliEA.param
|
||||
|
||||
(see the Lesson 5 of the tutorial for more details now).
|
||||
|
||||
HINTS
|
||||
-----
|
||||
|
||||
1- If some new classes you create require some user parameter, you can
|
||||
either read them in the file where they are created (e.g.
|
||||
make_op_Appli.h for variation operators), or pass the eoParser to the
|
||||
constructor of the class, and read the parameter from the parser.
|
||||
|
||||
2- If you stick to privacy for the data in your EO class, you will
|
||||
probably need to write accessors to those data, as well as some public
|
||||
methods to modify them, as soon as some other methods need them too.
|
||||
|
||||
3- The sample make_op_Appli.h supposes that you ony have one crossover
|
||||
and one mutation operator. However, the code for multiple operators is
|
||||
there: you can have for instance 2 crossover operators, and choose
|
||||
among them according to relative weights (proportional choice) - same
|
||||
for mutation. Look at the operator section in eoAppliEA.cpp In
|
||||
particular, the user parameters cross1Rate and mut1Rate are totally
|
||||
useless for a single operator.
|
||||
|
||||
To add another operator, you have to create another class by mimicking
|
||||
what has been done for the first operator.
|
||||
For instance, let's suppose you want to create another mutation.
|
||||
|
||||
* duplicate the code for eoAppliMutation class
|
||||
* in the second version, change the class name (eoAppliMutation) into
|
||||
another name (let's say eoAppliBetterMutation) - you must change the
|
||||
name in the class declaration, in the constructor and in the
|
||||
className() method.
|
||||
* in the new eoAppliBetterMutation class, change the code for the
|
||||
operator() - and eventually the code for the constructor.
|
||||
* in the make_op_Appli.h file, in the mutation section, uncomment the
|
||||
lines
|
||||
mut = new eoAppliSecondMutation<Indi>(varType _anyVariable);
|
||||
_state.storeFunctor(mut);
|
||||
double mut2Rate = _parser.createParam(1.0, "mut2Rate", "Relative rate for mutation 2", '2', "Variation Operators").value();
|
||||
propMutation.add(*mut, mut2Rate);
|
||||
|
||||
and change the name of the class from eoAppliSecondMutation to your
|
||||
name eoAppliBetterMutation (you can also change the keyword from
|
||||
mut2Rate to something more meaningful like BetterMutationRate).
|
||||
You're done!
|
||||
|
||||
In case of problem: Marc.Schoenauer@inria.fr
|
||||
10
eo/tutorial/Templates/README.tmpl
Normal file
10
eo/tutorial/Templates/README.tmpl
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
This is an autogenerated EO project
|
||||
|
||||
Fill in the marked code-snippets in the files in src/ and you have a
|
||||
complete EA project.
|
||||
|
||||
The project has a complete build-infrastructure based on
|
||||
automake/autoconf. You can simply run "make" in this directory to have
|
||||
the program compiled. The executable build will be in src/.
|
||||
|
||||
Enjoy!
|
||||
39
eo/tutorial/Templates/configure.ac.tmpl
Normal file
39
eo/tutorial/Templates/configure.ac.tmpl
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
# EO template autogeneration configure.ac template
|
||||
#
|
||||
# Copyright (C) 2006 Jochen Küpper <jochen@fhi-berlin.mpg.de>
|
||||
#
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
AC_INIT(MyStruct, 0.1)
|
||||
AC_CONFIG_SRCDIR(src/eoMyStruct.h)
|
||||
AM_INIT_AUTOMAKE
|
||||
AC_CONFIG_HEADERS(config.h)
|
||||
|
||||
dnl Checks for programs.
|
||||
AC_PROG_CC
|
||||
AC_PROG_CXX
|
||||
AC_ISC_POSIX
|
||||
|
||||
dnl Checks for header files.
|
||||
AC_STDC_HEADERS
|
||||
AC_LANG(C++)
|
||||
AC_CHECK_HEADERS([eo], [], [AC_ERROR(Evolving Objects headers are required)])
|
||||
|
||||
dnl Checks for libraries.
|
||||
AC_LANG(C++)
|
||||
AC_CHECK_LIB([eoutils], [main], [],
|
||||
AC_MSG_ERROR([Evolving Objects utility library is required.]))
|
||||
AC_CHECK_LIB([eo], [main], [],
|
||||
AC_MSG_ERROR([Evolving Objects library is required.]))
|
||||
AC_CHECK_LIB([es], [main], [],
|
||||
AC_MSG_ERROR([EO Evolutionary strategies library is required.]))
|
||||
|
||||
dnl Checks for library functions.
|
||||
|
||||
AC_OUTPUT([Makefile src/Makefile])
|
||||
|
||||
|
||||
dnl Local Variables:
|
||||
dnl coding: iso-8859-1
|
||||
dnl mode: autoconf
|
||||
dnl fill-column: 80
|
||||
dnl End:
|
||||
79
eo/tutorial/Templates/createEOproject.sh
Executable file
79
eo/tutorial/Templates/createEOproject.sh
Executable file
|
|
@ -0,0 +1,79 @@
|
|||
#! /bin/tcsh -f
|
||||
#
|
||||
# Script to create a completely new EO project from templates
|
||||
#
|
||||
# Originally by Marc Schoenauer
|
||||
# Copyright (C) 2006 Jochen Küpper <jochen@fhi-berlin.mpg.de>
|
||||
|
||||
if ($PWD:t != Templates) then
|
||||
echo "You must start this shell script from the EO Template directory"
|
||||
exit
|
||||
endif
|
||||
|
||||
if ($#argv < 1) then
|
||||
echo "Usage: $0 ApplicationName [TargetDirName]"
|
||||
echo " This will create ../TargetDirName if necessary (default dir name = ApplicationName),"
|
||||
echo " and will also put all the files there that are strictly necessary to compile and run"
|
||||
echo " your application."
|
||||
exit
|
||||
endif
|
||||
|
||||
# we're going to do something
|
||||
echo " "
|
||||
if ($#argv == 1) then
|
||||
set TargetDir = ../$1
|
||||
else
|
||||
set TargetDir = ../$2
|
||||
endif
|
||||
if ( -d $TargetDir ) then
|
||||
echo "Warning: The target directory does exist already."
|
||||
echo -n "Overwrite (yes/no)? "
|
||||
set REP = $<
|
||||
if ($REP != "yes") then
|
||||
echo "Stopping, nothing done!"
|
||||
exit
|
||||
endif
|
||||
else if ( -e $TargetDir ) then
|
||||
echo "Warning: $TargetDir exist but isn't a directory."
|
||||
echo "Stopping, nothing done!"
|
||||
exit
|
||||
endif
|
||||
mkdir -p $TargetDir/src
|
||||
|
||||
|
||||
# creating files
|
||||
echo "Creating source files for application $1 in $TargetDir/src"
|
||||
sed s/MyStruct/$1/g eoMyStruct.tmpl > $TargetDir/src/eo$1.h
|
||||
sed s/MyStruct/$1/g init.tmpl > $TargetDir/src/eo$1Init.h
|
||||
sed s/MyStruct/$1/g stat.tmpl > $TargetDir/src/eo$1Stat.h
|
||||
sed s/MyStruct/$1/g evalFunc.tmpl > $TargetDir/src/eo$1EvalFunc.h
|
||||
sed s/MyStruct/$1/g mutation.tmpl > $TargetDir/src/eo$1Mutation.h
|
||||
sed s/MyStruct/$1/g quadCrossover.tmpl > $TargetDir/src/eo$1QuadCrossover.h
|
||||
sed s/MyStruct/$1/g MyStructSEA.cpp > $TargetDir/src/$1EA.cpp
|
||||
|
||||
echo "Creating build-support files for application $1 in $TargetDir"
|
||||
sed s/MyStruct/$1/g configure.ac.tmpl > $TargetDir/configure.ac
|
||||
sed s/MyStruct/$1/g Makefile.am.top-tmpl > $TargetDir/Makefile.am
|
||||
sed s/MyStruct/$1/g Makefile.am.src-tmpl > $TargetDir/src/Makefile.am
|
||||
sed s/MyStruct/$1/g README.tmpl > $TargetDir/README
|
||||
touch $TargetDir/AUTHORS
|
||||
touch $TargetDir/ChangeLog
|
||||
touch $TargetDir/NEWS
|
||||
|
||||
echo "Successfully created project $1 in $TargetDir!"
|
||||
echo "Start building the new project"
|
||||
|
||||
|
||||
# building new project
|
||||
cd $TargetDir
|
||||
aclocal || exit
|
||||
autoheader || exit
|
||||
automake --add-missing --copy --gnu || exit
|
||||
autoconf || exit
|
||||
./configure || exit
|
||||
make || exit
|
||||
|
||||
|
||||
# done
|
||||
echo "Project $1 successfully build in $TargetDir!"
|
||||
echo "Implement your code and enjoy."
|
||||
|
|
@ -67,7 +67,7 @@ using namespace std;
|
|||
|
||||
// how to initialize the population
|
||||
// it IS representation independent if an eoInit is given
|
||||
#include <do/make_pop.h>
|
||||
#include <make_pop.h>
|
||||
eoPop<eoMyStruct<double> >& make_pop(eoParser& _parser, eoState& _state, eoInit<eoMyStruct<double> > & _init)
|
||||
{
|
||||
return do_make_pop(_parser, _state, _init);
|
||||
|
|
@ -79,7 +79,7 @@ eoPop<eoMyStruct<eoMinimizingFitness> >& make_pop(eoParser& _parser, eoState& _
|
|||
}
|
||||
|
||||
// the stopping criterion
|
||||
#include <do/make_continue.h>
|
||||
#include <make_continue.h>
|
||||
eoContinue<eoMyStruct<double> >& make_continue(eoParser& _parser, eoState& _state, eoEvalFuncCounter<eoMyStruct<double> > & _eval)
|
||||
{
|
||||
return do_make_continue(_parser, _state, _eval);
|
||||
|
|
@ -91,7 +91,7 @@ eoContinue<eoMyStruct<eoMinimizingFitness> >& make_continue(eoParser& _parser, e
|
|||
}
|
||||
|
||||
// outputs (stats, population dumps, ...)
|
||||
#include <do/make_checkpoint.h>
|
||||
#include <make_checkpoint.h>
|
||||
eoCheckPoint<eoMyStruct<double> >& make_checkpoint(eoParser& _parser, eoState& _state, eoEvalFuncCounter<eoMyStruct<double> >& _eval, eoContinue<eoMyStruct<double> >& _continue)
|
||||
{
|
||||
return do_make_checkpoint(_parser, _state, _eval, _continue);
|
||||
|
|
@ -103,7 +103,7 @@ eoCheckPoint<eoMyStruct<eoMinimizingFitness> >& make_checkpoint(eoParser& _parse
|
|||
}
|
||||
|
||||
// evolution engine (selection and replacement)
|
||||
#include <do/make_algo_scalar.h>
|
||||
#include <make_algo_scalar.h>
|
||||
eoAlgo<eoMyStruct<double> >& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc<eoMyStruct<double> >& _eval, eoContinue<eoMyStruct<double> >& _continue, eoGenOp<eoMyStruct<double> >& _op)
|
||||
{
|
||||
return do_make_algo_scalar(_parser, _state, _eval, _continue, _op);
|
||||
|
|
@ -116,7 +116,7 @@ eoAlgo<eoMyStruct<eoMinimizingFitness> >& make_algo_scalar(eoParser& _parser, e
|
|||
|
||||
// simple call to the algo. stays there for consistency reasons
|
||||
// no template for that one
|
||||
#include <do/make_run.h>
|
||||
#include <make_run.h>
|
||||
void run_ea(eoAlgo<eoMyStruct<double> >& _ga, eoPop<eoMyStruct<double> >& _pop)
|
||||
{
|
||||
do_run(_ga, _pop);
|
||||
|
|
|
|||
Reference in a new issue