edo/CMakeLists.txt updated
This commit is contained in:
parent
09d08bf043
commit
9bd53e3057
18 changed files with 154 additions and 251 deletions
|
|
@ -125,7 +125,7 @@ SET(SAMPLE_SRCS)
|
|||
|
||||
ADD_SUBDIRECTORY(src)
|
||||
ADD_SUBDIRECTORY(application)
|
||||
ADD_SUBDIRECTORY(test)
|
||||
#ADD_SUBDIRECTORY(test)
|
||||
ADD_SUBDIRECTORY(doc)
|
||||
|
||||
######################################################################################
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ int main(int ac, char** av)
|
|||
eoPopLoopEval<EOT> popEval( eval );
|
||||
|
||||
// EDA algorithm configuration
|
||||
edoAlgo< Distrib >* algo = new edoEDA< Distrib >
|
||||
edoAlgo< Distrib >* algo = new edoAlgoStateless< Distrib >
|
||||
(popEval, *selector, *estimator, *sampler, *replacor,
|
||||
pop_continue, *distribution_continue );
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
mkdir -p release
|
||||
cd release
|
||||
cmake ..
|
||||
cmake -DWITH_EIGEN=1 ..
|
||||
#cmake -DWITH_BOOST=1 ..
|
||||
make
|
||||
cd ..
|
||||
|
|
|
|||
|
|
@ -30,17 +30,21 @@ Authors:
|
|||
|
||||
#include "edoAlgo.h"
|
||||
//#include "edoEDASA.h"
|
||||
#include "edoEDA.h"
|
||||
#include "edoAlgoAdaptive.h"
|
||||
#include "edoAlgoStateless.h"
|
||||
|
||||
#include "edoDistrib.h"
|
||||
#include "edoUniform.h"
|
||||
#include "edoNormalMono.h"
|
||||
#include "edoNormalMulti.h"
|
||||
#include "edoNormalAdaptive.h"
|
||||
|
||||
#include "edoEstimator.h"
|
||||
#include "edoEstimatorUniform.h"
|
||||
#include "edoEstimatorNormalMono.h"
|
||||
#include "edoEstimatorNormalMulti.h"
|
||||
#include "edoEstimatorAdaptive.h"
|
||||
#include "edoEstimatorNormalAdaptive.h"
|
||||
|
||||
#include "edoModifier.h"
|
||||
#include "edoModifierDispersion.h"
|
||||
|
|
@ -53,6 +57,7 @@ Authors:
|
|||
#include "edoSamplerUniform.h"
|
||||
#include "edoSamplerNormalMono.h"
|
||||
#include "edoSamplerNormalMulti.h"
|
||||
#include "edoSamplerNormalAdaptive.h"
|
||||
|
||||
#include "edoVectorBounds.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ template < typename D >
|
|||
class edoAlgo : public eoAlgo< typename D::EOType >
|
||||
{
|
||||
//! Alias for the type
|
||||
typedef typename D::EOType EOT;
|
||||
typedef typename D::EOType EOType;
|
||||
|
||||
// virtual R operator()(A1) = 0; (defined in eoUF)
|
||||
|
||||
|
|
|
|||
195
edo/src/edoEDA.h
195
edo/src/edoEDA.h
|
|
@ -1,195 +0,0 @@
|
|||
/*
|
||||
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 _edoEDA_h
|
||||
#define _edoEDA_h
|
||||
|
||||
#include <eo>
|
||||
#include <mo>
|
||||
|
||||
#include <utils/eoRNG.h>
|
||||
|
||||
#include "edoAlgo.h"
|
||||
#include "edoEstimator.h"
|
||||
#include "edoModifierMass.h"
|
||||
#include "edoSampler.h"
|
||||
#include "edoContinue.h"
|
||||
|
||||
//! edoEDA< D >
|
||||
|
||||
template < typename D >
|
||||
class edoEDA : public edoAlgo< D >
|
||||
{
|
||||
public:
|
||||
//! Alias for the type EOT
|
||||
typedef typename D::EOType EOT;
|
||||
|
||||
//! Alias for the atom type
|
||||
typedef typename EOT::AtomType AtomType;
|
||||
|
||||
//! Alias for the fitness
|
||||
typedef typename EOT::Fitness Fitness;
|
||||
|
||||
public:
|
||||
|
||||
//! edoEDA constructor
|
||||
/*!
|
||||
Takes algo operators, all are mandatory
|
||||
|
||||
\param evaluation Evaluate a population
|
||||
\param selector Selection of the best candidate solutions in the population
|
||||
\param estimator Estimation of the distribution parameters
|
||||
\param sampler Generate feasible solutions using the distribution
|
||||
\param replacor Replace old solutions by new ones
|
||||
\param pop_continuator Stopping criterion based on the population features
|
||||
\param distribution_continuator Stopping criterion based on the distribution features
|
||||
*/
|
||||
edoEDA (
|
||||
eoPopEvalFunc < EOT > & evaluator,
|
||||
eoSelect< EOT > & selector,
|
||||
edoEstimator< D > & estimator,
|
||||
edoSampler< D > & sampler,
|
||||
eoReplacement< EOT > & replacor,
|
||||
eoContinue< EOT > & pop_continuator,
|
||||
edoContinue< D > & distribution_continuator
|
||||
) :
|
||||
_evaluator(evaluator),
|
||||
_selector(selector),
|
||||
_estimator(estimator),
|
||||
_sampler(sampler),
|
||||
_replacor(replacor),
|
||||
_pop_continuator(pop_continuator),
|
||||
_dummy_continue(),
|
||||
_distribution_continuator(distribution_continuator)
|
||||
{}
|
||||
|
||||
//! edoEDA constructor without an edoContinue
|
||||
/*!
|
||||
Takes algo operators, all are mandatory
|
||||
|
||||
\param evaluation Evaluate a population
|
||||
\param selector Selection of the best candidate solutions in the population
|
||||
\param estimator Estimation of the distribution parameters
|
||||
\param sampler Generate feasible solutions using the distribution
|
||||
\param replacor Replace old solutions by new ones
|
||||
\param pop_continuator Stopping criterion based on the population features
|
||||
*/
|
||||
edoEDA (
|
||||
eoPopEvalFunc < EOT > & evaluator,
|
||||
eoSelect< EOT > & selector,
|
||||
edoEstimator< D > & estimator,
|
||||
edoSampler< D > & sampler,
|
||||
eoReplacement< EOT > & replacor,
|
||||
eoContinue< EOT > & pop_continuator
|
||||
) :
|
||||
_evaluator(evaluator),
|
||||
_selector(selector),
|
||||
_estimator(estimator),
|
||||
_sampler(sampler),
|
||||
_replacor(replacor),
|
||||
_pop_continuator(pop_continuator),
|
||||
_dummy_continue(),
|
||||
_distribution_continuator( _dummy_continue )
|
||||
{}
|
||||
|
||||
|
||||
/** A basic EDA algorithm that iterates over:
|
||||
* selection, estimation, sampling, bounding, evaluation, replacement
|
||||
*
|
||||
* \param pop the population of candidate solutions
|
||||
* \return void
|
||||
*/
|
||||
void operator ()(eoPop< EOT > & pop)
|
||||
{
|
||||
assert(pop.size() > 0);
|
||||
|
||||
eoPop< EOT > current_pop;
|
||||
eoPop< EOT > selected_pop;
|
||||
|
||||
// FIXME one must instanciate a first distrib here because there is no empty constructor, see if it is possible to instanciate Distributions without parameters
|
||||
D distrib = _estimator(pop);
|
||||
|
||||
// Evaluating a first time the candidate solutions
|
||||
// The first pop is not supposed to be evaluated (@see eoPopLoopEval).
|
||||
_evaluator( current_pop, pop );
|
||||
|
||||
do {
|
||||
// (1) Selection of the best points in the population
|
||||
//selected_pop.clear(); // FIXME is it necessary to clear?
|
||||
_selector(pop, selected_pop);
|
||||
assert( selected_pop.size() > 0 );
|
||||
// TODO: utiliser selected_pop ou pop ???
|
||||
|
||||
// (2) Estimation of the distribution parameters
|
||||
distrib = _estimator(selected_pop);
|
||||
|
||||
// (3) sampling
|
||||
// The sampler produces feasible solutions (@see edoSampler that
|
||||
// encapsulate an edoBounder)
|
||||
current_pop.clear();
|
||||
for( unsigned int i = 0; i < pop.size(); ++i ) {
|
||||
current_pop.push_back( _sampler(distrib) );
|
||||
}
|
||||
|
||||
// (4) Evaluate new solutions
|
||||
_evaluator( pop, current_pop );
|
||||
|
||||
// (5) Replace old solutions by new ones
|
||||
_replacor(pop, current_pop); // e.g. copy current_pop in pop
|
||||
|
||||
} while( _distribution_continuator( distrib ) && _pop_continuator( pop ) );
|
||||
} // operator()
|
||||
|
||||
private:
|
||||
|
||||
//! A full evaluation function.
|
||||
eoPopEvalFunc < EOT > & _evaluator;
|
||||
|
||||
//! A EOT selector
|
||||
eoSelect < EOT > & _selector;
|
||||
|
||||
//! A EOT estimator. It is going to estimate distribution parameters.
|
||||
edoEstimator< D > & _estimator;
|
||||
|
||||
//! A D sampler
|
||||
edoSampler< D > & _sampler;
|
||||
|
||||
//! A EOT replacor
|
||||
eoReplacement < EOT > & _replacor;
|
||||
|
||||
//! A EOT population continuator
|
||||
eoContinue < EOT > & _pop_continuator;
|
||||
|
||||
//! A D continuator that always return true
|
||||
edoDummyContinue<D> _dummy_continue;
|
||||
|
||||
//! A D continuator
|
||||
edoContinue < D > & _distribution_continuator;
|
||||
|
||||
};
|
||||
|
||||
#endif // !_edoEDA_h
|
||||
|
|
@ -29,7 +29,7 @@ Authors:
|
|||
#define _edoEDASA_h
|
||||
|
||||
#include <eo>
|
||||
#include <mo>
|
||||
//#include <mo>
|
||||
|
||||
#include <utils/eoRNG.h>
|
||||
|
||||
|
|
@ -46,13 +46,13 @@ class edoEDASA : public edoAlgo< D >
|
|||
{
|
||||
public:
|
||||
//! Alias for the type EOT
|
||||
typedef typename D::EOType EOT;
|
||||
typedef typename D::EOType EOType;
|
||||
|
||||
//! Alias for the atom type
|
||||
typedef typename EOT::AtomType AtomType;
|
||||
typedef typename EOType::AtomType AtomType;
|
||||
|
||||
//! Alias for the fitness
|
||||
typedef typename EOT::Fitness Fitness;
|
||||
typedef typename EOType::Fitness Fitness;
|
||||
|
||||
public:
|
||||
|
||||
|
|
@ -73,18 +73,18 @@ public:
|
|||
\param initial_temperature The initial temperature.
|
||||
\param replacor Population replacor
|
||||
*/
|
||||
edoEDASA (eoSelect< EOT > & selector,
|
||||
edoEDASA (eoSelect< EOType > & selector,
|
||||
edoEstimator< D > & estimator,
|
||||
eoSelectOne< EOT > & selectone,
|
||||
eoSelectOne< EOType > & selectone,
|
||||
edoModifierMass< D > & modifier,
|
||||
edoSampler< D > & sampler,
|
||||
eoContinue< EOT > & pop_continue,
|
||||
eoContinue< EOType > & pop_continue,
|
||||
edoContinue< D > & distribution_continue,
|
||||
eoEvalFunc < EOT > & evaluation,
|
||||
moContinuator< moDummyNeighbor<EOT> > & sa_continue,
|
||||
moCoolingSchedule<EOT> & cooling_schedule,
|
||||
eoEvalFunc < EOType > & evaluation,
|
||||
moContinuator< moDummyNeighbor<EOType> > & sa_continue,
|
||||
moCoolingSchedule<EOType> & cooling_schedule,
|
||||
double initial_temperature,
|
||||
eoReplacement< EOT > & replacor
|
||||
eoReplacement< EOType > & replacor
|
||||
)
|
||||
: _selector(selector),
|
||||
_estimator(estimator),
|
||||
|
|
@ -108,15 +108,15 @@ public:
|
|||
\param pop A population to improve.
|
||||
\return TRUE.
|
||||
*/
|
||||
void operator ()(eoPop< EOT > & pop)
|
||||
void operator ()(eoPop< EOType > & pop)
|
||||
{
|
||||
assert(pop.size() > 0);
|
||||
|
||||
double temperature = _initial_temperature;
|
||||
|
||||
eoPop< EOT > current_pop;
|
||||
eoPop< EOType > current_pop;
|
||||
|
||||
eoPop< EOT > selected_pop;
|
||||
eoPop< EOType > selected_pop;
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
|
@ -165,7 +165,7 @@ public:
|
|||
// Init of a variable contening a point with the bestest fitnesses
|
||||
//-------------------------------------------------------------
|
||||
|
||||
EOT current_solution = _selectone(selected_pop);
|
||||
EOType current_solution = _selectone(selected_pop);
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
|
@ -200,7 +200,7 @@ public:
|
|||
|
||||
do
|
||||
{
|
||||
EOT candidate_solution = _sampler(distrib);
|
||||
EOType candidate_solution = _sampler(distrib);
|
||||
_evaluation( candidate_solution );
|
||||
|
||||
// TODO: verifier le critere d'acceptation
|
||||
|
|
@ -232,14 +232,14 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
//! A EOT selector
|
||||
eoSelect < EOT > & _selector;
|
||||
//! A EOType selector
|
||||
eoSelect < EOType > & _selector;
|
||||
|
||||
//! A EOT estimator. It is going to estimate distribution parameters.
|
||||
//! A EOType estimator. It is going to estimate distribution parameters.
|
||||
edoEstimator< D > & _estimator;
|
||||
|
||||
//! SelectOne
|
||||
eoSelectOne< EOT > & _selectone;
|
||||
eoSelectOne< EOType > & _selectone;
|
||||
|
||||
//! A D modifier
|
||||
edoModifierMass< D > & _modifier;
|
||||
|
|
@ -247,26 +247,26 @@ private:
|
|||
//! A D sampler
|
||||
edoSampler< D > & _sampler;
|
||||
|
||||
//! A EOT population continuator
|
||||
eoContinue < EOT > & _pop_continue;
|
||||
//! A EOType population continuator
|
||||
eoContinue < EOType > & _pop_continue;
|
||||
|
||||
//! A D continuator
|
||||
edoContinue < D > & _distribution_continue;
|
||||
|
||||
//! A full evaluation function.
|
||||
eoEvalFunc < EOT > & _evaluation;
|
||||
eoEvalFunc < EOType > & _evaluation;
|
||||
|
||||
//! Stopping criterion before temperature update
|
||||
moContinuator< moDummyNeighbor<EOT> > & _sa_continue;
|
||||
moContinuator< moDummyNeighbor<EOType> > & _sa_continue;
|
||||
|
||||
//! The cooling schedule
|
||||
moCoolingSchedule<EOT> & _cooling_schedule;
|
||||
moCoolingSchedule<EOType> & _cooling_schedule;
|
||||
|
||||
//! Initial temperature
|
||||
double _initial_temperature;
|
||||
|
||||
//! A EOT replacor
|
||||
eoReplacement < EOT > & _replacor;
|
||||
//! A EOType replacor
|
||||
eoReplacement < EOType > & _replacor;
|
||||
};
|
||||
|
||||
#endif // !_edoEDASA_h
|
||||
|
|
|
|||
|
|
@ -35,7 +35,11 @@ Authors:
|
|||
template < typename EOT >
|
||||
class edoNormalMono : public edoDistrib< EOT >
|
||||
{
|
||||
public:
|
||||
public:
|
||||
edoNormalMono()
|
||||
: _mean(EOT(1,0)), _variance(EOT(1,1))
|
||||
{}
|
||||
|
||||
edoNormalMono( const EOT& mean, const EOT& variance )
|
||||
: _mean(mean), _variance(variance)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -45,6 +45,15 @@ class edoNormalMulti : public edoDistrib< EOT >
|
|||
public:
|
||||
typedef typename EOT::AtomType AtomType;
|
||||
|
||||
edoNormalMulti( unsigned int dim = 1 ) :
|
||||
_mean( const ublas::vector<AtomType>(0,dim) ),
|
||||
_varcovar( const ublas::identity_matrix<AtomType>(dim) )
|
||||
{
|
||||
assert(_mean.size() > 0);
|
||||
assert(_mean.size() == _varcovar.size1());
|
||||
assert(_mean.size() == _varcovar.size2());
|
||||
}
|
||||
|
||||
edoNormalMulti
|
||||
(
|
||||
const ublas::vector< AtomType >& mean,
|
||||
|
|
@ -86,6 +95,15 @@ public:
|
|||
typedef Eigen::Matrix< AtomType, Eigen::Dynamic, 1> Vector;
|
||||
typedef Eigen::Matrix< AtomType, Eigen::Dynamic, Eigen::Dynamic> Matrix;
|
||||
|
||||
edoNormalMulti( unsigned int dim = 1 ) :
|
||||
_mean( Vector::Zero(dim) ),
|
||||
_varcovar( Matrix::Identity(dim,dim) )
|
||||
{
|
||||
assert(_mean.size() > 0);
|
||||
assert(_mean.innerSize() == _varcovar.innerSize());
|
||||
assert(_mean.innerSize() == _varcovar.outerSize());
|
||||
}
|
||||
|
||||
edoNormalMulti(
|
||||
const Vector & mean,
|
||||
const Matrix & varcovar
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ Authors:
|
|||
#include <boost/numeric/ublas/lu.hpp>
|
||||
#include <boost/numeric/ublas/symmetric.hpp>
|
||||
|
||||
template< class EOT, typename EOD = edoNormalMulti< EOT > >
|
||||
template< typename EOT, typename EOD = edoNormalMulti< EOT > >
|
||||
class edoSamplerNormalMulti : public edoSampler< EOD >
|
||||
{
|
||||
public:
|
||||
|
|
@ -91,7 +91,7 @@ protected:
|
|||
#else
|
||||
#ifdef WITH_EIGEN
|
||||
|
||||
template< class EOT, typename EOD = edoNormalMulti< EOT > >
|
||||
template< typename EOT, typename EOD = edoNormalMulti< EOT > >
|
||||
class edoSamplerNormalMulti : public edoSampler< EOD >
|
||||
{
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ Authors:
|
|||
#include<sstream>
|
||||
|
||||
#include "edoStat.h"
|
||||
#include "edoNormalMulti.h"
|
||||
#include "../edoNormalMulti.h"
|
||||
|
||||
#ifdef WITH_BOOST
|
||||
|
||||
|
|
@ -50,7 +50,7 @@ template < typename EOT >
|
|||
class edoStatNormalMulti : public edoDistribStat< edoNormalMulti< EOT > >
|
||||
{
|
||||
public:
|
||||
typedef typename EOT::AtomType AtomType;
|
||||
// typedef typename EOT::AtomType AtomType;
|
||||
|
||||
using edoDistribStat< edoNormalMulti< EOT > >::value;
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ Authors:
|
|||
#include <iomanip>
|
||||
|
||||
#include <eo>
|
||||
#include <mo>
|
||||
//#include <mo>
|
||||
|
||||
#include <edo>
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ Authors:
|
|||
#include <fstream>
|
||||
|
||||
#include <eo>
|
||||
#include <mo>
|
||||
//#include <mo>
|
||||
|
||||
#include <edo>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue