ILS v1 :)
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1727 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
6de0a60f27
commit
6bb2a4a822
21 changed files with 330 additions and 60 deletions
|
|
@ -40,7 +40,7 @@ template< class Neighbor >
|
||||||
class moAlwaysAcceptCrit : public moAcceptanceCriterion<Neighbor>, public moDummyMemory<Neighbor>{
|
class moAlwaysAcceptCrit : public moAcceptanceCriterion<Neighbor>, public moDummyMemory<Neighbor>{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef typename Neighor::EOT EOT;
|
typedef typename Neighbor::EOT EOT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Always accept the new solution
|
* Always accept the new solution
|
||||||
|
|
|
||||||
70
trunk/paradiseo-mo/src/continuator/moIterContinuator.h
Normal file
70
trunk/paradiseo-mo/src/continuator/moIterContinuator.h
Normal file
|
|
@ -0,0 +1,70 @@
|
||||||
|
/*
|
||||||
|
<moIterContinuator.h>
|
||||||
|
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||||
|
|
||||||
|
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||||
|
|
||||||
|
This software is governed by the CeCILL license under French law and
|
||||||
|
abiding by the rules of distribution of free software. You can ue,
|
||||||
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
|
"http://www.cecill.info".
|
||||||
|
|
||||||
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
|
software by the user in light of its specific status of free software,
|
||||||
|
that may mean that it is complicated to manipulate, and that also
|
||||||
|
therefore means that it is reserved for developers and experienced
|
||||||
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
|
encouraged to load and test the software's suitability as regards their
|
||||||
|
requirements in conditions enabling the security of their systems and/or
|
||||||
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
|
same conditions as regards security.
|
||||||
|
The fact that you are presently reading this means that you have had
|
||||||
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
|
|
||||||
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _moIterContinuator_h
|
||||||
|
#define _moIterContinuator_h
|
||||||
|
|
||||||
|
#include <continuator/moContinuator.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Continue until a maximum fixed number of iterations is reached
|
||||||
|
*/
|
||||||
|
template< class NH >
|
||||||
|
class moIterContinuator : public moContinuator<NH>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef typename NH::EOT EOT ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param _maxIter number maximum of iterations
|
||||||
|
*/
|
||||||
|
moIterContinuator(unsigned int _maxIter): maxIter(_maxIter){}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*@param _solution a solution
|
||||||
|
*@return true if counter < maxIter
|
||||||
|
*/
|
||||||
|
virtual bool operator()(EOT & _solution) {
|
||||||
|
return (cpt++ < maxIter);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* reset the counter of iteration
|
||||||
|
* @param _solution a solution
|
||||||
|
*/
|
||||||
|
virtual void init(EOT & _solution) {
|
||||||
|
cpt=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
unsigned int maxIter;
|
||||||
|
unsigned int cpt;
|
||||||
|
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
@ -35,6 +35,8 @@
|
||||||
#ifndef _moCoolingSchedule_h
|
#ifndef _moCoolingSchedule_h
|
||||||
#define _moCoolingSchedule_h
|
#define _moCoolingSchedule_h
|
||||||
|
|
||||||
|
#include <eoFunctor.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cooling Schedule of the temperature in the simulated algorithm
|
* Cooling Schedule of the temperature in the simulated algorithm
|
||||||
*
|
*
|
||||||
|
|
@ -47,20 +49,14 @@ public:
|
||||||
* Initial temperature
|
* Initial temperature
|
||||||
* @param _solution initial solution
|
* @param _solution initial solution
|
||||||
*/
|
*/
|
||||||
double init(EOT & _solution) = 0;
|
virtual double init(EOT & _solution) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* update the temperature
|
* update the temperature
|
||||||
* @param _temp current temperature to update
|
* @param _temp current temperature to update
|
||||||
*/
|
*/
|
||||||
void update(double& _temp) = 0;
|
virtual void update(double& _temp) = 0;
|
||||||
|
|
||||||
/**
|
|
||||||
* test the ending of the process
|
|
||||||
* @param _temp current temperature
|
|
||||||
* @return true if the process could be continue
|
|
||||||
*/
|
|
||||||
// bool operator()(double _temp) = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
template< class EOT >
|
template< class EOT >
|
||||||
class moSimpleCoolingSchedule : public eoUF<double, bool>
|
class moSimpleCoolingSchedule : public moCoolingSchedule<EOT>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
|
@ -91,18 +91,14 @@ public:
|
||||||
private:
|
private:
|
||||||
// initial temperature
|
// initial temperature
|
||||||
double initT;
|
double initT;
|
||||||
|
|
||||||
// threshold temperature
|
|
||||||
double finalT;
|
|
||||||
|
|
||||||
// coefficient of decrease
|
// coefficient of decrease
|
||||||
double alpha;
|
double alpha;
|
||||||
|
|
||||||
// maximum number of iterations at the same temperature
|
// maximum number of iterations at the same temperature
|
||||||
unisgned span;
|
unsigned int span;
|
||||||
|
// threshold temperature
|
||||||
|
double finalT;
|
||||||
// number of steps with the same temperature
|
// number of steps with the same temperature
|
||||||
unsigned step;
|
unsigned int step;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
52
trunk/paradiseo-mo/src/eval/moDummyEval.h
Normal file
52
trunk/paradiseo-mo/src/eval/moDummyEval.h
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
<moDummyEval.h>
|
||||||
|
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||||
|
|
||||||
|
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||||
|
|
||||||
|
This software is governed by the CeCILL license under French law and
|
||||||
|
abiding by the rules of distribution of free software. You can ue,
|
||||||
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
|
"http://www.cecill.info".
|
||||||
|
|
||||||
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
|
software by the user in light of its specific status of free software,
|
||||||
|
that may mean that it is complicated to manipulate, and that also
|
||||||
|
therefore means that it is reserved for developers and experienced
|
||||||
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
|
encouraged to load and test the software's suitability as regards their
|
||||||
|
requirements in conditions enabling the security of their systems and/or
|
||||||
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
|
same conditions as regards security.
|
||||||
|
The fact that you are presently reading this means that you have had
|
||||||
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
|
|
||||||
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _moDummyEval_h
|
||||||
|
#define _moDummyEval_h
|
||||||
|
|
||||||
|
#include <eval/moEval.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dummy Evaluation function
|
||||||
|
*/
|
||||||
|
template<class N>
|
||||||
|
class moDummyEval : public moEval<N>{
|
||||||
|
public:
|
||||||
|
typedef typename N::EOT EOT;
|
||||||
|
typedef typename EOT::Fitness Fitness;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NOTHING TO DO
|
||||||
|
* @param _sol a solution
|
||||||
|
*/
|
||||||
|
void operator()(EOT& _sol, N& _n){}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -41,20 +41,21 @@
|
||||||
#include <algo/moLocalSearch.h>
|
#include <algo/moLocalSearch.h>
|
||||||
#include <perturb/moPerturbation.h>
|
#include <perturb/moPerturbation.h>
|
||||||
#include <acceptCrit/moAcceptanceCriterion.h>
|
#include <acceptCrit/moAcceptanceCriterion.h>
|
||||||
|
#include <neighborhood/moDummyNeighborhood.h>
|
||||||
|
#include <neighborhood/moDummyNeighbor.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Explorer for an Iterated Local Search
|
* Explorer for an Iterated Local Search
|
||||||
*/
|
*/
|
||||||
template< class NHE >
|
template< class NHE >
|
||||||
class moILSexplorer : public moNeighborhoodExplorer<typename NHE::Neighborhood>
|
class moILSexplorer : public moNeighborhoodExplorer<moDummyNeighborhood<moDummyNeighbor<typename NHE::Neighborhood::EOT, typename NHE::Neighborhood::EOT::Fitness> > >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef typename NHE::Neighborhood Neighborhood ;
|
typedef typename NHE::Neighborhood Neighborhood ;
|
||||||
typedef typename Neighborhood::EOT EOT ;
|
typedef typename Neighborhood::EOT EOT ;
|
||||||
typedef typename Neighborhood::Neighbor Neighbor ;
|
typedef typename Neighborhood::Neighbor Neighbor ;
|
||||||
|
typedef moDummyNeighbor<EOT,typename EOT::Fitness> dummyNeighbor;
|
||||||
using moNeighborhoodExplorer<Neighborhood>::neighborhood;
|
typedef moDummyNeighborhood<dummyNeighbor> dummyNeighborhood;
|
||||||
using moNeighborhoodExplorer<Neighborhood>::eval;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
|
@ -62,7 +63,7 @@ public:
|
||||||
* @param _perturb a perturbation operator
|
* @param _perturb a perturbation operator
|
||||||
* @param _acceptCrit a acceptance criteria
|
* @param _acceptCrit a acceptance criteria
|
||||||
*/
|
*/
|
||||||
moILSexplorer(moLocalSearch<NHE>& _ls, moPerturbation<Neighbor>& _perturb, moAcceptanceCriterion<Neighbor>& _acceptCrit) : ls(_ls), perturb(_perturb), acceptCrit(_acceptCrit){
|
moILSexplorer(moLocalSearch<NHE>& _ls, moPerturbation<Neighbor>& _perturb, moAcceptanceCriterion<Neighbor>& _acceptCrit) : moNeighborhoodExplorer<dummyNeighborhood>(), ls(_ls), perturb(_perturb), acceptCrit(_acceptCrit){
|
||||||
firstIteration=true;
|
firstIteration=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -88,7 +89,7 @@ public:
|
||||||
* @param _solution the current solution
|
* @param _solution the current solution
|
||||||
*/
|
*/
|
||||||
virtual void updateParam(EOT & _solution){
|
virtual void updateParam(EOT & _solution){
|
||||||
if((*this).isMoved()){
|
if((*this).moveApplied()){
|
||||||
perturb.add(_solution,emptyNeighbor);
|
perturb.add(_solution,emptyNeighbor);
|
||||||
acceptCrit.add(_solution,emptyNeighbor);
|
acceptCrit.add(_solution,emptyNeighbor);
|
||||||
}
|
}
|
||||||
|
|
@ -110,8 +111,10 @@ public:
|
||||||
current=_solution;
|
current=_solution;
|
||||||
|
|
||||||
//perturb solution exept at the first iteration
|
//perturb solution exept at the first iteration
|
||||||
if(!firstIteration)
|
if(!firstIteration){
|
||||||
perturb(current);
|
perturb(current);
|
||||||
|
|
||||||
|
}
|
||||||
else
|
else
|
||||||
firstIteration=false;
|
firstIteration=false;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,9 @@
|
||||||
|
|
||||||
#include <neighborhood/moNeighborhood.h>
|
#include <neighborhood/moNeighborhood.h>
|
||||||
#include <eval/moEval.h>
|
#include <eval/moEval.h>
|
||||||
|
//#include <neighborhood/moDummyNeighbor.h>
|
||||||
|
#include <neighborhood/moDummyNeighborhood.h>
|
||||||
|
#include <eval/moDummyEval.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Explore the neighborhood
|
* Explore the neighborhood
|
||||||
|
|
@ -50,8 +53,11 @@ class moNeighborhoodExplorer : public eoUF<typename NH::EOT&, void>
|
||||||
public:
|
public:
|
||||||
typedef NH Neighborhood ;
|
typedef NH Neighborhood ;
|
||||||
typedef typename Neighborhood::EOT EOT ;
|
typedef typename Neighborhood::EOT EOT ;
|
||||||
|
typedef typename EOT::Fitness Fitness ;
|
||||||
typedef typename Neighborhood::Neighbor Neighbor ;
|
typedef typename Neighborhood::Neighbor Neighbor ;
|
||||||
|
|
||||||
|
moNeighborhoodExplorer():neighborhood(dummyNeighborhood), eval(dummyEval), isMoved(false) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor with a Neighborhood and evaluation function
|
* Constructor with a Neighborhood and evaluation function
|
||||||
* @param _neighborhood the neighborhood
|
* @param _neighborhood the neighborhood
|
||||||
|
|
@ -123,6 +129,8 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
moDummyNeighborhood<Neighbor> dummyNeighborhood;
|
||||||
|
moDummyEval<Neighbor> dummyEval;
|
||||||
Neighborhood & neighborhood;
|
Neighborhood & neighborhood;
|
||||||
moEval<Neighbor>& eval;
|
moEval<Neighbor>& eval;
|
||||||
bool isMoved;
|
bool isMoved;
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ public:
|
||||||
* @param _solNeighborComparator a solution vs neighbor comparator
|
* @param _solNeighborComparator a solution vs neighbor comparator
|
||||||
* @param _nbStep maximum number of step to do
|
* @param _nbStep maximum number of step to do
|
||||||
*/
|
*/
|
||||||
moSAexplorer(Neighborhood& _neighborhood, moEval<Neighbor>& _eval, moSolNeighborComparator<Neighbor>& _solNeighborComparator, moCoolingSchedule<EOT> _coolingSchedule) : moNeighborhoodExplorer<Neighborhood>(_neighborhood, _eval), solNeighborComparator(_solNeighborComparator), coolingSchedule(_coolingSchedule) {
|
moSAexplorer(Neighborhood& _neighborhood, moEval<Neighbor>& _eval, moSolNeighborComparator<Neighbor>& _solNeighborComparator, moCoolingSchedule<EOT>& _coolingSchedule) : moNeighborhoodExplorer<Neighborhood>(_neighborhood, _eval), solNeighborComparator(_solNeighborComparator), coolingSchedule(_coolingSchedule) {
|
||||||
isAccept = false;
|
isAccept = false;
|
||||||
|
|
||||||
if (!neighborhood.isRandom()) {
|
if (!neighborhood.isRandom()) {
|
||||||
|
|
@ -168,11 +168,9 @@ private:
|
||||||
// comparator betwenn solution and neighbor
|
// comparator betwenn solution and neighbor
|
||||||
moSolNeighborComparator<Neighbor>& solNeighborComparator;
|
moSolNeighborComparator<Neighbor>& solNeighborComparator;
|
||||||
|
|
||||||
// current number of step
|
moCoolingSchedule<EOT>& coolingSchedule;
|
||||||
unsigned int step;
|
|
||||||
|
|
||||||
// maximum number of steps to do
|
double temperature;
|
||||||
unsigned int nbStep;
|
|
||||||
|
|
||||||
//Pointer on the best and the current neighbor
|
//Pointer on the best and the current neighbor
|
||||||
Neighbor current;
|
Neighbor current;
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@
|
||||||
#include <continuator/moStat.h>
|
#include <continuator/moStat.h>
|
||||||
#include <continuator/moStatBase.h>
|
#include <continuator/moStatBase.h>
|
||||||
#include <continuator/moTrueContinuator.h>
|
#include <continuator/moTrueContinuator.h>
|
||||||
|
#include <continuator/moIterContinuator.h>
|
||||||
|
|
||||||
#include <eval/moEval.h>
|
#include <eval/moEval.h>
|
||||||
#include <eval/moFullEvalByCopy.h>
|
#include <eval/moFullEvalByCopy.h>
|
||||||
|
|
@ -103,8 +104,8 @@
|
||||||
#include <acceptCrit/moAcceptanceCriterion.h>
|
#include <acceptCrit/moAcceptanceCriterion.h>
|
||||||
#include <acceptCrit/moAlwaysAcceptCrit.h>
|
#include <acceptCrit/moAlwaysAcceptCrit.h>
|
||||||
|
|
||||||
#include <coolingschedule/moCoolingSchedule.h>
|
#include <coolingSchedule/moCoolingSchedule.h>
|
||||||
#include <coolingschedule/moSimpleCoolingSchedule.h>
|
#include <coolingSchedule/moSimpleCoolingSchedule.h>
|
||||||
|
|
||||||
//#include <old/moMove.h>
|
//#include <old/moMove.h>
|
||||||
//#include <old/moMoveIncrEval.h>
|
//#include <old/moMoveIncrEval.h>
|
||||||
|
|
|
||||||
48
trunk/paradiseo-mo/src/neighborhood/moDummyNeighbor.h
Normal file
48
trunk/paradiseo-mo/src/neighborhood/moDummyNeighbor.h
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
/*
|
||||||
|
<moDummyNeighbor.h>
|
||||||
|
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||||
|
|
||||||
|
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||||
|
|
||||||
|
This software is governed by the CeCILL license under French law and
|
||||||
|
abiding by the rules of distribution of free software. You can ue,
|
||||||
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
|
"http://www.cecill.info".
|
||||||
|
|
||||||
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
|
software by the user in light of its specific status of free software,
|
||||||
|
that may mean that it is complicated to manipulate, and that also
|
||||||
|
therefore means that it is reserved for developers and experienced
|
||||||
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
|
encouraged to load and test the software's suitability as regards their
|
||||||
|
requirements in conditions enabling the security of their systems and/or
|
||||||
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
|
same conditions as regards security.
|
||||||
|
The fact that you are presently reading this means that you have had
|
||||||
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
|
|
||||||
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _moDummyNeighbor_h
|
||||||
|
#define _moDummyNeighbor_h
|
||||||
|
|
||||||
|
#include <neighborhood/moNeighbor.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dummy Neighborhood
|
||||||
|
*/
|
||||||
|
template< class EOT , class Fitness >
|
||||||
|
class moDummyNeighbor : public moNeighbor< EOT,Fitness>{
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NOTHING TO DO
|
||||||
|
* @param _solution the related solution
|
||||||
|
*/
|
||||||
|
virtual void move(EOT& _solution){}
|
||||||
|
};
|
||||||
|
#endif
|
||||||
78
trunk/paradiseo-mo/src/neighborhood/moDummyNeighborhood.h
Normal file
78
trunk/paradiseo-mo/src/neighborhood/moDummyNeighborhood.h
Normal file
|
|
@ -0,0 +1,78 @@
|
||||||
|
/*
|
||||||
|
<moDummyNeighborhood.h>
|
||||||
|
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
|
||||||
|
|
||||||
|
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
|
||||||
|
|
||||||
|
This software is governed by the CeCILL license under French law and
|
||||||
|
abiding by the rules of distribution of free software. You can ue,
|
||||||
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
|
"http://www.cecill.info".
|
||||||
|
|
||||||
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
|
software by the user in light of its specific status of free software,
|
||||||
|
that may mean that it is complicated to manipulate, and that also
|
||||||
|
therefore means that it is reserved for developers and experienced
|
||||||
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
|
encouraged to load and test the software's suitability as regards their
|
||||||
|
requirements in conditions enabling the security of their systems and/or
|
||||||
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
|
same conditions as regards security.
|
||||||
|
The fact that you are presently reading this means that you have had
|
||||||
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
|
|
||||||
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _moDummyNeighborhood_h
|
||||||
|
#define _moDummyNeighborhood_h
|
||||||
|
|
||||||
|
#include <neighborhood/moDummyNeighbor.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dummy Neighborhood
|
||||||
|
*/
|
||||||
|
template< class N >
|
||||||
|
class moDummyNeighborhood : public moNeighborhood<N>{
|
||||||
|
public:
|
||||||
|
typedef N Neighbor;
|
||||||
|
typedef typename Neighbor::EOT EOT;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NOTHING TO DO
|
||||||
|
* @param _solution the related solution
|
||||||
|
* @return always false
|
||||||
|
*/
|
||||||
|
virtual bool hasNeighbor(EOT & _solution){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NOTHING TO DO
|
||||||
|
* @param _solution the solution to explore
|
||||||
|
* @param _current the first neighbor
|
||||||
|
*/
|
||||||
|
virtual void init(EOT & _solution, Neighbor & _current){}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NOTHING TO DO
|
||||||
|
* @param _solution the solution to explore
|
||||||
|
* @param _current the next neighbor
|
||||||
|
*/
|
||||||
|
virtual void next(EOT & _solution, Neighbor & _current){}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NOTHING TO DO
|
||||||
|
* @param _solution the solution to explore
|
||||||
|
* @return always false
|
||||||
|
*/
|
||||||
|
virtual bool cont(EOT & _solution){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -30,8 +30,10 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#ifndef _moMonOpPerturb_h
|
#ifndef _moMonOpPerturb_h
|
||||||
#define _moMonOpPerturb_h
|
#define _moMonOpPerturb_h
|
||||||
|
|
||||||
|
#include <eoEvalFunc.h>
|
||||||
#include <eoOp.h>
|
#include <eoOp.h>
|
||||||
#include <perturb/moPerturbation.h>
|
#include <perturb/moPerturbation.h>
|
||||||
|
#include <memory/moDummyMemory.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perturbation operator using only a eoMonOp
|
* Perturbation operator using only a eoMonOp
|
||||||
|
|
@ -46,7 +48,7 @@ public:
|
||||||
* Default Constructor
|
* Default Constructor
|
||||||
* @param _monOp an eoMonOp (pertubation operator)
|
* @param _monOp an eoMonOp (pertubation operator)
|
||||||
*/
|
*/
|
||||||
moMonOpPerturb(eoMonOp<EOT>& _monOp):monOp(_monOp){}
|
moMonOpPerturb(eoMonOp<EOT>& _monOp, eoEvalFunc<EOT>& _fullEval):monOp(_monOp), fullEval(_fullEval){}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply monOp on the solution
|
* Apply monOp on the solution
|
||||||
|
|
@ -54,12 +56,15 @@ public:
|
||||||
* @return value of monOp
|
* @return value of monOp
|
||||||
*/
|
*/
|
||||||
bool operator()(EOT& _solution){
|
bool operator()(EOT& _solution){
|
||||||
return monOp(_solution);
|
bool res = monOp(_solution);
|
||||||
|
fullEval(_solution);
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** monOp */
|
/** monOp */
|
||||||
eoMonOp<EOT>& monOp;
|
eoMonOp<EOT>& monOp;
|
||||||
|
eoEvalFunc<EOT>& fullEval;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ typedef moDummyRndNeighborhood bitNeighborhood ;
|
||||||
|
|
||||||
typedef EO<int> Solution;
|
typedef EO<int> Solution;
|
||||||
|
|
||||||
class moDummyNeighbor : public moNeighbor<Solution,int> {
|
class moDummyNeighborTest : public moNeighbor<Solution,int> {
|
||||||
public:
|
public:
|
||||||
virtual void move(Solution & _solution) {}
|
virtual void move(Solution & _solution) {}
|
||||||
};
|
};
|
||||||
|
|
@ -74,11 +74,11 @@ public:
|
||||||
virtual void moveBack(Solution & _solution) {}
|
virtual void moveBack(Solution & _solution) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class moDummyNeighborhood : public moNeighborhood<moDummyNeighbor> {
|
class moDummyNeighborhoodTest : public moNeighborhood<moDummyNeighborTest> {
|
||||||
public:
|
public:
|
||||||
typedef moDummyNeighbor Neighbor;
|
typedef moDummyNeighborTest Neighbor;
|
||||||
|
|
||||||
moDummyNeighborhood():i(0),j(0) {}
|
moDummyNeighborhoodTest():i(0),j(0) {}
|
||||||
|
|
||||||
virtual bool hasNeighbor(EOT & _solution) {
|
virtual bool hasNeighbor(EOT & _solution) {
|
||||||
bool res;
|
bool res;
|
||||||
|
|
@ -100,7 +100,7 @@ private:
|
||||||
int i,j;
|
int i,j;
|
||||||
};
|
};
|
||||||
|
|
||||||
class moDummyEval: public eoEvalFunc<Solution> {
|
class moDummyEvalTest: public eoEvalFunc<Solution> {
|
||||||
public:
|
public:
|
||||||
void operator()(Solution& _sol) {
|
void operator()(Solution& _sol) {
|
||||||
if (_sol.invalid())
|
if (_sol.invalid())
|
||||||
|
|
|
||||||
|
|
@ -45,11 +45,11 @@ int main() {
|
||||||
std::cout << "[t-moFullEvalByCopy] => START" << std::endl;
|
std::cout << "[t-moFullEvalByCopy] => START" << std::endl;
|
||||||
|
|
||||||
Solution sol;
|
Solution sol;
|
||||||
moDummyNeighbor neighbor;
|
moDummyNeighborTest neighbor;
|
||||||
moDummyEval eval;
|
moDummyEvalTest eval;
|
||||||
|
|
||||||
//verif constructor
|
//verif constructor
|
||||||
moFullEvalByCopy<moDummyNeighbor> test(eval);
|
moFullEvalByCopy<moDummyNeighborTest> test(eval);
|
||||||
|
|
||||||
sol.fitness(3);
|
sol.fitness(3);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ int main() {
|
||||||
|
|
||||||
Solution sol;
|
Solution sol;
|
||||||
moDummyBackableNeighbor neighbor;
|
moDummyBackableNeighbor neighbor;
|
||||||
moDummyEval eval;
|
moDummyEvalTest eval;
|
||||||
|
|
||||||
//verif constructor
|
//verif constructor
|
||||||
moFullEvalByModif<moDummyBackableNeighbor> test(eval);
|
moFullEvalByModif<moDummyBackableNeighbor> test(eval);
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ int main() {
|
||||||
std::cout << "[t-moNeighbor] => START" << std::endl;
|
std::cout << "[t-moNeighbor] => START" << std::endl;
|
||||||
|
|
||||||
//test constructor
|
//test constructor
|
||||||
moDummyNeighbor test1, test2;
|
moDummyNeighborTest test1, test2;
|
||||||
|
|
||||||
test1.fitness(3);
|
test1.fitness(3);
|
||||||
//test operateur d'affectation
|
//test operateur d'affectation
|
||||||
|
|
@ -50,7 +50,7 @@ int main() {
|
||||||
assert(test1.fitness()==test2.fitness());
|
assert(test1.fitness()==test2.fitness());
|
||||||
|
|
||||||
//test operateur de copy
|
//test operateur de copy
|
||||||
moDummyNeighbor test3(test1);
|
moDummyNeighborTest test3(test1);
|
||||||
assert(test1.fitness()==test3.fitness());
|
assert(test1.fitness()==test3.fitness());
|
||||||
|
|
||||||
test1.printOn(std::cout);
|
test1.printOn(std::cout);
|
||||||
|
|
|
||||||
|
|
@ -48,15 +48,15 @@ int main() {
|
||||||
std::cout << "[t-moSimpleHCexplorer] => START" << std::endl;
|
std::cout << "[t-moSimpleHCexplorer] => START" << std::endl;
|
||||||
|
|
||||||
Solution sol;
|
Solution sol;
|
||||||
moDummyNeighbor neighbor;
|
moDummyNeighborTest neighbor;
|
||||||
moDummyEval eval;
|
moDummyEvalTest eval;
|
||||||
moDummyNeighborhood nh;
|
moDummyNeighborhoodTest nh;
|
||||||
moFullEvalByCopy<moDummyNeighbor> fulleval(eval);
|
moFullEvalByCopy<moDummyNeighborTest> fulleval(eval);
|
||||||
moNeighborComparator<moDummyNeighbor> comp;
|
moNeighborComparator<moDummyNeighborTest> comp;
|
||||||
moSolNeighborComparator<moDummyNeighbor> solNeighborComp;
|
moSolNeighborComparator<moDummyNeighborTest> solNeighborComp;
|
||||||
|
|
||||||
//verif constructor
|
//verif constructor
|
||||||
moSimpleHCexplorer<moDummyNeighborhood> test(nh, fulleval, comp, solNeighborComp);
|
moSimpleHCexplorer<moDummyNeighborhoodTest> test(nh, fulleval, comp, solNeighborComp);
|
||||||
|
|
||||||
//verif operator() et accept: le neigorhood est construit pour qu'on tombe dans les 3 cas suivants:
|
//verif operator() et accept: le neigorhood est construit pour qu'on tombe dans les 3 cas suivants:
|
||||||
//hasNeighbor() retourne faux a l'entrée de l'operator() donc on doit pas continuer
|
//hasNeighbor() retourne faux a l'entrée de l'operator() donc on doit pas continuer
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ int main() {
|
||||||
|
|
||||||
std::cout << "[t-moTrueContinuator] => START" << std::endl;
|
std::cout << "[t-moTrueContinuator] => START" << std::endl;
|
||||||
|
|
||||||
moTrueContinuator<moDummyNeighborhood> test;
|
moTrueContinuator<moDummyNeighborhoodTest> test;
|
||||||
Solution s;
|
Solution s;
|
||||||
|
|
||||||
assert(test(s));
|
assert(test(s));
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
// the general include for eo
|
// the general include for eo
|
||||||
#include <eo>
|
#include <eo>
|
||||||
#include <ga.h>
|
#include <ga.h>
|
||||||
|
#include <ga/eoBitOp.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
@ -37,11 +38,16 @@ using namespace std;
|
||||||
#include <explorer/moSimpleHCexplorer.h>
|
#include <explorer/moSimpleHCexplorer.h>
|
||||||
#include <explorer/moILSexplorer.h>
|
#include <explorer/moILSexplorer.h>
|
||||||
|
|
||||||
|
#include <perturb/moMonOpPerturb.h>
|
||||||
|
#include <acceptCrit/moAlwaysAcceptCrit.h>
|
||||||
|
#include <continuator/moIterContinuator.h>
|
||||||
|
|
||||||
// REPRESENTATION
|
// REPRESENTATION
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
typedef eoBit<unsigned> Indi;
|
typedef eoBit<unsigned> Indi;
|
||||||
typedef moBitNeighbor<unsigned int> Neighbor ; // incremental evaluation
|
typedef moBitNeighbor<unsigned int> Neighbor ; // incremental evaluation
|
||||||
typedef moOrderNeighborhood<Neighbor> Neighborhood ;
|
typedef moOrderNeighborhood<Neighbor> Neighborhood ;
|
||||||
|
typedef moSimpleHCexplorer<Neighborhood> NHE;
|
||||||
|
|
||||||
void main_function(int argc, char **argv)
|
void main_function(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
|
@ -161,7 +167,20 @@ void main_function(int argc, char **argv)
|
||||||
|
|
||||||
moTrueContinuator<Neighborhood> continuator;//always continue
|
moTrueContinuator<Neighborhood> continuator;//always continue
|
||||||
|
|
||||||
moLocalSearch< moSimpleHCexplorer<Neighborhood> > localSearch(explorer, continuator, eval);
|
moLocalSearch< NHE > hc(explorer, continuator, eval);
|
||||||
|
|
||||||
|
eoBitMutation<Indi> monOp(1.0/vecSize);
|
||||||
|
|
||||||
|
moMonOpPerturb<Neighbor> perturb(monOp, eval);
|
||||||
|
|
||||||
|
moAlwaysAcceptCrit<Neighbor> accept;
|
||||||
|
|
||||||
|
moILSexplorer< NHE > explorerILS(hc, perturb, accept);
|
||||||
|
|
||||||
|
moIterContinuator<Neighborhood> continuatorILS(10);
|
||||||
|
|
||||||
|
moLocalSearch< moILSexplorer< moSimpleHCexplorer<Neighborhood> > >localSearch(explorerILS, continuatorILS, eval);
|
||||||
|
|
||||||
|
|
||||||
/* =========================================================
|
/* =========================================================
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -66,10 +66,6 @@ void main_function(int argc, char **argv)
|
||||||
parser.processParam( vecSizeParam, "Representation" );
|
parser.processParam( vecSizeParam, "Representation" );
|
||||||
unsigned vecSize = vecSizeParam.value();
|
unsigned vecSize = vecSizeParam.value();
|
||||||
|
|
||||||
eoValueParam<unsigned int> stepParam(10, "nbStep", "Number of steps of the random walk", 'n');
|
|
||||||
parser.processParam( stepParam, "Representation" );
|
|
||||||
unsigned nbStep = stepParam.value();
|
|
||||||
|
|
||||||
// the name of the "status" file where all actual parameter values will be saved
|
// the name of the "status" file where all actual parameter values will be saved
|
||||||
string str_status = parser.ProgramName() + ".status"; // default value
|
string str_status = parser.ProgramName() + ".status"; // default value
|
||||||
eoValueParam<string> statusParam(str_status.c_str(), "status", "Status file");
|
eoValueParam<string> statusParam(str_status.c_str(), "status", "Status file");
|
||||||
|
|
@ -154,7 +150,7 @@ void main_function(int argc, char **argv)
|
||||||
* ========================================================= */
|
* ========================================================= */
|
||||||
|
|
||||||
// initial temp, factor of decrease, number of steps without decrease, final temp.
|
// initial temp, factor of decrease, number of steps without decrease, final temp.
|
||||||
moSimpleCoolingSchdedule<Indi> coolingSchedule(10, 0.9, 1, 0.01);
|
moSimpleCoolingSchedule<Indi> coolingSchedule(10, 0.9, 1, 0.01);
|
||||||
|
|
||||||
/* =========================================================
|
/* =========================================================
|
||||||
*
|
*
|
||||||
|
|
@ -172,7 +168,7 @@ void main_function(int argc, char **argv)
|
||||||
|
|
||||||
moTrueContinuator<Neighborhood> continuator;//always continue
|
moTrueContinuator<Neighborhood> continuator;//always continue
|
||||||
|
|
||||||
moLocalSearch< moMetropolisHastingExplorer<Neighborhood> > localSearch(explorer, continuator, eval);
|
moLocalSearch< moSAexplorer<Neighborhood> > localSearch(explorer, continuator, eval);
|
||||||
|
|
||||||
/* =========================================================
|
/* =========================================================
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue