rename everything from 'do' to 'edo'

This commit is contained in:
Johann Dreo 2011-01-27 11:23:23 +01:00
commit d618ab07df
94 changed files with 2936 additions and 1534 deletions

View file

@ -2,8 +2,8 @@
### 1) Set all needed source files for the project
######################################################################################
FILE(GLOB HDRS *.h do)
INSTALL(FILES ${HDRS} DESTINATION include/do COMPONENT headers)
FILE(GLOB HDRS *.h edo)
INSTALL(FILES ${HDRS} DESTINATION include/edo COMPONENT headers)
FILE(GLOB SOURCES *.cpp)

59
src/do
View file

@ -1,59 +0,0 @@
// (c) Thales group, 2010
/*
Authors:
Johann Dreo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _do_
#define _do_
#include "doAlgo.h"
#include "doEDASA.h"
#include "doEDA.h"
#include "doDistrib.h"
#include "doUniform.h"
#include "doNormalMono.h"
#include "doNormalMulti.h"
#include "doEstimator.h"
#include "doEstimatorUniform.h"
#include "doEstimatorNormalMono.h"
#include "doEstimatorNormalMulti.h"
#include "doModifier.h"
#include "doModifierDispersion.h"
#include "doModifierMass.h"
#include "doUniformCenter.h"
#include "doNormalMonoCenter.h"
#include "doNormalMultiCenter.h"
#include "doSampler.h"
#include "doSamplerUniform.h"
#include "doSamplerNormalMono.h"
#include "doSamplerNormalMulti.h"
#include "doVectorBounds.h"
#include "doBounder.h"
#include "doBounderNo.h"
#include "doBounderBound.h"
#include "doBounderRng.h"
#include "doContinue.h"
#include "utils/doCheckPoint.h"
#include "utils/doStat.h"
#include "utils/doStatUniform.h"
#include "utils/doStatNormalMono.h"
#include "utils/doStatNormalMulti.h"
#include "utils/doFileSnapshot.h"
#include "utils/doPopStat.h"
#endif // !_do_
// Local Variables:
// mode: C++
// End:

View file

@ -1,8 +0,0 @@
// (c) Thales group, 2010
/*
Authors:
Johann Dreo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#include "do"

View file

@ -1,23 +0,0 @@
// (c) Thales group, 2010
/*
Authors:
Johann Dreo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _doAlgo_h
#define _doAlgo_h
#include <eoAlgo.h>
template < typename D >
class doAlgo : public eoAlgo< typename D::EOType >
{
//! Alias for the type
typedef typename D::EOType EOT;
public:
virtual ~doAlgo(){}
};
#endif // !_doAlgo_h

View file

@ -1,34 +0,0 @@
// (c) Thales group, 2010
/*
Authors:
Johann Dreo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _doBounder_h
#define _doBounder_h
#include <eoFunctor.h>
template < typename EOT >
class doBounder : public eoUF< EOT&, void >
{
public:
doBounder( EOT min = EOT(1, 0), EOT max = EOT(1, 0) )
: _min(min), _max(max)
{
assert(_min.size() > 0);
assert(_min.size() == _max.size());
}
// virtual void operator()( EOT& ) = 0 (provided by eoUF< A1, R >)
EOT& min(){return _min;}
EOT& max(){return _max;}
private:
EOT _min;
EOT _max;
};
#endif // !_doBounder_h

View file

@ -1,42 +0,0 @@
// (c) Thales group, 2010
/*
Authors:
Johann Dreo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _doBounderBound_h
#define _doBounderBound_h
#include "doBounder.h"
template < typename EOT >
class doBounderBound : public doBounder< EOT >
{
public:
doBounderBound( EOT min, EOT max )
: doBounder< EOT >( min, max )
{}
void operator()( EOT& x )
{
unsigned int size = x.size();
assert(size > 0);
for (unsigned int d = 0; d < size; ++d) // browse all dimensions
{
if (x[d] < this->min()[d])
{
x[d] = this->min()[d];
continue;
}
if (x[d] > this->max()[d])
{
x[d] = this->max()[d];
}
}
}
};
#endif // !_doBounderBound_h

View file

@ -1,20 +0,0 @@
// (c) Thales group, 2010
/*
Authors:
Johann Dreo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _doBounderNo_h
#define _doBounderNo_h
#include "doBounder.h"
template < typename EOT >
class doBounderNo : public doBounder< EOT >
{
public:
void operator()( EOT& ) {}
};
#endif // !_doBounderNo_h

View file

@ -1,42 +0,0 @@
// (c) Thales group, 2010
/*
Authors:
Johann Dreo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _doBounderRng_h
#define _doBounderRng_h
#include "doBounder.h"
template < typename EOT >
class doBounderRng : public doBounder< EOT >
{
public:
doBounderRng( EOT min, EOT max, eoRndGenerator< double > & rng )
: doBounder< EOT >( min, max ), _rng(rng)
{}
void operator()( EOT& x )
{
unsigned int size = x.size();
assert(size > 0);
for (unsigned int d = 0; d < size; ++d) // browse all dimensions
{
// FIXME: attention: les bornes RNG ont les memes bornes quelque soit les dimensions idealement on voudrait avoir des bornes differentes pour chaque dimensions.
if (x[d] < this->min()[d] || x[d] > this->max()[d])
{
x[d] = _rng();
}
}
}
private:
eoRndGenerator< double> & _rng;
};
#endif // !_doBounderRng_h

View file

@ -1,35 +0,0 @@
// (c) Thales group, 2010
/*
Authors:
Johann Dreo <johann.dreo@thalesgroup.com>
*/
#ifndef _doBounderUniform_h
#define _doBounderUniform_h
#include "doBounder.h"
template < typename EOT >
class doBounderUniform : public doBounder< EOT >
{
public:
doBounderUniform( EOT min, EOT max )
: doBounder< EOT >( min, max )
{}
void operator()( EOT& sol )
{
unsigned int size = sol.size();
assert(size > 0);
for (unsigned int d = 0; d < size; ++d) {
if ( sol[d] < this->min()[d] || sol[d] > this->max()[d]) {
// use EO's global "rng"
sol[d] = rng.uniform( this->min()[d], this->max()[d] );
}
} // for d in size
}
};
#endif // !_doBounderUniform_h

View file

@ -1,41 +0,0 @@
// (c) Thales group, 2010
/*
Authors:
Johann Dreo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _doContinue_h
#define _doContinue_h
#include <eoFunctor.h>
#include <eoPersistent.h>
//! doContinue< EOT > classe fitted to Distribution Object library
template < typename D >
class doContinue : public eoUF< const D&, bool >, public eoPersistent
{
public:
virtual std::string className(void) const { return "doContinue"; }
void readFrom(std::istream&)
{
/* It should be implemented by subclasses ! */
}
void printOn(std::ostream&) const
{
/* It should be implemented by subclasses ! */
}
};
template < typename D >
class doDummyContinue : public doContinue< D >
{
bool operator()(const D&){ return true; }
virtual std::string className() const { return "doDummyContinue"; }
};
#endif // !_doContinue_h

View file

@ -1,23 +0,0 @@
// (c) Thales group, 2010
/*
Authors:
Johann Dreo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _doDistrib_h
#define _doDistrib_h
#include <eoFunctor.h>
template < typename EOT >
class doDistrib : public eoFunctorBase
{
public:
//! Alias for the type
typedef EOT EOType;
virtual ~doDistrib(){}
};
#endif // !_doDistrib_h

View file

@ -1,23 +0,0 @@
// (c) Thales group, 2010
/*
Authors:
Johann Dreo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _doEstimator_h
#define _doEstimator_h
#include <eoPop.h>
#include <eoFunctor.h>
template < typename D >
class doEstimator : public eoUF< eoPop< typename D::EOType >&, D >
{
public:
typedef typename D::EOType EOType;
// virtual D operator() ( eoPop< EOT >& )=0 (provided by eoUF< A1, R >)
};
#endif // !_doEstimator_h

View file

@ -1,77 +0,0 @@
// (c) Thales group, 2010
/*
Authors:
Johann Dreo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _doEstimatorNormalMono_h
#define _doEstimatorNormalMono_h
#include "doEstimator.h"
#include "doNormalMono.h"
template < typename EOT >
class doEstimatorNormalMono : public doEstimator< doNormalMono< EOT > >
{
public:
typedef typename EOT::AtomType AtomType;
class Variance
{
public:
Variance() : _sumvar(0){}
void update(AtomType v)
{
_n++;
AtomType d = v - _mean;
_mean += 1 / _n * d;
_sumvar += (_n - 1) / _n * d * d;
}
AtomType get_mean() const {return _mean;}
AtomType get_var() const {return _sumvar / (_n - 1);}
AtomType get_std() const {return sqrt( get_var() );}
private:
AtomType _n;
AtomType _mean;
AtomType _sumvar;
};
public:
doNormalMono< EOT > operator()(eoPop<EOT>& pop)
{
unsigned int popsize = pop.size();
assert(popsize > 0);
unsigned int dimsize = pop[0].size();
assert(dimsize > 0);
std::vector< Variance > var( dimsize );
for (unsigned int i = 0; i < popsize; ++i)
{
for (unsigned int d = 0; d < dimsize; ++d)
{
var[d].update( pop[i][d] );
}
}
EOT mean( dimsize );
EOT variance( dimsize );
for (unsigned int d = 0; d < dimsize; ++d)
{
mean[d] = var[d].get_mean();
variance[d] = var[d].get_var();
}
return doNormalMono< EOT >( mean, variance );
}
};
#endif // !_doEstimatorNormalMono_h

View file

@ -1,51 +0,0 @@
// (c) Thales group, 2010
/*
Authors:
Johann Dreo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _doEstimatorUniform_h
#define _doEstimatorUniform_h
#include "doEstimator.h"
#include "doUniform.h"
// TODO: calcule de la moyenne + covariance dans une classe derivee
template < typename EOT >
class doEstimatorUniform : public doEstimator< doUniform< EOT > >
{
public:
doUniform< EOT > operator()(eoPop<EOT>& pop)
{
unsigned int size = pop.size();
assert(size > 0);
EOT min = pop[0];
EOT max = pop[0];
for (unsigned int i = 1; i < size; ++i)
{
unsigned int size = pop[i].size();
assert(size > 0);
// possibilité d'utiliser std::min_element et std::max_element mais exige 2 pass au lieu d'1.
for (unsigned int d = 0; d < size; ++d)
{
if (pop[i][d] < min[d])
min[d] = pop[i][d];
if (pop[i][d] > max[d])
max[d] = pop[i][d];
}
}
return doUniform< EOT >(min, max);
}
};
#endif // !_doEstimatorUniform_h

View file

@ -1,20 +0,0 @@
// (c) Thales group, 2010
/*
Authors:
Johann Dreo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _doModifier_h
#define _doModifier_h
template < typename D >
class doModifier
{
public:
virtual ~doModifier(){}
typedef typename D::EOType EOType;
};
#endif // !_doModifier_h

View file

@ -1,23 +0,0 @@
// (c) Thales group, 2010
/*
Authors:
Johann Dreo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _doModifierDispersion_h
#define _doModifierDispersion_h
#include <eoPop.h>
#include <eoFunctor.h>
#include "doModifier.h"
template < typename D >
class doModifierDispersion : public doModifier< D >, public eoBF< D&, eoPop< typename D::EOType >&, void >
{
public:
// virtual void operator() ( D&, eoPop< D::EOType >& )=0 (provided by eoBF< A1, A2, R >)
};
#endif // !_doModifierDispersion_h

View file

@ -1,24 +0,0 @@
// (c) Thales group, 2010
/*
Authors:
Johann Dreo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _doModifierMass_h
#define _doModifierMass_h
#include <eoFunctor.h>
#include "doModifier.h"
template < typename D >
class doModifierMass : public doModifier< D >, public eoBF< D&, typename D::EOType&, void >
{
public:
//typedef typename D::EOType::AtomType AtomType; // does not work !!!
// virtual void operator() ( D&, D::EOType& )=0 (provided by eoBF< A1, A2, R >)
};
#endif // !_doModifierMass_h

View file

@ -1,38 +0,0 @@
// (c) Thales group, 2010
/*
Authors:
Johann Dreo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _doNormalMono_h
#define _doNormalMono_h
#include "doDistrib.h"
template < typename EOT >
class doNormalMono : public doDistrib< EOT >
{
public:
doNormalMono( const EOT& mean, const EOT& variance )
: _mean(mean), _variance(variance)
{
assert(_mean.size() > 0);
assert(_mean.size() == _variance.size());
}
unsigned int size()
{
assert(_mean.size() == _variance.size());
return _mean.size();
}
EOT mean(){return _mean;}
EOT variance(){return _variance;}
private:
EOT _mean;
EOT _variance;
};
#endif // !_doNormalMono_h

View file

@ -1,26 +0,0 @@
// (c) Thales group, 2010
/*
Authors:
Johann Dreo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _doNormalMonoCenter_h
#define _doNormalMonoCenter_h
#include "doModifierMass.h"
#include "doNormalMono.h"
template < typename EOT >
class doNormalMonoCenter : public doModifierMass< doNormalMono< EOT > >
{
public:
typedef typename EOT::AtomType AtomType;
void operator() ( doNormalMono< EOT >& distrib, EOT& mass )
{
distrib.mean() = mass;
}
};
#endif // !_doNormalMonoCenter_h

View file

@ -1,28 +0,0 @@
// (c) Thales group, 2010
/*
Authors:
Johann Dreo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _doNormalMultiCenter_h
#define _doNormalMultiCenter_h
#include "doModifierMass.h"
#include "doNormalMulti.h"
template < typename EOT >
class doNormalMultiCenter : public doModifierMass< doNormalMulti< EOT > >
{
public:
typedef typename EOT::AtomType AtomType;
void operator() ( doNormalMulti< EOT >& distrib, EOT& mass )
{
ublas::vector< AtomType > mean( distrib.size() );
std::copy( mass.begin(), mass.end(), mean.begin() );
distrib.mean() = mean;
}
};
#endif // !_doNormalMultiCenter_h

View file

@ -1,75 +0,0 @@
// (c) Thales group, 2010
/*
Authors:
Johann Dreo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _doSampler_h
#define _doSampler_h
#include <eoFunctor.h>
#include "doBounder.h"
#include "doBounderNo.h"
template < typename D >
class doSampler : public eoUF< D&, typename D::EOType >
{
public:
typedef typename D::EOType EOType;
doSampler(doBounder< EOType > & bounder)
: /*_dummy_bounder(),*/ _bounder(bounder)
{}
/*
doSampler()
: _dummy_bounder(), _bounder( _dummy_bounder )
{}
*/
// virtual EOType operator()( D& ) = 0 (provided by eoUF< A1, R >)
virtual EOType sample( D& ) = 0;
EOType operator()( D& distrib )
{
unsigned int size = distrib.size();
assert(size > 0);
//-------------------------------------------------------------
// Point we want to sample to get higher a set of points
// (coordinates in n dimension)
// x = {x1, x2, ..., xn}
// the sample method is implemented in the derivated class
//-------------------------------------------------------------
EOType solution(sample(distrib));
//-------------------------------------------------------------
//-------------------------------------------------------------
// Now we are bounding the distribution thanks to min and max
// parameters.
//-------------------------------------------------------------
_bounder(solution);
//-------------------------------------------------------------
return solution;
}
private:
//doBounderNo<EOType> _dummy_bounder;
//! Bounder functor
doBounder< EOType > & _bounder;
};
#endif // !_doSampler_h

View file

@ -1,71 +0,0 @@
// (c) Thales group, 2010
/*
Authors:
Johann Dreo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _doSamplerNormalMono_h
#define _doSamplerNormalMono_h
#include <utils/eoRNG.h>
#include "doSampler.h"
#include "doNormalMono.h"
#include "doBounder.h"
/**
* doSamplerNormalMono
* This class uses the NormalMono distribution parameters (bounds) to return
* a random position used for population sampling.
*/
template < typename EOT >
class doSamplerNormalMono : public doSampler< doNormalMono< EOT > >
{
public:
typedef typename EOT::AtomType AtomType;
doSamplerNormalMono( doBounder< EOT > & bounder )
: doSampler< doNormalMono< EOT > >( bounder )
{}
EOT sample( doNormalMono< EOT >& distrib )
{
unsigned int size = distrib.size();
assert(size > 0);
//-------------------------------------------------------------
// Point we want to sample to get higher a set of points
// (coordinates in n dimension)
// x = {x1, x2, ..., xn}
//-------------------------------------------------------------
EOT solution;
//-------------------------------------------------------------
//-------------------------------------------------------------
// Sampling all dimensions
//-------------------------------------------------------------
for (unsigned int i = 0; i < size; ++i)
{
AtomType mean = distrib.mean()[i];
AtomType variance = distrib.variance()[i];
AtomType random = rng.normal(mean, variance);
assert(variance >= 0);
solution.push_back(random);
}
//-------------------------------------------------------------
return solution;
}
};
#endif // !_doSamplerNormalMono_h

View file

@ -1,76 +0,0 @@
// (c) Thales group, 2010
/*
Authors:
Johann Dreo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _doSamplerUniform_h
#define _doSamplerUniform_h
#include <utils/eoRNG.h>
#include "doSampler.h"
#include "doUniform.h"
/**
* doSamplerUniform
* This class uses the Uniform distribution parameters (bounds) to return
* a random position used for population sampling.
*/
template < typename EOT, class D=doUniform<EOT> > // FIXME: D template name is there really used ?!?
class doSamplerUniform : public doSampler< doUniform< EOT > >
{
public:
typedef D Distrib;
doSamplerUniform(doBounder< EOT > & bounder)
: doSampler< doUniform<EOT> >(bounder) // FIXME: Why D is not used here ?
{}
/*
doSamplerUniform()
: doSampler< doUniform<EOT> >()
{}
*/
EOT sample( doUniform< EOT >& distrib )
{
unsigned int size = distrib.size();
assert(size > 0);
//-------------------------------------------------------------
// Point we want to sample to get higher a set of points
// (coordinates in n dimension)
// x = {x1, x2, ..., xn}
//-------------------------------------------------------------
EOT solution;
//-------------------------------------------------------------
//-------------------------------------------------------------
// Sampling all dimensions
//-------------------------------------------------------------
for (unsigned int i = 0; i < size; ++i)
{
double min = distrib.min()[i];
double max = distrib.max()[i];
double random = rng.uniform(min, max);
assert(min <= random && random <= max);
solution.push_back(random);
}
//-------------------------------------------------------------
return solution;
}
};
#endif // !_doSamplerUniform_h

View file

@ -1,23 +0,0 @@
// (c) Thales group, 2010
/*
Authors:
Johann Dreo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _doUniform_h
#define _doUniform_h
#include "doDistrib.h"
#include "doVectorBounds.h"
template < typename EOT >
class doUniform : public doDistrib< EOT >, public doVectorBounds< EOT >
{
public:
doUniform(EOT min, EOT max)
: doVectorBounds< EOT >(min, max)
{}
};
#endif // !_doUniform_h

View file

@ -1,35 +0,0 @@
// (c) Thales group, 2010
/*
Authors:
Johann Dreo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _doUniformCenter_h
#define _doUniformCenter_h
#include "doModifierMass.h"
#include "doUniform.h"
template < typename EOT >
class doUniformCenter : public doModifierMass< doUniform< EOT > >
{
public:
typedef typename EOT::AtomType AtomType;
void operator() ( doUniform< EOT >& distrib, EOT& mass )
{
for (unsigned int i = 0, n = mass.size(); i < n; ++i)
{
AtomType& min = distrib.min()[i];
AtomType& max = distrib.max()[i];
AtomType range = (max - min) / 2;
min = mass[i] - range;
max = mass[i] + range;
}
}
};
#endif // !_doUniformCenter_h

View file

@ -1,36 +0,0 @@
// (c) Thales group, 2010
/*
Authors:
Johann Dreo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _doVectorBounds_h
#define _doVectorBounds_h
template < typename EOT >
class doVectorBounds
{
public:
doVectorBounds(EOT min, EOT max)
: _min(min), _max(max)
{
assert(_min.size() > 0);
assert(_min.size() == _max.size());
}
EOT min(){return _min;}
EOT max(){return _max;}
unsigned int size()
{
assert(_min.size() == _max.size());
return _min.size();
}
private:
EOT _min;
EOT _max;
};
#endif // !_doVectorBounds_h

79
src/edo Normal file
View file

@ -0,0 +1,79 @@
/*
The Evolving Distribution Objects framework (EDO) is a template-based,
ANSI-C++ evolutionary computation library which helps you to write your
own estimation of distribution algorithms.
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
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (C) 2010 Thales group
*/
/*
Authors:
Johann Dréo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _edo_
#define _edo_
#include "edoAlgo.h"
#include "edoEDASA.h"
#include "edoEDA.h"
#include "edoDistrib.h"
#include "edoUniform.h"
#include "edoNormalMono.h"
#include "edoNormalMulti.h"
#include "edoEstimator.h"
#include "edoEstimatorUniform.h"
#include "edoEstimatorNormalMono.h"
#include "edoEstimatorNormalMulti.h"
#include "edoModifier.h"
#include "edoModifierDispersion.h"
#include "edoModifierMass.h"
#include "edoUniformCenter.h"
#include "edoNormalMonoCenter.h"
#include "edoNormalMultiCenter.h"
#include "edoSampler.h"
#include "edoSamplerUniform.h"
#include "edoSamplerNormalMono.h"
#include "edoSamplerNormalMulti.h"
#include "edoVectorBounds.h"
#include "edoBounder.h"
#include "edoBounderNo.h"
#include "edoBounderBound.h"
#include "edoBounderRng.h"
#include "edoContinue.h"
#include "utils/edoCheckPoint.h"
#include "utils/edoStat.h"
#include "utils/edoStatUniform.h"
#include "utils/edoStatNormalMono.h"
#include "utils/edoStatNormalMulti.h"
#include "utils/edoFileSnapshot.h"
#include "utils/edoPopStat.h"
#endif // !_edo_
// Local Variables:
// mode: C++
// End:

28
src/edo.cpp Normal file
View file

@ -0,0 +1,28 @@
/*
The Evolving Distribution Objects framework (EDO) is a template-based,
ANSI-C++ evolutionary computation library which helps you to write your
own estimation of distribution algorithms.
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
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (C) 2010 Thales group
*/
/*
Authors:
Caner Candan <caner.candan@thalesgroup.com>
*/
#include "edo"

44
src/edoAlgo.h Normal file
View file

@ -0,0 +1,44 @@
/*
The Evolving Distribution Objects framework (EDO) is a template-based,
ANSI-C++ evolutionary computation library which helps you to write your
own estimation of distribution algorithms.
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
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (C) 2010 Thales group
*/
/*
Authors:
Johann Dréo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _edoAlgo_h
#define _edoAlgo_h
#include <eoAlgo.h>
template < typename D >
class edoAlgo : public eoAlgo< typename D::EOType >
{
//! Alias for the type
typedef typename D::EOType EOT;
public:
virtual ~edoAlgo(){}
};
#endif // !_edoAlgo_h

54
src/edoBounder.h Normal file
View file

@ -0,0 +1,54 @@
/*
The Evolving Distribution Objects framework (EDO) is a template-based,
ANSI-C++ evolutionary computation library which helps you to write your
own estimation of distribution algorithms.
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
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (C) 2010 Thales group
*/
/*
Authors:
Johann Dréo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _edoBounder_h
#define _edoBounder_h
#include <eoFunctor.h>
template < typename EOT >
class edoBounder : public eoUF< EOT&, void >
{
public:
edoBounder( EOT min = EOT(1, 0), EOT max = EOT(1, 0) )
: _min(min), _max(max)
{
assert(_min.size() > 0);
assert(_min.size() == _max.size());
}
// virtual void operator()( EOT& ) = 0 (provided by eoUF< A1, R >)
EOT& min(){return _min;}
EOT& max(){return _max;}
private:
EOT _min;
EOT _max;
};
#endif // !_edoBounder_h

62
src/edoBounderBound.h Normal file
View file

@ -0,0 +1,62 @@
/*
The Evolving Distribution Objects framework (EDO) is a template-based,
ANSI-C++ evolutionary computation library which helps you to write your
own estimation of distribution algorithms.
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
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (C) 2010 Thales group
*/
/*
Authors:
Johann Dréo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _edoBounderBound_h
#define _edoBounderBound_h
#include "edoBounder.h"
template < typename EOT >
class edoBounderBound : public edoBounder< EOT >
{
public:
edoBounderBound( EOT min, EOT max )
: edoBounder< EOT >( min, max )
{}
void operator()( EOT& x )
{
unsigned int size = x.size();
assert(size > 0);
for (unsigned int d = 0; d < size; ++d) // browse all dimensions
{
if (x[d] < this->min()[d])
{
x[d] = this->min()[d];
continue;
}
if (x[d] > this->max()[d])
{
x[d] = this->max()[d];
}
}
}
};
#endif // !_edoBounderBound_h

40
src/edoBounderNo.h Normal file
View file

@ -0,0 +1,40 @@
/*
The Evolving Distribution Objects framework (EDO) is a template-based,
ANSI-C++ evolutionary computation library which helps you to write your
own estimation of distribution algorithms.
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
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (C) 2010 Thales group
*/
/*
Authors:
Johann Dréo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _edoBounderNo_h
#define _edoBounderNo_h
#include "edoBounder.h"
template < typename EOT >
class edoBounderNo : public edoBounder< EOT >
{
public:
void operator()( EOT& ) {}
};
#endif // !_edoBounderNo_h

63
src/edoBounderRng.h Normal file
View file

@ -0,0 +1,63 @@
/*
The Evolving Distribution Objects framework (EDO) is a template-based,
ANSI-C++ evolutionary computation library which helps you to write your
own estimation of distribution algorithms.
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
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (C) 2010 Thales group
*/
/*
Authors:
Johann Dréo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _edoBounderRng_h
#define _edoBounderRng_h
#include "edoBounder.h"
template < typename EOT >
class edoBounderRng : public edoBounder< EOT >
{
public:
edoBounderRng( EOT min, EOT max, eoRndGenerator< double > & rng )
: edoBounder< EOT >( min, max ), _rng(rng)
{}
void operator()( EOT& x )
{
unsigned int size = x.size();
assert(size > 0);
for (unsigned int d = 0; d < size; ++d) // browse all dimensions
{
// FIXME: attention: les bornes RNG ont les memes bornes quelque soit les dimensions idealement on voudrait avoir des bornes differentes pour chaque dimensions.
if (x[d] < this->min()[d] || x[d] > this->max()[d])
{
x[d] = _rng();
}
}
}
private:
eoRndGenerator< double> & _rng;
};
#endif // !_edoBounderRng_h

55
src/edoBounderUniform.h Normal file
View file

@ -0,0 +1,55 @@
/*
The Evolving Distribution Objects framework (EDO) is a template-based,
ANSI-C++ evolutionary computation library which helps you to write your
own estimation of distribution algorithms.
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
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (C) 2010 Thales group
*/
/*
Authors:
Johann Dréo <johann.dreo@thalesgroup.com>
*/
#ifndef _edoBounderUniform_h
#define _edoBounderUniform_h
#include "edoBounder.h"
template < typename EOT >
class edoBounderUniform : public edoBounder< EOT >
{
public:
edoBounderUniform( EOT min, EOT max )
: edoBounder< EOT >( min, max )
{}
void operator()( EOT& sol )
{
unsigned int size = sol.size();
assert(size > 0);
for (unsigned int d = 0; d < size; ++d) {
if ( sol[d] < this->min()[d] || sol[d] > this->max()[d]) {
// use EO's global "rng"
sol[d] = rng.uniform( this->min()[d], this->max()[d] );
}
} // for d in size
}
};
#endif // !_edoBounderUniform_h

61
src/edoContinue.h Normal file
View file

@ -0,0 +1,61 @@
/*
The Evolving Distribution Objects framework (EDO) is a template-based,
ANSI-C++ evolutionary computation library which helps you to write your
own estimation of distribution algorithms.
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
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (C) 2010 Thales group
*/
/*
Authors:
Johann Dréo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _doContinue_h
#define _doContinue_h
#include <eoFunctor.h>
#include <eoPersistent.h>
//! edoContinue< EOT > classe fitted to Distribution Object library
template < typename D >
class edoContinue : public eoUF< const D&, bool >, public eoPersistent
{
public:
virtual std::string className(void) const { return "edoContinue"; }
void readFrom(std::istream&)
{
/* It should be implemented by subclasses ! */
}
void printOn(std::ostream&) const
{
/* It should be implemented by subclasses ! */
}
};
template < typename D >
class edoDummyContinue : public edoContinue< D >
{
bool operator()(const D&){ return true; }
virtual std::string className() const { return "edoDummyContinue"; }
};
#endif // !_edoContinue_h

43
src/edoDistrib.h Normal file
View file

@ -0,0 +1,43 @@
/*
The Evolving Distribution Objects framework (EDO) is a template-based,
ANSI-C++ evolutionary computation library which helps you to write your
own estimation of distribution algorithms.
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
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (C) 2010 Thales group
*/
/*
Authors:
Johann Dréo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _edoDistrib_h
#define _edoDistrib_h
#include <eoFunctor.h>
template < typename EOT >
class edoDistrib : public eoFunctorBase
{
public:
//! Alias for the type
typedef EOT EOType;
virtual ~edoDistrib(){}
};
#endif // !_edoDistrib_h

View file

@ -1,26 +1,46 @@
// (c) Thales group, 2010
/*
Authors:
Johann Dreo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
The Evolving Distribution Objects framework (EDO) is a template-based,
ANSI-C++ evolutionary computation library which helps you to write your
own estimation of distribution algorithms.
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
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (C) 2010 Thales group
*/
/*
Authors:
Johann Dréo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _doEDA_h
#define _doEDA_h
#ifndef _edoEDA_h
#define _edoEDA_h
#include <eo>
#include <mo>
#include <utils/eoRNG.h>
#include "doAlgo.h"
#include "doEstimator.h"
#include "doModifierMass.h"
#include "doSampler.h"
#include "doContinue.h"
#include "edoAlgo.h"
#include "edoEstimator.h"
#include "edoModifierMass.h"
#include "edoSampler.h"
#include "edoContinue.h"
template < typename D >
class doEDA : public doAlgo< D >
class edoEDA : public edoAlgo< D >
{
public:
//! Alias for the type EOT
@ -34,7 +54,7 @@ public:
public:
//! doEDA constructor
//! edoEDA constructor
/*!
All the boxes used by a EDASA need to be given.
@ -51,13 +71,13 @@ public:
\param initial_temperature The initial temperature.
\param replacor Population replacor
*/
doEDA (eoSelect< EOT > & selector,
doEstimator< D > & estimator,
edoEDA (eoSelect< EOT > & selector,
edoEstimator< D > & estimator,
eoSelectOne< EOT > & selectone,
doModifierMass< D > & modifier,
doSampler< D > & sampler,
edoModifierMass< D > & modifier,
edoSampler< D > & sampler,
eoContinue< EOT > & pop_continue,
doContinue< D > & distribution_continue,
edoContinue< D > & distribution_continue,
eoEvalFunc < EOT > & evaluation,
//moContinuator< moDummyNeighbor<EOT> > & sa_continue,
//moCoolingSchedule<EOT> & cooling_schedule,
@ -216,22 +236,22 @@ private:
eoSelect < EOT > & _selector;
//! A EOT estimator. It is going to estimate distribution parameters.
doEstimator< D > & _estimator;
edoEstimator< D > & _estimator;
//! SelectOne
eoSelectOne< EOT > & _selectone;
//! A D modifier
doModifierMass< D > & _modifier;
edoModifierMass< D > & _modifier;
//! A D sampler
doSampler< D > & _sampler;
edoSampler< D > & _sampler;
//! A EOT population continuator
eoContinue < EOT > & _pop_continue;
//! A D continuator
doContinue < D > & _distribution_continue;
edoContinue < D > & _distribution_continue;
//! A full evaluation function.
eoEvalFunc < EOT > & _evaluation;
@ -249,4 +269,4 @@ private:
eoReplacement < EOT > & _replacor;
};
#endif // !_doEDA_h
#endif // !_edoEDA_h

View file

@ -1,26 +1,46 @@
// (c) Thales group, 2010
/*
Authors:
Johann Dreo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
The Evolving Distribution Objects framework (EDO) is a template-based,
ANSI-C++ evolutionary computation library which helps you to write your
own estimation of distribution algorithms.
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
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (C) 2010 Thales group
*/
/*
Authors:
Johann Dréo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _doEDASA_h
#define _doEDASA_h
#ifndef _edoEDASA_h
#define _edoEDASA_h
#include <eo>
#include <mo>
#include <utils/eoRNG.h>
#include "doAlgo.h"
#include "doEstimator.h"
#include "doModifierMass.h"
#include "doSampler.h"
#include "doContinue.h"
#include "edoAlgo.h"
#include "edoEstimator.h"
#include "edoModifierMass.h"
#include "edoSampler.h"
#include "edoContinue.h"
template < typename D >
class doEDASA : public doAlgo< D >
class edoEDASA : public edoAlgo< D >
{
public:
//! Alias for the type EOT
@ -34,7 +54,7 @@ public:
public:
//! doEDASA constructor
//! edoEDASA constructor
/*!
All the boxes used by a EDASA need to be given.
@ -51,13 +71,13 @@ public:
\param initial_temperature The initial temperature.
\param replacor Population replacor
*/
doEDASA (eoSelect< EOT > & selector,
doEstimator< D > & estimator,
edoEDASA (eoSelect< EOT > & selector,
edoEstimator< D > & estimator,
eoSelectOne< EOT > & selectone,
doModifierMass< D > & modifier,
doSampler< D > & sampler,
edoModifierMass< D > & modifier,
edoSampler< D > & sampler,
eoContinue< EOT > & pop_continue,
doContinue< D > & distribution_continue,
edoContinue< D > & distribution_continue,
eoEvalFunc < EOT > & evaluation,
moContinuator< moDummyNeighbor<EOT> > & sa_continue,
moCoolingSchedule<EOT> & cooling_schedule,
@ -214,22 +234,22 @@ private:
eoSelect < EOT > & _selector;
//! A EOT estimator. It is going to estimate distribution parameters.
doEstimator< D > & _estimator;
edoEstimator< D > & _estimator;
//! SelectOne
eoSelectOne< EOT > & _selectone;
//! A D modifier
doModifierMass< D > & _modifier;
edoModifierMass< D > & _modifier;
//! A D sampler
doSampler< D > & _sampler;
edoSampler< D > & _sampler;
//! A EOT population continuator
eoContinue < EOT > & _pop_continue;
//! A D continuator
doContinue < D > & _distribution_continue;
edoContinue < D > & _distribution_continue;
//! A full evaluation function.
eoEvalFunc < EOT > & _evaluation;
@ -247,4 +267,4 @@ private:
eoReplacement < EOT > & _replacor;
};
#endif // !_doEDASA_h
#endif // !_edoEDASA_h

43
src/edoEstimator.h Normal file
View file

@ -0,0 +1,43 @@
/*
The Evolving Distribution Objects framework (EDO) is a template-based,
ANSI-C++ evolutionary computation library which helps you to write your
own estimation of distribution algorithms.
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
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (C) 2010 Thales group
*/
/*
Authors:
Johann Dréo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _edoEstimator_h
#define _edoEstimator_h
#include <eoPop.h>
#include <eoFunctor.h>
template < typename D >
class edoEstimator : public eoUF< eoPop< typename D::EOType >&, D >
{
public:
typedef typename D::EOType EOType;
// virtual D operator() ( eoPop< EOT >& )=0 (provided by eoUF< A1, R >)
};
#endif // !_edoEstimator_h

View file

@ -0,0 +1,97 @@
/*
The Evolving Distribution Objects framework (EDO) is a template-based,
ANSI-C++ evolutionary computation library which helps you to write your
own estimation of distribution algorithms.
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
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (C) 2010 Thales group
*/
/*
Authors:
Johann Dréo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _edoEstimatorNormalMono_h
#define _edoEstimatorNormalMono_h
#include "edoEstimator.h"
#include "edoNormalMono.h"
template < typename EOT >
class edoEstimatorNormalMono : public edoEstimator< edoNormalMono< EOT > >
{
public:
typedef typename EOT::AtomType AtomType;
class Variance
{
public:
Variance() : _sumvar(0){}
void update(AtomType v)
{
_n++;
AtomType d = v - _mean;
_mean += 1 / _n * d;
_sumvar += (_n - 1) / _n * d * d;
}
AtomType get_mean() const {return _mean;}
AtomType get_var() const {return _sumvar / (_n - 1);}
AtomType get_std() const {return sqrt( get_var() );}
private:
AtomType _n;
AtomType _mean;
AtomType _sumvar;
};
public:
edoNormalMono< EOT > operator()(eoPop<EOT>& pop)
{
unsigned int popsize = pop.size();
assert(popsize > 0);
unsigned int dimsize = pop[0].size();
assert(dimsize > 0);
std::vector< Variance > var( dimsize );
for (unsigned int i = 0; i < popsize; ++i)
{
for (unsigned int d = 0; d < dimsize; ++d)
{
var[d].update( pop[i][d] );
}
}
EOT mean( dimsize );
EOT variance( dimsize );
for (unsigned int d = 0; d < dimsize; ++d)
{
mean[d] = var[d].get_mean();
variance[d] = var[d].get_var();
}
return edoNormalMono< EOT >( mean, variance );
}
};
#endif // !_edoEstimatorNormalMono_h

View file

@ -1,18 +1,39 @@
// (c) Thales group, 2010
/*
Authors:
Johann Dreo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
The Evolving Distribution Objects framework (EDO) is a template-based,
ANSI-C++ evolutionary computation library which helps you to write your
own estimation of distribution algorithms.
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
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (C) 2010 Thales group
*/
/*
Authors:
Johann Dréo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _doEstimatorNormalMulti_h
#define _doEstimatorNormalMulti_h
#include "doEstimator.h"
#include "doNormalMulti.h"
#ifndef _edoEstimatorNormalMulti_h
#define _edoEstimatorNormalMulti_h
#include "edoEstimator.h"
#include "edoNormalMulti.h"
template < typename EOT >
class doEstimatorNormalMulti : public doEstimator< doNormalMulti< EOT > >
class edoEstimatorNormalMulti : public edoEstimator< edoNormalMulti< EOT > >
{
public:
class CovMatrix
@ -112,7 +133,7 @@ public:
public:
typedef typename EOT::AtomType AtomType;
doNormalMulti< EOT > operator()(eoPop<EOT>& pop)
edoNormalMulti< EOT > operator()(eoPop<EOT>& pop)
{
unsigned int popsize = pop.size();
assert(popsize > 0);
@ -122,8 +143,8 @@ public:
CovMatrix cov( pop );
return doNormalMulti< EOT >( cov.get_mean(), cov.get_varcovar() );
return edoNormalMulti< EOT >( cov.get_mean(), cov.get_varcovar() );
}
};
#endif // !_doEstimatorNormalMulti_h
#endif // !_edoEstimatorNormalMulti_h

71
src/edoEstimatorUniform.h Normal file
View file

@ -0,0 +1,71 @@
/*
The Evolving Distribution Objects framework (EDO) is a template-based,
ANSI-C++ evolutionary computation library which helps you to write your
own estimation of distribution algorithms.
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
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (C) 2010 Thales group
*/
/*
Authors:
Johann Dréo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _edoEstimatorUniform_h
#define _edoEstimatorUniform_h
#include "edoEstimator.h"
#include "edoUniform.h"
// TODO: calcule de la moyenne + covariance dans une classe derivee
template < typename EOT >
class edoEstimatorUniform : public edoEstimator< edoUniform< EOT > >
{
public:
edoUniform< EOT > operator()(eoPop<EOT>& pop)
{
unsigned int size = pop.size();
assert(size > 0);
EOT min = pop[0];
EOT max = pop[0];
for (unsigned int i = 1; i < size; ++i)
{
unsigned int size = pop[i].size();
assert(size > 0);
// possibilité d'utiliser std::min_element et std::max_element mais exige 2 pass au lieu d'1.
for (unsigned int d = 0; d < size; ++d)
{
if (pop[i][d] < min[d])
min[d] = pop[i][d];
if (pop[i][d] > max[d])
max[d] = pop[i][d];
}
}
return edoUniform< EOT >(min, max);
}
};
#endif // !_edoEstimatorUniform_h

41
src/edoModifier.h Normal file
View file

@ -0,0 +1,41 @@
/*
The Evolving Distribution Objects framework (EDO) is a template-based,
ANSI-C++ evolutionary computation library which helps you to write your
own estimation of distribution algorithms.
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
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (C) 2010 Thales group
*/
/*
Authors:
Johann Dréo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _edoModifier_h
#define _edoModifier_h
template < typename D >
class edoModifier
{
public:
virtual ~edoModifier(){}
typedef typename D::EOType EOType;
};
#endif // !_edoModifier_h

View file

@ -0,0 +1,43 @@
/*
The Evolving Distribution Objects framework (EDO) is a template-based,
ANSI-C++ evolutionary computation library which helps you to write your
own estimation of distribution algorithms.
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
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (C) 2010 Thales group
*/
/*
Authors:
Johann Dréo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _edoModifierDispersion_h
#define _edoModifierDispersion_h
#include <eoPop.h>
#include <eoFunctor.h>
#include "edoModifier.h"
template < typename D >
class edoModifierDispersion : public edoModifier< D >, public eoBF< D&, eoPop< typename D::EOType >&, void >
{
public:
// virtual void operator() ( D&, eoPop< D::EOType >& )=0 (provided by eoBF< A1, A2, R >)
};
#endif // !_edoModifierDispersion_h

45
src/edoModifierMass.h Normal file
View file

@ -0,0 +1,45 @@
/*
The Evolving Distribution Objects framework (EDO) is a template-based,
ANSI-C++ evolutionary computation library which helps you to write your
own estimation of distribution algorithms.
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
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (C) 2010 Thales group
*/
/*
Authors:
Johann Dréo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _edoModifierMass_h
#define _edoModifierMass_h
#include <eoFunctor.h>
#include "edoModifier.h"
template < typename D >
class edoModifierMass : public edoModifier< D >, public eoBF< D&, typename D::EOType&, void >
{
public:
//typedef typename D::EOType::AtomType AtomType; // does not work !!!
// virtual void operator() ( D&, D::EOType& )=0 (provided by eoBF< A1, A2, R >)
};
#endif // !_edoModifierMass_h

58
src/edoNormalMono.h Normal file
View file

@ -0,0 +1,58 @@
/*
The Evolving Distribution Objects framework (EDO) is a template-based,
ANSI-C++ evolutionary computation library which helps you to write your
own estimation of distribution algorithms.
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
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (C) 2010 Thales group
*/
/*
Authors:
Johann Dréo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _edoNormalMono_h
#define _edoNormalMono_h
#include "edoDistrib.h"
template < typename EOT >
class edoNormalMono : public edoDistrib< EOT >
{
public:
edoNormalMono( const EOT& mean, const EOT& variance )
: _mean(mean), _variance(variance)
{
assert(_mean.size() > 0);
assert(_mean.size() == _variance.size());
}
unsigned int size()
{
assert(_mean.size() == _variance.size());
return _mean.size();
}
EOT mean(){return _mean;}
EOT variance(){return _variance;}
private:
EOT _mean;
EOT _variance;
};
#endif // !_edoNormalMono_h

47
src/edoNormalMonoCenter.h Normal file
View file

@ -0,0 +1,47 @@
/*
The Evolving Distribution Objects framework (EDO) is a template-based,
ANSI-C++ evolutionary computation library which helps you to write your
own estimation of distribution algorithms.
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
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (C) 2010 Thales group
*/
/*
Authors:
Johann Dréo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _edoNormalMonoCenter_h
#define _edoNormalMonoCenter_h
#include "edoModifierMass.h"
#include "edoNormalMono.h"
template < typename EOT >
class edoNormalMonoCenter : public edoModifierMass< edoNormalMono< EOT > >
{
public:
typedef typename EOT::AtomType AtomType;
void operator() ( edoNormalMono< EOT >& distrib, EOT& mass )
{
distrib.mean() = mass;
}
};
#endif // !_edoNormalMonoCenter_h

View file

@ -5,23 +5,23 @@
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _doNormalMulti_h
#define _doNormalMulti_h
#ifndef _edoNormalMulti_h
#define _edoNormalMulti_h
#include <boost/numeric/ublas/symmetric.hpp>
#include <boost/numeric/ublas/lu.hpp>
#include "doDistrib.h"
#include "edoDistrib.h"
namespace ublas = boost::numeric::ublas;
template < typename EOT >
class doNormalMulti : public doDistrib< EOT >
class edoNormalMulti : public edoDistrib< EOT >
{
public:
typedef typename EOT::AtomType AtomType;
doNormalMulti
edoNormalMulti
(
const ublas::vector< AtomType >& mean,
const ublas::symmetric_matrix< AtomType, ublas::lower >& varcovar
@ -48,4 +48,4 @@ private:
ublas::symmetric_matrix< AtomType, ublas::lower > _varcovar;
};
#endif // !_doNormalMulti_h
#endif // !_edoNormalMulti_h

View file

@ -0,0 +1,48 @@
/*
The Evolving Distribution Objects framework (EDO) is a template-based,
ANSI-C++ evolutionary computation library which helps you to write your
own estimation of distribution algorithms.
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
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (C) 2010 Thales group
*/
/*
Authors:
Johann Dréo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _edoNormalMultiCenter_h
#define _edoNormalMultiCenter_h
#include "edoModifierMass.h"
#include "edoNormalMulti.h"
template < typename EOT >
class edoNormalMultiCenter : public edoModifierMass< edoNormalMulti< EOT > >
{
public:
typedef typename EOT::AtomType AtomType;
void operator() ( edoNormalMulti< EOT >& distrib, EOT& mass )
{
ublas::vector< AtomType > mean( distrib.size() );
std::copy( mass.begin(), mass.end(), mean.begin() );
distrib.mean() = mean;
}
};
#endif // !_edoNormalMultiCenter_h

95
src/edoSampler.h Normal file
View file

@ -0,0 +1,95 @@
/*
The Evolving Distribution Objects framework (EDO) is a template-based,
ANSI-C++ evolutionary computation library which helps you to write your
own estimation of distribution algorithms.
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
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (C) 2010 Thales group
*/
/*
Authors:
Johann Dréo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _edoSampler_h
#define _edoSampler_h
#include <eoFunctor.h>
#include "edoBounder.h"
#include "edoBounderNo.h"
template < typename D >
class edoSampler : public eoUF< D&, typename D::EOType >
{
public:
typedef typename D::EOType EOType;
edoSampler(edoBounder< EOType > & bounder)
: /*_dummy_bounder(),*/ _bounder(bounder)
{}
/*
edoSampler()
: _dummy_bounder(), _bounder( _dummy_bounder )
{}
*/
// virtual EOType operator()( D& ) = 0 (provided by eoUF< A1, R >)
virtual EOType sample( D& ) = 0;
EOType operator()( D& distrib )
{
unsigned int size = distrib.size();
assert(size > 0);
//-------------------------------------------------------------
// Point we want to sample to get higher a set of points
// (coordinates in n dimension)
// x = {x1, x2, ..., xn}
// the sample method is implemented in the derivated class
//-------------------------------------------------------------
EOType solution(sample(distrib));
//-------------------------------------------------------------
//-------------------------------------------------------------
// Now we are bounding the distribution thanks to min and max
// parameters.
//-------------------------------------------------------------
_bounder(solution);
//-------------------------------------------------------------
return solution;
}
private:
//edoBounderNo<EOType> _dummy_bounder;
//! Bounder functor
edoBounder< EOType > & _bounder;
};
#endif // !_edoSampler_h

View file

@ -0,0 +1,91 @@
/*
The Evolving Distribution Objects framework (EDO) is a template-based,
ANSI-C++ evolutionary computation library which helps you to write your
own estimation of distribution algorithms.
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
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (C) 2010 Thales group
*/
/*
Authors:
Johann Dréo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _edoSamplerNormalMono_h
#define _edoSamplerNormalMono_h
#include <utils/eoRNG.h>
#include "edoSampler.h"
#include "edoNormalMono.h"
#include "edoBounder.h"
/**
* edoSamplerNormalMono
* This class uses the NormalMono distribution parameters (bounds) to return
* a random position used for population sampling.
*/
template < typename EOT >
class edoSamplerNormalMono : public edoSampler< edoNormalMono< EOT > >
{
public:
typedef typename EOT::AtomType AtomType;
edoSamplerNormalMono( edoBounder< EOT > & bounder )
: edoSampler< edoNormalMono< EOT > >( bounder )
{}
EOT sample( edoNormalMono< EOT >& distrib )
{
unsigned int size = distrib.size();
assert(size > 0);
//-------------------------------------------------------------
// Point we want to sample to get higher a set of points
// (coordinates in n dimension)
// x = {x1, x2, ..., xn}
//-------------------------------------------------------------
EOT solution;
//-------------------------------------------------------------
//-------------------------------------------------------------
// Sampling all dimensions
//-------------------------------------------------------------
for (unsigned int i = 0; i < size; ++i)
{
AtomType mean = distrib.mean()[i];
AtomType variance = distrib.variance()[i];
AtomType random = rng.normal(mean, variance);
assert(variance >= 0);
solution.push_back(random);
}
//-------------------------------------------------------------
return solution;
}
};
#endif // !_edoSamplerNormalMono_h

View file

@ -1,30 +1,39 @@
// (c) Thales group, 2010
/*
Authors:
Johann Dreo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
The Evolving Distribution Objects framework (EDO) is a template-based,
ANSI-C++ evolutionary computation library which helps you to write your
own estimation of distribution algorithms.
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
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (C) 2010 Thales group
*/
/*
Authors:
Johann Dréo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _doSamplerNormalMulti_h
#define _doSamplerNormalMulti_h
#ifndef _edoSamplerNormalMulti_h
#define _edoSamplerNormalMulti_h
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/symmetric.hpp>
#include <edoSampler.h>
#include <boost/numeric/ublas/lu.hpp>
#include <boost/numeric/ublas/symmetric.hpp>
#include <utils/eoRNG.h>
#include "doSampler.h"
#include "doNormalMulti.h"
#include "doBounder.h"
/**
* doSamplerNormalMulti
* This class uses the Normal distribution parameters (bounds) to return
* a random position used for population sampling.
*/
template < typename EOT >
class doSamplerNormalMulti : public doSampler< doNormalMulti< EOT > >
template< class EOT >
class edoSamplerNormalMulti : public edoSampler< edoNormalMulti< EOT > >
{
public:
typedef typename EOT::AtomType AtomType;
@ -96,11 +105,11 @@ public:
ublas::symmetric_matrix< AtomType, ublas::lower > _L;
};
doSamplerNormalMulti( doBounder< EOT > & bounder )
: doSampler< doNormalMulti< EOT > >( bounder )
edoSamplerNormalMulti( edoBounder< EOT > & bounder )
: edoSampler< edoNormalMulti< EOT > >( bounder )
{}
EOT sample( doNormalMulti< EOT >& distrib )
EOT sample( edoNormalMulti< EOT >& distrib )
{
unsigned int size = distrib.size();
@ -162,4 +171,4 @@ public:
}
};
#endif // !_doSamplerNormalMulti_h
#endif // !_edoSamplerNormalMulti_h

96
src/edoSamplerUniform.h Normal file
View file

@ -0,0 +1,96 @@
/*
The Evolving Distribution Objects framework (EDO) is a template-based,
ANSI-C++ evolutionary computation library which helps you to write your
own estimation of distribution algorithms.
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
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (C) 2010 Thales group
*/
/*
Authors:
Johann Dréo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _edoSamplerUniform_h
#define _edoSamplerUniform_h
#include <utils/eoRNG.h>
#include "edoSampler.h"
#include "edoUniform.h"
/**
* edoSamplerUniform
* This class uses the Uniform distribution parameters (bounds) to return
* a random position used for population sampling.
*/
template < typename EOT, class D=edoUniform<EOT> > // FIXME: D template name is there really used ?!?
class edoSamplerUniform : public edoSampler< edoUniform< EOT > >
{
public:
typedef D Distrib;
edoSamplerUniform(edoBounder< EOT > & bounder)
: edoSampler< edoUniform<EOT> >(bounder) // FIXME: Why D is not used here ?
{}
/*
edoSamplerUniform()
: edoSampler< edoUniform<EOT> >()
{}
*/
EOT sample( edoUniform< EOT >& distrib )
{
unsigned int size = distrib.size();
assert(size > 0);
//-------------------------------------------------------------
// Point we want to sample to get higher a set of points
// (coordinates in n dimension)
// x = {x1, x2, ..., xn}
//-------------------------------------------------------------
EOT solution;
//-------------------------------------------------------------
//-------------------------------------------------------------
// Sampling all dimensions
//-------------------------------------------------------------
for (unsigned int i = 0; i < size; ++i)
{
double min = distrib.min()[i];
double max = distrib.max()[i];
double random = rng.uniform(min, max);
assert(min <= random && random <= max);
solution.push_back(random);
}
//-------------------------------------------------------------
return solution;
}
};
#endif // !_edoSamplerUniform_h

43
src/edoUniform.h Normal file
View file

@ -0,0 +1,43 @@
/*
The Evolving Distribution Objects framework (EDO) is a template-based,
ANSI-C++ evolutionary computation library which helps you to write your
own estimation of distribution algorithms.
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
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (C) 2010 Thales group
*/
/*
Authors:
Johann Dréo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _edoUniform_h
#define _edoUniform_h
#include "edoDistrib.h"
#include "edoVectorBounds.h"
template < typename EOT >
class edoUniform : public edoDistrib< EOT >, public edoVectorBounds< EOT >
{
public:
edoUniform(EOT min, EOT max)
: edoVectorBounds< EOT >(min, max)
{}
};
#endif // !_edoUniform_h

55
src/edoUniformCenter.h Normal file
View file

@ -0,0 +1,55 @@
/*
The Evolving Distribution Objects framework (EDO) is a template-based,
ANSI-C++ evolutionary computation library which helps you to write your
own estimation of distribution algorithms.
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
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (C) 2010 Thales group
*/
/*
Authors:
Johann Dréo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _edoUniformCenter_h
#define _edoUniformCenter_h
#include "edoModifierMass.h"
#include "edoUniform.h"
template < typename EOT >
class edoUniformCenter : public edoModifierMass< edoUniform< EOT > >
{
public:
typedef typename EOT::AtomType AtomType;
void operator() ( edoUniform< EOT >& distrib, EOT& mass )
{
for (unsigned int i = 0, n = mass.size(); i < n; ++i)
{
AtomType& min = distrib.min()[i];
AtomType& max = distrib.max()[i];
AtomType range = (max - min) / 2;
min = mass[i] - range;
max = mass[i] + range;
}
}
};
#endif // !_edoUniformCenter_h

56
src/edoVectorBounds.h Normal file
View file

@ -0,0 +1,56 @@
/*
The Evolving Distribution Objects framework (EDO) is a template-based,
ANSI-C++ evolutionary computation library which helps you to write your
own estimation of distribution algorithms.
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
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (C) 2010 Thales group
*/
/*
Authors:
Johann Dréo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _edoVectorBounds_h
#define _edoVectorBounds_h
template < typename EOT >
class edoVectorBounds
{
public:
edoVectorBounds(EOT min, EOT max)
: _min(min), _max(max)
{
assert(_min.size() > 0);
assert(_min.size() == _max.size());
}
EOT min(){return _min;}
EOT max(){return _max;}
unsigned int size()
{
assert(_min.size() == _max.size());
return _min.size();
}
private:
EOT _min;
EOT _max;
};
#endif // !_edoVectorBounds_h

View file

@ -5,10 +5,10 @@
FILE(GLOB SOURCES *.cpp)
SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
ADD_LIBRARY(doutils ${SOURCES})
INSTALL(TARGETS doutils ARCHIVE DESTINATION lib COMPONENT libraries)
ADD_LIBRARY(edoutils ${SOURCES})
INSTALL(TARGETS edoutils ARCHIVE DESTINATION lib COMPONENT libraries)
FILE(GLOB HDRS *.h utils)
INSTALL(FILES ${HDRS} DESTINATION include/do/utils COMPONENT headers)
INSTALL(FILES ${HDRS} DESTINATION include/edo/utils COMPONENT headers)
######################################################################################

View file

@ -1,74 +0,0 @@
//-----------------------------------------------------------------------------
// doFileSnapshot.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
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
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
Johann Dreo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
//-----------------------------------------------------------------------------
#ifndef _doFileSnapshot_h
#define _doFileSnapshot_h
#include <string>
#include <fstream>
#include <stdexcept>
#include "utils/eoMonitor.h"
class doFileSnapshot : public eoMonitor
{
public:
doFileSnapshot(std::string dirname,
unsigned int frequency = 1,
std::string filename = "gen",
std::string delim = " ",
unsigned int counter = 0,
bool rmFiles = true,
bool saveFilenames = true);
virtual ~doFileSnapshot();
virtual bool hasChanged() {return _boolChanged;}
virtual std::string getDirName() { return _dirname; }
virtual unsigned int getCounter() { return _counter; }
virtual const std::string baseFileName() { return _filename;}
std::string getFileName() {return _currentFileName;}
void setCurrentFileName();
virtual eoMonitor& operator()(void);
virtual eoMonitor& operator()(std::ostream& os);
private :
std::string _dirname;
unsigned int _frequency;
std::string _filename;
std::string _delim;
std::string _currentFileName;
unsigned int _counter;
bool _saveFilenames;
std::ofstream* _descOfFiles;
bool _boolChanged;
};
#endif // !_doFileSnapshot

View file

@ -1,32 +0,0 @@
// (c) Thales group, 2010
/*
Authors:
Johann Dreo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _doHyperVolume_h
#define _doHyperVolume_h
template < typename EOT >
class doHyperVolume
{
public:
typedef typename EOT::AtomType AtomType;
doHyperVolume() : _hv(1) {}
void update(AtomType v)
{
_hv *= ::sqrt( v );
assert( _hv <= std::numeric_limits< AtomType >::max() );
}
AtomType get_hypervolume() const { return _hv; }
protected:
AtomType _hv;
};
#endif // !_doHyperVolume_h

View file

@ -1,75 +0,0 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//-----------------------------------------------------------------------------
// doPopStat.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
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
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
Johann Dreo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
//-----------------------------------------------------------------------------
/** WARNING: this file contains 2 classes:
eoPopString and eoSortedPopString
that transform the population into a std::string
that can be used to dump to the screen
*/
#ifndef _doPopStat_h
#define _doPopStat_h
#include <utils/eoStat.h>
/** Thanks to MS/VC++, eoParam mechanism is unable to handle std::vectors of stats.
This snippet is a workaround:
This class will "print" a whole population into a std::string - that you can later
send to any stream
This is the plain version - see eoPopString for the Sorted version
Note: this Stat should probably be used only within eoStdOutMonitor, and not
inside an eoFileMonitor, as the eoState construct will work much better there.
*/
template <class EOT>
class doPopStat : public eoStat<EOT, std::string>
{
public:
using eoStat<EOT, std::string>::value;
/** default Ctor, void std::string by default, as it appears
on the description line once at beginning of evolution. and
is meaningless there. _howMany defaults to 0, that is, the whole
population*/
doPopStat(std::string _desc ="")
: eoStat<EOT, std::string>("", _desc) {}
/** Fills the value() of the eoParam with the dump of the population. */
void operator()(const eoPop<EOT>& _pop)
{
std::ostringstream os;
os << _pop;
value() = os.str();
}
};
#endif // !_doPopStat_h

View file

@ -1,54 +0,0 @@
// (c) Thales group, 2010
/*
Authors:
Johann Dreo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _doStat_h
#define _doStat_h
#include <eoFunctor.h>
template < typename D >
class doStatBase : public eoUF< const D&, void >
{
public:
// virtual void operator()( const D& ) = 0 (provided by eoUF< A1, R >)
virtual void lastCall( const D& ) {}
virtual std::string className() const { return "doStatBase"; }
};
template < typename D > class doCheckPoint;
template < typename D, typename T >
class doStat : public eoValueParam< T >, public doStatBase< D >
{
public:
doStat(T value, std::string description)
: eoValueParam< T >(value, description)
{}
virtual std::string className(void) const { return "doStat"; }
doStat< D, T >& addTo(doCheckPoint< D >& cp) { cp.add(*this); return *this; }
// TODO: doStat< D, T >& addTo(eoMonitor& mon) { mon.add(*this); return *this; }
};
//! A parent class for any kind of distribution to dump parameter to std::string type
template < typename D >
class doDistribStat : public doStat< D, std::string >
{
public:
using doStat< D, std::string >::value;
doDistribStat(std::string desc)
: doStat< D, std::string >("", desc)
{}
};
#endif // !_doStat_h

View file

@ -1,35 +0,0 @@
// (c) Thales group, 2010
/*
Authors:
Johann Dreo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _doStatNormalMono_h
#define _doStatNormalMono_h
#include "doStat.h"
#include "doNormalMono.h"
template < typename EOT >
class doStatNormalMono : public doDistribStat< doNormalMono< EOT > >
{
public:
using doDistribStat< doNormalMono< EOT > >::value;
doStatNormalMono( std::string desc = "" )
: doDistribStat< doNormalMono< EOT > >( desc )
{}
void operator()( const doNormalMono< EOT >& distrib )
{
value() = "\n# ====== mono normal distribution dump =====\n";
std::ostringstream os;
os << distrib.mean() << " " << distrib.variance() << std::endl;
value() += os.str();
}
};
#endif // !_doStatNormalMono_h

View file

@ -1,48 +0,0 @@
// (c) Thales group, 2010
/*
Authors:
Johann Dreo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _doStatNormalMulti_h
#define _doStatNormalMulti_h
#include <boost/numeric/ublas/io.hpp>
#include "doStat.h"
#include "doNormalMulti.h"
template < typename EOT >
class doStatNormalMulti : public doDistribStat< doNormalMulti< EOT > >
{
public:
typedef typename EOT::AtomType AtomType;
using doDistribStat< doNormalMulti< EOT > >::value;
doStatNormalMulti( std::string desc = "" )
: doDistribStat< doNormalMulti< EOT > >( desc )
{}
void operator()( const doNormalMulti< EOT >& distrib )
{
value() = "\n# ====== multi normal distribution dump =====\n";
std::ostringstream os;
os << distrib.mean() << " " << distrib.varcovar() << std::endl;
// ublas::vector< AtomType > mean = distrib.mean();
// std::copy(mean.begin(), mean.end(), std::ostream_iterator< std::string >( os, " " ));
// ublas::symmetric_matrix< AtomType, ublas::lower > varcovar = distrib.varcovar();
// std::copy(varcovar.begin(), varcovar.end(), std::ostream_iterator< std::string >( os, " " ));
// os << std::endl;
value() += os.str();
}
};
#endif // !_doStatNormalMulti_h

View file

@ -1,35 +0,0 @@
// (c) Thales group, 2010
/*
Authors:
Johann Dreo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _doStatUniform_h
#define _doStatUniform_h
#include "doStat.h"
#include "doUniform.h"
template < typename EOT >
class doStatUniform : public doDistribStat< doUniform< EOT > >
{
public:
using doDistribStat< doUniform< EOT > >::value;
doStatUniform( std::string desc = "" )
: doDistribStat< doUniform< EOT > >( desc )
{}
void operator()( const doUniform< EOT >& distrib )
{
value() = "\n# ====== uniform distribution dump =====\n";
std::ostringstream os;
os << distrib.min() << " " << distrib.max() << std::endl;
value() += os.str();
}
};
#endif // !_doStatUniform_h

View file

@ -1,28 +1,48 @@
// (c) Thales group, 2010
/*
Authors:
Johann Dreo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
The Evolving Distribution Objects framework (EDO) is a template-based,
ANSI-C++ evolutionary computation library which helps you to write your
own estimation of distribution algorithms.
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
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (C) 2010 Thales group
*/
/*
Authors:
Johann Dréo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _doCheckPoint_h
#define _doCheckPoint_h
#ifndef _edoCheckPoint_h
#define _edoCheckPoint_h
#include <utils/eoUpdater.h>
#include <utils/eoMonitor.h>
#include "doContinue.h"
#include "doStat.h"
#include "edoContinue.h"
#include "edoStat.h"
//! eoCheckPoint< EOT > classe fitted to Distribution Object library
template < typename D >
class doCheckPoint : public doContinue< D >
class edoCheckPoint : public edoContinue< D >
{
public:
typedef typename D::EOType EOType;
doCheckPoint(doContinue< D >& _cont)
edoCheckPoint(edoContinue< D >& _cont)
{
_continuators.push_back( &_cont );
}
@ -74,12 +94,12 @@ public:
return bContinue;
}
void add(doContinue< D >& cont) { _continuators.push_back( &cont ); }
void add(doStatBase< D >& stat) { _stats.push_back( &stat ); }
void add(edoContinue< D >& cont) { _continuators.push_back( &cont ); }
void add(edoStatBase< D >& stat) { _stats.push_back( &stat ); }
void add(eoMonitor& mon) { _monitors.push_back( &mon ); }
void add(eoUpdater& upd) { _updaters.push_back( &upd ); }
virtual std::string className(void) const { return "doCheckPoint"; }
virtual std::string className(void) const { return "edoCheckPoint"; }
std::string allClassNames() const
{
@ -117,10 +137,10 @@ public:
}
private:
std::vector< doContinue< D >* > _continuators;
std::vector< doStatBase< D >* > _stats;
std::vector< edoContinue< D >* > _continuators;
std::vector< edoStatBase< D >* > _stats;
std::vector< eoMonitor* > _monitors;
std::vector< eoUpdater* > _updaters;
};
#endif // !_doCheckPoint_h
#endif // !_edoCheckPoint_h

View file

@ -1,28 +1,33 @@
//-----------------------------------------------------------------------------
// doFileSnapshot.cpp
// (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
version 2 of the License, or (at your option) any later version.
The Evolving Distribution Objects framework (EDO) is a template-based,
ANSI-C++ evolutionary computation library which helps you to write your
own estimation of distribution algorithms.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
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
version 2.1 of the License, or (at your option) any later version.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
Marc.Schoenauer@polytechnique.fr
mkeijzer@dhi.dk
Johann Dreo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
//-----------------------------------------------------------------------------
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (c) Marc Schoenauer, Maarten Keijzer and GeNeura Team, 2001
Copyright (C) 2010 Thales group
*/
/*
Authors:
todos@geneura.ugr.es
Marc Schoenauer <Marc.Schoenauer@polytechnique.fr>
Martin Keijzer <mkeijzer@dhi.dk>
Johann Dréo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#include <cstdlib>
@ -30,11 +35,11 @@
#include <fstream>
#include <stdexcept>
#include <utils/doFileSnapshot.h>
#include <utils/edoFileSnapshot.h>
#include <utils/compatibility.h>
#include <utils/eoParam.h>
doFileSnapshot::doFileSnapshot(std::string dirname,
edoFileSnapshot::edoFileSnapshot(std::string dirname,
unsigned int frequency /*= 1*/,
std::string filename /*= "gen"*/,
std::string delim /*= " "*/,
@ -79,19 +84,19 @@ doFileSnapshot::doFileSnapshot(std::string dirname,
}
doFileSnapshot::~doFileSnapshot()
edoFileSnapshot::~edoFileSnapshot()
{
delete _descOfFiles;
}
void doFileSnapshot::setCurrentFileName()
void edoFileSnapshot::setCurrentFileName()
{
std::ostringstream oscount;
oscount << _counter;
_currentFileName = _dirname + "/" + _filename + oscount.str();
}
eoMonitor& doFileSnapshot::operator()(void)
eoMonitor& edoFileSnapshot::operator()(void)
{
if (_counter % _frequency)
{
@ -107,7 +112,7 @@ eoMonitor& doFileSnapshot::operator()(void)
if (!os)
{
std::string str = "doFileSnapshot: Could not open " + _currentFileName;
std::string str = "edoFileSnapshot: Could not open " + _currentFileName;
throw std::runtime_error(str);
}
@ -119,7 +124,7 @@ eoMonitor& doFileSnapshot::operator()(void)
return operator()(os);
}
eoMonitor& doFileSnapshot::operator()(std::ostream& os)
eoMonitor& edoFileSnapshot::operator()(std::ostream& os)
{
iterator it = vec.begin();

View file

@ -0,0 +1,79 @@
/*
The Evolving Distribution Objects framework (EDO) is a template-based,
ANSI-C++ evolutionary computation library which helps you to write your
own estimation of distribution algorithms.
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
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (c) Marc Schoenauer, Maarten Keijzer and GeNeura Team, 2001
Copyright (C) 2010 Thales group
*/
/*
Authors:
todos@geneura.ugr.es
Marc Schoenauer <Marc.Schoenauer@polytechnique.fr>
Martin Keijzer <mkeijzer@dhi.dk>
Johann Dréo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _edoFileSnapshot_h
#define _edoFileSnapshot_h
#include <string>
#include <fstream>
#include <stdexcept>
#include "utils/eoMonitor.h"
class edoFileSnapshot : public eoMonitor
{
public:
edoFileSnapshot(std::string dirname,
unsigned int frequency = 1,
std::string filename = "gen",
std::string delim = " ",
unsigned int counter = 0,
bool rmFiles = true,
bool saveFilenames = true);
virtual ~edoFileSnapshot();
virtual bool hasChanged() {return _boolChanged;}
virtual std::string getDirName() { return _dirname; }
virtual unsigned int getCounter() { return _counter; }
virtual const std::string baseFileName() { return _filename;}
std::string getFileName() {return _currentFileName;}
void setCurrentFileName();
virtual eoMonitor& operator()(void);
virtual eoMonitor& operator()(std::ostream& os);
private :
std::string _dirname;
unsigned int _frequency;
std::string _filename;
std::string _delim;
std::string _currentFileName;
unsigned int _counter;
bool _saveFilenames;
std::ofstream* _descOfFiles;
bool _boolChanged;
};
#endif // !_edoFileSnapshot

View file

@ -0,0 +1,52 @@
/*
The Evolving Distribution Objects framework (EDO) is a template-based,
ANSI-C++ evolutionary computation library which helps you to write your
own estimation of distribution algorithms.
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
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (C) 2010 Thales group
*/
/*
Authors:
Johann Dréo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _edoHyperVolume_h
#define _edoHyperVolume_h
template < typename EOT >
class edoHyperVolume
{
public:
typedef typename EOT::AtomType AtomType;
edoHyperVolume() : _hv(1) {}
void update(AtomType v)
{
_hv *= ::sqrt( v );
assert( _hv <= std::numeric_limits< AtomType >::max() );
}
AtomType get_hypervolume() const { return _hv; }
protected:
AtomType _hv;
};
#endif // !_edoHyperVolume_h

70
src/utils/edoPopStat.h Normal file
View file

@ -0,0 +1,70 @@
/*
The Evolving Distribution Objects framework (EDO) is a template-based,
ANSI-C++ evolutionary computation library which helps you to write your
own estimation of distribution algorithms.
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
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (c) Marc Schoenauer, Maarten Keijzer and GeNeura Team, 2001
Copyright (C) 2010 Thales group
*/
/*
Authors:
todos@geneura.ugr.es
Marc Schoenauer <Marc.Schoenauer@polytechnique.fr>
Martin Keijzer <mkeijzer@dhi.dk>
Johann Dréo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _edoPopStat_h
#define _edoPopStat_h
#include <utils/eoStat.h>
/** Thanks to MS/VC++, eoParam mechanism is unable to handle std::vectors of stats.
This snippet is a workaround:
This class will "print" a whole population into a std::string - that you can later
send to any stream
This is the plain version - see eoPopString for the Sorted version
Note: this Stat should probably be used only within eoStdOutMonitor, and not
inside an eoFileMonitor, as the eoState construct will work much better there.
*/
template <class EOT>
class edoPopStat : public eoStat<EOT, std::string>
{
public:
using eoStat<EOT, std::string>::value;
/** default Ctor, void std::string by default, as it appears
on the description line once at beginning of evolution. and
is meaningless there. _howMany defaults to 0, that is, the whole
population*/
edoPopStat(std::string _desc ="")
: eoStat<EOT, std::string>("", _desc) {}
/** Fills the value() of the eoParam with the dump of the population. */
void operator()(const eoPop<EOT>& _pop)
{
std::ostringstream os;
os << _pop;
value() = os.str();
}
};
#endif // !_edoPopStat_h

74
src/utils/edoStat.h Normal file
View file

@ -0,0 +1,74 @@
/*
The Evolving Distribution Objects framework (EDO) is a template-based,
ANSI-C++ evolutionary computation library which helps you to write your
own estimation of distribution algorithms.
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
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (C) 2010 Thales group
*/
/*
Authors:
Johann Dréo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _edoStat_h
#define _edoStat_h
#include <eoFunctor.h>
template < typename D >
class edoStatBase : public eoUF< const D&, void >
{
public:
// virtual void operator()( const D& ) = 0 (provided by eoUF< A1, R >)
virtual void lastCall( const D& ) {}
virtual std::string className() const { return "edoStatBase"; }
};
template < typename D > class edoCheckPoint;
template < typename D, typename T >
class edoStat : public eoValueParam< T >, public edoStatBase< D >
{
public:
edoStat(T value, std::string description)
: eoValueParam< T >(value, description)
{}
virtual std::string className(void) const { return "edoStat"; }
edoStat< D, T >& addTo(edoCheckPoint< D >& cp) { cp.add(*this); return *this; }
// TODO: edoStat< D, T >& addTo(eoMonitor& mon) { mon.add(*this); return *this; }
};
//! A parent class for any kind of distribution to dump parameter to std::string type
template < typename D >
class edoDistribStat : public edoStat< D, std::string >
{
public:
using edoStat< D, std::string >::value;
edoDistribStat(std::string desc)
: edoStat< D, std::string >("", desc)
{}
};
#endif // !_edoStat_h

View file

@ -0,0 +1,55 @@
/*
The Evolving Distribution Objects framework (EDO) is a template-based,
ANSI-C++ evolutionary computation library which helps you to write your
own estimation of distribution algorithms.
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
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (C) 2010 Thales group
*/
/*
Authors:
Johann Dréo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _edoStatNormalMono_h
#define _edoStatNormalMono_h
#include "edoStat.h"
#include "edoNormalMono.h"
template < typename EOT >
class edoStatNormalMono : public edoDistribStat< edoNormalMono< EOT > >
{
public:
using edoDistribStat< edoNormalMono< EOT > >::value;
edoStatNormalMono( std::string desc = "" )
: edoDistribStat< edoNormalMono< EOT > >( desc )
{}
void operator()( const edoNormalMono< EOT >& distrib )
{
value() = "\n# ====== mono normal distribution dump =====\n";
std::ostringstream os;
os << distrib.mean() << " " << distrib.variance() << std::endl;
value() += os.str();
}
};
#endif // !_edoStatNormalMono_h

View file

@ -0,0 +1,68 @@
/*
The Evolving Distribution Objects framework (EDO) is a template-based,
ANSI-C++ evolutionary computation library which helps you to write your
own estimation of distribution algorithms.
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
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (C) 2010 Thales group
*/
/*
Authors:
Johann Dréo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _edoStatNormalMulti_h
#define _edoStatNormalMulti_h
#include <boost/numeric/ublas/io.hpp>
#include "edoStat.h"
#include "edoNormalMulti.h"
template < typename EOT >
class edoStatNormalMulti : public edoDistribStat< edoNormalMulti< EOT > >
{
public:
typedef typename EOT::AtomType AtomType;
using edoDistribStat< edoNormalMulti< EOT > >::value;
edoStatNormalMulti( std::string desc = "" )
: edoDistribStat< edoNormalMulti< EOT > >( desc )
{}
void operator()( const edoNormalMulti< EOT >& distrib )
{
value() = "\n# ====== multi normal distribution dump =====\n";
std::ostringstream os;
os << distrib.mean() << " " << distrib.varcovar() << std::endl;
// ublas::vector< AtomType > mean = distrib.mean();
// std::copy(mean.begin(), mean.end(), std::ostream_iterator< std::string >( os, " " ));
// ublas::symmetric_matrix< AtomType, ublas::lower > varcovar = distrib.varcovar();
// std::copy(varcovar.begin(), varcovar.end(), std::ostream_iterator< std::string >( os, " " ));
// os << std::endl;
value() += os.str();
}
};
#endif // !_edoStatNormalMulti_h

View file

@ -0,0 +1,55 @@
/*
The Evolving Distribution Objects framework (EDO) is a template-based,
ANSI-C++ evolutionary computation library which helps you to write your
own estimation of distribution algorithms.
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
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (C) 2010 Thales group
*/
/*
Authors:
Johann Dréo <johann.dreo@thalesgroup.com>
Caner Candan <caner.candan@thalesgroup.com>
*/
#ifndef _edoStatUniform_h
#define _edoStatUniform_h
#include "edoStat.h"
#include "edoUniform.h"
template < typename EOT >
class edoStatUniform : public edoDistribStat< edoUniform< EOT > >
{
public:
using edoDistribStat< edoUniform< EOT > >::value;
edoStatUniform( std::string desc = "" )
: edoDistribStat< edoUniform< EOT > >( desc )
{}
void operator()( const edoUniform< EOT >& distrib )
{
value() = "\n# ====== uniform distribution dump =====\n";
std::ostringstream os;
os << distrib.min() << " " << distrib.max() << std::endl;
value() += os.str();
}
};
#endif // !_edoStatUniform_h