Merge branch 'master' of ssh://localhost:8007/do
This commit is contained in:
commit
6ff2a61e2e
4 changed files with 62 additions and 74 deletions
|
|
@ -10,6 +10,7 @@ LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
|
||||||
SET(RESOURCES
|
SET(RESOURCES
|
||||||
eda_sa.param
|
eda_sa.param
|
||||||
plot.py
|
plot.py
|
||||||
|
plot_on_ggobi.py
|
||||||
)
|
)
|
||||||
|
|
||||||
FOREACH(file ${RESOURCES})
|
FOREACH(file ${RESOURCES})
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@
|
||||||
#include <utils/eoLogger.h>
|
#include <utils/eoLogger.h>
|
||||||
#include <utils/eoParserLogger.h>
|
#include <utils/eoParserLogger.h>
|
||||||
|
|
||||||
|
#include <eoEvalFuncCounterBounder.h>
|
||||||
|
|
||||||
#include <do/make_pop.h>
|
#include <do/make_pop.h>
|
||||||
#include <do/make_run.h>
|
#include <do/make_run.h>
|
||||||
#include <do/make_continue.h>
|
#include <do/make_continue.h>
|
||||||
|
|
@ -14,12 +16,11 @@
|
||||||
#include "Rosenbrock.h"
|
#include "Rosenbrock.h"
|
||||||
#include "Sphere.h"
|
#include "Sphere.h"
|
||||||
|
|
||||||
typedef eoReal<eoMinimizingFitness> EOT;
|
|
||||||
|
|
||||||
//typedef doUniform< EOT > Distrib;
|
typedef eoReal<eoMinimizingFitness> EOT;
|
||||||
//typedef doNormalMono< EOT > Distrib;
|
|
||||||
typedef doNormalMulti< EOT > Distrib;
|
typedef doNormalMulti< EOT > Distrib;
|
||||||
|
|
||||||
|
|
||||||
int main(int ac, char** av)
|
int main(int ac, char** av)
|
||||||
{
|
{
|
||||||
eoParserLogger parser(ac, av);
|
eoParserLogger parser(ac, av);
|
||||||
|
|
@ -39,34 +40,27 @@ int main(int ac, char** av)
|
||||||
// Instantiate all needed parameters for EDASA algorithm
|
// Instantiate all needed parameters for EDASA algorithm
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
eoSelect< EOT >* selector = new eoDetSelect< EOT >(0.5);
|
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);
|
state.storeFunctor(selector);
|
||||||
|
|
||||||
doEstimator< Distrib >* estimator =
|
doEstimator< Distrib >* estimator = new doEstimatorNormalMulti< EOT >();
|
||||||
//new doEstimatorUniform< EOT >();
|
|
||||||
//new doEstimatorNormalMono< EOT >();
|
|
||||||
new doEstimatorNormalMulti< EOT >();
|
|
||||||
state.storeFunctor(estimator);
|
state.storeFunctor(estimator);
|
||||||
|
|
||||||
eoSelectOne< EOT >* selectone = new eoDetTournamentSelect< EOT >( 2 );
|
eoSelectOne< EOT >* selectone = new eoDetTournamentSelect< EOT >( 2 );
|
||||||
state.storeFunctor(selectone);
|
state.storeFunctor(selectone);
|
||||||
|
|
||||||
doModifierMass< Distrib >* modifier =
|
doModifierMass< Distrib >* modifier = new doNormalMultiCenter< EOT >();
|
||||||
//new doUniformCenter< EOT >();
|
|
||||||
//new doNormalMonoCenter< EOT >();
|
|
||||||
new doNormalMultiCenter< EOT >();
|
|
||||||
state.storeFunctor(modifier);
|
state.storeFunctor(modifier);
|
||||||
|
|
||||||
eoEvalFunc< EOT >* plainEval =
|
eoEvalFunc< EOT >* plainEval = new Rosenbrock< EOT >();
|
||||||
new Rosenbrock< EOT >();
|
|
||||||
//new Sphere< EOT >();
|
|
||||||
state.storeFunctor(plainEval);
|
state.storeFunctor(plainEval);
|
||||||
|
|
||||||
unsigned long max_eval = parser.getORcreateParam((unsigned long)0, "maxEval", "Maximum number of evaluations (0 = none)", 'E', "Stopping criterion").value(); // E
|
unsigned long max_eval = parser.getORcreateParam((unsigned long)0, "maxEval", "Maximum number of evaluations (0 = none)", 'E', "Stopping criterion").value(); // E
|
||||||
eoEvalFuncCounter< EOT > eval(*plainEval, max_eval);
|
eoEvalFuncCounterBounder< EOT > eval(*plainEval, max_eval);
|
||||||
|
|
||||||
eoRndGenerator< double >* gen = new eoUniformGenerator< double >(-5, 5);
|
eoRndGenerator< double >* gen = new eoUniformGenerator< double >(-5, 5);
|
||||||
//eoRndGenerator< double >* gen = new eoNormalGenerator< double >(0, 1);
|
|
||||||
state.storeFunctor(gen);
|
state.storeFunctor(gen);
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -106,8 +100,6 @@ int main(int ac, char** av)
|
||||||
// This is used by doSampler.
|
// This is used by doSampler.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
//doBounder< EOT >* bounder = new doBounderNo< EOT >();
|
|
||||||
doBounder< EOT >* bounder = new doBounderRng< EOT >(EOT(pop[0].size(), -5),
|
doBounder< EOT >* bounder = new doBounderRng< EOT >(EOT(pop[0].size(), -5),
|
||||||
EOT(pop[0].size(), 5),
|
EOT(pop[0].size(), 5),
|
||||||
*gen);
|
*gen);
|
||||||
|
|
@ -120,10 +112,7 @@ int main(int ac, char** av)
|
||||||
// Prepare sampler class with a specific distribution
|
// Prepare sampler class with a specific distribution
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
doSampler< Distrib >* sampler =
|
doSampler< Distrib >* sampler = new doSamplerNormalMulti< EOT >( *bounder );
|
||||||
//new doSamplerUniform< EOT >();
|
|
||||||
//new doSamplerNormalMono< EOT >( *bounder );
|
|
||||||
new doSamplerNormalMulti< EOT >( *bounder );
|
|
||||||
state.storeFunctor(sampler);
|
state.storeFunctor(sampler);
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
@ -133,11 +122,9 @@ int main(int ac, char** av)
|
||||||
// Metropolis sample parameters
|
// Metropolis sample parameters
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// FIXME: should I set the default value of rho to pop size ?!?
|
unsigned int popSize = parser.getORcreateParam((unsigned int)20, "popSize", "Population Size", 'P', "Evolution Engine").value();
|
||||||
|
|
||||||
unsigned int rho = parser.createParam((unsigned int)0, "rho", "Rho: metropolis sample size", 'p', section).value(); // p
|
moGenSolContinue< EOT >* sa_continue = new moGenSolContinue< EOT >( popSize );
|
||||||
|
|
||||||
moGenSolContinue< EOT >* sa_continue = new moGenSolContinue< EOT >(rho);
|
|
||||||
state.storeFunctor(sa_continue);
|
state.storeFunctor(sa_continue);
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
@ -170,7 +157,16 @@ int main(int ac, char** av)
|
||||||
// general output
|
// general output
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
eoCheckPoint< EOT >& monitoring_continue = do_make_checkpoint(parser, state, eval, eo_continue);
|
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("ResPop");
|
||||||
|
state.storeFunctor(fileSnapshot);
|
||||||
|
fileSnapshot->add(*popStat);
|
||||||
|
pop_continue.add(*fileSnapshot);
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -179,17 +175,6 @@ int main(int ac, char** av)
|
||||||
// population output
|
// population output
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
eoCheckPoint< EOT >* pop_continue = new eoCheckPoint< EOT >( eo_continue );
|
|
||||||
state.storeFunctor(pop_continue);
|
|
||||||
|
|
||||||
doPopStat< EOT >* popStat = new doPopStat<EOT>;
|
|
||||||
state.storeFunctor(popStat);
|
|
||||||
pop_continue->add(*popStat);
|
|
||||||
|
|
||||||
doFileSnapshot* fileSnapshot = new doFileSnapshot("ResPop");
|
|
||||||
state.storeFunctor(fileSnapshot);
|
|
||||||
fileSnapshot->add(*popStat);
|
|
||||||
pop_continue->add(*fileSnapshot);
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -244,7 +229,7 @@ int main(int ac, char** av)
|
||||||
|
|
||||||
doAlgo< Distrib >* algo = new doEDASA< Distrib >
|
doAlgo< Distrib >* algo = new doEDASA< Distrib >
|
||||||
(*selector, *estimator, *selectone, *modifier, *sampler,
|
(*selector, *estimator, *selectone, *modifier, *sampler,
|
||||||
monitoring_continue, *pop_continue, *distribution_continue,
|
pop_continue, *distribution_continue,
|
||||||
eval, *sa_continue, *cooling_schedule,
|
eval, *sa_continue, *cooling_schedule,
|
||||||
initial_temperature, *replacor);
|
initial_temperature, *replacor);
|
||||||
|
|
||||||
|
|
@ -273,13 +258,13 @@ int main(int ac, char** av)
|
||||||
{
|
{
|
||||||
do_run(*algo, pop);
|
do_run(*algo, pop);
|
||||||
}
|
}
|
||||||
catch (eoReachedThresholdException& e)
|
catch (eoEvalFuncCounterBounderException& e)
|
||||||
{
|
{
|
||||||
eo::log << eo::warnings << e.what() << std::endl;
|
eo::log << eo::warnings << "warning: " << e.what() << std::endl;
|
||||||
}
|
}
|
||||||
catch (std::exception& e)
|
catch (std::exception& e)
|
||||||
{
|
{
|
||||||
eo::log << eo::errors << "exception: " << e.what() << std::endl;
|
eo::log << eo::errors << "error: " << e.what() << std::endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
4
src/do
4
src/do
|
|
@ -52,3 +52,7 @@
|
||||||
#include "utils/doPopStat.h"
|
#include "utils/doPopStat.h"
|
||||||
|
|
||||||
#endif // !_do_
|
#endif // !_do_
|
||||||
|
|
||||||
|
// Local Variables:
|
||||||
|
// mode: C++
|
||||||
|
// End:
|
||||||
|
|
|
||||||
|
|
@ -38,23 +38,24 @@ public:
|
||||||
/*!
|
/*!
|
||||||
All the boxes used by a EDASA need to be given.
|
All the boxes used by a EDASA need to be given.
|
||||||
|
|
||||||
\param selector The EOT selector
|
\param selector Population Selector
|
||||||
\param estomator The EOT selector
|
\param estimator Distribution Estimator
|
||||||
\param selectone SelectOne
|
\param selectone SelectOne
|
||||||
\param modifier The D modifier
|
\param modifier Distribution Modifier
|
||||||
\param sampler The D sampler
|
\param sampler Distribution Sampler
|
||||||
\param evaluation The evaluation function.
|
\param pop_continue Population Continuator
|
||||||
\param continue The stopping criterion.
|
\param distribution_continue Distribution Continuator
|
||||||
\param cooling_schedule The cooling schedule, describes how the temperature is modified.
|
\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 initial_temperature The initial temperature.
|
||||||
\param replacor The EOT replacor
|
\param replacor Population replacor
|
||||||
*/
|
*/
|
||||||
doEDASA (eoSelect< EOT > & selector,
|
doEDASA (eoSelect< EOT > & selector,
|
||||||
doEstimator< D > & estimator,
|
doEstimator< D > & estimator,
|
||||||
eoSelectOne< EOT > & selectone,
|
eoSelectOne< EOT > & selectone,
|
||||||
doModifierMass< D > & modifier,
|
doModifierMass< D > & modifier,
|
||||||
doSampler< D > & sampler,
|
doSampler< D > & sampler,
|
||||||
eoContinue< EOT > & monitoring_continue,
|
|
||||||
eoContinue< EOT > & pop_continue,
|
eoContinue< EOT > & pop_continue,
|
||||||
doContinue< D > & distribution_continue,
|
doContinue< D > & distribution_continue,
|
||||||
eoEvalFunc < EOT > & evaluation,
|
eoEvalFunc < EOT > & evaluation,
|
||||||
|
|
@ -68,7 +69,6 @@ public:
|
||||||
_selectone(selectone),
|
_selectone(selectone),
|
||||||
_modifier(modifier),
|
_modifier(modifier),
|
||||||
_sampler(sampler),
|
_sampler(sampler),
|
||||||
_monitoring_continue(monitoring_continue),
|
|
||||||
_pop_continue(pop_continue),
|
_pop_continue(pop_continue),
|
||||||
_distribution_continue(distribution_continue),
|
_distribution_continue(distribution_continue),
|
||||||
_evaluation(evaluation),
|
_evaluation(evaluation),
|
||||||
|
|
@ -91,7 +91,7 @@ public:
|
||||||
|
|
||||||
double temperature = _initial_temperature;
|
double temperature = _initial_temperature;
|
||||||
|
|
||||||
eoPop< EOT > current_pop = pop;
|
eoPop< EOT > current_pop;
|
||||||
|
|
||||||
eoPop< EOT > selected_pop;
|
eoPop< EOT > selected_pop;
|
||||||
|
|
||||||
|
|
@ -111,19 +111,12 @@ public:
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (pop != current_pop)
|
|
||||||
{
|
|
||||||
_replacor(pop, current_pop);
|
|
||||||
}
|
|
||||||
|
|
||||||
current_pop.clear();
|
|
||||||
selected_pop.clear();
|
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------
|
//-------------------------------------------------------------
|
||||||
// (3) Selection of the best points in the population
|
// (3) Selection of the best points in the population
|
||||||
//-------------------------------------------------------------
|
//-------------------------------------------------------------
|
||||||
|
|
||||||
|
selected_pop.clear();
|
||||||
|
|
||||||
_selector(pop, selected_pop);
|
_selector(pop, selected_pop);
|
||||||
|
|
||||||
assert( selected_pop.size() > 0 );
|
assert( selected_pop.size() > 0 );
|
||||||
|
|
@ -172,6 +165,8 @@ public:
|
||||||
// Building of the sampler in current_pop
|
// Building of the sampler in current_pop
|
||||||
//-------------------------------------------------------------
|
//-------------------------------------------------------------
|
||||||
|
|
||||||
|
current_pop.clear();
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
EOT candidate_solution = _sampler(distrib);
|
EOT candidate_solution = _sampler(distrib);
|
||||||
|
|
@ -189,14 +184,20 @@ public:
|
||||||
current_solution = 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
|
||||||
|
|
||||||
|
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 ( _cooling_schedule( temperature ) &&
|
while ( 1 );
|
||||||
_distribution_continue( distrib ) &&
|
|
||||||
_pop_continue( current_pop ) &&
|
|
||||||
_monitoring_continue( selected_pop )
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -216,9 +217,6 @@ private:
|
||||||
//! A D sampler
|
//! A D sampler
|
||||||
doSampler< D > & _sampler;
|
doSampler< D > & _sampler;
|
||||||
|
|
||||||
//! A EOT monitoring continuator
|
|
||||||
eoContinue < EOT > & _monitoring_continue;
|
|
||||||
|
|
||||||
//! A EOT population continuator
|
//! A EOT population continuator
|
||||||
eoContinue < EOT > & _pop_continue;
|
eoContinue < EOT > & _pop_continue;
|
||||||
|
|
||||||
|
|
|
||||||
Reference in a new issue