rename files

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1754 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
jhumeau 2010-04-28 15:50:22 +00:00
commit 0720d5f05d
14 changed files with 144 additions and 68 deletions

View file

@ -31,7 +31,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#define _moFirstImprHC_h
#include <algo/moLocalSearch.h>
#include <explorer/moFirstImprExplorer.h>
#include <explorer/moFirstImprHCexplorer.h>
#include <continuator/moTrueContinuator.h>
#include <eval/moEval.h>
#include <eoEvalFunc.h>
@ -88,7 +88,7 @@ private:
// compare the fitness values of the solution and the neighbor: true if strictly greater
moSolNeighborComparator<Neighbor> defaultSolNeighborComp;
// the explorer of the first improvement HC
moFirstImprExplorer<Neighbor> explorer;
moFirstImprHCexplorer<Neighbor> explorer;
};
#endif

View file

@ -31,7 +31,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#define _moRandomBestHC_h
#include <algo/moLocalSearch.h>
#include <explorer/moRandomBestHCExplorer.h>
#include <explorer/moRandomBestHCexplorer.h>
#include <continuator/moTrueContinuator.h>
#include <eval/moEval.h>
#include <eoEvalFunc.h>
@ -88,7 +88,7 @@ private:
// compare the fitness values of the solution and the neighbor: true if strictly greater
moSolNeighborComparator<Neighbor> defaultSolNeighborComp;
// the explorer of the HC with random choice of the best solution
moRandomBestHCExplorer<Neighbor> explorer;
moRandomBestHCexplorer<Neighbor> explorer;
};
#endif

View file

@ -53,7 +53,7 @@ public:
* @param _spanNoMove maximum number of no improvement with equal temperature
* @param _nbSpan maximum number of span with no improvmement before stopping the search
*/
moDynSpanCoolingSchedule(double _initT, double _alpha, unsigned _spanMove, unsigned _spanNoMove, unsigned _nbSpan) : initT(_initT), alpha(_alpha), spanMove(_spanMove), spanNoMove(_spanNoMove), nbSpan(_nbSpan) {
moDynSpanCoolingSchedule(double _initT, double _alpha, unsigned int _spanMove, unsigned int _spanNoMove, unsigned int _nbSpan) : initT(_initT), alpha(_alpha), spanMove(_spanMove), spanNoMove(_spanNoMove), nbSpan(_nbSpan) {
}
/**
@ -101,12 +101,22 @@ public:
private:
// initial temperature
double initT;
// coefficient of decrease
double alpha;
//
unsigned int spanMove;
//
unsigned int spanNoMove;
// maximum number of iterations at the same temperature
unsigned int span;
unsigned int nbSpan;
// threshold temperature
double finalT;
// number of steps with the same temperature
unsigned int step;
};

View file

@ -0,0 +1,163 @@
/*
<moFirstImprHCexplorer.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 use,
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".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
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 _moFirstImprHCexplorer_h
#define _moFirstImprHCexplorer_h
#include <explorer/moNeighborhoodExplorer.h>
#include <comparator/moNeighborComparator.h>
#include <comparator/moSolNeighborComparator.h>
#include <neighborhood/moNeighborhood.h>
/**
* Explorer for a first imporvement heuristic
*/
template< class Neighbor>
class moFirstImprHCexplorer : public moNeighborhoodExplorer<Neighbor>
{
public:
typedef typename Neighbor::EOT EOT ;
typedef moNeighborhood<Neighbor> Neighborhood ;
using moNeighborhoodExplorer<Neighbor>::neighborhood;
using moNeighborhoodExplorer<Neighbor>::eval;
/**
* Constructor
* @param _neighborhood the neighborhood
* @param _eval the evaluation function
* @param _neighborComparator a neighbor comparator
* @param _solNeighborComparator a solution vs neighbor comparator
*/
moFirstImprHCexplorer(Neighborhood& _neighborhood, moEval<Neighbor>& _eval, moNeighborComparator<Neighbor>& _neighborComparator, moSolNeighborComparator<Neighbor>& _solNeighborComparator) : moNeighborhoodExplorer<Neighbor>(_neighborhood, _eval), neighborComparator(_neighborComparator), solNeighborComparator(_solNeighborComparator) {
isAccept = false;
current=new Neighbor();
}
/**
* Destructor
*/
~moFirstImprHCexplorer() {
delete current;
}
/**
* initParam: NOTHING TO DO
*/
virtual void initParam(EOT & solution) {};
/**
* updateParam: NOTHING TO DO
*/
virtual void updateParam(EOT & solution) {};
/**
* terminate: NOTHING TO DO
*/
virtual void terminate(EOT & solution) {};
/**
* Explore the neighborhood of a solution
* @param _solution
*/
virtual void operator()(EOT & _solution) {
//Test if _solution has a Neighbor
if (neighborhood.hasNeighbor(_solution)) {
//init the first neighbor
neighborhood.init(_solution, (*current));
//eval the _solution moved with the neighbor and stock the result in the neighbor
eval(_solution, (*current));
//test all others neighbors
while (! solNeighborComparator(_solution, *current) && neighborhood.cont(_solution)) {
//next neighbor
neighborhood.next(_solution, (*current));
//eval
eval(_solution, (*current));
}
}
else {
//if _solution hasn't neighbor,
isAccept=false;
}
};
/**
* continue if a move is accepted
* @param _solution the solution
* @return true if an ameliorated neighbor was be found
*/
virtual bool isContinue(EOT & _solution) {
return isAccept ;
};
/**
* move the solution with the best neighbor
* @param _solution the solution to move
*/
virtual void move(EOT & _solution) {
//move the solution
(*current).move(_solution);
//update its fitness
_solution.fitness((*current).fitness());
};
/**
* accept test if an amelirated neighbor was be found
* @param _solution the solution
* @return true if the best neighbor ameliorate the fitness
*/
virtual bool accept(EOT & _solution) {
if (neighborhood.hasNeighbor(_solution)) {
isAccept = solNeighborComparator(_solution, (*current)) ;
}
return isAccept;
};
private:
// comparator betwenn solution and neighbor or between neighbors
moNeighborComparator<Neighbor>& neighborComparator;
moSolNeighborComparator<Neighbor>& solNeighborComparator;
//Pointer on the best and the current neighbor
Neighbor* current;
// true if the move is accepted
bool isAccept ;
};
#endif

View file

@ -1,5 +1,5 @@
/*
<moHCneutralExplorer.h>
<moNeutralHCexplorer.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau
@ -32,10 +32,10 @@
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef _moHCneutralExplorer_h
#define _moHCneutralExplorer_h
#ifndef _moNeutralHCexplorer_h
#define _moNeutralHCexplorer_h
#include <explorer/moRandomBestHCExplorer.h>
#include <explorer/moRandomBestHCexplorer.h>
#include <comparator/moNeighborComparator.h>
#include <comparator/moSolNeighborComparator.h>
#include <neighborhood/moNeighborhood.h>
@ -44,18 +44,18 @@
* Explorer for a neutral Hill-climbing
*/
template< class Neighbor >
class moHCneutralExplorer : public moRandomBestHCExplorer<Neighbor>
class moNeutralHCexplorer : public moRandomBestHCexplorer<Neighbor>
{
public:
typedef typename Neighbor::EOT EOT ;
typedef moNeighborhood<Neighbor> Neighborhood ;
using moNeighborhoodExplorer<Neighbor>::neighborhood;
using moRandomBestHCExplorer<Neighbor>::solNeighborComparator;
using moRandomBestHCExplorer<Neighbor>::isAccept;
using moRandomBestHCExplorer<Neighbor>::bestVector;
using moRandomBestHCExplorer<Neighbor>::initParam;
using moRandomBestHCExplorer<Neighbor>::updateParam;
using moRandomBestHCexplorer<Neighbor>::solNeighborComparator;
using moRandomBestHCexplorer<Neighbor>::isAccept;
using moRandomBestHCexplorer<Neighbor>::bestVector;
using moRandomBestHCexplorer<Neighbor>::initParam;
using moRandomBestHCexplorer<Neighbor>::updateParam;
/**
* Constructor
@ -65,30 +65,30 @@ public:
* @param _solNeighborComparator a solution vs neighbor comparator
* @param _nbStep maximum step to do
*/
moHCneutralExplorer(Neighborhood& _neighborhood,
moNeutralHCexplorer(Neighborhood& _neighborhood,
moEval<Neighbor>& _eval,
moNeighborComparator<Neighbor>& _neighborComparator,
moSolNeighborComparator<Neighbor>& _solNeighborComparator,
unsigned _nbStep) :
moRandomBestHCExplorer<Neighbor>(_neighborhood, _eval, _neighborComparator, _solNeighborComparator),
moRandomBestHCexplorer<Neighbor>(_neighborhood, _eval, _neighborComparator, _solNeighborComparator),
nbStep(_nbStep) {
//Some cycle is possible with equals fitness solutions if the neighborhood is not random
if (!neighborhood.isRandom()) {
std::cout << "moHCneutralExplorer::Warning -> the neighborhood used is not random" << std::endl;
std::cout << "moNeutralHCexplorer::Warning -> the neighborhood used is not random" << std::endl;
}
}
/**
* Destructor
*/
~moHCneutralExplorer() {
~moNeutralHCexplorer() {
}
/**
* initial number of step
*/
virtual void initParam(EOT & solution) {
moRandomBestHCExplorer<Neighbor>::initParam(solution);
moRandomBestHCexplorer<Neighbor>::initParam(solution);
step = 0;
};
@ -97,7 +97,7 @@ public:
* one more step
*/
virtual void updateParam(EOT & solution) {
moRandomBestHCExplorer<Neighbor>::updateParam(solution);
moRandomBestHCexplorer<Neighbor>::updateParam(solution);
step++;
};

View file

@ -0,0 +1,195 @@
/*
<moRandomBestHCexplorer.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sebastien Verel, Arnaud Liefooghe, Jeremie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
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".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
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 _moRandomBestHCexplorer_h
#define _moRandomBestHCexplorer_h
#include <explorer/moNeighborhoodExplorer.h>
#include <comparator/moNeighborComparator.h>
#include <comparator/moSolNeighborComparator.h>
#include <neighborhood/moNeighborhood.h>
#include <vector>
#include <utils/eoRNG.h>
/**
* Explorer for Hill-Climbing
* which choose randomly one of the best solution in the neighborhood at each iteration
*/
template< class Neighbor >
class moRandomBestHCexplorer : public moNeighborhoodExplorer<Neighbor>
{
public:
typedef typename Neighbor::EOT EOT ;
typedef moNeighborhood<Neighbor> Neighborhood ;
using moNeighborhoodExplorer<Neighbor>::neighborhood;
using moNeighborhoodExplorer<Neighbor>::eval;
/**
* Constructor
* @param _neighborhood the neighborhood
* @param _eval the evaluation function
* @param _neighborComparator a neighbor comparator
* @param _solNeighborComparator solution vs neighbor comparator
*/
moRandomBestHCexplorer(Neighborhood& _neighborhood,
moEval<Neighbor>& _eval,
moNeighborComparator<Neighbor>& _neighborComparator,
moSolNeighborComparator<Neighbor>& _solNeighborComparator) :
moNeighborhoodExplorer<Neighbor>(_neighborhood, _eval),
neighborComparator(_neighborComparator),
solNeighborComparator(_solNeighborComparator) {
isAccept = false;
current=new Neighbor();
}
/**
* Destructor
*/
~moRandomBestHCexplorer() {
delete current;
}
/**
* empty the vector of best solutions
*/
virtual void initParam(EOT & solution) {
// delete all the best solutions
bestVector.clear();
};
/**
* empty the vector of best solutions
*/
virtual void updateParam(EOT & solution) {
// delete all the best solutions
bestVector.clear();
};
/**
* terminate: NOTHING TO DO
*/
virtual void terminate(EOT & solution) {};
/**
* Explore the neighborhood of a solution
* @param _solution
*/
virtual void operator()(EOT & _solution) {
//Test if _solution has a Neighbor
if (neighborhood.hasNeighbor(_solution)) {
//init the first neighbor
neighborhood.init(_solution, (*current));
//eval the _solution moved with the neighbor and stock the result in the neighbor
eval(_solution, (*current));
//initialize the best neighbor
bestVector.push_back(*current);
//test all others neighbors
while (neighborhood.cont(_solution)) {
//next neighbor
neighborhood.next(_solution, (*current));
//eval
eval(_solution, (*current));
//if we found a better neighbor, update the best
if (neighborComparator(bestVector[0], (*current))) {
bestVector.clear();
bestVector.push_back(*current);
}
else if (neighborComparator.equals((*current), bestVector[0])) //if the current is equals to previous best solutions then update vector of the best solution
bestVector.push_back(*current);
}
}
else {
//if _solution hasn't neighbor,
isAccept=false;
}
};
/**
* continue if a move is accepted
* @param _solution the solution
* @return true if an ameliorated neighbor was be found
*/
virtual bool isContinue(EOT & _solution) {
return isAccept ;
};
/**
* move the solution with the best neighbor
* @param _solution the solution to move
*/
virtual void move(EOT & _solution) {
// choose randomly one of the best solutions
unsigned int i = rng.random(bestVector.size());
//move the solution
bestVector[i].move(_solution);
//update its fitness
_solution.fitness(bestVector[i].fitness());
};
/**
* accept test if an amelirated neighbor was be found
* @param _solution the solution
* @return true if the best neighbor ameliorate the fitness
*/
virtual bool accept(EOT & _solution) {
if (neighborhood.hasNeighbor(_solution))
isAccept = solNeighborComparator(_solution, bestVector[0]) ;
return isAccept;
};
protected:
// comparator betwenn solution and neighbor or between neighbors
moNeighborComparator<Neighbor>& neighborComparator;
moSolNeighborComparator<Neighbor>& solNeighborComparator;
// the best solutions in the neighborhood
std::vector<Neighbor> bestVector;
//Pointer on the current neighbor
Neighbor* current;
// true if the move is accepted
bool isAccept ;
};
#endif

View file

@ -0,0 +1,255 @@
/*
<moTSexplorer.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 use,
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".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
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 _moTSexplorer_h
#define _moTSexplorer_h
#include <explorer/moNeighborhoodExplorer.h>
#include <comparator/moNeighborComparator.h>
#include <comparator/moSolNeighborComparator.h>
#include <memory/moAspiration.h>
#include <memory/moTabuList.h>
#include <memory/moIntensification.h>
#include <memory/moDiversification.h>
#include <neighborhood/moNeighborhood.h>
/**
* Explorer for a Tabu Search
*/
template< class Neighbor >
class moTSexplorer : public moNeighborhoodExplorer<Neighbor>
{
public:
typedef typename Neighbor::EOT EOT ;
typedef moNeighborhood<Neighbor> Neighborhood ;
/**
* Constructor
* @param _neighborhood the neighborhood
* @param _eval the evaluation function
* @param _neighborComparator a neighbor comparator
* @param _solNeighborComparator a comparator between a solution and a neighbor
* @param _tabuList the tabu list
* @param _intensification the intensification box
* @param _diversification the diversification box
* @param _aspiration the aspiration criteria
*/
moTSexplorer(Neighborhood& _neighborhood,
moEval<Neighbor>& _eval,
moNeighborComparator<Neighbor>& _neighborComparator,
moSolNeighborComparator<Neighbor>& _solNeighborComparator,
moTabuList<Neighbor> & _tabuList,
moIntensification<Neighbor> & _intensification,
moDiversification<Neighbor> & _diversification,
moAspiration<Neighbor> & _aspiration
) :
moNeighborhoodExplorer<Neighbor>(_neighborhood, _eval), neighborComparator(_neighborComparator), solNeighborComparator(_solNeighborComparator),
tabuList(_tabuList), intensification(_intensification), diversification(_diversification), aspiration(_aspiration)
{
isAccept = false;
current=new Neighbor();
best=new Neighbor();
}
/**
* Destructor
*/
~moTSexplorer() {
delete current;
delete best;
}
/**
* init tabu list, intensification box, diversification box and aspiration criteria
* @param _solution
*/
virtual void initParam(EOT& _solution)
{
tabuList.init(_solution);
intensification.init(_solution);
diversification.init(_solution);
aspiration.init(_solution);
bestSoFar=_solution;
};
/**
* update params of tabu list, intensification box, diversification box and aspiration criteria
* @param _solution
*/
virtual void updateParam(EOT& _solution)
{
if ((*this).moveApplied()) {
tabuList.add(_solution, *best);
intensification.add(_solution, *best);
diversification.add(_solution, *best);
if (_solution.fitness() > bestSoFar.fitness())
bestSoFar = _solution;
}
tabuList.update(_solution, *best);
intensification.update(_solution, *best);
diversification.update(_solution, *best);
aspiration.update(_solution, *best);
};
/**
* terminate : _solution becomes the best so far
*/
virtual void terminate(EOT & _solution) {
_solution= bestSoFar;
};
/**
* Explore the neighborhood of a solution
* @param _solution
*/
virtual void operator()(EOT & _solution)
{
bool found=false;
intensification(_solution);
diversification(_solution);
if (neighborhood.hasNeighbor(_solution))
{
//init the current neighbor
neighborhood.init(_solution, *current);
//eval the current neighbor
eval(_solution, *current);
//Find the first non-tabu element
if ( (!tabuList.check(_solution, *current)) || aspiration(_solution, *current) ) {
// set best
(*best)= (*current);
found=true;
}
while (neighborhood.cont(_solution) && !found) {
//next neighbor
neighborhood.next(_solution, (*current));
//eval
eval(_solution, (*current));
if ( (!tabuList.check(_solution, *current)) || aspiration(_solution, *current) ) {
// set best
(*best)=(*current);
found=true;
}
}
//Explore the neighborhood
if (found) {
isAccept=true;
while (neighborhood.cont(_solution)) {
//next neighbor
neighborhood.next(_solution, (*current));
//eval
eval(_solution, (*current));
//check if the current is better than the best and is not tabu or if it is aspirat (by the aspiration criteria of course)
if ( (!tabuList.check(_solution, *current) || aspiration(_solution, (*current))) && neighborComparator((*best),(*current))) {
// set best
(*best)=(*current);
}
}
}
else {
isAccept=false;
}
}
else {
isAccept=false;
}
};
/**
* always continue
* @param _solution the solution
* @return true
*/
virtual bool isContinue(EOT & _solution) {
return true;
};
/**
* move the solution with the best neighbor
* @param _solution the solution to move
*/
virtual void move(EOT & _solution) {
//move the solution
best->move(_solution);
//update its fitness
_solution.fitness(best->fitness());
};
/**
* accept test if an ameliorated neighbor was be found
* @param _solution the solution
* @return true if the best neighbor ameliorate the fitness
*/
virtual bool accept(EOT & _solution) {
return isAccept;
};
protected:
using moNeighborhoodExplorer<Neighbor>::neighborhood;
using moNeighborhoodExplorer<Neighbor>::eval;
// comparator between solution and neighbor or between neighbors
moNeighborComparator<Neighbor>& neighborComparator;
moSolNeighborComparator<Neighbor>& solNeighborComparator;
// Tabu components
moTabuList<Neighbor> & tabuList;
moIntensification<Neighbor> & intensification;
moDiversification<Neighbor> & diversification;
moAspiration<Neighbor> & aspiration;
//Current and best neighbor
Neighbor* best;
Neighbor* current;
//Best so far Solution
EOT bestSoFar;
// true if the move is accepted
bool isAccept ;
};
#endif

View file

@ -70,15 +70,15 @@
#include <eval/moFullEvalByModif.h>
#include <eval/moDummyEval.h>
#include <explorer/moFirstImprExplorer.h>
#include <explorer/moHCneutralExplorer.h>
#include <explorer/moFirstImprHCexplorer.h>
#include <explorer/moNeutralHCexplorer.h>
#include <explorer/moMetropolisHastingExplorer.h>
#include <explorer/moNeighborhoodExplorer.h>
#include <explorer/moRandomNeutralWalkExplorer.h>
#include <explorer/moRandomWalkExplorer.h>
#include <explorer/moSimpleHCexplorer.h>
#include <explorer/moRandomBestHCExplorer.h>
#include <explorer/moTSExplorer.h>
#include <explorer/moRandomBestHCexplorer.h>
#include <explorer/moTSexplorer.h>
#include <explorer/moILSexplorer.h>
#include <explorer/moSAexplorer.h>

View file

@ -51,13 +51,13 @@ SET (TEST_LIST
t-moSolVectorTabuList
t-moBestImprAspiration
t-moSimpleHCexplorer
t-moSimpleHCneutralExplorer
t-moHCneutralExplorer
t-moFirstImprExplorer
t-moRandomBestHCexplorer
t-moNeutralHCexplorer
t-moFirstImprHCexplorer
t-moRandomWalkExplorer
t-moMetropolisHastingExplorer
t-moRandomNeutralWalkExplorer
t-moTSExplorer
t-moTSexplorer
t-moForwardVariableNeighborhood
t-moSolComparator
t-moDummyEval
@ -74,6 +74,7 @@ SET (TEST_LIST
t-moSA
t-moLocalSearch
t-moILSexplorer
t-moSimpleHC
)
FOREACH (test ${TEST_LIST})

View file

@ -0,0 +1,93 @@
/*
<t-moFirstImprExplorer.cpp>
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
*/
#include <comparator/moNeighborComparator.h>
#include <comparator/moSolNeighborComparator.h>
#include <explorer/moFirstImprHCexplorer.h>
#include "moTestClass.h"
#include <iostream>
#include <cstdlib>
#include <cassert>
int main() {
std::cout << "[t-moFirstImprHCexplorer] => START" << std::endl;
//Instanciation
eoBit<eoMinimizingFitness> sol(4, true);
sol.fitness(4);
bitNeighborhood nh(4);
evalOneMax eval(4);
moNeighborComparator<bitNeighbor> ncomp;
moSolNeighborComparator<bitNeighbor> sncomp;
moFirstImprHCexplorer<bitNeighbor> test(nh, eval, ncomp, sncomp);
//on verifie qu'on améliore peut continuer à explorer tant qu'on améliore la solution
test(sol);
assert(test.accept(sol));
test.move(sol);
assert(sol.fitness()==3);
assert(!sol[0]);
assert(test.isContinue(sol));
test(sol);
assert(test.accept(sol));
test.move(sol);
assert(sol.fitness()==2);
assert(!sol[1]);
assert(test.isContinue(sol));
test(sol);
assert(test.accept(sol));
test.move(sol);
assert(sol.fitness()==1);
assert(!sol[2]);
assert(test.isContinue(sol));
test(sol);
assert(test.accept(sol));
test.move(sol);
assert(sol.fitness()==0);
assert(!sol[3]);
assert(test.isContinue(sol));
test(sol);
assert(!test.accept(sol));
assert(sol.fitness()==0);
assert(!test.isContinue(sol));
std::cout << "[t-moFirstImprHCexplorer] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,92 @@
/*
<t-moNeutralHCexplorer.cpp>
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
*/
#include <comparator/moNeighborComparator.h>
#include <comparator/moSolNeighborComparator.h>
#include <explorer/moNeutralHCexplorer.h>
#include "moTestClass.h"
#include <iostream>
#include <cstdlib>
#include <cassert>
int main() {
std::cout << "[t-moNeutralHCexplorer] => START" << std::endl;
//Instanciation
eoBit<eoMinimizingFitness> sol(4, true);
sol.fitness(4);
bitNeighborhood nh(4);
evalOneMax eval(4);
moNeighborComparator<bitNeighbor> ncomp;
moSolNeighborComparator<bitNeighbor> sncomp;
moNeutralHCexplorer<bitNeighbor> test(nh, eval, ncomp, sncomp,3);
//on verifie qu'on ameliore bien la solution et que l'exploration dure 3 itérations
test.initParam(sol);
test(sol);
assert(test.accept(sol));
test.move(sol);
assert(sol.fitness()==3);
test.updateParam(sol);
assert(test.isContinue(sol));
//les affichages permettent de voir qu'on prend pas toujours les mm voisins(lancer plusieurs fois l'exe)
std::cout << sol << std::endl;
test(sol);
assert(test.accept(sol));
test.move(sol);
assert(sol.fitness()==2);
test.updateParam(sol);
assert(test.isContinue(sol));
std::cout << sol << std::endl;
test(sol);
assert(test.accept(sol));
test.move(sol);
assert(sol.fitness()==1);
test.updateParam(sol);
assert(!test.isContinue(sol));
std::cout << sol << std::endl;
std::cout << "[t-moNeutralHCexplorer] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,101 @@
/*
<t-moRandomBestHCExplorer.cpp>
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
*/
#include <comparator/moNeighborComparator.h>
#include <comparator/moSolNeighborComparator.h>
#include <explorer/moRandomBestHCexplorer.h>
#include "moTestClass.h"
#include <iostream>
#include <cstdlib>
#include <cassert>
int main() {
std::cout << "[t-moRandomBestHCexplorer] => START" << std::endl;
//instanciation
eoBit<eoMinimizingFitness> sol(4, true);
sol.fitness(4);
bitNeighborhood nh(4);
evalOneMax eval(4);
moNeighborComparator<bitNeighbor> ncomp;
moSolNeighborComparator<bitNeighbor> sncomp;
moRandomBestHCexplorer<bitNeighbor> test(nh, eval, ncomp, sncomp);
//test qu'on ameliore bien a chaque itération
test.initParam(sol);
test(sol);
assert(test.accept(sol));
test.move(sol);
assert(sol.fitness()==3);
assert(test.isContinue(sol));
test.updateParam(sol);
//les affichages permettent de voir qu'on choisit pas toujours les mm voisins améliorant (lancer plusieurs fois l'exe)
std::cout << sol << std::endl;
test(sol);
assert(test.accept(sol));
test.move(sol);
assert(sol.fitness()==2);
assert(test.isContinue(sol));
test.updateParam(sol);
std::cout << sol << std::endl;
test(sol);
assert(test.accept(sol));
test.move(sol);
assert(sol.fitness()==1);
assert(test.isContinue(sol));
test.updateParam(sol);
std::cout << sol << std::endl;
test(sol);
assert(test.accept(sol));
test.move(sol);
assert(sol.fitness()==0);
assert(test.isContinue(sol));
test.updateParam(sol);
test(sol);
assert(!test.accept(sol));
assert(sol.fitness()==0);
assert(!test.isContinue(sol));
test.updateParam(sol);
std::cout << "[t-moRandomBestHCexplorer] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,65 @@
/*
<t-moSimpleHC.cpp>
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
*/
#include <iostream>
#include <cstdlib>
#include <cassert>
#include <algo/moSimpleHC.h>
#include "moTestClass.h"
#include <problems/eval/oneMaxFullEval.h>
#include <continuator/moTrueContinuator.h>
#include <comparator/moSolNeighborComparator.h>
int main(){
std::cout << "[t-moSimpleHC] => START" << std::endl;
bitNeighborhood nh(4);
oneMaxFullEval<bitVector> fullEval;
evalOneMax eval(4);
//test first constructor
moSimpleHC<bitNeighbor> test1(nh, fullEval, eval);
//test second constructor
moTrueContinuator<bitNeighbor> cont;
moSimpleHC<bitNeighbor> test2(nh, fullEval, eval, cont);
//test third constructor
moSolNeighborComparator<bitNeighbor> sncomp;
moNeighborComparator<bitNeighbor> ncomp;
moSimpleHC<bitNeighbor> test3(nh, fullEval, eval, cont, ncomp, sncomp);
std::cout << "[t-moSimpleHC] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,165 @@
/*
<t-moTSexplorer.cpp>
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
*/
#include <memory/moSolVectorTabuList.h>
#include <memory/moDummyIntensification.h>
#include <memory/moDummyDiversification.h>
#include <memory/moBestImprAspiration.h>
#include <explorer/moTSexplorer.h>
#include "moTestClass.h"
#include <iostream>
#include <cstdlib>
#include <cassert>
int main() {
std::cout << "[t-moTSexplorer] => START" << std::endl;
//instansiation
eoBit<eoMinimizingFitness> sol(4, true);
sol.fitness(4);
bitNeighborhood nh(4);
bitNeighborhood emptyNH(0);
evalOneMax eval(4);
moNeighborComparator<bitNeighbor> ncomp;
moSolNeighborComparator<bitNeighbor> sncomp;
moDummyIntensification<bitNeighbor> intens;
moDummyDiversification<bitNeighbor> diver;
moSolVectorTabuList<bitNeighbor> tabuList(4,0);
moBestImprAspiration<bitNeighbor> aspir;
moTSexplorer<bitNeighbor> test(nh, eval, ncomp, sncomp, tabuList, intens, diver, aspir);
moTSexplorer<bitNeighbor> test2(emptyNH, eval, ncomp, sncomp, tabuList, intens, diver, aspir);
//test d'un voisinage vide
test2.initParam(sol);
test2(sol);
assert(!test2.accept(sol));
//test le comportement classique de la taboo
test.initParam(sol);
assert(aspir.getBest()==sol);
test(sol);
test.updateParam(sol);
assert(aspir.getBest()==sol);
//on ameliore et on stock une sol tabou 0111
test(sol);
test.move(sol);
test.moveApplied(true);
test.updateParam(sol);
assert(aspir.getBest()==sol);
//on ameliore et on stock une autre sol tabou 0011
test(sol);
test.move(sol);
test.moveApplied(true);
test.updateParam(sol);
assert(aspir.getBest()==sol);
//pareil on stock 0001 met pdt la recherche on se rend compte que 0111 est tabou
test(sol);
test.move(sol);
test.moveApplied(true);
test.updateParam(sol);
assert(aspir.getBest()==sol);
//on modifie la sol en 1001(fitness 2) pour que la 1er sol exploré(0001) soit tabou
//De plus on change la solution mais elle est pas meilleure que la best so Far
sol[0]=true;
std::cout << sol << std::endl;
sol.fitness(2);
test(sol);
test.move(sol);
test.moveApplied(true);
test.updateParam(sol);
assert( sol[0] && !sol[1] && !sol[2] && !sol[3]);
sol[0]=false;
sol[3]=true;
assert(aspir.getBest()==sol);
//test du isContinue
assert(test.isContinue(sol));
//test du terminate
test.initParam(sol);
sol[0]=true;
sol[1]=true;
sol[2]=true;
sol[3]=true;
sol.fitness(4);
test(sol);
test.move(sol);
test.moveApplied(true);
test.updateParam(sol);
assert( !sol[0] && sol[1] && sol[2] && sol[3]);
test.terminate(sol);
assert( !sol[0] && !sol[1] && !sol[2] && sol[3]);
//test pour avoir que des mouvement taboo
eoBit<eoMinimizingFitness> sol2(2, true);
sol2.fitness(2);
bitNeighborhood nh2(2);
evalOneMax eval2(2);
moTSexplorer<bitNeighbor> test3(nh2, eval2, ncomp, sncomp, tabuList, intens, diver, aspir);
test3.initParam(sol2);
test3(sol2);
test3.move(sol2);
test3.moveApplied(true);
test3.updateParam(sol2);
test3(sol2);
test3.move(sol2);
test3.moveApplied(true);
test3.updateParam(sol2);
test3(sol2);
test3.move(sol2);
test3.moveApplied(true);
test3.updateParam(sol2);
test3(sol2);
test3.move(sol2);
test3.moveApplied(true);
test3.updateParam(sol2);
//on a rempli la liste tabu pour que tout les voisins soit tabu
test3(sol2);
assert(!test3.accept(sol2));
std::cout << "[t-moTSexplorer] => OK" << std::endl;
return EXIT_SUCCESS;
}