+ eda algo: same algo than eda-sa without sa, + plotting scripts and problem functions moved to application/common
This commit is contained in:
parent
ba6770df43
commit
65191e2212
16 changed files with 595 additions and 14 deletions
|
|
@ -83,6 +83,7 @@ ADD_SUBDIRECTORY(doc)
|
|||
######################################################################################
|
||||
|
||||
|
||||
|
||||
######################################################################################
|
||||
### 7) Create executable, link libraries and prepare target
|
||||
######################################################################################
|
||||
|
|
|
|||
|
|
@ -2,6 +2,12 @@
|
|||
### 1) Where do we go now ?!?
|
||||
######################################################################################
|
||||
|
||||
INCLUDE_DIRECTORIES(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/common
|
||||
)
|
||||
|
||||
ADD_SUBDIRECTORY(common)
|
||||
ADD_SUBDIRECTORY(eda_sa)
|
||||
ADD_SUBDIRECTORY(eda)
|
||||
|
||||
######################################################################################
|
||||
|
|
|
|||
14
application/common/CMakeLists.txt
Normal file
14
application/common/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
PROJECT(common)
|
||||
|
||||
SET(RESOURCES
|
||||
gplot.py
|
||||
ggobi.py
|
||||
)
|
||||
|
||||
FOREACH(file ${RESOURCES})
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${file}
|
||||
${DO_BINARY_DIR}/${file}
|
||||
)
|
||||
ENDFOREACH(file)
|
||||
27
application/eda/CMakeLists.txt
Normal file
27
application/eda/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
PROJECT(eda)
|
||||
|
||||
FIND_PACKAGE(Boost 1.33.0)
|
||||
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
|
||||
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
|
||||
|
||||
SET(RESOURCES
|
||||
${PROJECT_NAME}.param
|
||||
)
|
||||
|
||||
FOREACH(file ${RESOURCES})
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${file}
|
||||
${DO_BINARY_DIR}/${file}
|
||||
)
|
||||
ENDFOREACH(file)
|
||||
|
||||
FILE(GLOB SOURCES *.cpp)
|
||||
|
||||
SET(EXECUTABLE_OUTPUT_PATH ${DO_BINARY_DIR})
|
||||
|
||||
ADD_EXECUTABLE(${PROJECT_NAME} ${SOURCES})
|
||||
TARGET_LINK_LIBRARIES(${PROJECT_NAME} do doutils ${EO_LIBRARIES} ${MO_LIBRARIES} ${Boost_LIBRARIES})
|
||||
7
application/eda/eda.param
Normal file
7
application/eda/eda.param
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
--rho=0 # -p : <etropolis sample size
|
||||
--alpha=0 # -a : Temperature dicrease rate
|
||||
--threshold=0.1 # -t : Temperature threshold stopping criteria
|
||||
--sample-size=10 # -P : Sample size
|
||||
--dimension-size=10 # -d : Dimension size
|
||||
--temperature=100 # -T : Initial temperature
|
||||
#--verbose # Enable verbose mode
|
||||
267
application/eda/main.cpp
Normal file
267
application/eda/main.cpp
Normal file
|
|
@ -0,0 +1,267 @@
|
|||
#include <eo>
|
||||
#include <mo>
|
||||
|
||||
#include <utils/eoLogger.h>
|
||||
#include <utils/eoParserLogger.h>
|
||||
|
||||
#include <eoEvalFuncCounterBounder.h>
|
||||
|
||||
#include <do/make_pop.h>
|
||||
#include <do/make_run.h>
|
||||
#include <do/make_continue.h>
|
||||
#include <do/make_checkpoint.h>
|
||||
|
||||
#include <do>
|
||||
|
||||
#include "Rosenbrock.h"
|
||||
#include "Sphere.h"
|
||||
|
||||
|
||||
typedef eoReal<eoMinimizingFitness> EOT;
|
||||
typedef doNormalMulti< EOT > Distrib;
|
||||
|
||||
|
||||
int main(int ac, char** av)
|
||||
{
|
||||
eoParserLogger parser(ac, av);
|
||||
|
||||
// Letters used by the following declarations:
|
||||
// a d i p t
|
||||
|
||||
std::string section("Algorithm parameters");
|
||||
|
||||
// FIXME: default value to check
|
||||
//double initial_temperature = parser.createParam((double)10e5, "temperature", "Initial temperature", 'i', section).value(); // i
|
||||
|
||||
eoState state;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Instantiate all needed parameters for EDA algorithm
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
double selection_rate = parser.createParam((double)0.5, "selection_rate", "Selection Rate", 'R', section).value(); // R
|
||||
|
||||
eoSelect< EOT >* selector = new eoDetSelect< EOT >( selection_rate );
|
||||
state.storeFunctor(selector);
|
||||
|
||||
doEstimator< Distrib >* estimator = new doEstimatorNormalMulti< EOT >();
|
||||
state.storeFunctor(estimator);
|
||||
|
||||
eoSelectOne< EOT >* selectone = new eoDetTournamentSelect< EOT >( 2 );
|
||||
state.storeFunctor(selectone);
|
||||
|
||||
doModifierMass< Distrib >* modifier = new doNormalMultiCenter< EOT >();
|
||||
state.storeFunctor(modifier);
|
||||
|
||||
eoEvalFunc< EOT >* plainEval = new Rosenbrock< EOT >();
|
||||
state.storeFunctor(plainEval);
|
||||
|
||||
unsigned long max_eval = parser.getORcreateParam((unsigned long)0, "maxEval", "Maximum number of evaluations (0 = none)", 'E', "Stopping criterion").value(); // E
|
||||
eoEvalFuncCounterBounder< EOT > eval(*plainEval, max_eval);
|
||||
|
||||
eoRndGenerator< double >* gen = new eoUniformGenerator< double >(-5, 5);
|
||||
state.storeFunctor(gen);
|
||||
|
||||
|
||||
unsigned int dimension_size = parser.createParam((unsigned int)10, "dimension-size", "Dimension size", 'd', section).value(); // d
|
||||
|
||||
eoInitFixedLength< EOT >* init = new eoInitFixedLength< EOT >( dimension_size, *gen );
|
||||
state.storeFunctor(init);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// (1) Population init and sampler
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Generation of population from do_make_pop (creates parameters, manages persistance and so on...)
|
||||
// ... and creates the parameters: L P r S
|
||||
|
||||
// this first sampler creates a uniform distribution independently from our distribution (it does not use doUniform).
|
||||
|
||||
eoPop< EOT >& pop = do_make_pop(parser, state, *init);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// (2) First evaluation before starting the research algorithm
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
apply(eval, pop);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Prepare bounder class to set bounds of sampling.
|
||||
// This is used by doSampler.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
doBounder< EOT >* bounder = new doBounderRng< EOT >(EOT(pop[0].size(), -5),
|
||||
EOT(pop[0].size(), 5),
|
||||
*gen);
|
||||
state.storeFunctor(bounder);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Prepare sampler class with a specific distribution
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
doSampler< Distrib >* sampler = new doSamplerNormalMulti< EOT >( *bounder );
|
||||
state.storeFunctor(sampler);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Metropolis sample parameters
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//unsigned int popSize = parser.getORcreateParam((unsigned int)20, "popSize", "Population Size", 'P', "Evolution Engine").value();
|
||||
|
||||
//moContinuator< moDummyNeighbor<EOT> >* sa_continue = new moIterContinuator< moDummyNeighbor<EOT> >( popSize );
|
||||
//state.storeFunctor(sa_continue);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// SA parameters
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//double threshold_temperature = parser.createParam((double)0.1, "threshold", "Minimal temperature at which stop", 't', section).value(); // t
|
||||
//double alpha = parser.createParam((double)0.1, "alpha", "Temperature decrease rate", 'a', section).value(); // a
|
||||
|
||||
//moCoolingSchedule<EOT>* cooling_schedule = new moSimpleCoolingSchedule<EOT>(initial_temperature, alpha, 0, threshold_temperature);
|
||||
//state.storeFunctor(cooling_schedule);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// stopping criteria
|
||||
// ... and creates the parameter letters: C E g G s T
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
eoContinue< EOT >& eo_continue = do_make_continue(parser, state, eval);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// population output
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
eoCheckPoint< EOT >& pop_continue = do_make_checkpoint(parser, state, eval, eo_continue);
|
||||
|
||||
doPopStat< EOT >* popStat = new doPopStat<EOT>;
|
||||
state.storeFunctor(popStat);
|
||||
pop_continue.add(*popStat);
|
||||
|
||||
doFileSnapshot* fileSnapshot = new doFileSnapshot("EDA_ResPop");
|
||||
state.storeFunctor(fileSnapshot);
|
||||
fileSnapshot->add(*popStat);
|
||||
pop_continue.add(*fileSnapshot);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// distribution output
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
doDummyContinue< Distrib >* dummy_continue = new doDummyContinue< Distrib >();
|
||||
state.storeFunctor(dummy_continue);
|
||||
|
||||
doCheckPoint< Distrib >* distribution_continue = new doCheckPoint< Distrib >( *dummy_continue );
|
||||
state.storeFunctor(distribution_continue);
|
||||
|
||||
doDistribStat< Distrib >* distrib_stat = new doStatNormalMulti< EOT >();
|
||||
state.storeFunctor(distrib_stat);
|
||||
|
||||
distribution_continue->add( *distrib_stat );
|
||||
|
||||
// eoMonitor* stdout_monitor = new eoStdoutMonitor();
|
||||
// state.storeFunctor(stdout_monitor);
|
||||
// stdout_monitor->add(*distrib_stat);
|
||||
// distribution_continue->add( *stdout_monitor );
|
||||
|
||||
eoFileMonitor* file_monitor = new eoFileMonitor("eda_distribution_bounds.txt");
|
||||
state.storeFunctor(file_monitor);
|
||||
file_monitor->add(*distrib_stat);
|
||||
distribution_continue->add( *file_monitor );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// eoEPRemplacement causes the using of the current and previous
|
||||
// sample for sampling.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
eoReplacement< EOT >* replacor = new eoEPReplacement< EOT >(pop.size());
|
||||
|
||||
// Below, use eoGenerationalReplacement to sample only on the current sample
|
||||
|
||||
//eoReplacement< EOT >* replacor = new eoGenerationalReplacement< EOT >(); // FIXME: to define the size
|
||||
|
||||
state.storeFunctor(replacor);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// EDA algorithm configuration
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
doAlgo< Distrib >* algo = new doEDA< Distrib >
|
||||
(*selector, *estimator, *selectone, *modifier, *sampler,
|
||||
pop_continue, *distribution_continue,
|
||||
eval,
|
||||
//*sa_continue, *cooling_schedule, initial_temperature,
|
||||
*replacor);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
// state.storeFunctor(algo);
|
||||
|
||||
if (parser.userNeedsHelp())
|
||||
{
|
||||
parser.printHelp(std::cout);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Help + Verbose routines
|
||||
|
||||
make_verbose(parser);
|
||||
make_help(parser);
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Beginning of the algorithm call
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
try
|
||||
{
|
||||
do_run(*algo, pop);
|
||||
}
|
||||
catch (eoEvalFuncCounterBounderException& e)
|
||||
{
|
||||
eo::log << eo::warnings << "warning: " << e.what() << std::endl;
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
eo::log << eo::errors << "error: " << e.what() << std::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -8,9 +8,7 @@ INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
|
|||
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
|
||||
|
||||
SET(RESOURCES
|
||||
eda_sa.param
|
||||
gplot.py
|
||||
ggobi.py
|
||||
${PROJECT_NAME}.param
|
||||
)
|
||||
|
||||
FOREACH(file ${RESOURCES})
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ int main(int ac, char** av)
|
|||
state.storeFunctor(popStat);
|
||||
pop_continue.add(*popStat);
|
||||
|
||||
doFileSnapshot* fileSnapshot = new doFileSnapshot("ResPop");
|
||||
doFileSnapshot* fileSnapshot = new doFileSnapshot("EDASA_ResPop");
|
||||
state.storeFunctor(fileSnapshot);
|
||||
fileSnapshot->add(*popStat);
|
||||
pop_continue.add(*fileSnapshot);
|
||||
|
|
@ -191,7 +191,7 @@ int main(int ac, char** av)
|
|||
// stdout_monitor->add(*distrib_stat);
|
||||
// distribution_continue->add( *stdout_monitor );
|
||||
|
||||
eoFileMonitor* file_monitor = new eoFileMonitor("distribution_bounds.txt");
|
||||
eoFileMonitor* file_monitor = new eoFileMonitor("eda_sa_distribution_bounds.txt");
|
||||
state.storeFunctor(file_monitor);
|
||||
file_monitor->add(*distrib_stat);
|
||||
distribution_continue->add( *file_monitor );
|
||||
|
|
|
|||
1
src/do
1
src/do
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include "doAlgo.h"
|
||||
#include "doEDASA.h"
|
||||
#include "doEDA.h"
|
||||
|
||||
#include "doDistrib.h"
|
||||
#include "doUniform.h"
|
||||
|
|
|
|||
252
src/doEDA.h
Normal file
252
src/doEDA.h
Normal file
|
|
@ -0,0 +1,252 @@
|
|||
// (c) Thales group, 2010
|
||||
/*
|
||||
Authors:
|
||||
Johann Dreo <johann.dreo@thalesgroup.com>
|
||||
Caner Candan <caner.candan@thalesgroup.com>
|
||||
*/
|
||||
|
||||
#ifndef _doEDA_h
|
||||
#define _doEDA_h
|
||||
|
||||
#include <eo>
|
||||
#include <mo>
|
||||
|
||||
#include <utils/eoRNG.h>
|
||||
|
||||
#include "doAlgo.h"
|
||||
#include "doEstimator.h"
|
||||
#include "doModifierMass.h"
|
||||
#include "doSampler.h"
|
||||
#include "doContinue.h"
|
||||
|
||||
template < typename D >
|
||||
class doEDA : public doAlgo< 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:
|
||||
|
||||
//! doEDA constructor
|
||||
/*!
|
||||
All the boxes used by a EDASA need to be given.
|
||||
|
||||
\param selector Population Selector
|
||||
\param estimator Distribution Estimator
|
||||
\param selectone SelectOne
|
||||
\param modifier Distribution Modifier
|
||||
\param sampler Distribution Sampler
|
||||
\param pop_continue Population Continuator
|
||||
\param distribution_continue Distribution Continuator
|
||||
\param evaluation Evaluation function.
|
||||
\param sa_continue Stopping criterion.
|
||||
\param cooling_schedule Cooling schedule, describes how the temperature is modified.
|
||||
\param initial_temperature The initial temperature.
|
||||
\param replacor Population replacor
|
||||
*/
|
||||
doEDA (eoSelect< EOT > & selector,
|
||||
doEstimator< D > & estimator,
|
||||
eoSelectOne< EOT > & selectone,
|
||||
doModifierMass< D > & modifier,
|
||||
doSampler< D > & sampler,
|
||||
eoContinue< EOT > & pop_continue,
|
||||
doContinue< D > & distribution_continue,
|
||||
eoEvalFunc < EOT > & evaluation,
|
||||
//moContinuator< moDummyNeighbor<EOT> > & sa_continue,
|
||||
//moCoolingSchedule<EOT> & cooling_schedule,
|
||||
//double initial_temperature,
|
||||
eoReplacement< EOT > & replacor
|
||||
)
|
||||
: _selector(selector),
|
||||
_estimator(estimator),
|
||||
_selectone(selectone),
|
||||
_modifier(modifier),
|
||||
_sampler(sampler),
|
||||
_pop_continue(pop_continue),
|
||||
_distribution_continue(distribution_continue),
|
||||
_evaluation(evaluation),
|
||||
//_sa_continue(sa_continue),
|
||||
//_cooling_schedule(cooling_schedule),
|
||||
//_initial_temperature(initial_temperature),
|
||||
_replacor(replacor)
|
||||
|
||||
{}
|
||||
|
||||
//! function that launches the EDASA algorithm.
|
||||
/*!
|
||||
As a moTS or a moHC, the EDASA can be used for HYBRIDATION in an evolutionary algorithm.
|
||||
|
||||
\param pop A population to improve.
|
||||
\return TRUE.
|
||||
*/
|
||||
void operator ()(eoPop< EOT > & pop)
|
||||
{
|
||||
assert(pop.size() > 0);
|
||||
|
||||
//double temperature = _initial_temperature;
|
||||
|
||||
eoPop< EOT > current_pop;
|
||||
|
||||
eoPop< EOT > selected_pop;
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Estimating a first time the distribution parameter thanks
|
||||
// to population.
|
||||
//-------------------------------------------------------------
|
||||
|
||||
D distrib = _estimator(pop);
|
||||
|
||||
double size = distrib.size();
|
||||
assert(size > 0);
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
//-------------------------------------------------------------
|
||||
// (3) Selection of the best points in the population
|
||||
//-------------------------------------------------------------
|
||||
|
||||
selected_pop.clear();
|
||||
|
||||
_selector(pop, selected_pop);
|
||||
|
||||
assert( selected_pop.size() > 0 );
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// (4) Estimation of the distribution parameters
|
||||
//-------------------------------------------------------------
|
||||
|
||||
distrib = _estimator(selected_pop);
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
// TODO: utiliser selected_pop ou pop ???
|
||||
|
||||
assert(selected_pop.size() > 0);
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Init of a variable contening a point with the bestest fitnesses
|
||||
//-------------------------------------------------------------
|
||||
|
||||
EOT current_solution = _selectone(selected_pop);
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Fit the current solution with the distribution parameters (bounds)
|
||||
//-------------------------------------------------------------
|
||||
|
||||
// FIXME: si besoin de modifier la dispersion de la distribution
|
||||
// _modifier_dispersion(distribution, selected_pop);
|
||||
_modifier(distrib, current_solution);
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Evaluating a first time the current solution
|
||||
//-------------------------------------------------------------
|
||||
|
||||
_evaluation( current_solution );
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Building of the sampler in current_pop
|
||||
//-------------------------------------------------------------
|
||||
|
||||
//_sa_continue.init( current_solution );
|
||||
|
||||
current_pop.clear();
|
||||
|
||||
for ( unsigned int i = 0; i < pop.size(); ++i )
|
||||
//do
|
||||
{
|
||||
EOT candidate_solution = _sampler(distrib);
|
||||
_evaluation( candidate_solution );
|
||||
|
||||
// TODO: verifier le critere d'acceptation
|
||||
if ( candidate_solution.fitness() < current_solution.fitness()
|
||||
// || rng.uniform() < exp( ::fabs(candidate_solution.fitness() - current_solution.fitness()) / temperature )
|
||||
)
|
||||
{
|
||||
current_pop.push_back(candidate_solution);
|
||||
current_solution = candidate_solution;
|
||||
}
|
||||
}
|
||||
//while ( _sa_continue( current_solution) );
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
_replacor(pop, current_pop); // copy current_pop in pop
|
||||
|
||||
pop.sort();
|
||||
|
||||
//if ( ! _cooling_schedule( temperature ) ){ eo::log << eo::debug << "_cooling_schedule" << std::endl; break; }
|
||||
|
||||
if ( ! _distribution_continue( distrib ) ){ eo::log << eo::debug << "_distribution_continue" << std::endl; break; }
|
||||
|
||||
if ( ! _pop_continue( pop ) ){ eo::log << eo::debug << "_pop_continue" << std::endl; break; }
|
||||
|
||||
}
|
||||
while ( 1 );
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! A EOT selector
|
||||
eoSelect < EOT > & _selector;
|
||||
|
||||
//! A EOT estimator. It is going to estimate distribution parameters.
|
||||
doEstimator< D > & _estimator;
|
||||
|
||||
//! SelectOne
|
||||
eoSelectOne< EOT > & _selectone;
|
||||
|
||||
//! A D modifier
|
||||
doModifierMass< D > & _modifier;
|
||||
|
||||
//! A D sampler
|
||||
doSampler< D > & _sampler;
|
||||
|
||||
//! A EOT population continuator
|
||||
eoContinue < EOT > & _pop_continue;
|
||||
|
||||
//! A D continuator
|
||||
doContinue < D > & _distribution_continue;
|
||||
|
||||
//! A full evaluation function.
|
||||
eoEvalFunc < EOT > & _evaluation;
|
||||
|
||||
//! Stopping criterion before temperature update
|
||||
//moContinuator< moDummyNeighbor<EOT> > & _sa_continue;
|
||||
|
||||
//! The cooling schedule
|
||||
//moCoolingSchedule<EOT> & _cooling_schedule;
|
||||
|
||||
//! Initial temperature
|
||||
//double _initial_temperature;
|
||||
|
||||
//! A EOT replacor
|
||||
eoReplacement < EOT > & _replacor;
|
||||
};
|
||||
|
||||
#endif // !_doEDA_h
|
||||
|
|
@ -159,6 +159,15 @@ public:
|
|||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Evaluating a first time the current solution
|
||||
//-------------------------------------------------------------
|
||||
|
||||
_evaluation( current_solution );
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Building of the sampler in current_pop
|
||||
//-------------------------------------------------------------
|
||||
|
|
@ -170,21 +179,20 @@ public:
|
|||
do
|
||||
{
|
||||
EOT candidate_solution = _sampler(distrib);
|
||||
|
||||
EOT& e1 = candidate_solution;
|
||||
_evaluation( e1 );
|
||||
EOT& e2 = current_solution;
|
||||
_evaluation( e2 );
|
||||
_evaluation( candidate_solution );
|
||||
|
||||
// TODO: verifier le critere d'acceptation
|
||||
if ( e1.fitness() < e2.fitness() ||
|
||||
rng.uniform() < exp( ::fabs(e1.fitness() - e2.fitness()) / temperature ) )
|
||||
if ( candidate_solution.fitness() < current_solution.fitness() ||
|
||||
rng.uniform() < exp( ::fabs(candidate_solution.fitness() - current_solution.fitness()) / temperature ) )
|
||||
{
|
||||
current_pop.push_back(candidate_solution);
|
||||
current_solution = candidate_solution;
|
||||
}
|
||||
}
|
||||
while ( _sa_continue( current_solution) );
|
||||
while ( _sa_continue( current_solution ) );
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
_replacor(pop, current_pop); // copy current_pop in pop
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
|
|||
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
|
||||
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
|
||||
|
||||
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/application/eda_sa)
|
||||
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/application/common)
|
||||
|
||||
SET(SOURCES
|
||||
t-doEstimatorNormalMulti
|
||||
|
|
|
|||
Reference in a new issue