* New tree configuration of the project:
.../
... + -- EO
| |
| |
+-- src ----- + -- EDO
| |
| |
+-- test + -- MO
| |
| |
+-- tutorial + -- MOEO
| |
| |
+-- doc + -- SMP
| |
| |
... + -- EOMPI
|
|
+ -- EOSERIAL
Question for current maintainers: ./README: new release?
Also:
* Moving out eompi & eoserial modules (issue #2).
* Correction of the errors when executing "make doc" command.
* Adding a solution for the conflicting headers problem (see the two CMake Cache
Values: PROJECT_TAG & PROJECT_HRS_INSTALL_SUBPATH) (issue #1)
* Header inclusions:
** src: changing absolute paths into relative paths ('#include <...>' -> '#include "..."')
** test, tutorial: changing relative paths into absolute paths ('#include "..."' -> '#include <...>')
* Moving out some scripts from EDO -> to the root
* Add a new script for compilation and installation (see build_gcc_linux_install)
* Compilation with uBLAS library or EDO module: now ok
* Minor modifications on README & INSTALL files
* Comment eompi failed tests with no end
*** TODO: CPack (debian (DEB) & RedHat (RPM) packages) (issues #6 & #7) ***
This commit is contained in:
parent
515bd5943d
commit
490e837f7a
2359 changed files with 7688 additions and 16329 deletions
95
tutorial/eo/Lesson4/BitEA.cpp
Executable file
95
tutorial/eo/Lesson4/BitEA.cpp
Executable file
|
|
@ -0,0 +1,95 @@
|
|||
#include <iostream>
|
||||
|
||||
#include <paradiseo/eo/ga/make_ga.h>
|
||||
#include <paradiseo/eo/apply.h>
|
||||
|
||||
// EVAL
|
||||
#include "binary_value.h"
|
||||
|
||||
// GENERAL
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
// REPRESENTATION
|
||||
//-----------------------------------------------------------------------------
|
||||
// define your genotype and fitness types
|
||||
typedef eoBit<double> EOT;
|
||||
|
||||
// PARAMETRES
|
||||
eoParser parser(argc, argv); // for user-parameter reading
|
||||
|
||||
// GENERAL
|
||||
eoState state; // keeps all things allocated
|
||||
|
||||
///// FIRST, problem or representation dependent stuff
|
||||
//////////////////////////////////////////////////////
|
||||
|
||||
// EVAL
|
||||
// The evaluation fn - encapsulated into an eval counter for output
|
||||
eoEvalFuncPtr<EOT, double> mainEval( binary_value<EOT> );
|
||||
eoEvalFuncCounter<EOT> eval(mainEval);
|
||||
|
||||
// REPRESENTATION
|
||||
// the genotype - through a genotype initializer
|
||||
eoInit<EOT>& init = make_genotype(parser, state, EOT());
|
||||
|
||||
// if you want to do sharing, you'll need a distance.
|
||||
// here Hamming distance
|
||||
eoHammingDistance<EOT> dist;
|
||||
|
||||
// OPERATORS
|
||||
// Build the variation operator (any seq/prop construct)
|
||||
eoGenOp<EOT>& op = make_op(parser, state, init);
|
||||
|
||||
// GENERAL
|
||||
//// Now the representation-independent things
|
||||
//////////////////////////////////////////////
|
||||
|
||||
// initialize the population - and evaluate
|
||||
// yes, this is representation indepedent once you have an eoInit
|
||||
eoPop<EOT>& pop = make_pop(parser, state, init);
|
||||
|
||||
// STOP
|
||||
// stopping criteria
|
||||
eoContinue<EOT> & term = make_continue(parser, state, eval);
|
||||
// output
|
||||
eoCheckPoint<EOT> & checkpoint = make_checkpoint(parser, state, eval, term);
|
||||
// GENERATION
|
||||
// algorithm (need the operator!)
|
||||
eoAlgo<EOT>& ga = make_algo_scalar(parser, state, eval, checkpoint, op, &dist);
|
||||
|
||||
///// End of construction of the algorith
|
||||
/////////////////////////////////////////
|
||||
// PARAMETRES
|
||||
// to be called AFTER all parameters have been read!!!
|
||||
make_help(parser);
|
||||
|
||||
//// GO
|
||||
///////
|
||||
// EVAL
|
||||
// evaluate intial population AFTER help and status in case it takes time
|
||||
apply<EOT>(eval, pop);
|
||||
// STOP
|
||||
// print it out (sort witout modifying)
|
||||
cout << "Initial Population\n";
|
||||
pop.sortedPrintOn(cout);
|
||||
cout << endl;
|
||||
|
||||
// GENERATION
|
||||
run_ea(ga, pop); // run the ga
|
||||
// STOP
|
||||
// print it out (sort witout modifying)
|
||||
cout << "Final Population\n";
|
||||
pop.sortedPrintOn(cout);
|
||||
cout << endl;
|
||||
// GENERAL
|
||||
}
|
||||
catch(exception& e)
|
||||
{
|
||||
cout << e.what() << endl;
|
||||
}
|
||||
}
|
||||
98
tutorial/eo/Lesson4/CMakeLists.txt
Executable file
98
tutorial/eo/Lesson4/CMakeLists.txt
Executable file
|
|
@ -0,0 +1,98 @@
|
|||
######################################################################################
|
||||
### 0) Copy the ESEA.param and RealEA.param files in the build directory for an easy use.
|
||||
######################################################################################
|
||||
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${EO_TUTORIAL_DIR}/Lesson4/ESEA.param
|
||||
${EO_BIN_DIR}/tutorial/Lesson4/ESEA.param
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${EO_TUTORIAL_DIR}/Lesson4/RealEA.param
|
||||
${EO_BIN_DIR}/tutorial/Lesson4/RealEA.param
|
||||
)
|
||||
|
||||
##############
|
||||
# OLD_TARGETS
|
||||
##############
|
||||
#add_custom_target(param DEPENDS ${EO_SRC_DIR}/tutorial/Lesson4/ESEA.param)
|
||||
#add_custom_command(
|
||||
# TARGET param
|
||||
# POST_BUILD
|
||||
# COMMAND ${CMAKE_COMMAND}
|
||||
# ARGS -E copy_if_different
|
||||
# ${EO_SRC_DIR}/tutorial/Lesson4/ESEA.param
|
||||
# ${EO_BIN_DIR}/tutorial/Lesson4)
|
||||
#add_custom_target(param DEPENDS ${EO_SRC_DIR}/tutorial/Lesson4/RealEA.param)
|
||||
#add_custom_command(
|
||||
# TARGET param
|
||||
# POST_BUILD
|
||||
# COMMAND ${CMAKE_COMMAND}
|
||||
# ARGS -E copy_if_different
|
||||
# ${EO_SRC_DIR}/tutorial/Lesson4/RealEA.param
|
||||
# ${EO_BIN_DIR}/tutorial/Lesson4)
|
||||
|
||||
######################################################################################
|
||||
### 1) Include the sources
|
||||
######################################################################################
|
||||
|
||||
#include_directories(${EO_SRC_DIR}/src)
|
||||
#include_directories(${EO_SRC_DIR}/src/es)
|
||||
#include_directories(${EO_SRC_DIR}/src/utils)
|
||||
#include_directories(${EO_SRC_DIR}/src/ga)
|
||||
|
||||
######################################################################################
|
||||
### 2) Specify where CMake can find the libraries
|
||||
######################################################################################
|
||||
|
||||
if(NOT WIN32 OR CYGWIN)
|
||||
link_directories(${EO_BIN_DIR}/lib)
|
||||
endif(NOT WIN32 OR CYGWIN)
|
||||
|
||||
# especially for Visual Studio
|
||||
if(WIN32 AND NOT CYGWIN)
|
||||
link_directories(${EO_BIN_DIR}\\lib\\${CMAKE_BUILD_TYPE})
|
||||
endif(WIN32 AND NOT CYGWIN)
|
||||
|
||||
######################################################################################
|
||||
### 3) Define your targets
|
||||
######################################################################################
|
||||
|
||||
# no matter what is the OS, hopefully
|
||||
add_executable(BitEA BitEA.cpp)
|
||||
add_executable(RealEA RealEA.cpp)
|
||||
add_executable(ESEA ESEA.cpp)
|
||||
|
||||
#add_dependencies(BitEA es ga eo eoutils)
|
||||
#add_dependencies(RealEA es ga eo eoutils)
|
||||
#add_dependencies(ESEA es ga eo eoutils)
|
||||
|
||||
######################################################################################
|
||||
### 4) Optionnal
|
||||
######################################################################################
|
||||
|
||||
set(BITEA_VERSION ${GLOBAL_VERSION})
|
||||
set_target_properties(BitEA PROPERTIES VERSION "${BITEA_VERSION}")
|
||||
|
||||
set(REALEA_VERSION ${GLOBAL_VERSION})
|
||||
set_target_properties(RealEA PROPERTIES VERSION "${REALEA_VERSION}")
|
||||
|
||||
set(ESEA_VERSION ${GLOBAL_VERSION})
|
||||
set_target_properties(ESEA PROPERTIES VERSION "${ESEA_VERSION}")
|
||||
|
||||
######################################################################################
|
||||
### 5) Link the librairies for the targets
|
||||
######################################################################################
|
||||
|
||||
target_link_libraries(BitEA es ga eo eoutils)
|
||||
target_link_libraries(RealEA es ga eo eoutils)
|
||||
target_link_libraries(ESEA es ga eo eoutils)
|
||||
|
||||
######################################################################################
|
||||
### 6) Configure project installation paths
|
||||
######################################################################################
|
||||
|
||||
install(TARGETS BitEA RUNTIME DESTINATION share/${PROJECT_TAG}/eo/examples/Lesson4 COMPONENT examples)
|
||||
install(TARGETS RealEA RUNTIME DESTINATION share/${PROJECT_TAG}/eo/examples/Lesson4 COMPONENT examples)
|
||||
install(TARGETS ESEA RUNTIME DESTINATION share/${PROJECT_TAG}/eo/examples/Lesson4 COMPONENT examples)
|
||||
|
||||
######################################################################################
|
||||
137
tutorial/eo/Lesson4/ESEA.cpp
Executable file
137
tutorial/eo/Lesson4/ESEA.cpp
Executable file
|
|
@ -0,0 +1,137 @@
|
|||
// Program to test several EO-ES features
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable:4786)
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <stdexcept>
|
||||
#include <time.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#include <paradiseo/eo.h>
|
||||
|
||||
// representation specific
|
||||
#include <paradiseo/eo/es/make_es.h>
|
||||
|
||||
#include "real_value.h" // the sphere fitness
|
||||
|
||||
// Now the main
|
||||
///////////////
|
||||
typedef eoMinimizingFitness FitT;
|
||||
|
||||
template <class EOT>
|
||||
void runAlgorithm(EOT, eoParser& _parser, eoState& _state);
|
||||
|
||||
int main_function(int argc, char *argv[])
|
||||
{
|
||||
// Create the command-line parser
|
||||
eoParser parser(argc, argv); // for user-parameter reading
|
||||
|
||||
eoState state; // keeps all things allocated
|
||||
|
||||
|
||||
eoValueParam<bool>& simpleParam = parser.createParam(true, "Isotropic", "Isotropic self-adaptive mutation", 'i', "ES mutation");
|
||||
eoValueParam<bool>& stdevsParam = parser.createParam(false, "Stdev", "One self-adaptive stDev per variable", 's', "ES mutation");
|
||||
eoValueParam<bool>& corrParam = parser.createParam(false, "Correl", "Use correlated mutations", 'c', "ES mutation");
|
||||
|
||||
// Run the appropriate algorithm
|
||||
if (simpleParam.value() == false)
|
||||
{
|
||||
cout << "Using eoReal" << endl;
|
||||
runAlgorithm(eoReal<FitT>(), parser, state);
|
||||
}
|
||||
else if (stdevsParam.value() == false)
|
||||
{
|
||||
cout << "Using eoEsSimple" << endl;
|
||||
runAlgorithm(eoEsSimple<FitT>(), parser, state);
|
||||
}
|
||||
else if (corrParam.value() == false)
|
||||
{
|
||||
cout << "Using eoEsStdev" << endl;
|
||||
runAlgorithm(eoEsStdev<FitT>(), parser, state);
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "Using eoEsFull" << endl;
|
||||
runAlgorithm(eoEsFull<FitT>(), parser, state);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// A main that catches the exceptions
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
try
|
||||
{
|
||||
main_function(argc, argv);
|
||||
}
|
||||
catch(exception& e)
|
||||
{
|
||||
cout << "Exception: " << e.what() << '\n';
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/** The templatized main (sort of)
|
||||
* quite similar to the main of other genotypes
|
||||
* (e.g. t-eoReal and t-eoGA in test dir)
|
||||
*/
|
||||
template <class EOT>
|
||||
void runAlgorithm(EOT, eoParser& _parser, eoState& _state)
|
||||
{
|
||||
typedef typename EOT::Fitness FitT;
|
||||
|
||||
///// FIRST, problem or representation dependent stuff
|
||||
//////////////////////////////////////////////////////
|
||||
|
||||
// The evaluation fn - encapsulated into an eval counter for output
|
||||
eoEvalFuncPtr<EOT, double, const std::vector<double>&>
|
||||
mainEval( real_value );
|
||||
eoEvalFuncCounter<EOT> eval(mainEval);
|
||||
|
||||
// the genotype - through a genotype initializer
|
||||
eoRealInitBounded<EOT>& init = make_genotype(_parser, _state, EOT());
|
||||
|
||||
// Build the variation operator (any seq/prop construct)
|
||||
eoGenOp<EOT>& op = make_op(_parser, _state, init);
|
||||
|
||||
//// Now the representation-independent things
|
||||
//////////////////////////////////////////////
|
||||
|
||||
// initialize the population - and evaluate
|
||||
// yes, this is representation indepedent once you have an eoInit
|
||||
eoPop<EOT>& pop = make_pop(_parser, _state, init);
|
||||
apply<EOT>(eval, pop);
|
||||
|
||||
// stopping criteria
|
||||
eoContinue<EOT> & term = make_continue(_parser, _state, eval);
|
||||
// output
|
||||
eoCheckPoint<EOT> & checkpoint = make_checkpoint(_parser, _state, eval, term);
|
||||
// algorithm (need the operator!)
|
||||
eoAlgo<EOT>& ga = make_algo_scalar(_parser, _state, eval, checkpoint, op);
|
||||
|
||||
///// End of construction of the algorith
|
||||
/////////////////////////////////////////
|
||||
// to be called AFTER all parameters have been read!!!
|
||||
make_help(_parser);
|
||||
|
||||
//// GO
|
||||
///////
|
||||
cout << "Initial Population\n";
|
||||
pop.sortedPrintOn(cout);
|
||||
cout << endl;
|
||||
|
||||
run_ea(ga, pop); // run the ga
|
||||
|
||||
cout << "Final Population\n";
|
||||
pop.sortedPrintOn(cout);
|
||||
cout << endl;
|
||||
}
|
||||
61
tutorial/eo/Lesson4/ESEA.param
Executable file
61
tutorial/eo/Lesson4/ESEA.param
Executable file
|
|
@ -0,0 +1,61 @@
|
|||
###### General ######
|
||||
# --help=0 # -h : Prints this message
|
||||
# --stopOnUnknownParam=1 # Stop if unkown param entered
|
||||
# --seed=1104133126 # -S : Random number seed
|
||||
|
||||
###### ES mutation ######
|
||||
# --Isotropic=1 # -i : Isotropic self-adaptive mutation
|
||||
# --Stdev=0 # -s : One self-adaptive stDev per variable
|
||||
# --Correl=0 # -c : Use correlated mutations
|
||||
|
||||
###### Evolution Engine ######
|
||||
--popSize=1 # -P : Population Size
|
||||
--selection=Sequential # -S : Selection: DetTour(T), StochTour(t), Roulette, Ranking(p,e) or Sequential(ordered/unordered)
|
||||
--nbOffspring=700% # -O : Nb of offspring (percentage or absolute)
|
||||
--replacement=Comma # -R : Replacement: Comma, Plus or EPTour(T), SSGAWorst, SSGADet(T), SSGAStoch(t)
|
||||
--weakElitism=0 # -w : Old best parent replaces new worst offspring *if necessary*
|
||||
|
||||
###### Genotype Initialization ######
|
||||
# --vecSize=10 # -n : The number of variables
|
||||
# --initBounds=10[-1,1] # -B : Bounds for initialization (MUST be bounded)
|
||||
--sigmaInit=0.3% # -s : Initial value for Sigmas (with a '%' -> scaled by the range of each variable)
|
||||
|
||||
###### Output ######
|
||||
# --useEval=1 # Use nb of eval. as counter (vs nb of gen.)
|
||||
# --useTime=1 # Display time (s) every generation
|
||||
# --printBestStat=1 # Print Best/avg/stdev every gen.
|
||||
# --printPop=0 # Print sorted pop. every gen.
|
||||
|
||||
###### Output - Disk ######
|
||||
# --resDir=Res # Directory to store DISK outputs
|
||||
# --eraseDir=1 # erase files in dirName if any
|
||||
# --fileBestStat=0 # Output bes/avg/std to file
|
||||
|
||||
###### Output - Graphical ######
|
||||
# --plotBestStat=0 # Plot Best/avg Stat
|
||||
# --plotHisto=0 # Plot histogram of fitnesses
|
||||
|
||||
###### Persistence ######
|
||||
# --Load= # -L : A save file to restart from
|
||||
# --recomputeFitness=0 # -r : Recompute the fitness after re-loading the pop.?
|
||||
# --saveFrequency=0 # Save every F generation (0 = only final state, absent = never)
|
||||
# --saveTimeInterval=0 # Save every T seconds (0 or absent = never)
|
||||
# --status=t-eoESAll.status # Status file
|
||||
|
||||
###### Stopping criterion ######
|
||||
# --maxGen=100 # -G : Maximum number of generations () = none)
|
||||
# --steadyGen=100 # -s : Number of generations with no improvement
|
||||
# --minGen=0 # -g : Minimum number of generations
|
||||
# --maxEval=0 # -E : Maximum number of evaluations (0 = none)
|
||||
# --targetFitness=0 # -T : Stop when fitness reaches
|
||||
# --CtrlC=0 # -C : Terminate current generation upon Ctrl C
|
||||
|
||||
###### Variation Operators ######
|
||||
# --objectBounds=10[-inf,+inf] # -B : Bounds for variables
|
||||
# --operator=SGA # -o : Description of the operator (SGA only now)
|
||||
# --pCross=1 # -C : Probability of Crossover
|
||||
# --pMut=1 # -M : Probability of Mutation
|
||||
# --crossType=global # -C : Type of ES recombination (global or standard)
|
||||
# --crossObj=discrete # -O : Recombination of object variables (discrete, intermediate or none)
|
||||
# --crossStdev=intermediate # -S : Recombination of mutation strategy parameters (intermediate, discrete or none)
|
||||
# --TauLoc=1 # -l : Local Tau (before normalization)
|
||||
33
tutorial/eo/Lesson4/Makefile.simple
Executable file
33
tutorial/eo/Lesson4/Makefile.simple
Executable file
|
|
@ -0,0 +1,33 @@
|
|||
### This Makefile is part of the tutorial of the EO library
|
||||
# Unlike other Makefiles in EO, it is not using the automake/autoconf
|
||||
# so that it stays easy to understant (you are in the tutorial, remember!)
|
||||
# MS, Oct. 2002
|
||||
|
||||
# if you use this Makefile as a starting point for another application
|
||||
# you might need to modify the following
|
||||
DIR_EO = ../../src
|
||||
|
||||
.SUFFIXES: .cpp
|
||||
|
||||
# Warning: $(CXX) in Linux (RedHat and Mandrake at least) is g++
|
||||
# However, if you are using this Makefile within xemacs,
|
||||
# and have problems with the interpretation of the output (and its colors)
|
||||
# then you should use c++ instead (make CXX=c++ will do)
|
||||
|
||||
.cpp: ; $(CXX) -DPACKAGE=\"eo\" -DVERSION=\"0.9.3\" -I. -I$(DIR_EO) -Wall -g -o $@ $*.cpp $(DIR_EO)/utils/libeoutils.a $(DIR_EO)/libeo.a
|
||||
|
||||
.cpp.o: ; $(CXX) -DPACKAGE=\"eo\" -DVERSION=\"0.9.3\" -I. -I$(DIR_EO) -Wall -g -c $*.cpp
|
||||
|
||||
ALL = BitEA RealEA ESEA
|
||||
|
||||
all : $(ALL)
|
||||
|
||||
BitEA : BitEA.o ;
|
||||
$(CXX) -DPACKAGE=\"eo\" -DVERSION=\"0.9.2\" -Wall -g -o $@ $< $(DIR_EO)/ga/libga.a $(DIR_EO)/utils/libeoutils.a $(DIR_EO)/libeo.a
|
||||
|
||||
RealEA : RealEA.o ; $(CXX) -DPACKAGE=\"eo\" -DVERSION=\"0.9.2\" -Wall -g -o $@ $< $(DIR_EO)/es/libes.a $(DIR_EO)/utils/libeoutils.a $(DIR_EO)/libeo.a
|
||||
|
||||
ESEA : ESEA.o ; $(CXX) -DPACKAGE=\"eo\" -DVERSION=\"0.9.2\" -Wall -g -o $@ $< $(DIR_EO)/es/libes.a $(DIR_EO)/utils/libeoutils.a $(DIR_EO)/libeo.a
|
||||
|
||||
clean :
|
||||
@/bin/rm $(ALL) *.o *.sav *.xg *.status *~
|
||||
72
tutorial/eo/Lesson4/RealEA.cpp
Executable file
72
tutorial/eo/Lesson4/RealEA.cpp
Executable file
|
|
@ -0,0 +1,72 @@
|
|||
#include <iostream>
|
||||
|
||||
#include <paradiseo/eo/es/make_real.h>
|
||||
#include "real_value.h"
|
||||
#include <paradiseo/eo/apply.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
typedef eoReal<eoMinimizingFitness> EOT;
|
||||
|
||||
eoParser parser(argc, argv); // for user-parameter reading
|
||||
|
||||
eoState state; // keeps all things allocated
|
||||
|
||||
///// FIRST, problem or representation dependent stuff
|
||||
//////////////////////////////////////////////////////
|
||||
|
||||
// The evaluation fn - encapsulated into an eval counter for output
|
||||
eoEvalFuncPtr<EOT, double, const std::vector<double>&>
|
||||
mainEval( real_value );
|
||||
eoEvalFuncCounter<EOT> eval(mainEval);
|
||||
|
||||
// the genotype - through a genotype initializer
|
||||
eoRealInitBounded<EOT>& init = make_genotype(parser, state, EOT());
|
||||
|
||||
// Build the variation operator (any seq/prop construct)
|
||||
eoGenOp<EOT>& op = make_op(parser, state, init);
|
||||
|
||||
//// Now the representation-independent things
|
||||
//////////////////////////////////////////////
|
||||
|
||||
// initialize the population - and evaluate
|
||||
// yes, this is representation indepedent once you have an eoInit
|
||||
eoPop<EOT>& pop = make_pop(parser, state, init);
|
||||
|
||||
// stopping criteria
|
||||
eoContinue<EOT> & term = make_continue(parser, state, eval);
|
||||
// output
|
||||
eoCheckPoint<EOT> & checkpoint = make_checkpoint(parser, state, eval, term);
|
||||
// algorithm (need the operator!)
|
||||
eoAlgo<EOT>& ea = make_algo_scalar(parser, state, eval, checkpoint, op);
|
||||
|
||||
///// End of construction of the algorith
|
||||
/////////////////////////////////////////
|
||||
// to be called AFTER all parameters have been read!!!
|
||||
make_help(parser);
|
||||
|
||||
//// GO
|
||||
///////
|
||||
// evaluate intial population AFTER help and status in case it takes time
|
||||
apply<EOT>(eval, pop);
|
||||
// print it out
|
||||
cout << "Initial Population\n";
|
||||
pop.sortedPrintOn(cout);
|
||||
cout << endl;
|
||||
|
||||
run_ea(ea, pop); // run the ea
|
||||
|
||||
cout << "Final Population\n";
|
||||
pop.sortedPrintOn(cout);
|
||||
cout << endl;
|
||||
}
|
||||
catch(exception& e)
|
||||
{
|
||||
cout << e.what() << endl;
|
||||
}
|
||||
}
|
||||
56
tutorial/eo/Lesson4/RealEA.param
Executable file
56
tutorial/eo/Lesson4/RealEA.param
Executable file
|
|
@ -0,0 +1,56 @@
|
|||
###### General ######
|
||||
# --help=0 # -h : Prints this message
|
||||
# --stopOnUnknownParam=1 # Stop if unkown param entered
|
||||
# --seed=1104133126 # -S : Random number seed
|
||||
|
||||
###### Evolution Engine ######
|
||||
--popSize=10 # -P : Population Size
|
||||
--selection=Sequential # -S : Selection: DetTour(T), StochTour(t), Roulette, Ranking(p,e) or Sequential(ordered/unordered)
|
||||
--nbOffspring=700% # -O : Nb of offspring (percentage or absolute)
|
||||
--replacement=Plus # -R : Replacement: Comma, Plus or EPTour(T), SSGAWorst, SSGADet(T), SSGAStoch(t)
|
||||
--weakElitism=0 # -w : Old best parent replaces new worst offspring *if necessary*
|
||||
|
||||
###### Genotype Initialization ######
|
||||
# --vecSize=10 # -n : The number of variables
|
||||
# --initBounds=10[-1,1] # -B : Bounds for initialization (MUST be bounded)
|
||||
--sigmaInit=0.3% # -s : Initial value for Sigmas (with a '%' -> scaled by the range of each variable)
|
||||
|
||||
###### Output ######
|
||||
# --useEval=1 # Use nb of eval. as counter (vs nb of gen.)
|
||||
# --useTime=1 # Display time (s) every generation
|
||||
# --printBestStat=1 # Print Best/avg/stdev every gen.
|
||||
# --printPop=0 # Print sorted pop. every gen.
|
||||
|
||||
###### Output - Disk ######
|
||||
# --resDir=Res # Directory to store DISK outputs
|
||||
# --eraseDir=1 # erase files in dirName if any
|
||||
# --fileBestStat=0 # Output bes/avg/std to file
|
||||
|
||||
###### Output - Graphical ######
|
||||
# --plotBestStat=0 # Plot Best/avg Stat
|
||||
# --plotHisto=0 # Plot histogram of fitnesses
|
||||
|
||||
###### Persistence ######
|
||||
# --Load= # -L : A save file to restart from
|
||||
# --recomputeFitness=0 # -r : Recompute the fitness after re-loading the pop.?
|
||||
# --saveFrequency=0 # Save every F generation (0 = only final state, absent = never)
|
||||
# --saveTimeInterval=0 # Save every T seconds (0 or absent = never)
|
||||
# --status=t-eoESAll.status # Status file
|
||||
|
||||
###### Stopping criterion ######
|
||||
# --maxGen=100 # -G : Maximum number of generations () = none)
|
||||
# --steadyGen=100 # -s : Number of generations with no improvement
|
||||
# --minGen=0 # -g : Minimum number of generations
|
||||
# --maxEval=0 # -E : Maximum number of evaluations (0 = none)
|
||||
# --targetFitness=0 # -T : Stop when fitness reaches
|
||||
# --CtrlC=0 # -C : Terminate current generation upon Ctrl C
|
||||
|
||||
###### Variation Operators ######
|
||||
# --objectBounds=10[-inf,+inf] # -B : Bounds for variables
|
||||
# --operator=SGA # -o : Description of the operator (SGA only now)
|
||||
# --pCross=1 # -C : Probability of Crossover
|
||||
# --pMut=1 # -M : Probability of Mutation
|
||||
# --crossType=global # -C : Type of ES recombination (global or standard)
|
||||
# --crossObj=discrete # -O : Recombination of object variables (discrete, intermediate or none)
|
||||
# --crossStdev=intermediate # -S : Recombination of mutation strategy parameters (intermediate, discrete or none)
|
||||
# --TauLoc=1 # -l : Local Tau (before normalization)
|
||||
25
tutorial/eo/Lesson4/binary_value.h
Executable file
25
tutorial/eo/Lesson4/binary_value.h
Executable file
|
|
@ -0,0 +1,25 @@
|
|||
#include <paradiseo/eo.h>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/** Just a simple function that takes binary value of a chromosome and sets
|
||||
the fitnes.
|
||||
@param _chrom A binary chromosome
|
||||
*/
|
||||
|
||||
template <class Chrom> double binary_value(const Chrom& _chrom)
|
||||
{
|
||||
double sum = 0;
|
||||
for (unsigned i = 0; i < _chrom.size(); i++)
|
||||
if (_chrom[i])
|
||||
sum += _chrom[i];
|
||||
return sum;
|
||||
}
|
||||
|
||||
struct BinaryValue
|
||||
{
|
||||
template <class Chrom> void operator()(Chrom& _chrom)
|
||||
{
|
||||
_chrom.fitness(binary_value(_chrom));
|
||||
}
|
||||
};
|
||||
16
tutorial/eo/Lesson4/real_value.h
Executable file
16
tutorial/eo/Lesson4/real_value.h
Executable file
|
|
@ -0,0 +1,16 @@
|
|||
#include <vector>
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
/** Just a simple function that takes an eoEsBase<double> and sets the fitnes
|
||||
to sphere
|
||||
@param _ind vector<double>
|
||||
*/
|
||||
|
||||
double real_value(const std::vector<double>& _ind)
|
||||
{
|
||||
double sum = 0;
|
||||
for (unsigned i = 0; i < _ind.size(); i++)
|
||||
sum += _ind[i] * _ind[i];
|
||||
return sqrt(sum);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue