* whitespace cleanup
This commit is contained in:
parent
56c6edab04
commit
70e60a50d2
195 changed files with 1763 additions and 1873 deletions
|
|
@ -1,5 +1,3 @@
|
|||
|
||||
|
||||
######################################################################################
|
||||
### 1) Include the sources
|
||||
######################################################################################
|
||||
|
|
@ -16,14 +14,14 @@ INCLUDE_DIRECTORIES(${EO_SOURCE_DIR}/src/do)
|
|||
### 2) Specify where CMake can find the libraries
|
||||
######################################################################################
|
||||
|
||||
IF(NOT WIN32 OR CYGWIN)
|
||||
IF(NOT WIN32 OR CYGWIN)
|
||||
LINK_DIRECTORIES(${EO_BINARY_DIR}/lib)
|
||||
ENDIF(NOT WIN32 OR CYGWIN)
|
||||
|
||||
# especially for Visual Studio
|
||||
IF(WIN32 AND NOT CYGWIN)
|
||||
IF(WIN32 AND NOT CYGWIN)
|
||||
LINK_DIRECTORIES(${EO_BINARY_DIR}\\lib\\${CMAKE_BUILD_TYPE})
|
||||
ENDIF(WIN32 AND NOT CYGWIN)
|
||||
ENDIF(WIN32 AND NOT CYGWIN)
|
||||
|
||||
######################################################################################
|
||||
|
||||
|
|
@ -33,7 +31,7 @@ ENDIF(WIN32 AND NOT CYGWIN)
|
|||
### 3) Define your targets
|
||||
######################################################################################
|
||||
|
||||
ADD_EXECUTABLE(MyStructEA MyStructEA.cpp)
|
||||
ADD_EXECUTABLE(MyStructEA MyStructEA.cpp)
|
||||
|
||||
######################################################################################
|
||||
|
||||
|
|
@ -42,7 +40,6 @@ ADD_EXECUTABLE(MyStructEA MyStructEA.cpp)
|
|||
### 4) Link the librairies for the targets
|
||||
######################################################################################
|
||||
|
||||
TARGET_LINK_LIBRARIES(MyStructEA eo eoutils ga es)
|
||||
TARGET_LINK_LIBRARIES(MyStructEA eo eoutils ga es)
|
||||
|
||||
######################################################################################
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
|
||||
|
||||
######################################################################################
|
||||
### 1) Main project config
|
||||
### 1) Main project config
|
||||
######################################################################################
|
||||
|
||||
# set the project name
|
||||
|
|
@ -19,16 +17,16 @@ ENABLE_LANGUAGE(CXX)
|
|||
|
||||
IF(NOT EO_SOURCE_DIR)
|
||||
SET( EO_SOURCE_DIR
|
||||
EO_SRC_DIR CACHE STRING
|
||||
"EO source directory"
|
||||
FORCE)
|
||||
EO_SRC_DIR CACHE STRING
|
||||
"EO source directory"
|
||||
FORCE)
|
||||
ENDIF(NOT EO_SOURCE_DIR)
|
||||
|
||||
IF(NOT EO_BINARY_DIR)
|
||||
SET( EO_BINARY_DIR
|
||||
EO_BIN_DIR CACHE STRING
|
||||
"EO binary directory"
|
||||
FORCE)
|
||||
SET( EO_BINARY_DIR
|
||||
EO_BIN_DIR CACHE STRING
|
||||
"EO binary directory"
|
||||
FORCE)
|
||||
ENDIF(NOT EO_BINARY_DIR)
|
||||
######################################################################################
|
||||
|
||||
|
|
|
|||
|
|
@ -35,12 +35,12 @@
|
|||
* 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
|
||||
|
|
|
|||
|
|
@ -370,8 +370,8 @@ public:
|
|||
void printOn(ostream& os) const
|
||||
{
|
||||
// First write the fitness
|
||||
EO<FitT>::printOn(os);
|
||||
os << ' ';
|
||||
EO<FitT>::printOn(os);
|
||||
os << ' ';
|
||||
// START Code of default output
|
||||
|
||||
/** HINTS
|
||||
|
|
|
|||
|
|
@ -8,11 +8,11 @@ Template for creating a new representation in EO
|
|||
================================================
|
||||
|
||||
This is the template main file for compiling after creating a
|
||||
"library", i.e. putting everything but the fitness in a separate file
|
||||
"library", i.e. putting everything but the fitness in a separate file
|
||||
(make_MyStruct.cpp) and compiling it once and for all.
|
||||
*/
|
||||
|
||||
// Miscilaneous include and declaration
|
||||
// Miscilaneous include and declaration
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
|
|
@ -24,17 +24,17 @@ using namespace std;
|
|||
// include here whatever specific files for your representation
|
||||
// Basically, this should include at least the following
|
||||
|
||||
/** definition of representation:
|
||||
/** definition of representation:
|
||||
* class eoMyStruct MUST derive from EO<FitT> for some fitness
|
||||
*/
|
||||
#include "eoMyStruct.h"
|
||||
|
||||
/** definition of initilizqtion:
|
||||
/** definition of initilizqtion:
|
||||
* class eoMyStructInit MUST derive from eoInit<eoMyStruct>
|
||||
*/
|
||||
#include "eoMyStructInit.h"
|
||||
|
||||
/** definition of evaluation:
|
||||
/** definition of evaluation:
|
||||
* class eoMyStructEvalFunc MUST derive from eoEvalFunc<eoMyStruct>
|
||||
* and should test for validity before doing any computation
|
||||
* see tutorial/Templates/evalFunc.tmpl
|
||||
|
|
@ -46,12 +46,12 @@ using namespace std;
|
|||
//
|
||||
// START fitness type: double or eoMaximizingFitness if you are maximizing
|
||||
// eoMinimizingFitness if you are minimizing
|
||||
typedef eoMinimizingFitness MyFitT ; // type of fitness
|
||||
typedef eoMinimizingFitness MyFitT ; // type of fitness
|
||||
// END fitness type
|
||||
//
|
||||
|
||||
// Then define your EO objects using that fitness type
|
||||
typedef eoMyStruct<MyFitT> Indi; // ***MUST*** derive from EO
|
||||
typedef eoMyStruct<MyFitT> Indi; // ***MUST*** derive from EO
|
||||
|
||||
// create an initializer - done here and NOT in make_MyStruct.cpp
|
||||
// because it is NOT representation independent
|
||||
|
|
@ -59,7 +59,7 @@ typedef eoMyStruct<MyFitT> Indi; // ***MUST*** derive from EO
|
|||
eoInit<Indi> & make_genotype(eoParser& _parser, eoState&_state, Indi _eo)
|
||||
{
|
||||
return do_make_genotype(_parser, _state, _eo);
|
||||
}
|
||||
}
|
||||
|
||||
// same thing for the variation operaotrs
|
||||
#include "make_op_MyStruct.h"
|
||||
|
|
@ -70,7 +70,7 @@ eoGenOp<Indi>& make_op(eoParser& _parser, eoState& _state, eoInit<Indi>& _init)
|
|||
|
||||
// The representation independent routines are simply declared here
|
||||
|
||||
// how to initialize the population
|
||||
// how to initialize the population
|
||||
// it IS representation independent if an eoInit is given
|
||||
eoPop<Indi >& make_pop(eoParser& _parser, eoState& _state, eoInit<Indi> & _init);
|
||||
|
||||
|
|
@ -83,7 +83,7 @@ eoCheckPoint<Indi>& make_checkpoint(eoParser& _parser, eoState& _state, eoEvalFu
|
|||
// evolution engine (selection and replacement)
|
||||
eoAlgo<Indi>& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc<Indi>& _eval, eoContinue<Indi>& _continue, eoGenOp<Indi>& _op);
|
||||
|
||||
// simple call to the algo. stays there for consistency reasons
|
||||
// simple call to the algo. stays there for consistency reasons
|
||||
// no template for that one
|
||||
void run_ea(eoAlgo<Indi>& _ga, eoPop<Indi>& _pop);
|
||||
|
||||
|
|
@ -115,7 +115,7 @@ int main(int argc, char* argv[])
|
|||
eoGenOp<Indi>& op = make_op(parser, state, init);
|
||||
|
||||
|
||||
//// Now the representation-independent things
|
||||
//// Now the representation-independent things
|
||||
//
|
||||
// YOU SHOULD NOT NEED TO MODIFY ANYTHING BEYOND THIS POINT
|
||||
// unless you want to add specific statistics to the checkpoint
|
||||
|
|
|
|||
|
|
@ -19,10 +19,10 @@ When running bash, use this:
|
|||
|
||||
You can freely move the created project around. However, whenever you
|
||||
change the location of the source- or build-directories, you need to
|
||||
run
|
||||
run
|
||||
touch configure.ac && autoreconf
|
||||
in the source-directory and
|
||||
make
|
||||
in the source-directory and
|
||||
make
|
||||
in the build-directory (which might or might not be the same for you).
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ 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
|
||||
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).
|
||||
|
||||
|
|
@ -13,7 +13,7 @@ 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
|
||||
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.
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ 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).
|
||||
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
|
||||
|
|
@ -41,24 +41,24 @@ eoAppliXXX)
|
|||
2- create the directory for your application (let's assume you call it
|
||||
APPLICATION): type in
|
||||
|
||||
mkdir APPLICATION
|
||||
mkdir APPLICATION
|
||||
|
||||
3- go to the Templates dir
|
||||
3- go to the Templates dir
|
||||
|
||||
cd Templates
|
||||
cd Templates
|
||||
|
||||
and run the helper script create.sh with the following arguments
|
||||
and run the helper script create.sh with the following arguments
|
||||
|
||||
./create.sh Appli ../APPLICATION
|
||||
./create.sh Appli ../APPLICATION
|
||||
|
||||
4- cd to the APPLICATION dir (cd ../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
|
||||
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
|
||||
|
|
@ -78,11 +78,11 @@ 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
|
||||
% make
|
||||
|
||||
7- Run the resulting program:
|
||||
|
||||
% eoAppliEA
|
||||
% eoAppliEA
|
||||
|
||||
The default output is one line per generation with the generation
|
||||
number, the number of evaluations performed, the best and average
|
||||
|
|
@ -93,7 +93,7 @@ The algorithm stops by default after 100 generations.
|
|||
e.g. eoAppliEA.param, edit eoAppliEA.param (uncomment the lines you
|
||||
want to become active), and run
|
||||
|
||||
% eoAppliEA @eoAppliEA.param
|
||||
% eoAppliEA @eoAppliEA.param
|
||||
|
||||
(see the Lesson 5 of the tutorial for more details now).
|
||||
|
||||
|
|
@ -121,19 +121,19 @@ 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
|
||||
* 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
|
||||
* 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);
|
||||
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
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ The above line is useful in Emacs-like editors
|
|||
Template for simple binary crossover operators
|
||||
==============================================
|
||||
|
||||
Binary crossover operators modify the first genotype only,
|
||||
based on the second
|
||||
Binary crossover operators modify the first genotype only,
|
||||
based on the second
|
||||
*/
|
||||
|
||||
#ifndef eoMyStructBinCrossover_H
|
||||
|
|
@ -16,14 +16,14 @@ based on the second
|
|||
|
||||
#include <eoOp.h>
|
||||
|
||||
/**
|
||||
/**
|
||||
* Always write a comment in this format before class definition
|
||||
* if you want the class to be documented by Doxygen
|
||||
*
|
||||
* THere is NO ASSUMPTION on the class GenoypeT.
|
||||
* In particular, it does not need to derive from EO
|
||||
*/
|
||||
template<class GenotypeT>
|
||||
template<class GenotypeT>
|
||||
class eoMyStructBinCrossover: public eoBinOp<GenotypeT>
|
||||
{
|
||||
public:
|
||||
|
|
@ -31,8 +31,8 @@ public:
|
|||
* Ctor - no requirement
|
||||
*/
|
||||
// START eventually add or modify the anyVariable argument
|
||||
eoMyStructBinCrossover()
|
||||
// eoMyStructBinCrossover( varType _anyVariable) : anyVariable(_anyVariable)
|
||||
eoMyStructBinCrossover()
|
||||
// eoMyStructBinCrossover( varType _anyVariable) : anyVariable(_anyVariable)
|
||||
// END eventually add or modify the anyVariable argument
|
||||
{
|
||||
// START Code of Ctor of an eoMyStructEvalFunc object
|
||||
|
|
@ -47,7 +47,7 @@ public:
|
|||
* @param _genotype1 The first genotype
|
||||
* @param _genotype2 The second genotype - const
|
||||
*/
|
||||
bool operator()(GenotypeT & _genotype1, const GenotypeT & _genotype2)
|
||||
bool operator()(GenotypeT & _genotype1, const GenotypeT & _genotype2)
|
||||
{
|
||||
// START code for crossover of _genotype1 and _genotype2 objects
|
||||
|
||||
|
|
|
|||
|
|
@ -21,11 +21,11 @@ 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_MSG_ERROR([Evolving Objects utility library is required.]))
|
||||
AC_CHECK_LIB([eo], [main], [],
|
||||
AC_MSG_ERROR([Evolving Objects library is required.]))
|
||||
AC_MSG_ERROR([Evolving Objects library is required.]))
|
||||
AC_CHECK_LIB([es], [main], [],
|
||||
AC_MSG_ERROR([EO Evolutionary strategies library is required.]))
|
||||
AC_MSG_ERROR([EO Evolutionary strategies library is required.]))
|
||||
|
||||
dnl Checks for library functions.
|
||||
|
||||
|
|
|
|||
|
|
@ -14,11 +14,11 @@ Template for continuator in EO, i.e. stopping conditions for EO algorithms
|
|||
// include the base definition of eoContinue
|
||||
#include <eoContinue.h>
|
||||
|
||||
/**
|
||||
/**
|
||||
* Always write a comment in this format before class definition
|
||||
* if you want the class to be documented by Doxygen
|
||||
*
|
||||
* ATTENTION, class EOT *must* derive from EO, as operator() will
|
||||
* ATTENTION, class EOT *must* derive from EO, as operator() will
|
||||
* be called with an eoPop<EOT>
|
||||
*/
|
||||
template< class EOT>
|
||||
|
|
@ -29,7 +29,7 @@ public:
|
|||
*/
|
||||
// START eventually add or modify the anyVariable argument
|
||||
eoMyStructContinue()
|
||||
// eoMyStructBinCrossover( varType _anyVariable) : anyVariable(_anyVariable)
|
||||
// eoMyStructBinCrossover( varType _anyVariable) : anyVariable(_anyVariable)
|
||||
// END eventually add or modify the anyVariable argument
|
||||
{
|
||||
// START Code of Ctor of an eoMyStructEvalFunc object
|
||||
|
|
@ -41,7 +41,7 @@ public:
|
|||
*
|
||||
* @param _pop an eoPop
|
||||
*/
|
||||
virtual bool operator() ( const eoPop<EOT>& _pop )
|
||||
virtual bool operator() ( const eoPop<EOT>& _pop )
|
||||
{
|
||||
bool stopCondition ; // to store the stopping condition
|
||||
// START Code of computation of stopping condition
|
||||
|
|
@ -62,4 +62,3 @@ private:
|
|||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ endif
|
|||
|
||||
if ($#argv < 1) then
|
||||
echo "Usage: $0 ApplicationName [TargetDirName]"
|
||||
echo " This will create ../TargetDirName if necessary (default dir name = ApplicationName),"
|
||||
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
|
||||
|
|
@ -94,7 +94,7 @@ echo "Start building the new project"
|
|||
#cd $TargetDir
|
||||
#aclocal || exit
|
||||
#autoheader || exit
|
||||
#automake --add-missing --copy --gnu || exit
|
||||
#automake --add-missing --copy --gnu || exit
|
||||
|
||||
# !!!!! uncompatible option: --force-missing for the latest version of automake
|
||||
|
||||
|
|
|
|||
|
|
@ -14,11 +14,11 @@ Mandatory:
|
|||
However, if you are using dynamic memory, there are 2 places
|
||||
to allocate it: the default constructor (if possible?), or, more in
|
||||
the EO spirit, the eoInit object, that you will need to write anyway
|
||||
(template file init.tmpl).
|
||||
(template file init.tmpl).
|
||||
|
||||
But remember that a COPY CONSTRUCTOR will be used in many places in EO,
|
||||
so make sure that the default copy constructor works, or, even better,
|
||||
do write your own if in doubt.
|
||||
do write your own if in doubt.
|
||||
And of course write the corresponding destructor!
|
||||
|
||||
*/
|
||||
|
|
@ -26,7 +26,7 @@ And of course write the corresponding destructor!
|
|||
#ifndef _eoMyStruct_h
|
||||
#define _eoMyStruct_h
|
||||
|
||||
/**
|
||||
/**
|
||||
* Always write a comment in this format before class definition
|
||||
* if you want the class to be documented by Doxygen
|
||||
|
||||
|
|
@ -35,7 +35,7 @@ And of course write the corresponding destructor!
|
|||
* like eoVector for instance, if you handle a vector of something....
|
||||
|
||||
* If you create a structure from scratch,
|
||||
* the only thing you need to provide are
|
||||
* the only thing you need to provide are
|
||||
* a default constructor
|
||||
* IO routines printOn and readFrom
|
||||
*
|
||||
|
|
@ -46,11 +46,11 @@ template< class FitT>
|
|||
class eoMyStruct: public EO<FitT> {
|
||||
public:
|
||||
/** Ctor: you MUST provide a default ctor.
|
||||
* though such individuals will generally be processed
|
||||
* though such individuals will generally be processed
|
||||
* by some eoInit object
|
||||
*/
|
||||
eoMyStruct()
|
||||
{
|
||||
eoMyStruct()
|
||||
{
|
||||
// START Code of default Ctor of an eoMyStruct object
|
||||
// END Code of default Ctor of an eoMyStruct object
|
||||
}
|
||||
|
|
@ -60,11 +60,11 @@ public:
|
|||
* If this is the case, uncomment and fill the following
|
||||
*/
|
||||
/*
|
||||
eoMyStruct(const eoMyStruct &)
|
||||
{
|
||||
eoMyStruct(const eoMyStruct &)
|
||||
{
|
||||
// START Code of copy Ctor of an eoMyStruct object
|
||||
// END Code of copy Ctor of an eoMyStruct object
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
|
@ -82,7 +82,7 @@ public:
|
|||
// First write the fitness
|
||||
EO<FitT>::printOn(os);
|
||||
os << ' ';
|
||||
// START Code of default output
|
||||
// START Code of default output
|
||||
|
||||
/** HINTS
|
||||
* in EO we systematically write the sizes of things before the things
|
||||
|
|
@ -92,7 +92,7 @@ public:
|
|||
// END Code of default output
|
||||
}
|
||||
|
||||
/** reading...
|
||||
/** reading...
|
||||
* of course, your readFrom must be able to read what printOn writes!!!
|
||||
*/
|
||||
void readFrom(istream& is)
|
||||
|
|
@ -115,4 +115,3 @@ private: // put all data here
|
|||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
/** -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
|
||||
The above line is usefulin Emacs-like editors
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
Template for evaluator in EO, a functor that computes the fitness of an EO
|
||||
==========================================================================
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _eoMyStructEvalFunc_h
|
||||
#define _eoMyStructEvalFunc_h
|
||||
|
||||
|
|
@ -18,7 +18,7 @@ Template for evaluator in EO, a functor that computes the fitness of an EO
|
|||
// include the base definition of eoEvalFunc
|
||||
#include "eoEvalFunc.h"
|
||||
|
||||
/**
|
||||
/**
|
||||
Always write a comment in this format before class definition
|
||||
if you want the class to be documented by Doxygen
|
||||
*/
|
||||
|
|
@ -29,7 +29,7 @@ public:
|
|||
/// Ctor - no requirement
|
||||
// START eventually add or modify the anyVariable argument
|
||||
eoMyStructEvalFunc()
|
||||
// eoMyStructEvalFunc( varType _anyVariable) : anyVariable(_anyVariable)
|
||||
// eoMyStructEvalFunc( varType _anyVariable) : anyVariable(_anyVariable)
|
||||
// END eventually add or modify the anyVariable argument
|
||||
{
|
||||
// START Code of Ctor of an eoMyStructEvalFunc object
|
||||
|
|
@ -39,7 +39,7 @@ public:
|
|||
/** Actually compute the fitness
|
||||
*
|
||||
* @param EOT & _eo the EO object to evaluate
|
||||
* it should stay templatized to be usable
|
||||
* it should stay templatized to be usable
|
||||
* with any fitness type
|
||||
*/
|
||||
void operator()(EOT & _eo)
|
||||
|
|
|
|||
|
|
@ -14,12 +14,12 @@ Template for EO objects initialization in EO
|
|||
// include the base definition of eoInit
|
||||
#include <eoInit.h>
|
||||
|
||||
/**
|
||||
/**
|
||||
* Always write a comment in this format before class definition
|
||||
* if you want the class to be documented by Doxygen
|
||||
*
|
||||
* There is NO ASSUMPTION on the class GenoypeT.
|
||||
* In particular, it does not need to derive from EO (e.g. to initialize
|
||||
* In particular, it does not need to derive from EO (e.g. to initialize
|
||||
* atoms of an eoVector you will need an eoInit<AtomType>)
|
||||
*/
|
||||
template <class GenotypeT>
|
||||
|
|
@ -28,7 +28,7 @@ public:
|
|||
/// Ctor - no requirement
|
||||
// START eventually add or modify the anyVariable argument
|
||||
eoMyStructInit()
|
||||
// eoMyStructInit( varType _anyVariable) : anyVariable(_anyVariable)
|
||||
// eoMyStructInit( varType _anyVariable) : anyVariable(_anyVariable)
|
||||
// END eventually add or modify the anyVariable argument
|
||||
{
|
||||
// START Code of Ctor of an eoMyStructInit object
|
||||
|
|
@ -55,4 +55,3 @@ private:
|
|||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ i.e. that takes any number of parents and generates any number of offspring
|
|||
|
||||
a GenOp that creates less offspring than there are parents
|
||||
|
||||
Second version, get parents using an external eoSelectOne
|
||||
Second version, get parents using an external eoSelectOne
|
||||
*/
|
||||
|
||||
#ifndef eoLessOffspringExternalSelectorGenOp_H
|
||||
|
|
@ -18,21 +18,21 @@ Second version, get parents using an external eoSelectOne
|
|||
|
||||
#include <eoGenOp.h>
|
||||
|
||||
/**
|
||||
/**
|
||||
* Always write a comment in this format before class definition
|
||||
* if you want the class to be documented by Doxygen
|
||||
*
|
||||
* ATTENTION, class EOT *must* derive from EO, as method invalidate()
|
||||
* ATTENTION, class EOT *must* derive from EO, as method invalidate()
|
||||
* must be called if the genotypes of the indis is modified
|
||||
*/
|
||||
template<class EOT>
|
||||
template<class EOT>
|
||||
class eoLessOffspringExternalSelectorGenOp: public eoGenOp<EOT>
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* (Default) Constructor.
|
||||
*/
|
||||
eoLessOffspringExternalSelectorGenOp(eoSelectOne<EOT> & _sel, paramType _anyParameter) :
|
||||
eoLessOffspringExternalSelectorGenOp(eoSelectOne<EOT> & _sel, paramType _anyParameter) :
|
||||
sel(_sel), anyParameter(_anyParameter) {}
|
||||
|
||||
/// The class name. Used to display statistics
|
||||
|
|
@ -58,11 +58,11 @@ public:
|
|||
// get extra parents - use private selector
|
||||
// _plop.source() is the eoPop<EOT> used by _plop to get parents
|
||||
// WARNING: you are not allowed to modify them (mandatory "const")
|
||||
const EOT& parentN+1 = sel(_plop.source());
|
||||
...
|
||||
const EOT& parentN+K = sel(_plop.source());
|
||||
const EOT& parentN+1 = sel(_plop.source());
|
||||
...
|
||||
const EOT& parentN+K = sel(_plop.source());
|
||||
|
||||
// modify (in place) the "true" parents
|
||||
// modify (in place) the "true" parents
|
||||
// (i.e. parent1, ..., parentsN)
|
||||
...
|
||||
|
||||
|
|
|
|||
|
|
@ -18,21 +18,21 @@ First version, get parents from populator using the imbedded select() method
|
|||
|
||||
#include <eoGenOp.h>
|
||||
|
||||
/**
|
||||
/**
|
||||
* Always write a comment in this format before class definition
|
||||
* if you want the class to be documented by Doxygen
|
||||
*
|
||||
* ATTENTION, class EOT *must* derive from EO, as method invalidate()
|
||||
* ATTENTION, class EOT *must* derive from EO, as method invalidate()
|
||||
* must be called if the genotypes of the indis is modified
|
||||
*/
|
||||
template<class EOT>
|
||||
template<class EOT>
|
||||
class eoLessOffspringSameSelectorGenOp: public eoGenOp<EOT>
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* (Default) Constructor.
|
||||
*/
|
||||
eoLessOffspringSameSelectorGenOp(paramType _anyParameter) :
|
||||
eoLessOffspringSameSelectorGenOp(paramType _anyParameter) :
|
||||
anyParameter(_anyParameter) {}
|
||||
|
||||
/// The class name. Used to display statistics
|
||||
|
|
@ -42,7 +42,7 @@ public:
|
|||
unsigned max_production(void) { return NbLeftParents; }
|
||||
|
||||
/**
|
||||
* eoLesOffspringSameSelectorGenOp operator -
|
||||
* eoLesOffspringSameSelectorGenOp operator -
|
||||
* gets extra parents from the populator
|
||||
*
|
||||
* @param _pop a POPULATOR (not a simple population)
|
||||
|
|
|
|||
|
|
@ -126,4 +126,3 @@ void run_ea(eoAlgo<eoMyStruct<eoMinimizingFitness> >& _ga, eoPop<eoMyStruct<eoMi
|
|||
{
|
||||
do_run(_ga, _pop);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// make_genotype.h
|
||||
// (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2001
|
||||
/*
|
||||
/*
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
|
|
@ -19,8 +19,8 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
|
||||
Marc.Schoenauer@polytechnique.fr
|
||||
mkeijzer@dhi.dk
|
||||
Marc.Schoenauer@polytechnique.fr
|
||||
mkeijzer@dhi.dk
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -37,27 +37,27 @@
|
|||
/*
|
||||
* This fuction does the create an eoInit<eoMyStruct>
|
||||
*
|
||||
* It could be here tempatized only on the fitness, as it can be used
|
||||
* It could be here tempatized only on the fitness, as it can be used
|
||||
* to evolve structures with any fitness.
|
||||
* However, for consistency reasons, it was finally chosen, as in
|
||||
* the rest of EO, to templatize by the full EOT, as this eventually
|
||||
* However, for consistency reasons, it was finally chosen, as in
|
||||
* the rest of EO, to templatize by the full EOT, as this eventually
|
||||
* allows to choose the type of genotype at run time (see in es dir)
|
||||
*
|
||||
* It returns an eoInit<EOT> that can later be used to initialize
|
||||
* It returns an eoInit<EOT> that can later be used to initialize
|
||||
* the population (see make_pop.h).
|
||||
*
|
||||
* It uses a parser (to get user parameters) and a state (to store the memory)
|
||||
* the last argument is to disambiguate the call upon different instanciations.
|
||||
*
|
||||
* WARNING: that last argument will generally be the result of calling
|
||||
* the default ctor of EOT, resulting in most cases in an EOT
|
||||
* WARNING: that last argument will generally be the result of calling
|
||||
* the default ctor of EOT, resulting in most cases in an EOT
|
||||
* that is ***not properly initialized***
|
||||
*/
|
||||
|
||||
template <class EOT>
|
||||
eoInit<EOT> & do_make_genotype(eoParser& _parser, eoState& _state, EOT)
|
||||
{
|
||||
// read any useful parameter here from the parser
|
||||
// read any useful parameter here from the parser
|
||||
// the param itself will belong to the parser (as far as memory is concerned)
|
||||
|
||||
// paramType & param = _parser.createParam(deafultValue, "Keyword", "Comment to appear in help and status", 'c',"Section of status file").value();
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// make_op_MyStruct.h
|
||||
// (c) Marc Schoenauer, Maarten Keijzer and GeNeura Team, 2001
|
||||
/*
|
||||
/*
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
|
|
@ -19,8 +19,8 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
|
||||
Marc.Schoenauer@polytechnique.fr
|
||||
mkeijzer@dhi.dk
|
||||
Marc.Schoenauer@polytechnique.fr
|
||||
mkeijzer@dhi.dk
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -35,14 +35,14 @@
|
|||
// combinations of simple eoOps (eoMonOp and eoQuadOp)
|
||||
#include <eoProportionalCombinedOp.h>
|
||||
|
||||
/** definition of mutation:
|
||||
/** definition of mutation:
|
||||
* class eoMyStructMonop MUST derive from eoMonOp<eoMyStruct>
|
||||
*/
|
||||
#include "eoMyStructMutation.h"
|
||||
|
||||
/** definition of crossover (either as eoBinOp (2->1) or eoQuadOp (2->2):
|
||||
/** definition of crossover (either as eoBinOp (2->1) or eoQuadOp (2->2):
|
||||
* class eoMyStructBinCrossover MUST derive from eoBinOp<eoMyStruct>
|
||||
* OR
|
||||
* OR
|
||||
* class eoMyStructQuadCrossover MUST derive from eoQuadOp<eoMyStruct>
|
||||
*/
|
||||
// #include "eoMyStructBinOp.h"
|
||||
|
|
@ -61,9 +61,9 @@
|
|||
* This function builds the operators that will be applied to the eoMyStruct
|
||||
*
|
||||
* It uses a parser (to get user parameters), a state (to store the memory)
|
||||
* the last parameter is an eoInit: if some operator needs some info
|
||||
* the last parameter is an eoInit: if some operator needs some info
|
||||
* about the genotypes, the init has it all (e.g. bounds, ...)
|
||||
* Simply do
|
||||
* Simply do
|
||||
* EOT myEO;
|
||||
* _init(myEO);
|
||||
* and myEO is then an ACTUAL object
|
||||
|
|
@ -85,7 +85,7 @@ eoGenOp<EOT> & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit<EO
|
|||
// Variation operators
|
||||
////////////////////////////
|
||||
// read crossover and mutations, combine each in a proportional Op
|
||||
// and create the eoGenOp that calls crossover at rate pCross
|
||||
// and create the eoGenOp that calls crossover at rate pCross
|
||||
// then mutation with rate pMut
|
||||
|
||||
// the crossovers
|
||||
|
|
@ -94,10 +94,10 @@ eoGenOp<EOT> & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit<EO
|
|||
// here we can have eoQuadOp (2->2) only - no time for the eoBinOp case
|
||||
|
||||
// you can have more than one - combined in a proportional way
|
||||
|
||||
|
||||
// first, define the crossover objects and read their rates from the parser
|
||||
|
||||
// A first crossover
|
||||
|
||||
// A first crossover
|
||||
eoQuadOp<Indi> *cross = new eoMyStructQuadCrossover<Indi> /* (varType _anyVariable) */;
|
||||
// store in the state
|
||||
_state.storeFunctor(cross);
|
||||
|
|
@ -106,21 +106,21 @@ eoGenOp<EOT> & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit<EO
|
|||
double cross1Rate = _parser.createParam(1.0, "cross1Rate", "Relative rate for crossover 1", '1', "Variation Operators").value();
|
||||
|
||||
// and create the combined operator with this one
|
||||
eoPropCombinedQuadOp<Indi> *propXover =
|
||||
eoPropCombinedQuadOp<Indi> *propXover =
|
||||
new eoPropCombinedQuadOp<Indi>(*cross, cross1Rate);
|
||||
// and of course stor it in the state
|
||||
_state.storeFunctor(propXover);
|
||||
|
||||
|
||||
// Optional: A second(and third, and ...) crossover
|
||||
// Optional: A second(and third, and ...) crossover
|
||||
// of course you must create the corresponding classes
|
||||
// and all ***MUST*** derive from eoQuadOp<Indi>
|
||||
|
||||
/* Uncomment if necessary - and replicate as many time as you need
|
||||
cross = new eoMyStructSecondCrossover<Indi>(varType _anyVariable);
|
||||
cross = new eoMyStructSecondCrossover<Indi>(varType _anyVariable);
|
||||
_state.storeFunctor(cross);
|
||||
double cross2Rate = _parser.createParam(1.0, "cross2Rate", "Relative rate for crossover 2", '2', "Variation Operators").value();
|
||||
propXover.add(*cross, cross2Rate);
|
||||
double cross2Rate = _parser.createParam(1.0, "cross2Rate", "Relative rate for crossover 2", '2', "Variation Operators").value();
|
||||
propXover.add(*cross, cross2Rate);
|
||||
*/
|
||||
// if you want some gentle output, the last one shoudl be like
|
||||
// propXover.add(*cross, crossXXXRate, true);
|
||||
|
|
@ -130,12 +130,12 @@ eoGenOp<EOT> & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit<EO
|
|||
////////////////
|
||||
// you can have more than one - combined in a proportional way
|
||||
|
||||
// for each mutation,
|
||||
// for each mutation,
|
||||
// - define the mutator object
|
||||
// - read its rate from the parser
|
||||
// - add it to the proportional combination
|
||||
|
||||
// a first mutation
|
||||
// a first mutation
|
||||
eoMonOp<Indi> *mut = new eoMyStructMutation<Indi>/* (varType _anyVariable) */;
|
||||
_state.storeFunctor(mut);
|
||||
// its relative rate in the combination
|
||||
|
|
@ -151,8 +151,8 @@ eoGenOp<EOT> & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit<EO
|
|||
/* Uncomment if necessary - and replicate as many time as you need
|
||||
mut = new eoMyStructSecondMutation<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);
|
||||
double mut2Rate = _parser.createParam(1.0, "mut2Rate", "Relative rate for mutation 2", '2', "Variation Operators").value();
|
||||
propMutation.add(*mut, mut2Rate);
|
||||
*/
|
||||
// if you want some gentle output, the last one shoudl be like
|
||||
// propMutation.add(*mut, mutXXXRate, true);
|
||||
|
|
@ -170,7 +170,7 @@ eoGenOp<EOT> & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit<EO
|
|||
// to simulate SGA (crossover with proba pCross + mutation with proba pMut
|
||||
// we must construct
|
||||
// a sequential combination of
|
||||
// with proba 1, a proportional combination of
|
||||
// with proba 1, a proportional combination of
|
||||
// a QuadCopy and our crossover
|
||||
// with proba pMut, our mutation
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ Template for general operators
|
|||
===============================
|
||||
i.e. that takes any number of parents and generates any number of offspring
|
||||
|
||||
Here, a GenOp that creates more (or same number of) offspring
|
||||
Here, a GenOp that creates more (or same number of) offspring
|
||||
than there are parents
|
||||
*/
|
||||
|
||||
|
|
@ -17,21 +17,21 @@ than there are parents
|
|||
|
||||
#include <eoGenOp.h>
|
||||
|
||||
/**
|
||||
/**
|
||||
* Always write a comment in this format before class definition
|
||||
* if you want the class to be documented by Doxygen
|
||||
*
|
||||
* ATTENTION, class EOT *must* derive from EO, as method invalidate()
|
||||
* ATTENTION, class EOT *must* derive from EO, as method invalidate()
|
||||
* must be called if the genotypes of the indis is modified
|
||||
*/
|
||||
template<class EOT>
|
||||
template<class EOT>
|
||||
class eoMoreOffspringGenOp: public eoGenOp<EOT>
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* (Default) Constructor.
|
||||
*/
|
||||
eoMoreOffspringGenOp(paramType _anyParameter) :
|
||||
eoMoreOffspringGenOp(paramType _anyParameter) :
|
||||
anyParameter(_anyParameter) {}
|
||||
|
||||
/// The class name. Used to display statistics
|
||||
|
|
@ -52,16 +52,16 @@ public:
|
|||
++_plop; // advance once for each selected parents
|
||||
...
|
||||
EOT& parentN = *_plop; // select the last parent
|
||||
// don't advance after the last one: _plop always
|
||||
// points to the last that has already been treated
|
||||
// don't advance after the last one: _plop always
|
||||
// points to the last that has already been treated
|
||||
|
||||
// apply operator to the parents (modifying them AND generating
|
||||
// new individuals ofs1, ofs2, ..., ofsN
|
||||
// new individuals ofs1, ofs2, ..., ofsN
|
||||
++_plop; // advance before each insertion
|
||||
_plop.insert(ofs1);
|
||||
...
|
||||
++_plop; // advance before each insertion
|
||||
_plop.insert(ofsN);
|
||||
_plop.insert(ofsN);
|
||||
|
||||
// oh right, and invalidate fitnesses of modified parents
|
||||
parent1.invalidate();
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public :
|
|||
}
|
||||
|
||||
void operator()(const eoPop<EOT>& _pop){
|
||||
double tmpStat(0.);
|
||||
double tmpStat(0.);
|
||||
// START Code for computing the statistics - in tmpStat
|
||||
// tmpStat = blablabla
|
||||
// END Code for computing the statistics
|
||||
|
|
@ -61,4 +61,3 @@ private :
|
|||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue