diff --git a/eo/src/eo b/eo/src/eo index 95b804082..b3c5149dc 100644 --- a/eo/src/eo +++ b/eo/src/eo @@ -61,46 +61,26 @@ #include #include -//#include - -//#include -//#include #include -#include -#include #include -//#include -//#include -//#include #include -//#include -//#include -//#include -//#include -//#include -//#include - #include -#include -#include -#include // Evaluation functions #include #include -// Continuators -// #include // already included in the following +// Continuators - all include eoContinue.h #include #include #include #include // Selection -// the eoSelectOne +// the eoSelectOne's #include #include #include @@ -111,7 +91,9 @@ #include #include #include -// other batch selections +// other batch selections +// DetSelect probably shoudl be turned into an eoSelectOne +// (using setup and an index) #include @@ -127,14 +109,7 @@ #include #include -//#include -//#include -//#include -//#include -//#include - -//#include - +// a simple transformer #include // Algorithms @@ -151,16 +126,12 @@ #include // aliens -//#include #include //----------------------------------------------------------------------------- // to be continued ... //----------------------------------------------------------------------------- -/* -//#include -//#include -*/ + //----------------------------------------------------------------------------- #endif _eo_ diff --git a/eo/src/eoGenericQuadOp.h b/eo/src/eoGenericQuadOp.h index 0df6b966d..95b3667de 100644 --- a/eo/src/eoGenericQuadOp.h +++ b/eo/src/eoGenericQuadOp.h @@ -50,7 +50,7 @@ class eoGenericQuadOp: public eoOp, public eoBF public: /// Ctor eoGenericQuadOp() - : eoOp( eoOp::binary ) {}; + : eoOp( eoOp::quadratic ) {}; virtual string className() const {return "eoGenericQuadOp";}; }; diff --git a/eo/src/es/eoEsChromInit.h b/eo/src/es/eoEsChromInit.h index 41fa33ba4..43a61af0d 100644 --- a/eo/src/es/eoEsChromInit.h +++ b/eo/src/es/eoEsChromInit.h @@ -27,7 +27,7 @@ #ifndef _eoEsChromInit_H #define _eoEsChromInit_H -#include +#include #include #include #include @@ -59,7 +59,7 @@ class eoEsChromInit : public eoInit public : typedef typename EOT::Fitness FitT; - eoEsChromInit(eoEsObjectiveBounds& _bounds) : bounds(_bounds) + eoEsChromInit(eoRealVectorBounds& _bounds) : bounds(_bounds) {} void operator()(EOT& _eo) @@ -71,29 +71,28 @@ private : eoEsSimple& create(eoEsSimple& result) { - result.resize(bounds.chromSize()); + result.resize(bounds.size()); - for (unsigned i = 0; i < result.size(); ++i) - { - result[i] = bounds.minimum(i) + rng.uniform(bounds.maximum(i) - bounds.minimum(i)); - } + bounds.uniform(result); + + result.stdev = 0.3*bounds.averageRange(); // 0.3 should be read as a parameter return result; } eoEsStdev create(eoEsStdev& result) { - unsigned chromSize = bounds.chromSize(); + unsigned chromSize = bounds.size(); result.resize(chromSize); result.stdevs.resize(chromSize); + bounds.uniform(result); for (unsigned i = 0; i < chromSize; ++i) { - double length = bounds.maximum(i) - bounds.minimum(i); - result[i] = bounds.minimum(i) + rng.uniform(length); - - // Just a guess at the stdevs (anyone a better idea?) - result.stdevs[i] = rng.uniform(length); + // uniformly in [0.2,0.4) + // scaled by the range of the object variable) + // Just a guess (anyone a better idea?) + result.stdevs[i] = bounds.range(i) * (0.2 + 0.2*eo::rng.uniform()); } return result; @@ -101,7 +100,7 @@ private : eoEsFull create(eoEsFull& result) { - unsigned chromSize = bounds.chromSize(); + unsigned chromSize = bounds.size(); result.resize(chromSize); result.stdevs.resize(chromSize); @@ -128,7 +127,7 @@ private : return result; } - eoEsObjectiveBounds& bounds; + eoRealVectorBounds& bounds; }; #endif diff --git a/eo/src/es/eoRealBounds.h b/eo/src/es/eoRealBounds.h index 97b5f5515..19b4c1e90 100644 --- a/eo/src/es/eoRealBounds.h +++ b/eo/src/es/eoRealBounds.h @@ -204,11 +204,15 @@ public: // virtual desctructor (to avoid warining?) virtual ~eoRealVectorBounds(){} + // Default Ctor + eoRealVectorBounds() : + vector(0) {} + /** Simple bounds = minimum and maximum (allowed) */ // Ctor: same bonds for everybody, explicit - eoRealVectorBounds(unsigned _dim, double _min=0, double _max=1) : + eoRealVectorBounds(unsigned _dim, double _min, double _max) : vector(_dim, new eoRealInterval(_min, _max)) { if (_max-_min<=0) @@ -328,7 +332,7 @@ public: Simple bounds = minimum and maximum (allowed) */ // Ctor: nothing to do! - eoRealVectorNoBounds(unsigned _dim=0) : eoRealVectorBounds(_dim) {} + eoRealVectorNoBounds(unsigned _dim=0) {} virtual bool isBounded(unsigned) {return false;} diff --git a/eo/test/t-eobin.cpp b/eo/test/t-eobin.cpp index 55dee20b7..feee305d3 100644 --- a/eo/test/t-eobin.cpp +++ b/eo/test/t-eobin.cpp @@ -25,8 +25,8 @@ #include // cout #include // ostrstream, istrstream -#include // eoBin - +#include // general EO +#include // bitstring representation & operators #include "binary_value.h" //----------------------------------------------------------------------------- diff --git a/eo/tutorial/Lesson1/FirstBitGA.cpp b/eo/tutorial/Lesson1/FirstBitGA.cpp index 97b5a0f89..1ea79a766 100644 --- a/eo/tutorial/Lesson1/FirstBitGA.cpp +++ b/eo/tutorial/Lesson1/FirstBitGA.cpp @@ -16,6 +16,8 @@ // REPRESENTATION //----------------------------------------------------------------------------- +// Include the corresponding file +#include // bitstring representation & operators // define your individuals typedef eoBin Indi; // A bitstring with fitness double @@ -87,6 +89,11 @@ void main_function(int argc, char **argv) // Print (sorted) intial population (raw printout) cout << "Initial Population" << endl; cout << pop; + // shuffle - this is a test + pop.shuffle(); + // Print (sorted) intial population (raw printout) + cout << "Shuffled Population" << endl; + cout << pop; // ENGINE ///////////////////////////////////// diff --git a/eo/tutorial/Lesson1/FirstRealGA.cpp b/eo/tutorial/Lesson1/FirstRealGA.cpp index f1b719a6c..5e1c69e4d 100644 --- a/eo/tutorial/Lesson1/FirstRealGA.cpp +++ b/eo/tutorial/Lesson1/FirstRealGA.cpp @@ -16,6 +16,8 @@ // REPRESENTATION //----------------------------------------------------------------------------- +// Include the corresponding file +#include // real-representation & operators // define your individuals typedef eoReal Indi; diff --git a/eo/tutorial/Lesson1/exercise1.3.cpp b/eo/tutorial/Lesson1/exercise1.3.cpp index c0c248c80..f2e03652c 100644 --- a/eo/tutorial/Lesson1/exercise1.3.cpp +++ b/eo/tutorial/Lesson1/exercise1.3.cpp @@ -17,6 +17,8 @@ #include //----------------------------------------------------------------------------- +// Include the corresponding file +#include // bitstring representation & operators // define your individuals typedef eoBin Indi; // A bitstring with fitness double diff --git a/eo/tutorial/Lesson2/FirstBitEA.cpp b/eo/tutorial/Lesson2/FirstBitEA.cpp index 0c34adae6..a5b3e0dee 100644 --- a/eo/tutorial/Lesson2/FirstBitEA.cpp +++ b/eo/tutorial/Lesson2/FirstBitEA.cpp @@ -16,6 +16,8 @@ // REPRESENTATION //----------------------------------------------------------------------------- +// Include the corresponding file +#include // bitstring representation & operators // define your individuals typedef eoBin Indi; // A bitstring with fitness double diff --git a/eo/tutorial/Lesson2/FirstRealEA.cpp b/eo/tutorial/Lesson2/FirstRealEA.cpp index 7c5b45808..934fb0c35 100644 --- a/eo/tutorial/Lesson2/FirstRealEA.cpp +++ b/eo/tutorial/Lesson2/FirstRealEA.cpp @@ -16,6 +16,8 @@ // REPRESENTATION //----------------------------------------------------------------------------- +// Include the corresponding file +#include // real-valued representation & operators // define your individuals typedef eoReal Indi; diff --git a/eo/tutorial/Lesson2/exercise2.3.cpp b/eo/tutorial/Lesson2/exercise2.3.cpp index 489956985..09b6bbc01 100644 --- a/eo/tutorial/Lesson2/exercise2.3.cpp +++ b/eo/tutorial/Lesson2/exercise2.3.cpp @@ -16,6 +16,8 @@ // REPRESENTATION //----------------------------------------------------------------------------- +// Include the corresponding file +#include // bitstring representation & operators // define your individuals typedef eoBin Indi; // A bitstring with fitness double diff --git a/eo/tutorial/Lesson3/SecondBitEA.cpp b/eo/tutorial/Lesson3/SecondBitEA.cpp index 5ec568828..60412fb18 100644 --- a/eo/tutorial/Lesson3/SecondBitEA.cpp +++ b/eo/tutorial/Lesson3/SecondBitEA.cpp @@ -20,6 +20,8 @@ // REPRESENTATION //----------------------------------------------------------------------------- +// Include the corresponding file +#include // bitstring representation & operators // define your genotype and fitness types typedef eoBin Indi; diff --git a/eo/tutorial/Lesson3/exercise3.1.cpp b/eo/tutorial/Lesson3/exercise3.1.cpp index 66532bb96..5264002e8 100644 --- a/eo/tutorial/Lesson3/exercise3.1.cpp +++ b/eo/tutorial/Lesson3/exercise3.1.cpp @@ -21,6 +21,8 @@ // REPRESENTATION //----------------------------------------------------------------------------- +// Include the corresponding file +#include // bitstring representation & operators // define your genotype and fitness types typedef eoBin Indi;