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
|
||||
eda_sa.param
|
||||
plot.py
|
||||
plot_on_ggobi.py
|
||||
)
|
||||
|
||||
FOREACH(file ${RESOURCES})
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
#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>
|
||||
|
|
@ -14,12 +16,11 @@
|
|||
#include "Rosenbrock.h"
|
||||
#include "Sphere.h"
|
||||
|
||||
typedef eoReal<eoMinimizingFitness> EOT;
|
||||
|
||||
//typedef doUniform< EOT > Distrib;
|
||||
//typedef doNormalMono< EOT > Distrib;
|
||||
typedef eoReal<eoMinimizingFitness> EOT;
|
||||
typedef doNormalMulti< EOT > Distrib;
|
||||
|
||||
|
||||
int main(int ac, char** av)
|
||||
{
|
||||
eoParserLogger parser(ac, av);
|
||||
|
|
@ -39,34 +40,27 @@ int main(int ac, char** av)
|
|||
// 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);
|
||||
|
||||
doEstimator< Distrib >* estimator =
|
||||
//new doEstimatorUniform< EOT >();
|
||||
//new doEstimatorNormalMono< EOT >();
|
||||
new doEstimatorNormalMulti< EOT >();
|
||||
doEstimator< Distrib >* estimator = new doEstimatorNormalMulti< EOT >();
|
||||
state.storeFunctor(estimator);
|
||||
|
||||
eoSelectOne< EOT >* selectone = new eoDetTournamentSelect< EOT >( 2 );
|
||||
state.storeFunctor(selectone);
|
||||
|
||||
doModifierMass< Distrib >* modifier =
|
||||
//new doUniformCenter< EOT >();
|
||||
//new doNormalMonoCenter< EOT >();
|
||||
new doNormalMultiCenter< EOT >();
|
||||
doModifierMass< Distrib >* modifier = new doNormalMultiCenter< EOT >();
|
||||
state.storeFunctor(modifier);
|
||||
|
||||
eoEvalFunc< EOT >* plainEval =
|
||||
new Rosenbrock< EOT >();
|
||||
//new Sphere< EOT >();
|
||||
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
|
||||
eoEvalFuncCounter< EOT > eval(*plainEval, max_eval);
|
||||
eoEvalFuncCounterBounder< EOT > eval(*plainEval, max_eval);
|
||||
|
||||
eoRndGenerator< double >* gen = new eoUniformGenerator< double >(-5, 5);
|
||||
//eoRndGenerator< double >* gen = new eoNormalGenerator< double >(0, 1);
|
||||
state.storeFunctor(gen);
|
||||
|
||||
|
||||
|
|
@ -106,8 +100,6 @@ int main(int ac, char** av)
|
|||
// This is used by doSampler.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//doBounder< EOT >* bounder = new doBounderNo< EOT >();
|
||||
doBounder< EOT >* bounder = new doBounderRng< EOT >(EOT(pop[0].size(), -5),
|
||||
EOT(pop[0].size(), 5),
|
||||
*gen);
|
||||
|
|
@ -120,10 +112,7 @@ int main(int ac, char** av)
|
|||
// Prepare sampler class with a specific distribution
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
doSampler< Distrib >* sampler =
|
||||
//new doSamplerUniform< EOT >();
|
||||
//new doSamplerNormalMono< EOT >( *bounder );
|
||||
new doSamplerNormalMulti< EOT >( *bounder );
|
||||
doSampler< Distrib >* sampler = new doSamplerNormalMulti< EOT >( *bounder );
|
||||
state.storeFunctor(sampler);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -133,11 +122,9 @@ int main(int ac, char** av)
|
|||
// 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 >(rho);
|
||||
moGenSolContinue< EOT >* sa_continue = new moGenSolContinue< EOT >( popSize );
|
||||
state.storeFunctor(sa_continue);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -170,7 +157,16 @@ int main(int ac, char** av)
|
|||
// 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
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
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 >
|
||||
(*selector, *estimator, *selectone, *modifier, *sampler,
|
||||
monitoring_continue, *pop_continue, *distribution_continue,
|
||||
pop_continue, *distribution_continue,
|
||||
eval, *sa_continue, *cooling_schedule,
|
||||
initial_temperature, *replacor);
|
||||
|
||||
|
|
@ -273,13 +258,13 @@ int main(int ac, char** av)
|
|||
{
|
||||
do_run(*algo, pop);
|
||||
}
|
||||
catch (eoReachedThresholdException& e)
|
||||
{
|
||||
eo::log << eo::warnings << e.what() << std::endl;
|
||||
}
|
||||
catch (eoEvalFuncCounterBounderException& e)
|
||||
{
|
||||
eo::log << eo::warnings << "warning: " << e.what() << std::endl;
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
|||
4
src/do
4
src/do
|
|
@ -52,3 +52,7 @@
|
|||
#include "utils/doPopStat.h"
|
||||
|
||||
#endif // !_do_
|
||||
|
||||
// Local Variables:
|
||||
// mode: C++
|
||||
// End:
|
||||
|
|
|
|||
|
|
@ -38,23 +38,24 @@ public:
|
|||
/*!
|
||||
All the boxes used by a EDASA need to be given.
|
||||
|
||||
\param selector The EOT selector
|
||||
\param estomator The EOT selector
|
||||
\param selector Population Selector
|
||||
\param estimator Distribution Estimator
|
||||
\param selectone SelectOne
|
||||
\param modifier The D modifier
|
||||
\param sampler The D sampler
|
||||
\param evaluation The evaluation function.
|
||||
\param continue The stopping criterion.
|
||||
\param cooling_schedule The cooling schedule, describes how the temperature is modified.
|
||||
\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 The EOT replacor
|
||||
\param replacor Population replacor
|
||||
*/
|
||||
doEDASA (eoSelect< EOT > & selector,
|
||||
doEstimator< D > & estimator,
|
||||
eoSelectOne< EOT > & selectone,
|
||||
doModifierMass< D > & modifier,
|
||||
doSampler< D > & sampler,
|
||||
eoContinue< EOT > & monitoring_continue,
|
||||
eoContinue< EOT > & pop_continue,
|
||||
doContinue< D > & distribution_continue,
|
||||
eoEvalFunc < EOT > & evaluation,
|
||||
|
|
@ -68,7 +69,6 @@ public:
|
|||
_selectone(selectone),
|
||||
_modifier(modifier),
|
||||
_sampler(sampler),
|
||||
_monitoring_continue(monitoring_continue),
|
||||
_pop_continue(pop_continue),
|
||||
_distribution_continue(distribution_continue),
|
||||
_evaluation(evaluation),
|
||||
|
|
@ -91,7 +91,7 @@ public:
|
|||
|
||||
double temperature = _initial_temperature;
|
||||
|
||||
eoPop< EOT > current_pop = pop;
|
||||
eoPop< EOT > current_pop;
|
||||
|
||||
eoPop< EOT > selected_pop;
|
||||
|
||||
|
|
@ -111,19 +111,12 @@ public:
|
|||
|
||||
do
|
||||
{
|
||||
if (pop != current_pop)
|
||||
{
|
||||
_replacor(pop, current_pop);
|
||||
}
|
||||
|
||||
current_pop.clear();
|
||||
selected_pop.clear();
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// (3) Selection of the best points in the population
|
||||
//-------------------------------------------------------------
|
||||
|
||||
selected_pop.clear();
|
||||
|
||||
_selector(pop, selected_pop);
|
||||
|
||||
assert( selected_pop.size() > 0 );
|
||||
|
|
@ -172,6 +165,8 @@ public:
|
|||
// Building of the sampler in current_pop
|
||||
//-------------------------------------------------------------
|
||||
|
||||
current_pop.clear();
|
||||
|
||||
do
|
||||
{
|
||||
EOT candidate_solution = _sampler(distrib);
|
||||
|
|
@ -189,14 +184,20 @@ public:
|
|||
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 ) &&
|
||||
_distribution_continue( distrib ) &&
|
||||
_pop_continue( current_pop ) &&
|
||||
_monitoring_continue( selected_pop )
|
||||
);
|
||||
while ( 1 );
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
@ -216,9 +217,6 @@ private:
|
|||
//! A D sampler
|
||||
doSampler< D > & _sampler;
|
||||
|
||||
//! A EOT monitoring continuator
|
||||
eoContinue < EOT > & _monitoring_continue;
|
||||
|
||||
//! A EOT population continuator
|
||||
eoContinue < EOT > & _pop_continue;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue