intermediate commit

This commit is contained in:
LPTK 2013-06-21 18:03:57 +02:00
commit 1e6240f9bf
9 changed files with 370 additions and 178 deletions

View file

@ -28,8 +28,6 @@ Lionel Parreaux <lionel.parreaux@gmail.com>
#include <es.h>
#include <edo>
//#include <trikisa>
#include <edoBounderUniform.h>
#include "neighborhood/moRealNeighbor.h"
@ -40,10 +38,6 @@ Lionel Parreaux <lionel.parreaux@gmail.com>
#include "coolingSchedule/moTrikiCoolingSchedule.h"
//#include "moRealInitTemperature.h"
//#include "do/make_real_init_temperature.h"
typedef eoReal< eoMinimizingFitness > EOT;
typedef moRealNeighbor< EOT > Neighbor;
@ -52,9 +46,9 @@ double objective_function(const EOT & sol)
double sum = 0;
for ( size_t i = 0; i < sol.size(); ++i )
{
sum += sol[i] * sol[i];
}
{
sum += sol[i] * sol[i];
}
return sum;
}
@ -66,18 +60,10 @@ int main( int ac, char** av )
eoState state;
eoEvalFuncPtr< EOT, double > eval( objective_function );
moFullEvalByCopy< Neighbor > fullEval( eval );
//moNeighborhood< Neighbor >* neighborhood;
moFullEvalByCopy< Neighbor > neval( eval );
int dimSize = 20;
//moRealInitTemperature< EOT >& real_init = do_make_real_init_temperature( parser, state, eval );
//moInitTemperature< EOT, Neighbor >& real_init = do_make_real_init_temperature( parser, state, eval, neval );
//moInitTemperature< EOT, Neighbor >& real_init = do_make_init_temperature<EOT, Neighbor>( parser, state, eval, neval, neighborhood );
//moStdDevEstimator< EOT, Neighbor >& real_init = do_make_init_temperature<EOT, Neighbor>( parser, state, eval, neval, neighborhood, dimSize );
//-------------------------------------------------------
// Parameters
//-------------------------------------------------------
@ -87,8 +73,7 @@ int main( int ac, char** av )
unsigned int dimension_size = parser.getORcreateParam( (unsigned int)dimSize, "dimension-size", "Dimension size", 'd', section ).value();
double jump_bound = parser.getORcreateParam( (double)1, "jump-bound", "Bound of jump", '\0', section ).value();
unsigned int maxiter = parser.getORcreateParam( (unsigned int)10, "max-iter", "Maximum number of iterations", '\0', section ).value();
//unsigned int ratio = parser.getORcreateParam( (unsigned int)1, "ratio", "Bounder ratio", '\0', section ).value(); // not used
//-------------------------------------------------------
@ -102,13 +87,9 @@ int main( int ac, char** av )
edoSamplerUniform< EOT > sampler( bounder_search );
//moRealNeighborhood< edoUniform< EOT >, Neighbor >* neighborhood = new moRealNeighborhood< edoUniform< EOT >, Neighbor >( *distrib, *sampler, *bounder_search );
moRealNeighborhood< edoUniform< EOT >, Neighbor > neighborhood( distrib, sampler, bounder_search );
//state.storeFunctor(neighborhood);state.storeFunctor(neighborhood);
//moStdDevEstimator< EOT, Neighbor >* init = new moStdDevEstimator< EOT, Neighbor >( *neighborhood, fullEval, eval, maxiter );
//moStdDevEstimator< EOT, Neighbor > init( maxiter, neighborhood, fullEval, eval );
moStdDevEstimator< EOT, Neighbor > init( maxiter, neighborhood, fullEval );
moStdDevEstimator< EOT, Neighbor > init( maxiter, neighborhood, eval );
//-------------------------------------------------------
@ -129,57 +110,52 @@ int main( int ac, char** av )
//-------------------------------------------------------
//EOT solution(2, 5);
EOT solution(dimSize, 5);
/*
real_init( solution );
std::cout << "do_make_real_init_temperature( parser, eval ): "
<< real_init.value()
<< std::endl;
*/
std::cout << "do_make_real_init_temperature( parser, eval ): "
<< init( solution )
<< std::endl;
std::cout << "init temp: "
<< init( solution )
<< std::endl;
moTrueContinuator<Neighbor> continuator;
moCheckpoint<Neighbor> checkpoint(continuator);
moFitnessStat<EOT> fitStat;
checkpoint.add(fitStat);
eoFileMonitor monitor("triki.out", "");
//eoGnuplot1DMonitor monitor2("trikignu.out", true);
moCounterMonitorSaver countMon(1, monitor);
checkpoint.add(countMon);
//moCounterMonitorSaver gnuMon (1, monitor2);
//checkpoint.add(gnuMon);
monitor.add(fitStat);
//monitor2.add(fitStat);
moTrueContinuator<Neighbor> continuator;
moCheckpoint<Neighbor> checkpoint(continuator);
moFitnessStat<EOT> fitStat;
checkpoint.add(fitStat);
eoFileMonitor monitor("triki.out", "");
//eoGnuplot1DMonitor monitor2("trikignu.out", true);
moCounterMonitorSaver countMon(1, monitor);
checkpoint.add(countMon);
//moCounterMonitorSaver gnuMon (1, monitor2);
//checkpoint.add(gnuMon);
monitor.add(fitStat);
//monitor2.add(fitStat);
moTrikiCoolingSchedule<EOT, Neighbor> coolingSchedule (
neighborhood, neval, init( solution ),
//50,
200, //150,
//100
350 // 250
);
moSA<Neighbor> localSearch(*neighborhood, eval, fullEval, coolingSchedule, checkpoint);
std::cout << "#########################################" << std::endl;
std::cout << "initial solution1: " << solution << std::endl ;
localSearch(solution);
std::cout << "final solution1: " << solution << std::endl ;
std::cout << "#########################################" << std::endl;
//delete neighborhood;
moTrikiCoolingSchedule<EOT, Neighbor> coolingSchedule (
neighborhood, neval, init( solution ),
//50,
200, //150,
//100
350 // 250
);
//moSA<Neighbor> localSearch(neighborhood, eval, neval, coolingSchedule, checkpoint);
//moSA<Neighbor> localSearch(neighborhood, eval, neval);
//moSA<Neighbor> localSearch(neighborhood, eval, coolingSchedule, neval, checkpoint);
//moSA<Neighbor> localSearch(neighborhood, eval, coolingSchedule);
moSA<Neighbor> localSearch(neighborhood, eval, coolingSchedule, neval, checkpoint);
std::cout << "#########################################" << std::endl;
std::cout << "initial solution1: " << solution << std::endl ;
localSearch(solution);
std::cout << "final solution1: " << solution << std::endl ;
std::cout << "#########################################" << std::endl;
return 0;
}