I have separated the include files into

eo   everything that is general to any representation
   es.h everything about real representation (in es dir)
   ga.h everything related to bitstring representation (in ga dir)

To be continued by gp.h, and ...

This has lead to some slight modifications in test file eobin and all tutorial
examples files...
This commit is contained in:
evomarc 2001-01-27 07:41:46 +00:00
commit 41ff11bd7f
13 changed files with 51 additions and 56 deletions

View file

@ -61,46 +61,26 @@
#include <eoVariableLength.h>
#include <eoFixedLength.h>
//#include <eoID.h>
//#include <eoVector.h>
//#include <eo1d.h>
#include <other/eoString.h>
#include <ga/eoBin.h>
#include <es/eoReal.h>
#include <eoInit.h>
//#include <eoUniform.h>
//#include <eoNormal.h>
//#include <eoNegExp.h>
#include <eoOp.h>
//#include <eoDup.h>
//#include <eoKill.h>
//#include <eoTranspose.h>
//#include <eoXOver2.h>
//#include <eoUniformXOver.h>
//#include <eoMutation.h>
#include <eoPop.h>
#include <ga/eoBitOp.h>
#include <es/eoRealOp.h>
#include <es/eoNormalMutation.h>
// Evaluation functions
#include <eoEvalFunc.h>
#include <eoEvalFuncPtr.h>
// Continuators
// #include <eoContinue.h> // already included in the following
// Continuators - all include eoContinue.h
#include <eoCombinedContinue.h>
#include <eoGenContinue.h>
#include <eoSteadyFitContinue.h>
#include <eoFitContinue.h>
// Selection
// the eoSelectOne
// the eoSelectOne's
#include <eoRandomSelect.h>
#include <eoDetTournamentSelect.h>
#include <eoProportionalSelect.h>
@ -111,7 +91,9 @@
#include <eoSelectPerc.h>
#include <eoSelectNumber.h>
#include <eoSelectMany.h>
// other batch selections
// other batch selections
// DetSelect probably shoudl be turned into an eoSelectOne
// (using setup and an index)
#include <eoDetSelect.h>
@ -127,14 +109,7 @@
#include <eoProportionalGOpSel.h>
#include <eoSequentialGOpSel.h>
//#include <eoLottery.h>
//#include <eoBreeder.h>
//#include <eoInsertion.h>
//#include <eoInclusion.h>
//#include <eoGeneration.h>
//#include <eoProportionalOpSel.h>
// a simple transformer
#include <eoSGATransform.h>
// Algorithms
@ -151,16 +126,12 @@
#include <utils/checkpointing>
// aliens
//#include <eoNonUniform.h>
#include <eoCounter.h>
//-----------------------------------------------------------------------------
// to be continued ...
//-----------------------------------------------------------------------------
/*
//#include <eoFitness.h>
//#include <eoProblem.h>
*/
//-----------------------------------------------------------------------------
#endif _eo_

View file

@ -50,7 +50,7 @@ class eoGenericQuadOp: public eoOp<EOT>, public eoBF<EOT &, EOT &, bool>
public:
/// Ctor
eoGenericQuadOp()
: eoOp<EOT>( eoOp<EOT>::binary ) {};
: eoOp<EOT>( eoOp<EOT>::quadratic ) {};
virtual string className() const {return "eoGenericQuadOp";};
};

View file

@ -27,7 +27,7 @@
#ifndef _eoEsChromInit_H
#define _eoEsChromInit_H
#include <es/eoEsObjectiveBounds.h>
#include <es/eoRealBounds.h>
#include <es/eoEsSimple.h>
#include <es/eoEsStdev.h>
#include <es/eoEsFull.h>
@ -59,7 +59,7 @@ class eoEsChromInit : public eoInit<EOT>
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<FitT>& create(eoEsSimple<FitT>& 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<FitT> create(eoEsStdev<FitT>& 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<FitT> create(eoEsFull<FitT>& 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

View file

@ -204,11 +204,15 @@ public:
// virtual desctructor (to avoid warining?)
virtual ~eoRealVectorBounds(){}
// Default Ctor
eoRealVectorBounds() :
vector<eoRealBounds *>(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<eoRealBounds *>(_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;}

View file

@ -25,8 +25,8 @@
#include <iostream> // cout
#include <strstream> // ostrstream, istrstream
#include <eo> // eoBin
#include <eo> // general EO
#include <ga.h> // bitstring representation & operators
#include "binary_value.h"
//-----------------------------------------------------------------------------

View file

@ -16,6 +16,8 @@
// REPRESENTATION
//-----------------------------------------------------------------------------
// Include the corresponding file
#include <ga.h> // bitstring representation & operators
// define your individuals
typedef eoBin<double> 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
/////////////////////////////////////

View file

@ -16,6 +16,8 @@
// REPRESENTATION
//-----------------------------------------------------------------------------
// Include the corresponding file
#include <es.h> // real-representation & operators
// define your individuals
typedef eoReal<double> Indi;

View file

@ -17,6 +17,8 @@
#include <eo>
//-----------------------------------------------------------------------------
// Include the corresponding file
#include <ga.h> // bitstring representation & operators
// define your individuals
typedef eoBin<double> Indi; // A bitstring with fitness double

View file

@ -16,6 +16,8 @@
// REPRESENTATION
//-----------------------------------------------------------------------------
// Include the corresponding file
#include <ga.h> // bitstring representation & operators
// define your individuals
typedef eoBin<double> Indi; // A bitstring with fitness double

View file

@ -16,6 +16,8 @@
// REPRESENTATION
//-----------------------------------------------------------------------------
// Include the corresponding file
#include <es.h> // real-valued representation & operators
// define your individuals
typedef eoReal<double> Indi;

View file

@ -16,6 +16,8 @@
// REPRESENTATION
//-----------------------------------------------------------------------------
// Include the corresponding file
#include <ga.h> // bitstring representation & operators
// define your individuals
typedef eoBin<double> Indi; // A bitstring with fitness double

View file

@ -20,6 +20,8 @@
// REPRESENTATION
//-----------------------------------------------------------------------------
// Include the corresponding file
#include <ga.h> // bitstring representation & operators
// define your genotype and fitness types
typedef eoBin<double> Indi;

View file

@ -21,6 +21,8 @@
// REPRESENTATION
//-----------------------------------------------------------------------------
// Include the corresponding file
#include <ga.h> // bitstring representation & operators
// define your genotype and fitness types
typedef eoBin<double> Indi;