* whitespace cleanup
This commit is contained in:
parent
56c6edab04
commit
70e60a50d2
195 changed files with 1763 additions and 1873 deletions
|
|
@ -10,23 +10,23 @@ INCLUDE_DIRECTORIES(${EO_SOURCE_DIR}/src/utils)
|
|||
### 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)
|
||||
|
||||
######################################################################################
|
||||
### 3) Define your targets
|
||||
######################################################################################
|
||||
|
||||
# no matter what is the OS, hopefully
|
||||
ADD_EXECUTABLE(FirstBitGA FirstBitGA.cpp)
|
||||
ADD_EXECUTABLE(FirstRealGA FirstRealGA.cpp)
|
||||
ADD_EXECUTABLE(exercise1.3 exercise1.3.cpp)
|
||||
ADD_EXECUTABLE(FirstBitGA FirstBitGA.cpp)
|
||||
ADD_EXECUTABLE(FirstRealGA FirstRealGA.cpp)
|
||||
ADD_EXECUTABLE(exercise1.3 exercise1.3.cpp)
|
||||
|
||||
ADD_DEPENDENCIES(FirstBitGA ga eo eoutils)
|
||||
ADD_DEPENDENCIES(FirstRealGA ga eo eoutils)
|
||||
|
|
|
|||
|
|
@ -78,10 +78,10 @@ void main_function(int argc, char **argv)
|
|||
{
|
||||
Indi v; // void individual, to be filled
|
||||
for (unsigned ivar=0; ivar<VEC_SIZE; ivar++)
|
||||
{
|
||||
bool r = rng.flip(); // new value, random in {0,1}
|
||||
v.push_back(r); // append that random value to v
|
||||
}
|
||||
{
|
||||
bool r = rng.flip(); // new value, random in {0,1}
|
||||
v.push_back(r); // append that random value to v
|
||||
}
|
||||
eval(v); // evaluate it
|
||||
pop.push_back(v); // and put it in the population
|
||||
}
|
||||
|
|
@ -138,7 +138,7 @@ void main_function(int argc, char **argv)
|
|||
|
||||
|
||||
eoSGA<Indi> gga(select, xover, CROSS_RATE, mutation, MUT_RATE,
|
||||
eval, continuator);
|
||||
eval, continuator);
|
||||
|
||||
// Apply algo to pop - that's it!
|
||||
gga(pop);
|
||||
|
|
@ -156,11 +156,11 @@ int main(int argc, char **argv)
|
|||
|
||||
try
|
||||
{
|
||||
main_function(argc, argv);
|
||||
main_function(argc, argv);
|
||||
}
|
||||
catch(exception& e)
|
||||
{
|
||||
cout << "Exception: " << e.what() << '\n';
|
||||
cout << "Exception: " << e.what() << '\n';
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
|
|
|||
|
|
@ -78,10 +78,10 @@ void main_function(int argc, char **argv)
|
|||
{
|
||||
Indi v; // void individual, to be filled
|
||||
for (unsigned ivar=0; ivar<VEC_SIZE; ivar++)
|
||||
{
|
||||
double r = 2*rng.uniform() - 1; // new value, random in [-1,1)
|
||||
v.push_back(r); // append that random value to v
|
||||
}
|
||||
{
|
||||
double r = 2*rng.uniform() - 1; // new value, random in [-1,1)
|
||||
v.push_back(r); // append that random value to v
|
||||
}
|
||||
eval(v); // evaluate it
|
||||
pop.push_back(v); // and put it in the population
|
||||
}
|
||||
|
|
@ -133,7 +133,7 @@ void main_function(int argc, char **argv)
|
|||
|
||||
|
||||
eoSGA<Indi> gga(select, xover, CROSS_RATE, mutation, MUT_RATE,
|
||||
eval, continuator);
|
||||
eval, continuator);
|
||||
|
||||
// Apply algo to pop - that's it!
|
||||
gga(pop);
|
||||
|
|
@ -151,11 +151,11 @@ int main(int argc, char **argv)
|
|||
{
|
||||
try
|
||||
{
|
||||
main_function(argc, argv);
|
||||
main_function(argc, argv);
|
||||
}
|
||||
catch(exception& e)
|
||||
{
|
||||
cout << "Exception: " << e.what() << '\n';
|
||||
cout << "Exception: " << e.what() << '\n';
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@ 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,
|
||||
# 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 -pg -o $@ $*.cpp $(DIR_EO)/utils/libeoutils.a $(DIR_EO)/libeo.a
|
||||
.cpp: ; $(CXX) -DPACKAGE=\"eo\" -DVERSION=\"0.9.3\" -I. -I$(DIR_EO) -Wall -g -pg -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 -pg $*.cpp
|
||||
|
||||
|
|
@ -21,5 +21,5 @@ lesson1 : $(firstGA)
|
|||
|
||||
all : $(ALL)
|
||||
|
||||
clean :
|
||||
clean :
|
||||
@/bin/rm $(ALL) *.o *~
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Include the corresponding file
|
||||
#include <ga.h> // bitstring representation & operators
|
||||
#include <ga.h> // bitstring representation & operators
|
||||
// define your individuals
|
||||
typedef eoBit<double> Indi; // A bitstring with fitness double
|
||||
|
||||
|
|
@ -151,11 +151,11 @@ int main(int argc, char **argv)
|
|||
|
||||
try
|
||||
{
|
||||
main_function(argc, argv);
|
||||
main_function(argc, argv);
|
||||
}
|
||||
catch(exception& e)
|
||||
{
|
||||
cout << "Exception: " << e.what() << '\n';
|
||||
cout << "Exception: " << e.what() << '\n';
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
|
|
|||
|
|
@ -10,23 +10,23 @@ INCLUDE_DIRECTORIES(${EO_SOURCE_DIR}/src/utils)
|
|||
### 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)
|
||||
|
||||
######################################################################################
|
||||
### 3) Define your targets
|
||||
######################################################################################
|
||||
|
||||
# no matter what is the OS, hopefully
|
||||
ADD_EXECUTABLE(FirstBitEA FirstBitEA.cpp)
|
||||
ADD_EXECUTABLE(FirstRealEA FirstRealEA.cpp)
|
||||
ADD_EXECUTABLE(exercise2.3 exercise2.3.cpp)
|
||||
ADD_EXECUTABLE(FirstBitEA FirstBitEA.cpp)
|
||||
ADD_EXECUTABLE(FirstRealEA FirstRealEA.cpp)
|
||||
ADD_EXECUTABLE(exercise2.3 exercise2.3.cpp)
|
||||
|
||||
######################################################################################
|
||||
### 4) Optionnal
|
||||
|
|
|
|||
|
|
@ -182,11 +182,11 @@ int main(int argc, char **argv)
|
|||
|
||||
try
|
||||
{
|
||||
main_function(argc, argv);
|
||||
main_function(argc, argv);
|
||||
}
|
||||
catch(exception& e)
|
||||
{
|
||||
cout << "Exception: " << e.what() << '\n';
|
||||
cout << "Exception: " << e.what() << '\n';
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ void main_function(int argc, char **argv)
|
|||
const float P_MUT = 0.5; // mutation probability
|
||||
|
||||
const double EPSILON = 0.01; // range for real uniform mutation
|
||||
double SIGMA = 0.3; // std dev. for normal mutation
|
||||
double SIGMA = 0.3; // std dev. for normal mutation
|
||||
// some parameters for chosing among different operators
|
||||
const double hypercubeRate = 0.5; // relative weight for hypercube Xover
|
||||
const double segmentRate = 0.5; // relative weight for segment Xover
|
||||
|
|
@ -181,11 +181,11 @@ int main(int argc, char **argv)
|
|||
{
|
||||
try
|
||||
{
|
||||
main_function(argc, argv);
|
||||
main_function(argc, argv);
|
||||
}
|
||||
catch(exception& e)
|
||||
{
|
||||
cout << "Exception: " << e.what() << '\n';
|
||||
cout << "Exception: " << e.what() << '\n';
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
### This Makefile is part of the tutorial of the EO library
|
||||
# Unlike other Makefiles in EO, it is not using the automake/autoconf
|
||||
# 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
|
||||
|
||||
|
|
@ -10,11 +10,11 @@ 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,
|
||||
# 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 -pg -o $@ $*.cpp $(DIR_EO)/utils/libeoutils.a $(DIR_EO)/libeo.a
|
||||
.cpp: ; $(CXX) -DPACKAGE=\"eo\" -DVERSION=\"0.9.3\" -I. -I$(DIR_EO) -Wall -g -pg -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 -pg $*.cpp
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ lesson2 : $(firstEA)
|
|||
|
||||
all : $(ALL)
|
||||
|
||||
clean :
|
||||
clean :
|
||||
@/bin/rm $(ALL) *.o *~
|
||||
|
||||
FirstRealEA : real_value.h
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
/** Just a simple function that takes binary value of a chromosome and sets
|
||||
the fitnes.
|
||||
@param _chrom A binary chromosome
|
||||
@param _chrom A binary chromosome
|
||||
*/
|
||||
// INIT
|
||||
double binary_value(const std::vector<bool>& _chrom)
|
||||
|
|
@ -14,4 +14,3 @@ double binary_value(const std::vector<bool>& _chrom)
|
|||
sum += _chrom[i];
|
||||
return sum;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
// REPRESENTATION
|
||||
//-----------------------------------------------------------------------------
|
||||
// Include the corresponding file
|
||||
#include <ga.h> // bitstring representation & operators
|
||||
#include <ga.h> // bitstring representation & operators
|
||||
// define your individuals
|
||||
typedef eoBit<double> Indi; // A bitstring with fitness double
|
||||
|
||||
|
|
@ -186,11 +186,11 @@ int main(int argc, char **argv)
|
|||
{
|
||||
try
|
||||
{
|
||||
main_function(argc, argv);
|
||||
main_function(argc, argv);
|
||||
}
|
||||
catch(exception& e)
|
||||
{
|
||||
cout << "Exception: " << e.what() << '\n';
|
||||
cout << "Exception: " << e.what() << '\n';
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
#include <vector>
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Just a simple function that takes an vector<double> and sets the fitnes
|
||||
/** Just a simple function that takes an vector<double> and sets the fitnes
|
||||
to the sphere function. Please use doubles not float!!!
|
||||
@param _ind A floatingpoint vector
|
||||
@param _ind A floatingpoint vector
|
||||
*/
|
||||
|
||||
// INIT
|
||||
|
|
@ -15,6 +15,3 @@ double real_value(const std::vector<double>& _ind)
|
|||
}
|
||||
return -sum;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -10,23 +10,23 @@ INCLUDE_DIRECTORIES(${EO_SOURCE_DIR}/src/utils)
|
|||
### 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)
|
||||
|
||||
######################################################################################
|
||||
### 3) Define your targets
|
||||
######################################################################################
|
||||
|
||||
# no matter what is the OS, hopefully
|
||||
ADD_EXECUTABLE(SecondBitEA SecondBitEA.cpp)
|
||||
ADD_EXECUTABLE(SecondRealEA SecondRealEA.cpp)
|
||||
ADD_EXECUTABLE(exercise3.1 exercise3.1.cpp)
|
||||
ADD_EXECUTABLE(SecondBitEA SecondBitEA.cpp)
|
||||
ADD_EXECUTABLE(SecondRealEA SecondRealEA.cpp)
|
||||
ADD_EXECUTABLE(exercise3.1 exercise3.1.cpp)
|
||||
|
||||
ADD_DEPENDENCIES(SecondBitEA ga eoutils eo)
|
||||
ADD_DEPENDENCIES(SecondRealEA ga eoutils eo)
|
||||
|
|
@ -62,4 +62,3 @@ INSTALL(TARGETS SecondRealEA RUNTIME DESTINATION share/eo/examples/Lesson3 COMPO
|
|||
INSTALL(TARGETS exercise3.1 RUNTIME DESTINATION share/eo/examples/Lesson3 COMPONENT examples)
|
||||
|
||||
######################################################################################
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
### This Makefile is part of the tutorial of the EO library
|
||||
# Unlike other Makefiles in EO, it is not using the automake/autoconf
|
||||
# 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
|
||||
|
||||
|
|
@ -10,11 +10,11 @@ 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,
|
||||
# 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 -pg -o $@ $*.cpp $(DIR_EO)/utils/libeoutils.a $(DIR_EO)/libeo.a
|
||||
.cpp: ; $(CXX) -DPACKAGE=\"eo\" -DVERSION=\"0.9.3\" -I. -I$(DIR_EO) -Wall -g -pg -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 -pg $*.cpp
|
||||
|
||||
|
|
@ -29,5 +29,5 @@ all : $(ALL)
|
|||
SecondBitEA : binary_value.h
|
||||
SecondRealEA : real_value.h
|
||||
|
||||
clean :
|
||||
clean :
|
||||
@/bin/rm $(ALL) *.o *.sav *.xg *.status *~
|
||||
|
|
|
|||
|
|
@ -126,8 +126,8 @@ void main_function(int argc, char **argv)
|
|||
// i.e. in case you need parameters somewhere else, postpone these
|
||||
if (parser.userNeedsHelp())
|
||||
{
|
||||
parser.printHelp(cout);
|
||||
exit(1);
|
||||
parser.printHelp(cout);
|
||||
exit(1);
|
||||
}
|
||||
if (statusParam.value() != "")
|
||||
{
|
||||
|
|
@ -337,11 +337,11 @@ int main(int argc, char **argv)
|
|||
{
|
||||
try
|
||||
{
|
||||
main_function(argc, argv);
|
||||
main_function(argc, argv);
|
||||
}
|
||||
catch(exception& e)
|
||||
{
|
||||
cout << "Exception: " << e.what() << '\n';
|
||||
cout << "Exception: " << e.what() << '\n';
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
|
|
|||
|
|
@ -104,8 +104,8 @@ void main_function(int argc, char **argv)
|
|||
// i.e. in case you need parameters somewhere else, postpone these
|
||||
if (parser.userNeedsHelp())
|
||||
{
|
||||
parser.printHelp(cout);
|
||||
exit(1);
|
||||
parser.printHelp(cout);
|
||||
exit(1);
|
||||
}
|
||||
if (statusName != "")
|
||||
{
|
||||
|
|
@ -318,11 +318,11 @@ int main(int argc, char **argv)
|
|||
{
|
||||
try
|
||||
{
|
||||
main_function(argc, argv);
|
||||
main_function(argc, argv);
|
||||
}
|
||||
catch(exception& e)
|
||||
{
|
||||
cout << "Exception: " << e.what() << '\n';
|
||||
cout << "Exception: " << e.what() << '\n';
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
/** Just a simple function that takes binary value of a chromosome and sets
|
||||
the fitnes.
|
||||
@param _chrom A binary chromosome
|
||||
@param _chrom A binary chromosome
|
||||
*/
|
||||
// INIT
|
||||
double binary_value(const std::vector<bool>& _chrom)
|
||||
|
|
@ -14,4 +14,3 @@ double binary_value(const std::vector<bool>& _chrom)
|
|||
sum += _chrom[i];
|
||||
return sum;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
// REPRESENTATION
|
||||
//-----------------------------------------------------------------------------
|
||||
// Include the corresponding file
|
||||
#include <ga.h> // bitstring representation & operators
|
||||
#include <ga.h> // bitstring representation & operators
|
||||
// define your genotype and fitness types
|
||||
typedef eoBit<eoMinimizingFitness> Indi;
|
||||
|
||||
|
|
@ -126,8 +126,8 @@ void main_function(int argc, char **argv)
|
|||
// i.e. in case you need parameters somewhere else, postpone these
|
||||
if (parser.userNeedsHelp())
|
||||
{
|
||||
parser.printHelp(cout);
|
||||
exit(1);
|
||||
parser.printHelp(cout);
|
||||
exit(1);
|
||||
}
|
||||
if (statusParam.value() != "")
|
||||
{
|
||||
|
|
@ -393,11 +393,11 @@ int main(int argc, char **argv)
|
|||
{
|
||||
try
|
||||
{
|
||||
main_function(argc, argv);
|
||||
main_function(argc, argv);
|
||||
}
|
||||
catch(exception& e)
|
||||
{
|
||||
cout << "Exception: " << e.what() << '\n';
|
||||
cout << "Exception: " << e.what() << '\n';
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
#include <vector>
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Just a simple function that takes an vector<double> and sets the fitnes
|
||||
/** Just a simple function that takes an vector<double> and sets the fitnes
|
||||
to the sphere function. Please use doubles not float!!!
|
||||
@param _ind A floatingpoint vector
|
||||
@param _ind A floatingpoint vector
|
||||
*/
|
||||
|
||||
// INIT
|
||||
|
|
@ -15,6 +15,3 @@ double real_value(const std::vector<double>& _ind)
|
|||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
using namespace std;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
|
|
@ -29,7 +29,7 @@ int main(int argc, char* argv[])
|
|||
//////////////////////////////////////////////////////
|
||||
|
||||
// EVAL
|
||||
// The evaluation fn - encapsulated into an eval counter for output
|
||||
// The evaluation fn - encapsulated into an eval counter for output
|
||||
eoEvalFuncPtr<EOT, double> mainEval( binary_value<EOT> );
|
||||
eoEvalFuncCounter<EOT> eval(mainEval);
|
||||
|
||||
|
|
@ -38,7 +38,7 @@ int main(int argc, char* argv[])
|
|||
eoInit<EOT>& init = make_genotype(parser, state, EOT());
|
||||
|
||||
// if you want to do sharing, you'll need a distance.
|
||||
// here Hamming distance
|
||||
// here Hamming distance
|
||||
eoHammingDistance<EOT> dist;
|
||||
|
||||
// OPERATORS
|
||||
|
|
@ -74,7 +74,7 @@ int main(int argc, char* argv[])
|
|||
// evaluate intial population AFTER help and status in case it takes time
|
||||
apply<EOT>(eval, pop);
|
||||
// STOP
|
||||
// print it out (sort witout modifying)
|
||||
// print it out (sort witout modifying)
|
||||
cout << "Initial Population\n";
|
||||
pop.sortedPrintOn(cout);
|
||||
cout << endl;
|
||||
|
|
@ -82,7 +82,7 @@ int main(int argc, char* argv[])
|
|||
// GENERATION
|
||||
run_ea(ga, pop); // run the ga
|
||||
// STOP
|
||||
// print it out (sort witout modifying)
|
||||
// print it out (sort witout modifying)
|
||||
cout << "Final Population\n";
|
||||
pop.sortedPrintOn(cout);
|
||||
cout << endl;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ EXECUTE_PROCESS(
|
|||
# COMMAND ${CMAKE_COMMAND}
|
||||
# ARGS -E copy_if_different
|
||||
# ${EO_SOURCE_DIR}/tutorial/Lesson4/ESEA.param
|
||||
# ${EO_BINARY_DIR}/tutorial/Lesson4)
|
||||
# ${EO_BINARY_DIR}/tutorial/Lesson4)
|
||||
#ADD_CUSTOM_TARGET(param DEPENDS ${EO_SOURCE_DIR}/tutorial/Lesson4/RealEA.param)
|
||||
#ADD_CUSTOM_COMMAND(
|
||||
# TARGET param
|
||||
|
|
@ -29,7 +29,7 @@ EXECUTE_PROCESS(
|
|||
# COMMAND ${CMAKE_COMMAND}
|
||||
# ARGS -E copy_if_different
|
||||
# ${EO_SOURCE_DIR}/tutorial/Lesson4/RealEA.param
|
||||
# ${EO_BINARY_DIR}/tutorial/Lesson4)
|
||||
# ${EO_BINARY_DIR}/tutorial/Lesson4)
|
||||
|
||||
######################################################################################
|
||||
### 1) Include the sources
|
||||
|
|
@ -44,23 +44,23 @@ INCLUDE_DIRECTORIES(${EO_SOURCE_DIR}/src/ga)
|
|||
### 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)
|
||||
|
||||
######################################################################################
|
||||
### 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_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)
|
||||
|
|
@ -96,4 +96,3 @@ INSTALL(TARGETS RealEA RUNTIME DESTINATION share/eo/examples/Lesson4 COMPONENT e
|
|||
INSTALL(TARGETS ESEA RUNTIME DESTINATION share/eo/examples/Lesson4 COMPONENT examples)
|
||||
|
||||
######################################################################################
|
||||
|
||||
|
|
|
|||
|
|
@ -20,14 +20,14 @@ using namespace std;
|
|||
|
||||
#include "real_value.h" // the sphere fitness
|
||||
|
||||
// Now the main
|
||||
///////////////
|
||||
// Now the main
|
||||
///////////////
|
||||
typedef eoMinimizingFitness FitT;
|
||||
|
||||
template <class EOT>
|
||||
void runAlgorithm(EOT, eoParser& _parser, eoState& _state);
|
||||
|
||||
int main_function(int argc, char *argv[])
|
||||
|
||||
int main_function(int argc, char *argv[])
|
||||
{
|
||||
// Create the command-line parser
|
||||
eoParser parser(argc, argv); // for user-parameter reading
|
||||
|
|
@ -55,33 +55,33 @@ int main_function(int argc, char *argv[])
|
|||
cout << "Using eoEsStdev" << endl;
|
||||
runAlgorithm(eoEsStdev<FitT>(), parser, state);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
cout << "Using eoEsFull" << endl;
|
||||
runAlgorithm(eoEsFull<FitT>(), parser, state);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// A main that catches the exceptions
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
try
|
||||
{
|
||||
main_function(argc, argv);
|
||||
main_function(argc, argv);
|
||||
}
|
||||
catch(exception& e)
|
||||
{
|
||||
cout << "Exception: " << e.what() << '\n';
|
||||
cout << "Exception: " << e.what() << '\n';
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/** The templatized main (sort of)
|
||||
* quite similar to the main of other genotypes
|
||||
* quite similar to the main of other genotypes
|
||||
* (e.g. t-eoReal and t-eoGA in test dir)
|
||||
*/
|
||||
template <class EOT>
|
||||
|
|
@ -92,9 +92,9 @@ void runAlgorithm(EOT, eoParser& _parser, eoState& _state)
|
|||
///// 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 );
|
||||
// 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
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
###### General ######
|
||||
# --help=0 # -h : Prints this message
|
||||
# --stopOnUnknownParam=1 # Stop if unkown param entered
|
||||
|
|
@ -17,7 +16,7 @@
|
|||
--weakElitism=0 # -w : Old best parent replaces new worst offspring *if necessary*
|
||||
|
||||
###### Genotype Initialization ######
|
||||
# --vecSize=10 # -n : The number of variables
|
||||
# --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)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
### This Makefile is part of the tutorial of the EO library
|
||||
# Unlike other Makefiles in EO, it is not using the automake/autoconf
|
||||
# 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
|
||||
|
||||
|
|
@ -10,11 +10,11 @@ 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,
|
||||
# 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: ; $(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
|
||||
|
||||
|
|
@ -22,12 +22,12 @@ 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
|
||||
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 :
|
||||
clean :
|
||||
@/bin/rm $(ALL) *.o *.sav *.xg *.status *~
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@ int main(int argc, char* argv[])
|
|||
///// 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 );
|
||||
// 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
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
###### General ######
|
||||
# --help=0 # -h : Prints this message
|
||||
# --stopOnUnknownParam=1 # Stop if unkown param entered
|
||||
|
|
@ -12,7 +11,7 @@
|
|||
--weakElitism=0 # -w : Old best parent replaces new worst offspring *if necessary*
|
||||
|
||||
###### Genotype Initialization ######
|
||||
# --vecSize=10 # -n : The number of variables
|
||||
# --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)
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
/** Just a simple function that takes binary value of a chromosome and sets
|
||||
the fitnes.
|
||||
@param _chrom A binary chromosome
|
||||
@param _chrom A binary chromosome
|
||||
*/
|
||||
|
||||
template <class Chrom> double binary_value(const Chrom& _chrom)
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
/** Just a simple function that takes an eoEsBase<double> and sets the fitnes
|
||||
to sphere
|
||||
/** Just a simple function that takes an eoEsBase<double> and sets the fitnes
|
||||
to sphere
|
||||
@param _ind vector<double>
|
||||
*/
|
||||
|
||||
|
|
@ -14,6 +14,3 @@ double real_value(const std::vector<double>& _ind)
|
|||
sum += _ind[i] * _ind[i];
|
||||
return sqrt(sum);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -9,22 +9,22 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
|
|||
### 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)
|
||||
|
||||
######################################################################################
|
||||
### 3) Define your targets
|
||||
######################################################################################
|
||||
|
||||
# no matter what is the OS, hopefully
|
||||
ADD_EXECUTABLE(OneMaxEA OneMaxEA.cpp)
|
||||
ADD_EXECUTABLE(OneMaxLibEA OneMaxLibEA.cpp make_OneMax.cpp)
|
||||
ADD_EXECUTABLE(OneMaxEA OneMaxEA.cpp)
|
||||
ADD_EXECUTABLE(OneMaxLibEA OneMaxLibEA.cpp make_OneMax.cpp)
|
||||
|
||||
ADD_DEPENDENCIES(OneMaxEA es ga eo eoutils)
|
||||
ADD_DEPENDENCIES(OneMaxLibEA es ga eo eoutils)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
### This Makefile is part of the tutorial of the EO library
|
||||
# Unlike other Makefiles in EO, it is not using the automake/autoconf
|
||||
# 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
|
||||
|
||||
|
|
@ -10,11 +10,11 @@ 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,
|
||||
# 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: ; $(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
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ LIB_EO = $(DIR_EO)/utils/libeoutils.a $(DIR_EO)/libeo.a
|
|||
ALL = OneMaxEA OneMaxLibEA
|
||||
|
||||
OneMaxEA : OneMaxEA.o
|
||||
$(CXX) -g -o $@ OneMaxEA.o $(DIR_EO)/utils/libeoutils.a $(DIR_EO)/libeo.a -lm
|
||||
$(CXX) -g -o $@ OneMaxEA.o $(DIR_EO)/utils/libeoutils.a $(DIR_EO)/libeo.a -lm
|
||||
|
||||
OneMaxLibEA : OneMaxLibEA.o make_OneMax.o
|
||||
$(CXX) -g -o $@ OneMaxLibEA.o make_OneMax.o $(DIR_EO)/utils/libeoutils.a $(DIR_EO)/libeo.a -lm
|
||||
|
|
@ -53,4 +53,4 @@ clean : ; /bin/rm *.o $(ALL)
|
|||
########## local dependencies
|
||||
OneMaxEA.o : $(COMMON_SOURCES) OneMaxEA.cpp
|
||||
OneMaxLibEA.o : $(COMMON_SOURCES) OneMaxLibEA.cpp
|
||||
make_OneMax.o : make_OneMax.cpp eoOneMax.h
|
||||
make_OneMax.o : make_OneMax.cpp eoOneMax.h
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ main file BitEA in tutorial/Lesson4 dir.
|
|||
Or you can wait until we do it :-)
|
||||
*/
|
||||
|
||||
// Miscilaneous include and declaration
|
||||
// Miscilaneous include and declaration
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
|
|
@ -29,17 +29,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 eoOneMax MUST derive from EO<FitT> for some fitness
|
||||
*/
|
||||
#include "eoOneMax.h"
|
||||
|
||||
/** definition of initilizqtion:
|
||||
/** definition of initilizqtion:
|
||||
* class eoOneMaxInit MUST derive from eoInit<eoOneMax>
|
||||
*/
|
||||
#include "eoOneMaxInit.h"
|
||||
|
||||
/** definition of evaluation:
|
||||
/** definition of evaluation:
|
||||
* class eoOneMaxEvalFunc MUST derive from eoEvalFunc<eoOneMax>
|
||||
* and should test for validity before doing any computation
|
||||
* see tutorial/Templates/evalFunc.tmpl
|
||||
|
|
@ -51,19 +51,19 @@ using namespace std;
|
|||
//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
|
||||
// START fitness type: double or eoMaximizingFitness if you are maximizing
|
||||
// eoMinimizingFitness if you are minimizing
|
||||
typedef eoMaximizingFitness MyFitT ; // type of fitness
|
||||
typedef eoMaximizingFitness MyFitT ; // type of fitness
|
||||
// END fitness type
|
||||
//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
|
||||
|
||||
// Then define your EO objects using that fitness type
|
||||
typedef eoOneMax<MyFitT> Indi; // ***MUST*** derive from EO
|
||||
typedef eoOneMax<MyFitT> Indi; // ***MUST*** derive from EO
|
||||
|
||||
// create an initializer
|
||||
#include "make_genotype_OneMax.h"
|
||||
eoInit<Indi> & make_genotype(eoParser& _parser, eoState&_state, Indi _eo)
|
||||
{
|
||||
return do_make_genotype(_parser, _state, _eo);
|
||||
}
|
||||
}
|
||||
|
||||
// and the variation operaotrs
|
||||
#include "make_op_OneMax.h"
|
||||
|
|
@ -75,7 +75,7 @@ eoGenOp<Indi>& make_op(eoParser& _parser, eoState& _state, eoInit<Indi>& _init)
|
|||
// Use existing modules to define representation independent routines
|
||||
// These are parser-based definitions of objects
|
||||
|
||||
// how to initialize the population
|
||||
// how to initialize the population
|
||||
// it IS representation independent if an eoInit is given
|
||||
#include <do/make_pop.h>
|
||||
eoPop<Indi >& make_pop(eoParser& _parser, eoState& _state, eoInit<Indi> & _init)
|
||||
|
|
@ -92,7 +92,7 @@ eoContinue<Indi>& make_continue(eoParser& _parser, eoState& _state, eoEvalFuncCo
|
|||
|
||||
// outputs (stats, population dumps, ...)
|
||||
#include <do/make_checkpoint.h>
|
||||
eoCheckPoint<Indi>& make_checkpoint(eoParser& _parser, eoState& _state, eoEvalFuncCounter<Indi>& _eval, eoContinue<Indi>& _continue)
|
||||
eoCheckPoint<Indi>& make_checkpoint(eoParser& _parser, eoState& _state, eoEvalFuncCounter<Indi>& _eval, eoContinue<Indi>& _continue)
|
||||
{
|
||||
return do_make_checkpoint(_parser, _state, _eval, _continue);
|
||||
}
|
||||
|
|
@ -104,7 +104,7 @@ eoAlgo<Indi>& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc<I
|
|||
return do_make_algo_scalar(_parser, _state, _eval, _continue, _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
|
||||
#include <do/make_run.h>
|
||||
// the instanciating fitnesses
|
||||
|
|
@ -141,7 +141,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
|
||||
|
|
|
|||
|
|
@ -8,11 +8,11 @@ Template for creating a new representation in EO
|
|||
================================================
|
||||
|
||||
This is the template main file for compiling after creating a
|
||||
library.
|
||||
library.
|
||||
See make_OneMax.cpp file.
|
||||
*/
|
||||
|
||||
// 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 eoOneMax MUST derive from EO<FitT> for some fitness
|
||||
*/
|
||||
#include "eoOneMax.h"
|
||||
|
||||
/** definition of initilizqtion:
|
||||
/** definition of initilizqtion:
|
||||
* class eoOneMaxInit MUST derive from eoInit<eoOneMax>
|
||||
*/
|
||||
#include "eoOneMaxInit.h"
|
||||
|
||||
/** definition of evaluation:
|
||||
/** definition of evaluation:
|
||||
* class eoOneMaxEvalFunc MUST derive from eoEvalFunc<eoOneMax>
|
||||
* 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 eoOneMax<MyFitT> Indi; // ***MUST*** derive from EO
|
||||
typedef eoOneMax<MyFitT> Indi; // ***MUST*** derive from EO
|
||||
|
||||
// create an initializer - done here and NOT in make_OneMax.cpp
|
||||
// because it is NOT representation independent
|
||||
|
|
@ -59,7 +59,7 @@ typedef eoOneMax<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_OneMax.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
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ Template for creating a new representation in EO
|
|||
#ifndef _eoOneMax_h
|
||||
#define _eoOneMax_h
|
||||
|
||||
/**
|
||||
/**
|
||||
* Always write a comment in this format before class definition
|
||||
* if you want the class to be documented by Doxygen
|
||||
|
||||
|
|
@ -20,7 +20,7 @@ Template for creating a new representation in EO
|
|||
* 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
|
||||
*
|
||||
|
|
@ -31,11 +31,11 @@ template< class FitT>
|
|||
class eoOneMax: 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
|
||||
*/
|
||||
eoOneMax()
|
||||
{
|
||||
eoOneMax()
|
||||
{
|
||||
// START Code of default Ctor of an eoOneMax object
|
||||
// END Code of default Ctor of an eoOneMax object
|
||||
}
|
||||
|
|
@ -54,7 +54,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
|
||||
|
|
@ -66,7 +66,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)
|
||||
|
|
@ -87,7 +87,7 @@ public:
|
|||
bool bTmp;
|
||||
_is >> bTmp;
|
||||
b[i] = bTmp;
|
||||
}
|
||||
}
|
||||
// END Code of input
|
||||
}
|
||||
|
||||
|
|
@ -108,4 +108,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 _eoOneMaxEvalFunc_h
|
||||
#define _eoOneMaxEvalFunc_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
|
||||
eoOneMaxEvalFunc()
|
||||
// eoOneMaxEvalFunc( varType _anyVariable) : anyVariable(_anyVariable)
|
||||
// eoOneMaxEvalFunc( varType _anyVariable) : anyVariable(_anyVariable)
|
||||
// END eventually add or modify the anyVariable argument
|
||||
{
|
||||
// START Code of Ctor of an eoOneMaxEvalFunc 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
|
||||
// eoOneMaxInit()
|
||||
eoOneMaxInit( unsigned _vecSize) : vecSize(_vecSize)
|
||||
eoOneMaxInit( unsigned _vecSize) : vecSize(_vecSize)
|
||||
// END eventually add or modify the anyVariable argument
|
||||
{
|
||||
// START Code of Ctor of an eoOneMaxInit object
|
||||
|
|
@ -60,4 +60,3 @@ private:
|
|||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -32,10 +32,10 @@ public:
|
|||
eoOneMaxMutation()
|
||||
// eoOneMaxMutation( varType _anyVariable) : anyVariable(_anyVariable)
|
||||
// END eventually add or modify the anyVariable argument
|
||||
{
|
||||
// START Code of Ctor of an eoOneMaxEvalFunc object
|
||||
// END Code of Ctor of an eoOneMaxEvalFunc object
|
||||
}
|
||||
{
|
||||
// START Code of Ctor of an eoOneMaxEvalFunc object
|
||||
// END Code of Ctor of an eoOneMaxEvalFunc object
|
||||
}
|
||||
|
||||
/// The class name. Used to display statistics
|
||||
string className() const { return "eoOneMaxMutation"; }
|
||||
|
|
@ -45,19 +45,19 @@ public:
|
|||
* @param _genotype The parent genotype (will be modified)
|
||||
*/
|
||||
bool operator()(GenotypeT & _genotype)
|
||||
{
|
||||
bool isModified(true);
|
||||
// START code for mutation of the _genotype object
|
||||
{
|
||||
bool isModified(true);
|
||||
// START code for mutation of the _genotype object
|
||||
|
||||
/** Requirement
|
||||
* if (_genotype has been modified)
|
||||
* isModified = true;
|
||||
* else
|
||||
* isModified = false;
|
||||
*/
|
||||
return isModified;
|
||||
// END code for mutation of the _genotype object
|
||||
}
|
||||
/** Requirement
|
||||
* if (_genotype has been modified)
|
||||
* isModified = true;
|
||||
* else
|
||||
* isModified = false;
|
||||
*/
|
||||
return isModified;
|
||||
// END code for mutation of the _genotype object
|
||||
}
|
||||
|
||||
private:
|
||||
// START Private data of an eoOneMaxMutation object
|
||||
|
|
|
|||
|
|
@ -33,10 +33,10 @@ public:
|
|||
eoOneMaxQuadCrossover()
|
||||
// eoOneMaxQuadCrossover( varType _anyVariable) : anyVariable(_anyVariable)
|
||||
// END eventually add or modify the anyVariable argument
|
||||
{
|
||||
// START Code of Ctor of an eoOneMaxEvalFunc object
|
||||
// END Code of Ctor of an eoOneMaxEvalFunc object
|
||||
}
|
||||
{
|
||||
// START Code of Ctor of an eoOneMaxEvalFunc object
|
||||
// END Code of Ctor of an eoOneMaxEvalFunc object
|
||||
}
|
||||
|
||||
/// The class name. Used to display statistics
|
||||
string className() const { return "eoOneMaxQuadCrossover"; }
|
||||
|
|
@ -47,19 +47,19 @@ public:
|
|||
* @param _genotype2 The second parent
|
||||
*/
|
||||
bool operator()(GenotypeT& _genotype1, GenotypeT & _genotype2)
|
||||
{
|
||||
bool oneAtLeastIsModified(true);
|
||||
// START code for crossover of _genotype1 and _genotype2 objects
|
||||
{
|
||||
bool oneAtLeastIsModified(true);
|
||||
// START code for crossover of _genotype1 and _genotype2 objects
|
||||
|
||||
/** Requirement
|
||||
* if (at least one genotype has been modified) // no way to distinguish
|
||||
* oneAtLeastIsModified = true;
|
||||
* else
|
||||
* oneAtLeastIsModified = false;
|
||||
*/
|
||||
return oneAtLeastIsModified;
|
||||
// END code for crossover of _genotype1 and _genotype2 objects
|
||||
}
|
||||
/** Requirement
|
||||
* if (at least one genotype has been modified) // no way to distinguish
|
||||
* oneAtLeastIsModified = true;
|
||||
* else
|
||||
* oneAtLeastIsModified = false;
|
||||
*/
|
||||
return oneAtLeastIsModified;
|
||||
// END code for crossover of _genotype1 and _genotype2 objects
|
||||
}
|
||||
|
||||
private:
|
||||
// START Private data of an eoOneMaxQuadCrossover object
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ and src/es (for real vectors).
|
|||
|
||||
*/
|
||||
|
||||
// Miscilaneous include and declaration
|
||||
// Miscilaneous include and declaration
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
|
|
@ -29,7 +29,7 @@ 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 eoOneMax MUST derive from EO<FitT> for some fitness
|
||||
*/
|
||||
#include "eoOneMax.h"
|
||||
|
|
@ -43,12 +43,12 @@ using namespace std;
|
|||
// eoInit<eoOneMax<double>> & make_genotype(eoParser& _parser, eoState&_state, eoOneMax<double> _eo)
|
||||
// {
|
||||
// return do_make_genotype(_parser, _state, _eo);
|
||||
// }
|
||||
// }
|
||||
|
||||
// eoInit<eoOneMax<eoMinimizingFitness>> & make_genotype(eoParser& _parser, eoState&_state, eoOneMax<eoMinimizingFitness> _eo)
|
||||
// {
|
||||
// return do_make_genotype(_parser, _state, _eo);
|
||||
// }
|
||||
// }
|
||||
|
||||
// same thing for the variation operaotrs
|
||||
//---------------------------------------
|
||||
|
|
@ -65,7 +65,7 @@ using namespace std;
|
|||
|
||||
// The following modules use ***representation independent*** routines
|
||||
|
||||
// how to initialize the population
|
||||
// how to initialize the population
|
||||
// it IS representation independent if an eoInit is given
|
||||
#include <do/make_pop.h>
|
||||
eoPop<eoOneMax<double> >& make_pop(eoParser& _parser, eoState& _state, eoInit<eoOneMax<double> > & _init)
|
||||
|
|
@ -92,12 +92,12 @@ eoContinue<eoOneMax<eoMinimizingFitness> >& make_continue(eoParser& _parser, eoS
|
|||
|
||||
// outputs (stats, population dumps, ...)
|
||||
#include <do/make_checkpoint.h>
|
||||
eoCheckPoint<eoOneMax<double> >& make_checkpoint(eoParser& _parser, eoState& _state, eoEvalFuncCounter<eoOneMax<double> >& _eval, eoContinue<eoOneMax<double> >& _continue)
|
||||
eoCheckPoint<eoOneMax<double> >& make_checkpoint(eoParser& _parser, eoState& _state, eoEvalFuncCounter<eoOneMax<double> >& _eval, eoContinue<eoOneMax<double> >& _continue)
|
||||
{
|
||||
return do_make_checkpoint(_parser, _state, _eval, _continue);
|
||||
}
|
||||
|
||||
eoCheckPoint<eoOneMax<eoMinimizingFitness> >& make_checkpoint(eoParser& _parser, eoState& _state, eoEvalFuncCounter<eoOneMax<eoMinimizingFitness> >& _eval, eoContinue<eoOneMax<eoMinimizingFitness> >& _continue)
|
||||
eoCheckPoint<eoOneMax<eoMinimizingFitness> >& make_checkpoint(eoParser& _parser, eoState& _state, eoEvalFuncCounter<eoOneMax<eoMinimizingFitness> >& _eval, eoContinue<eoOneMax<eoMinimizingFitness> >& _continue)
|
||||
{
|
||||
return do_make_checkpoint(_parser, _state, _eval, _continue);
|
||||
}
|
||||
|
|
@ -114,7 +114,7 @@ eoAlgo<eoOneMax<eoMinimizingFitness> >& make_algo_scalar(eoParser& _parser, eoS
|
|||
return do_make_algo_scalar(_parser, _state, _eval, _continue, _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
|
||||
#include <do/make_run.h>
|
||||
void run_ea(eoAlgo<eoOneMax<double> >& _ga, eoPop<eoOneMax<double> >& _pop)
|
||||
|
|
@ -126,4 +126,3 @@ void run_ea(eoAlgo<eoOneMax<eoMinimizingFitness> >& _ga, eoPop<eoOneMax<eoMinimi
|
|||
{
|
||||
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<eoOneMax>
|
||||
*
|
||||
* 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(eoParameterLoader& _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_OneMax.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 eoOneMaxMonop MUST derive from eoMonOp<eoOneMax>
|
||||
*/
|
||||
#include "eoOneMaxMutation.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 eoOneMaxBinCrossover MUST derive from eoBinOp<eoOneMax>
|
||||
* OR
|
||||
* OR
|
||||
* class eoOneMaxQuadCrossover MUST derive from eoQuadOp<eoOneMax>
|
||||
*/
|
||||
// #include "eoOneMaxBinOp.h"
|
||||
|
|
@ -61,9 +61,9 @@
|
|||
* This function builds the operators that will be applied to the eoOneMax
|
||||
*
|
||||
* 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 eoOneMaxQuadCrossover<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 eoOneMaxSecondCrossover<Indi>(varType _anyVariable);
|
||||
cross = new eoOneMaxSecondCrossover<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 eoOneMaxMutation<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 eoOneMaxSecondMutation<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
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ double binary_value (const Particle & _particle)
|
|||
{
|
||||
double sum = 0;
|
||||
for (unsigned i = 0; i < _particle.size(); i++)
|
||||
sum +=_particle[i];
|
||||
sum +=_particle[i];
|
||||
return (sum);
|
||||
}
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ void main_function(int argc, char **argv)
|
|||
// PARAMETRES
|
||||
// all parameters are hard-coded!
|
||||
const unsigned int SEED = 42; // seed for random number generator
|
||||
|
||||
|
||||
const unsigned int MAX_GEN=500;
|
||||
const unsigned int VEC_SIZE = 10;
|
||||
const unsigned int POP_SIZE = 20;
|
||||
|
|
@ -47,10 +47,10 @@ void main_function(int argc, char **argv)
|
|||
|
||||
const double VELOCITY_INIT_MIN= -1;
|
||||
const double VELOCITY_INIT_MAX= 1;
|
||||
|
||||
|
||||
const double VELOCITY_MIN= -1.5;
|
||||
const double VELOCITY_MAX= 1.5;
|
||||
|
||||
|
||||
const double INERTIA= 1;
|
||||
const double LEARNING_FACTOR1= 1.7;
|
||||
const double LEARNING_FACTOR2= 2.3;
|
||||
|
|
@ -63,9 +63,9 @@ void main_function(int argc, char **argv)
|
|||
// you'll aways get the same result, NOT a random run
|
||||
rng.reseed(SEED);
|
||||
|
||||
|
||||
|
||||
/// SWARM
|
||||
// population <=> swarm
|
||||
// population <=> swarm
|
||||
eoPop<Particle> pop;
|
||||
|
||||
/// EVALUATION
|
||||
|
|
@ -78,8 +78,8 @@ void main_function(int argc, char **argv)
|
|||
//////////////
|
||||
// ring topology
|
||||
eoRingTopology<Particle> topology(NEIGHBORHOOD_SIZE);
|
||||
|
||||
|
||||
|
||||
|
||||
/////////////////////
|
||||
// INITIALIZATION
|
||||
////////////////////
|
||||
|
|
@ -87,7 +87,7 @@ void main_function(int argc, char **argv)
|
|||
eoUniformGenerator<bool> uGen;
|
||||
eoInitFixedLength < Particle > random (VEC_SIZE, uGen);
|
||||
pop.append (POP_SIZE, random);
|
||||
|
||||
|
||||
// velocities initialization component
|
||||
eoUniformGenerator < double >sGen (VELOCITY_INIT_MIN, VELOCITY_INIT_MAX);
|
||||
eoVelocityInitFixedLength < Particle > veloRandom (VEC_SIZE, sGen);
|
||||
|
|
@ -101,23 +101,23 @@ void main_function(int argc, char **argv)
|
|||
// - the first best positions of each particle
|
||||
// - setups the topology
|
||||
eoInitializer <Particle> fullInit(eval,veloRandom,localInit,topology,pop);
|
||||
|
||||
|
||||
// Full initialization here to be able to print the initial population
|
||||
// Else: give the "init" component in the eoEasyPSO constructor
|
||||
fullInit();
|
||||
|
||||
|
||||
/////////////
|
||||
// OUTPUT
|
||||
////////////
|
||||
// sort pop before printing it!
|
||||
pop.sort();
|
||||
|
||||
|
||||
// Print (sorted) the initial population (raw printout)
|
||||
cout << "INITIAL POPULATION:" << endl;
|
||||
for (unsigned i = 0; i < pop.size(); ++i)
|
||||
cout << "\t best fit=" << pop[i] << endl;
|
||||
cout << "\t best fit=" << pop[i] << endl;
|
||||
|
||||
|
||||
|
||||
///////////////
|
||||
/// VELOCITY
|
||||
//////////////
|
||||
|
|
@ -148,7 +148,7 @@ void main_function(int argc, char **argv)
|
|||
////////////////////////////////////////
|
||||
// standard PSO requires
|
||||
// stopping criteria, evaluation,velocity, flight
|
||||
|
||||
|
||||
eoEasyPSO<Particle> pso(genCont, eval, velocity, flight);
|
||||
|
||||
// Apply the algo to the swarm - that's it!
|
||||
|
|
@ -159,7 +159,7 @@ void main_function(int argc, char **argv)
|
|||
pop.sort();
|
||||
cout << "FINAL POPULATION:" << endl;
|
||||
for (unsigned i = 0; i < pop.size(); ++i)
|
||||
cout << "\t best fit=" << pop[i] << endl;
|
||||
cout << "\t best fit=" << pop[i] << endl;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -167,14 +167,14 @@ void main_function(int argc, char **argv)
|
|||
// A main that catches the exceptions
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
{
|
||||
try
|
||||
{
|
||||
main_function(argc, argv);
|
||||
main_function(argc, argv);
|
||||
}
|
||||
catch(exception& e)
|
||||
{
|
||||
cout << "Exception: " << e.what() << '\n';
|
||||
cout << "Exception: " << e.what() << '\n';
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
|
|
|||
|
|
@ -8,21 +8,21 @@ INCLUDE_DIRECTORIES(${EO_SOURCE_DIR}/src)
|
|||
### 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)
|
||||
|
||||
######################################################################################
|
||||
### 3) Define your targets
|
||||
######################################################################################
|
||||
|
||||
ADD_EXECUTABLE(BinaryPSO BinaryPSO.cpp)
|
||||
ADD_EXECUTABLE(RealPSO RealPSO.cpp)
|
||||
ADD_EXECUTABLE(BinaryPSO BinaryPSO.cpp)
|
||||
ADD_EXECUTABLE(RealPSO RealPSO.cpp)
|
||||
|
||||
######################################################################################
|
||||
### 4) Optionnal
|
||||
|
|
@ -49,4 +49,3 @@ INSTALL(TARGETS BinaryPSO RUNTIME DESTINATION share/eo/examples/Lesson6 COMPONEN
|
|||
INSTALL(TARGETS RealPSO RUNTIME DESTINATION share/eo/examples/Lesson6 COMPONENT examples)
|
||||
|
||||
######################################################################################
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
### This Makefile is part of the tutorial of the EO library
|
||||
# Unlike other Makefiles in EO, it is not using the automake/autoconf
|
||||
# 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
|
||||
|
||||
|
|
@ -10,12 +10,12 @@ 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,
|
||||
# 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 -pg -o $@ $*.cpp
|
||||
#$(DIR_EO)/utils/libeoutils.a $(DIR_EO)/libeo.a
|
||||
.cpp: ; $(CXX) -DPACKAGE=\"eo\" -DVERSION=\"0.9.3\" -I. -I$(DIR_EO) -Wall -g -pg -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 -pg $*.cpp
|
||||
|
||||
|
|
@ -27,5 +27,5 @@ lesson6 : $(PSO)
|
|||
|
||||
all : $(ALL)
|
||||
|
||||
clean :
|
||||
clean :
|
||||
@/bin/rm $(ALL) *.o *.sav *.xg *.status *~
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ FitT real_value (const Particle & _particle)
|
|||
{
|
||||
double sum = 0;
|
||||
for (unsigned i = 0; i < _particle.size(); i++)
|
||||
sum += pow(_particle[i],2);
|
||||
sum += pow(_particle[i],2);
|
||||
return (sqrt(sum));
|
||||
}
|
||||
|
||||
|
|
@ -38,21 +38,21 @@ void main_function(int argc, char **argv)
|
|||
// PARAMETRES
|
||||
// all parameters are hard-coded!
|
||||
const unsigned int SEED = 42; // seed for random number generator
|
||||
|
||||
|
||||
const unsigned int MAX_GEN=100;
|
||||
const unsigned int VEC_SIZE = 2;
|
||||
const unsigned int POP_SIZE = 20;
|
||||
const unsigned int NEIGHBORHOOD_SIZE= 5;
|
||||
|
||||
|
||||
const double POS_INIT_MIN= -2;
|
||||
const double POS_INIT_MAX= 2;
|
||||
|
||||
|
||||
const double VELOCITY_INIT_MIN= -1;
|
||||
const double VELOCITY_INIT_MAX= 1;
|
||||
|
||||
|
||||
const double VELOCITY_MIN= -1.5;
|
||||
const double VELOCITY_MAX= 1.5;
|
||||
|
||||
|
||||
const double INERTIA= 1;
|
||||
const double LEARNING_FACTOR1= 1.7;
|
||||
const double LEARNING_FACTOR2= 2.3;
|
||||
|
|
@ -64,9 +64,9 @@ void main_function(int argc, char **argv)
|
|||
// you'll aways get the same result, NOT a random run
|
||||
rng.reseed(SEED);
|
||||
|
||||
|
||||
|
||||
/// SWARM
|
||||
// population <=> swarm
|
||||
// population <=> swarm
|
||||
eoPop<Particle> pop;
|
||||
|
||||
/// EVALUATION
|
||||
|
|
@ -79,8 +79,8 @@ void main_function(int argc, char **argv)
|
|||
//////////////
|
||||
// linear topology
|
||||
eoLinearTopology<Particle> topology(NEIGHBORHOOD_SIZE);
|
||||
|
||||
|
||||
|
||||
|
||||
/////////////////////
|
||||
// INITIALIZATION
|
||||
////////////////////
|
||||
|
|
@ -88,7 +88,7 @@ void main_function(int argc, char **argv)
|
|||
eoUniformGenerator < double >uGen (POS_INIT_MIN, POS_INIT_MAX);
|
||||
eoInitFixedLength < Particle > random (VEC_SIZE, uGen);
|
||||
pop.append (POP_SIZE, random);
|
||||
|
||||
|
||||
// velocities initialization component
|
||||
eoUniformGenerator < double >sGen (VELOCITY_INIT_MIN, VELOCITY_INIT_MAX);
|
||||
eoVelocityInitFixedLength < Particle > veloRandom (VEC_SIZE, sGen);
|
||||
|
|
@ -102,23 +102,23 @@ void main_function(int argc, char **argv)
|
|||
// - the first best positions of each particle
|
||||
// - setups the topology
|
||||
eoInitializer <Particle> fullInit(eval,veloRandom,localInit,topology,pop);
|
||||
|
||||
|
||||
// Full initialization here to be able to print the initial population
|
||||
// Else: give the "init" component in the eoEasyPSO constructor
|
||||
fullInit();
|
||||
|
||||
|
||||
/////////////
|
||||
// OUTPUT
|
||||
////////////
|
||||
// sort pop before printing it!
|
||||
pop.sort();
|
||||
|
||||
|
||||
// Print (sorted) the initial population (raw printout)
|
||||
cout << "INITIAL POPULATION:" << endl;
|
||||
for (unsigned i = 0; i < pop.size(); ++i)
|
||||
cout << "\t best fit=" << pop[i] << endl;
|
||||
cout << "\t best fit=" << pop[i] << endl;
|
||||
|
||||
|
||||
|
||||
///////////////
|
||||
/// VELOCITY
|
||||
//////////////
|
||||
|
|
@ -149,7 +149,7 @@ void main_function(int argc, char **argv)
|
|||
////////////////////////////////////////
|
||||
// standard PSO requires
|
||||
// stopping criteria, evaluation,velocity, flight
|
||||
|
||||
|
||||
eoEasyPSO<Particle> pso(genCont, eval, velocity, flight);
|
||||
|
||||
// Apply the algo to the swarm - that's it!
|
||||
|
|
@ -160,7 +160,7 @@ void main_function(int argc, char **argv)
|
|||
pop.sort();
|
||||
cout << "FINAL POPULATION:" << endl;
|
||||
for (unsigned i = 0; i < pop.size(); ++i)
|
||||
cout << "\t best fit=" << pop[i] << endl;
|
||||
cout << "\t best fit=" << pop[i] << endl;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -168,14 +168,14 @@ void main_function(int argc, char **argv)
|
|||
// A main that catches the exceptions
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
{
|
||||
try
|
||||
{
|
||||
main_function(argc, argv);
|
||||
main_function(argc, argv);
|
||||
}
|
||||
catch(exception& e)
|
||||
{
|
||||
cout << "Exception: " << e.what() << '\n';
|
||||
cout << "Exception: " << e.what() << '\n';
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
|
|
|||
|
|
@ -3,22 +3,22 @@ SUBDIRS = Lesson1 Lesson2 Lesson3 Lesson4 Lesson5 Lesson6
|
|||
all:
|
||||
for i in $(SUBDIRS); do cd $$i && $(MAKE) all; cd ..; done
|
||||
|
||||
lesson1 :
|
||||
lesson1 :
|
||||
cd Lesson1; make
|
||||
|
||||
lesson2 :
|
||||
lesson2 :
|
||||
cd Lesson2; make
|
||||
|
||||
lesson3 :
|
||||
lesson3 :
|
||||
cd Lesson3; make
|
||||
|
||||
lesson4 :
|
||||
lesson4 :
|
||||
cd Lesson4; make
|
||||
|
||||
lesson5 :
|
||||
lesson5 :
|
||||
cd Lesson5; make
|
||||
|
||||
lesson6 :
|
||||
lesson6 :
|
||||
cd Lesson6; make
|
||||
|
||||
#empty dist and distdir to let top-level 'make' do its job
|
||||
|
|
|
|||
|
|
@ -2,12 +2,11 @@ Eo Tutorial - corresponding to EO version 0.9.1+
|
|||
|
||||
To start the tutorial, read index.html in your favorite browser.
|
||||
|
||||
Many things are missing, including many solutions for the exercises,
|
||||
Many things are missing, including many solutions for the exercises,
|
||||
the introduction to EC and most of the Component-based pages.
|
||||
More important, all examples of this tutorial have only been tested
|
||||
on a Linux computer, and the Makefile will not work with MS-Windows
|
||||
More important, all examples of this tutorial have only been tested
|
||||
on a Linux computer, and the Makefile will not work with MS-Windows
|
||||
systems. Any help is welcome!
|
||||
|
||||
Be patient ...
|
||||
Be patient ...
|
||||
evoMarc
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Reference in a new issue