Migration from SVN
This commit is contained in:
parent
d7d6c3a217
commit
8cd56f37db
29069 changed files with 0 additions and 4096888 deletions
56
mo/src/neighborhood/moBackableNeighbor.h
Normal file
56
mo/src/neighborhood/moBackableNeighbor.h
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
<moBackableNeighbor.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 _BackableNeighbor_h
|
||||
#define _BackableNeighbor_h
|
||||
|
||||
#include <neighborhood/moNeighbor.h>
|
||||
|
||||
/**
|
||||
* Neighbor with a move back function to use in a moFullEvalByModif
|
||||
*/
|
||||
template< class EOT, class Fitness=typename EOT::Fitness >
|
||||
class moBackableNeighbor : virtual public moNeighbor<EOT, Fitness>
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* the function to move back a solution
|
||||
* @param _solution the solution to moveBack
|
||||
*/
|
||||
virtual void moveBack(EOT & _solution)=0;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
100
mo/src/neighborhood/moBackwardVectorVNSelection.h
Normal file
100
mo/src/neighborhood/moBackwardVectorVNSelection.h
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
/*
|
||||
<moBackwardVectorVNSelection.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 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 _moBackwardVectorVNSelection_h
|
||||
#define _moBackwardVectorVNSelection_h
|
||||
|
||||
#include <neighborhood/moVectorVNSelection.h>
|
||||
|
||||
/**
|
||||
* This class is used for the Variable Neighborhood Search explorer inherits from moVectorVNSelection
|
||||
* The search heuristics are saved in vectors
|
||||
* They are given in backward order from the last ones to the first ones
|
||||
*
|
||||
*/
|
||||
template< class EOT >
|
||||
class moBackwardVectorVNSelection: public moVectorVNSelection<EOT>{
|
||||
|
||||
using moVectorVNSelection<EOT>::LSvector;
|
||||
using moVectorVNSelection<EOT>::current;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Default constructor with first search heuristics
|
||||
*
|
||||
* @param _firstLS first local search
|
||||
* @param _firstShake first heuristic which perturbs the solution
|
||||
* @param _cycle when true, the first heuristics follows the last ones. Otherwise the search stop.
|
||||
*/
|
||||
moBackwardVectorVNSelection(eoMonOp<EOT>& _firstLS, eoMonOp<EOT>& _firstShake, bool _cycle = true) : moVectorVNSelection<EOT>(_firstLS, _firstShake), cycle(_cycle){}
|
||||
|
||||
/**
|
||||
* Return the class id.
|
||||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const {
|
||||
return "moBackwardVectorVNSelection";
|
||||
}
|
||||
|
||||
/**
|
||||
* test if there is still some heuristics
|
||||
*
|
||||
* @param _solution the current solution
|
||||
* @return true if there is some heuristics
|
||||
*/
|
||||
virtual bool cont(EOT& _solution){
|
||||
return (cycle || (current > 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* put the current heuristics on the first ones
|
||||
*
|
||||
* @param _solution the current solution
|
||||
*/
|
||||
virtual void init(EOT& _solution){
|
||||
current = LSvector.size() - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* put the current heuristics on the next ones
|
||||
*
|
||||
* @param _solution the current solution
|
||||
*/
|
||||
virtual void next(EOT& _solution){
|
||||
current = (current + LSvector.size() -1) % LSvector.size();
|
||||
}
|
||||
|
||||
private:
|
||||
// boolean to indicate the last heuristics follow the first ones
|
||||
bool cycle;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
48
mo/src/neighborhood/moDummyNeighbor.h
Normal file
48
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=typename EOT::Fitness >
|
||||
class moDummyNeighbor : public moNeighbor< EOT, Fitness > {
|
||||
public:
|
||||
|
||||
/**
|
||||
* NOTHING TO DO
|
||||
* @param _solution the related solution
|
||||
*/
|
||||
virtual void move(EOT& _solution) {}
|
||||
};
|
||||
#endif
|
||||
78
mo/src/neighborhood/moDummyNeighborhood.h
Normal file
78
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>
|
||||
#include <neighborhood/moNeighborhood.h>
|
||||
|
||||
/**
|
||||
* Dummy Neighborhood
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moDummyNeighborhood : public moNeighborhood<Neighbor> {
|
||||
public:
|
||||
typedef typename Neighbor::EOT EOT;
|
||||
|
||||
/**
|
||||
* NOTHING TO DO
|
||||
* @param _solution unused solution
|
||||
* @return always false
|
||||
*/
|
||||
virtual bool hasNeighbor(EOT & _solution) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* NOTHING TO DO
|
||||
* @param _solution unused solution
|
||||
* @param _current unused neighbor
|
||||
*/
|
||||
virtual void init(EOT & _solution, Neighbor & _current) {}
|
||||
|
||||
/**
|
||||
* NOTHING TO DO
|
||||
* @param _solution unused solution
|
||||
* @param _current unused neighbor
|
||||
*/
|
||||
virtual void next(EOT & _solution, Neighbor & _current) {}
|
||||
|
||||
/**
|
||||
* NOTHING TO DO
|
||||
* @param _solution unused solution
|
||||
* @return always false
|
||||
*/
|
||||
virtual bool cont(EOT & _solution) {
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
128
mo/src/neighborhood/moEvaluatedNeighborhood.h
Normal file
128
mo/src/neighborhood/moEvaluatedNeighborhood.h
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
/*
|
||||
<moEvaluatedNeighborhood.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 _moEvaluatedNeighborhood_h
|
||||
#define _moEvaluatedNeighborhood_h
|
||||
|
||||
#include <neighborhood/moNeighborhood.h>
|
||||
#include <eval/moNeighborhoodEvaluation.h>
|
||||
|
||||
/**
|
||||
* A Neighborhood for the evaluation of all neighbors
|
||||
* in one step
|
||||
*
|
||||
* It is usefull for example in a double incremental evaluation (QAP, UBQP problems)
|
||||
* This class is used in combinaison with the class moNeighborhoodEvaluation
|
||||
*/
|
||||
template<class Neighbor>
|
||||
class moEvaluatedNeighborhood: public moNeighborhood<Neighbor> {
|
||||
public:
|
||||
|
||||
/**
|
||||
* Define type of a solution corresponding to Neighbor
|
||||
*/
|
||||
typedef typename Neighbor::EOT EOT;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _originalNeighborhood the original neighborhood to apply
|
||||
* @param _nhEval the evaluation function of the neighborhood
|
||||
*/
|
||||
moEvaluatedNeighborhood(moNeighborhood<Neighbor> & _originalNeighborhood, moNeighborhoodEvaluation<Neighbor> & _nhEval) :
|
||||
moNeighborhood<Neighbor>(), originalNeighborhood(_originalNeighborhood), nhEval(_nhEval) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the neighborhood is random (default false)
|
||||
*/
|
||||
virtual bool isRandom() {
|
||||
return originalNeighborhood.isRandom();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if a neighbor exists
|
||||
* @param _solution the solution to explore
|
||||
* @return true if the neighborhood was not empty
|
||||
*/
|
||||
virtual bool hasNeighbor(EOT& _solution) {
|
||||
return originalNeighborhood.hasNeighbor(_solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialization of the neighborhood with the full evaluation
|
||||
*
|
||||
* @param _solution the solution to explore
|
||||
* @param _neighbor the first neighbor
|
||||
*/
|
||||
virtual void init(EOT & _solution, Neighbor & _neighbor) {
|
||||
// full evaluation of the neighborhood
|
||||
nhEval(_solution);
|
||||
// initialisation of the original neighborhood
|
||||
originalNeighborhood.init(_solution, _neighbor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Give the next neighbor with the original neighborhood
|
||||
* @param _solution the solution to explore
|
||||
* @param _neighbor the next neighbor
|
||||
*/
|
||||
virtual void next(EOT & _solution, Neighbor & _neighbor) {
|
||||
originalNeighborhood.next(_solution, _neighbor);
|
||||
}
|
||||
|
||||
/**
|
||||
* give the continuation with the original neighborhood
|
||||
*
|
||||
* @param _solution the solution to explore
|
||||
* @return true if there is again a neighbor to explore
|
||||
*/
|
||||
virtual bool cont(EOT & _solution) {
|
||||
return originalNeighborhood.cont(_solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the class Name
|
||||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const {
|
||||
return "moEvaluatedNeighborhood";
|
||||
}
|
||||
|
||||
protected:
|
||||
moNeighborhood<Neighbor> & originalNeighborhood;
|
||||
moNeighborhoodEvaluation<Neighbor> & nhEval ;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
100
mo/src/neighborhood/moForwardVectorVNSelection.h
Normal file
100
mo/src/neighborhood/moForwardVectorVNSelection.h
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
/*
|
||||
<moForwardVectorVNSelection.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 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 _moForwardVectorVNSelection_h
|
||||
#define _moForwardVectorVNSelection_h
|
||||
|
||||
#include <neighborhood/moVectorVNSelection.h>
|
||||
|
||||
/**
|
||||
* This class is used for the Variable Neighborhood Search explorer inherits from moVectorVNSelection
|
||||
* The search heuristics are saved in vectors
|
||||
* They are given in forward order from the first ones to the last ones
|
||||
*
|
||||
*/
|
||||
template< class EOT >
|
||||
class moForwardVectorVNSelection: public moVectorVNSelection<EOT>{
|
||||
|
||||
using moVectorVNSelection<EOT>::LSvector;
|
||||
using moVectorVNSelection<EOT>::current;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Default constructor with first search heuristics
|
||||
*
|
||||
* @param _firstLS first local search
|
||||
* @param _firstShake first heuristic which perturbs the solution
|
||||
* @param _cycle when true, the first heuristics follows the last ones. Otherwise the search stop.
|
||||
*/
|
||||
moForwardVectorVNSelection(eoMonOp<EOT>& _firstLS, eoMonOp<EOT>& _firstShake, bool _cycle = true) : moVectorVNSelection<EOT>(_firstLS, _firstShake), cycle(_cycle){}
|
||||
|
||||
/**
|
||||
* Return the class id.
|
||||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const {
|
||||
return "moForwardVectorVNSelection";
|
||||
}
|
||||
|
||||
/**
|
||||
* test if there is still some heuristics
|
||||
*
|
||||
* @param _solution the current solution
|
||||
* @return true if there is some heuristics
|
||||
*/
|
||||
virtual bool cont(EOT& _solution){
|
||||
return (cycle || (current <= (LSvector.size() - 2)));
|
||||
}
|
||||
|
||||
/**
|
||||
* put the current heuristics on the first ones
|
||||
*
|
||||
* @param _solution the current solution
|
||||
*/
|
||||
virtual void init(EOT& _solution){
|
||||
current = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* put the current heuristics on the next ones
|
||||
*
|
||||
* @param _solution the current solution
|
||||
*/
|
||||
virtual void next(EOT& _solution){
|
||||
current = (current + 1) % LSvector.size();
|
||||
}
|
||||
|
||||
private:
|
||||
// boolean to indicate the first heuristics follow the last ones
|
||||
bool cycle;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
115
mo/src/neighborhood/moIndexNeighbor.h
Normal file
115
mo/src/neighborhood/moIndexNeighbor.h
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
<moIndexNeighbor.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 _IndexNeighbor_h
|
||||
#define _IndexNeighbor_h
|
||||
|
||||
#include <neighborhood/moNeighbor.h>
|
||||
|
||||
/**
|
||||
* Index Neighbor
|
||||
*/
|
||||
template<class EOT, class Fitness = typename EOT::Fitness>
|
||||
class moIndexNeighbor: virtual public moNeighbor<EOT, Fitness> {
|
||||
public:
|
||||
|
||||
using moNeighbor<EOT, Fitness>::fitness;
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
*/
|
||||
moIndexNeighbor() :
|
||||
moNeighbor<EOT, Fitness> (), key(0) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy Constructor
|
||||
* @param _n the neighbor to copy
|
||||
*/
|
||||
moIndexNeighbor(const moIndexNeighbor& _n) :
|
||||
moNeighbor<EOT, Fitness> (_n) {
|
||||
this->key = _n.key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assignment operator
|
||||
* @param _source the source neighbor
|
||||
*/
|
||||
|
||||
moIndexNeighbor<EOT, Fitness> & operator=(const moIndexNeighbor<EOT,
|
||||
Fitness> & _source) {
|
||||
moNeighbor<EOT, Fitness>::operator=(_source);
|
||||
this->key = _source.key;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the class Name
|
||||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const {
|
||||
return "moIndexNeighbor";
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter
|
||||
* @return index of the IndexNeighbor
|
||||
*/
|
||||
unsigned int index() {
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter
|
||||
* @param _key index of the IndexNeighbor
|
||||
*/
|
||||
void index(unsigned int _key) {
|
||||
key = _key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param _neighbor a neighbor
|
||||
* @return if _neighbor and this one are equals
|
||||
*/
|
||||
virtual bool equals(moIndexNeighbor<EOT>& _neighbor) {
|
||||
return (key == _neighbor.index());
|
||||
}
|
||||
|
||||
protected:
|
||||
// key allowing to describe the neighbor
|
||||
unsigned int key;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
89
mo/src/neighborhood/moIndexNeighborhood.h
Normal file
89
mo/src/neighborhood/moIndexNeighborhood.h
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
<moIndexNeighborhood.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 _moIndexNeighborhood_h
|
||||
#define _moIndexNeighborhood_h
|
||||
|
||||
#include <neighborhood/moNeighborhood.h>
|
||||
|
||||
/**
|
||||
* A Indexed Neighborhood
|
||||
*/
|
||||
template<class Neighbor>
|
||||
class moIndexNeighborhood: virtual public moNeighborhood<Neighbor> {
|
||||
public:
|
||||
/**
|
||||
* Define type of a solution corresponding to Neighbor
|
||||
*/
|
||||
typedef typename Neighbor::EOT EOT;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _neighborhoodSize the size of the neighborhood
|
||||
*/
|
||||
moIndexNeighborhood(unsigned int _neighborhoodSize) :
|
||||
neighborhoodSize(_neighborhoodSize) {
|
||||
}
|
||||
|
||||
/**
|
||||
* getter to get the value of neighborhoodSize
|
||||
* @return the neighborhoodSize
|
||||
*/
|
||||
unsigned int getNeighborhoodSize() const {
|
||||
return neighborhoodSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter to fixe the neighoodSize
|
||||
* @param _neighborhoodSize the value to set
|
||||
*/
|
||||
|
||||
void setNeighborhoodSize(unsigned int _neighborhoodSize) {
|
||||
neighborhoodSize = _neighborhoodSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the class Name
|
||||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const {
|
||||
return "moIndexNeighborhood";
|
||||
}
|
||||
|
||||
protected:
|
||||
// size of the neighborhood
|
||||
unsigned int neighborhoodSize;
|
||||
};
|
||||
|
||||
#endif
|
||||
110
mo/src/neighborhood/moNeighbor.h
Normal file
110
mo/src/neighborhood/moNeighbor.h
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
/*
|
||||
<moNeighbor.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 _moNeighbor_h
|
||||
#define _moNeighbor_h
|
||||
|
||||
//EO inclusion
|
||||
#include <EO.h>
|
||||
#include <eoObject.h>
|
||||
#include <eoPersistent.h>
|
||||
|
||||
/**
|
||||
* Container of the neighbor informations
|
||||
*/
|
||||
template<class EOType, class Fitness = typename EOType::Fitness>
|
||||
class moNeighbor: public EO<Fitness> {
|
||||
public:
|
||||
typedef EOType EOT;
|
||||
using EO<Fitness>::fitness;
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
*/
|
||||
moNeighbor() :
|
||||
EO<Fitness> () {
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy Constructor
|
||||
* @param _neighbor to copy
|
||||
*/
|
||||
moNeighbor(const moNeighbor<EOT, Fitness>& _neighbor) {
|
||||
if (!(_neighbor.invalid()))
|
||||
fitness(_neighbor.fitness());
|
||||
else
|
||||
(*this).invalidate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Assignment operator
|
||||
* @param _neighbor the neighbor to assign
|
||||
* @return a neighbor equal to the other
|
||||
*/
|
||||
virtual moNeighbor<EOT, Fitness>& operator=(
|
||||
const moNeighbor<EOT, Fitness>& _neighbor) {
|
||||
if (!(_neighbor.invalid()))
|
||||
fitness(_neighbor.fitness());
|
||||
else
|
||||
(*this).invalidate();
|
||||
|
||||
return (*this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Move a solution
|
||||
* @param _solution the related solution
|
||||
*/
|
||||
virtual void move(EOT & _solution) = 0;
|
||||
|
||||
/**
|
||||
* Test equality between two neighbors
|
||||
* @param _neighbor a neighbor
|
||||
* @return if _neighbor and this one are equals
|
||||
*/
|
||||
virtual bool equals(moNeighbor<EOT, Fitness> & _neighbor) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the class Name
|
||||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const {
|
||||
return "moNeighbor";
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
101
mo/src/neighborhood/moNeighborhood.h
Normal file
101
mo/src/neighborhood/moNeighborhood.h
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
<moNeighborhood.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 _moNeighborhood_h
|
||||
#define _moNeighborhood_h
|
||||
|
||||
#include <eoObject.h>
|
||||
|
||||
/**
|
||||
* A Neighborhood
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moNeighborhood : public eoObject
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Define type of a solution corresponding to Neighbor
|
||||
*/
|
||||
typedef typename Neighbor::EOT EOT;
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
*/
|
||||
moNeighborhood() {}
|
||||
|
||||
/**
|
||||
* @return true if the neighborhood is random (default false)
|
||||
*/
|
||||
virtual bool isRandom() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if a solution has (again) a Neighbor
|
||||
* @param _solution the related solution
|
||||
* @return true if _solution has a Neighbor
|
||||
*/
|
||||
virtual bool hasNeighbor(EOT & _solution) = 0 ;
|
||||
|
||||
/**
|
||||
* Initialization of the neighborhood
|
||||
* @param _solution the solution to explore
|
||||
* @param _current the first neighbor
|
||||
*/
|
||||
virtual void init(EOT & _solution, Neighbor & _current) = 0 ;
|
||||
|
||||
/**
|
||||
* Give the next neighbor
|
||||
* @param _solution the solution to explore
|
||||
* @param _current the next neighbor
|
||||
*/
|
||||
virtual void next(EOT & _solution, Neighbor & _current) = 0 ;
|
||||
|
||||
/**
|
||||
* Test if there is again a neighbor
|
||||
* @param _solution the solution to explore
|
||||
* @return true if there is again a neighbor not explored
|
||||
*/
|
||||
virtual bool cont(EOT & _solution) = 0 ;
|
||||
|
||||
/**
|
||||
* Return the class Name
|
||||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const {
|
||||
return "moNeighborhood";
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
130
mo/src/neighborhood/moOrderNeighborhood.h
Normal file
130
mo/src/neighborhood/moOrderNeighborhood.h
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
/*
|
||||
<moOrderNeighborhood.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 _moOrderNeighborhood_h
|
||||
#define _moOrderNeighborhood_h
|
||||
|
||||
#include <neighborhood/moIndexNeighborhood.h>
|
||||
|
||||
/**
|
||||
* An ordered Neighborhood
|
||||
*/
|
||||
template<class Neighbor>
|
||||
class moOrderNeighborhood: public moIndexNeighborhood<Neighbor> {
|
||||
public:
|
||||
|
||||
/**
|
||||
* Define type of a solution corresponding to Neighbor
|
||||
*/
|
||||
typedef typename Neighbor::EOT EOT;
|
||||
|
||||
using moIndexNeighborhood<Neighbor>::neighborhoodSize;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _neighborhoodSize the size of the neighborhood
|
||||
*/
|
||||
moOrderNeighborhood(unsigned int _neighborhoodSize) :
|
||||
moIndexNeighborhood<Neighbor> (_neighborhoodSize), currentIndex(0) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if a neighbor exists
|
||||
* @param _solution the solution to explore
|
||||
* @return true if the neighborhood was not empty
|
||||
*/
|
||||
virtual bool hasNeighbor(EOT& _solution) {
|
||||
return neighborhoodSize > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialization of the neighborhood
|
||||
* @param _solution the solution to explore
|
||||
* @param _neighbor the first neighbor
|
||||
*/
|
||||
virtual void init(EOT & _solution, Neighbor & _neighbor) {
|
||||
currentIndex = 0;
|
||||
_neighbor.index(currentIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Give the next neighbor
|
||||
* @param _solution the solution to explore
|
||||
* @param _neighbor the next neighbor
|
||||
*/
|
||||
virtual void next(EOT & _solution, Neighbor & _neighbor) {
|
||||
currentIndex++;
|
||||
_neighbor.index(currentIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* test if all neighbors are explore or not,if false, there is no neighbor left to explore
|
||||
* currentIndex is the index which have been used before, it is not the next neighbor which can be possibly evaluated
|
||||
*
|
||||
* @param _solution the solution to explore
|
||||
* @return true if there is again a neighbor to explore
|
||||
*/
|
||||
virtual bool cont(EOT & _solution) {
|
||||
return (currentIndex < neighborhoodSize - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter
|
||||
* @return the position in the Neighborhood
|
||||
*/
|
||||
unsigned int position() {
|
||||
return currentIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter the position in the Neighborhood
|
||||
*/
|
||||
void setPosition(unsigned int _currentIndex) {
|
||||
currentIndex=_currentIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the class Name
|
||||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const {
|
||||
return "moOrderNeighborhood";
|
||||
}
|
||||
|
||||
protected:
|
||||
unsigned int currentIndex;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
51
mo/src/neighborhood/moRndNeighborhood.h
Normal file
51
mo/src/neighborhood/moRndNeighborhood.h
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
<moRndNeighborhood.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 _moRndNeighborhood_h
|
||||
#define _moRndNeighborhood_h
|
||||
|
||||
#include <neighborhood/moNeighborhood.h>
|
||||
|
||||
/**
|
||||
* Class used to specify a neighborhood is random
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moRndNeighborhood : virtual public moNeighborhood<Neighbor> {
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* @return true
|
||||
*/
|
||||
bool isRandom() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
118
mo/src/neighborhood/moRndVectorVNSelection.h
Normal file
118
mo/src/neighborhood/moRndVectorVNSelection.h
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
/*
|
||||
<moRndVectorVNSelection.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 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 _moRndVectorVNSelection_h
|
||||
#define _moRndVectorVNSelection_h
|
||||
|
||||
#include <utils/eoRndGenerators.h>
|
||||
#include <utils/rnd_generators.h>
|
||||
|
||||
#include <neighborhood/moVectorVNSelection.h>
|
||||
|
||||
/**
|
||||
* This class is used for the Variable Neighborhood Search explorer inherits from moVectorVNSelection
|
||||
* The search heuristics are saved in vectors
|
||||
* They are given in random order (at each initialization the order is changed)
|
||||
*
|
||||
*/
|
||||
template< class EOT >
|
||||
class moRndVectorVNSelection: public moVectorVNSelection<EOT>
|
||||
{
|
||||
using moVectorVNSelection<EOT>::LSvector;
|
||||
using moVectorVNSelection<EOT>::current;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Default constructor with first search heuristics
|
||||
*
|
||||
* @param _firstLS first local search
|
||||
* @param _firstShake first heuristic which perturbs the solution
|
||||
* @param _cycle when true, the first heuristics follows the last ones. Otherwise the search stop.
|
||||
*/
|
||||
moRndVectorVNSelection(eoMonOp<EOT>& _firstLS, eoMonOp<EOT>& _firstShake, bool _cycle = true) : moVectorVNSelection<EOT>(_firstLS, _firstShake), cycle(_cycle){}
|
||||
|
||||
/**
|
||||
* Return the class id.
|
||||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const {
|
||||
return "moRndVectorVNSelection";
|
||||
}
|
||||
|
||||
/**
|
||||
* test if there is still some heuristics
|
||||
*
|
||||
* @param _solution the current solution
|
||||
* @return true if there is some heuristics
|
||||
*/
|
||||
virtual bool cont(EOT& _solution){
|
||||
return ( cycle || (currentOrder <= (order.size() - 2)) );
|
||||
}
|
||||
|
||||
/**
|
||||
* put the current heuristics on the first ones
|
||||
*
|
||||
* @param _solution the current solution
|
||||
*/
|
||||
virtual void init(EOT& _solution) {
|
||||
if(order.size() == 0)
|
||||
for(unsigned int i = 0; i < LSvector.size(); i++)
|
||||
order.push_back(i);
|
||||
|
||||
std::random_shuffle(order.begin(), order.end(), gen);
|
||||
|
||||
currentOrder = 0;
|
||||
current = order[currentOrder];
|
||||
}
|
||||
|
||||
/**
|
||||
* put the current heuristics on the next ones
|
||||
*
|
||||
* @param _solution the current solution
|
||||
*/
|
||||
virtual void next(EOT& _solution){
|
||||
currentOrder = (currentOrder + 1) % order.size();
|
||||
|
||||
current = order[currentOrder];
|
||||
}
|
||||
|
||||
private:
|
||||
// boolean to indicate the first heuristics follow the last ones
|
||||
bool cycle;
|
||||
// index in order vector
|
||||
unsigned int currentOrder;
|
||||
// the index of heuristics in random order
|
||||
std::vector<unsigned int> order;
|
||||
// random generator
|
||||
UF_random_generator<unsigned int> gen;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
109
mo/src/neighborhood/moRndWithReplNeighborhood.h
Normal file
109
mo/src/neighborhood/moRndWithReplNeighborhood.h
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
<moRndWithReplNeighborhood.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 _moRndWithReplNeighborhood_h
|
||||
#define _moRndWithReplNeighborhood_h
|
||||
|
||||
#include <neighborhood/moIndexNeighborhood.h>
|
||||
#include <neighborhood/moRndNeighborhood.h>
|
||||
#include <utils/eoRNG.h>
|
||||
|
||||
/**
|
||||
* A Random With replacement Neighborhood
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moRndWithReplNeighborhood : public moIndexNeighborhood<Neighbor>, public moRndNeighborhood<Neighbor>
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Define type of a solution corresponding to Neighbor
|
||||
*/
|
||||
typedef typename Neighbor::EOT EOT;
|
||||
|
||||
using moIndexNeighborhood<Neighbor>::neighborhoodSize;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _neighborhoodSize the size of the neighborhood
|
||||
*/
|
||||
moRndWithReplNeighborhood(unsigned int _neighborhoodSize): moIndexNeighborhood<Neighbor>(_neighborhoodSize) {}
|
||||
|
||||
/**
|
||||
* Test if it exist a neighbor
|
||||
* @param _solution the solution to explore
|
||||
* @return true if the neighborhood was not empty
|
||||
*/
|
||||
virtual bool hasNeighbor(EOT& _solution) {
|
||||
return neighborhoodSize > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialization of the neighborhood
|
||||
* @param _solution the solution to explore
|
||||
* @param _neighbor the first neighbor
|
||||
*/
|
||||
virtual void init(EOT & _solution, Neighbor & _neighbor) {
|
||||
_neighbor.index(rng.random(neighborhoodSize));
|
||||
}
|
||||
|
||||
/**
|
||||
* Give the next neighbor
|
||||
* @param _solution the solution to explore
|
||||
* @param _neighbor the next neighbor
|
||||
*/
|
||||
virtual void next(EOT & _solution, Neighbor & _neighbor) {
|
||||
_neighbor.index(rng.random(neighborhoodSize));
|
||||
}
|
||||
|
||||
/**
|
||||
* test if all neighbors are explore or not,if false, there is no neighbor left to explore
|
||||
* @param _solution the solution to explore
|
||||
* @return true if there is again a neighbor to explore
|
||||
*/
|
||||
virtual bool cont(EOT & _solution) {
|
||||
return neighborhoodSize > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the class Name
|
||||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const {
|
||||
return "moRndWithReplNeighborhood";
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
138
mo/src/neighborhood/moRndWithoutReplNeighborhood.h
Normal file
138
mo/src/neighborhood/moRndWithoutReplNeighborhood.h
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/*
|
||||
<moRndWithoutReplNeighborhood.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 _moRndWithoutReplNeighborhood_h
|
||||
#define _moRndWithoutReplNeighborhood_h
|
||||
|
||||
#include <neighborhood/moIndexNeighborhood.h>
|
||||
#include <neighborhood/moRndNeighborhood.h>
|
||||
#include <utils/eoRNG.h>
|
||||
|
||||
/**
|
||||
* A Random without replacement Neighborhood
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moRndWithoutReplNeighborhood : public moIndexNeighborhood<Neighbor>, public moRndNeighborhood<Neighbor>
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Define type of a solution corresponding to Neighbor
|
||||
*/
|
||||
typedef typename Neighbor::EOT EOT;
|
||||
|
||||
|
||||
using moIndexNeighborhood<Neighbor>::neighborhoodSize;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _neighborhoodSize the size of the neighborhood
|
||||
*/
|
||||
moRndWithoutReplNeighborhood(unsigned int _neighborhoodSize): moIndexNeighborhood<Neighbor>(_neighborhoodSize), maxIndex(0) {
|
||||
for (unsigned int i=0; i < neighborhoodSize; i++)
|
||||
indexVector.push_back(i);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if it exist a neighbor
|
||||
* @param _solution the solution to explore
|
||||
* @return true if the neighborhood was not empty
|
||||
*/
|
||||
virtual bool hasNeighbor(EOT& _solution) {
|
||||
return neighborhoodSize > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialization of the neighborhood
|
||||
* @param _solution the solution to explore
|
||||
* @param _neighbor the first neighbor
|
||||
*/
|
||||
virtual void init(EOT & _solution, Neighbor & _neighbor) {
|
||||
unsigned int i, tmp;
|
||||
maxIndex = neighborhoodSize ;
|
||||
i = rng.random(maxIndex);
|
||||
_neighbor.index(indexVector[i]);
|
||||
tmp=indexVector[i];
|
||||
indexVector[i]=indexVector[maxIndex-1];
|
||||
indexVector[maxIndex-1]=tmp;
|
||||
maxIndex--;
|
||||
}
|
||||
|
||||
/**
|
||||
* Give the next neighbor
|
||||
* @param _solution the solution to explore
|
||||
* @param _neighbor the next neighbor
|
||||
*/
|
||||
virtual void next(EOT & _solution, Neighbor & _neighbor) {
|
||||
unsigned int i, tmp;
|
||||
i = rng.random(maxIndex);
|
||||
_neighbor.index(indexVector[i]);
|
||||
tmp=indexVector[i];
|
||||
indexVector[i]=indexVector[maxIndex-1];
|
||||
indexVector[maxIndex-1]=tmp;
|
||||
maxIndex--;
|
||||
}
|
||||
|
||||
/**
|
||||
* test if all neighbors are explore or not,if false, there is no neighbor left to explore
|
||||
* maxIndex is number of neighbors
|
||||
* @param _solution the solution to explore
|
||||
* @return true if there is again a neighbor to explore
|
||||
*/
|
||||
virtual bool cont(EOT & _solution) {
|
||||
return (maxIndex > 0) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter
|
||||
* @return the position in the Neighborhood
|
||||
*/
|
||||
unsigned int position() {
|
||||
return indexVector[maxIndex];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the class Name
|
||||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const {
|
||||
return "moRndWithoutReplNeighborhood";
|
||||
}
|
||||
|
||||
private:
|
||||
unsigned int maxIndex;
|
||||
std::vector<unsigned int> indexVector;
|
||||
};
|
||||
|
||||
#endif
|
||||
88
mo/src/neighborhood/moVariableNeighborhoodSelection.h
Normal file
88
mo/src/neighborhood/moVariableNeighborhoodSelection.h
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
<moVariableNeighborhoodSelection.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 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 _moVariableNeighborhoodSelection_h
|
||||
#define _moVariableNeighborhoodSelection_h
|
||||
|
||||
#include <eoOp.h>
|
||||
#include <vector>
|
||||
|
||||
/**
|
||||
* This class is used for the Variable Neighborhood Search explorer
|
||||
* It gives the sequence of search heuristics based on the different "neighborhoods"
|
||||
* The class is built such as the moNeighborhood" with init, next, cont
|
||||
* and two methods to get the heuristics which shake the solution, and which give the local search
|
||||
*
|
||||
*/
|
||||
template< class EOT >
|
||||
class moVariableNeighborhoodSelection
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Return the class id.
|
||||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const {
|
||||
return "moVariableNeighborhoodSelection";
|
||||
}
|
||||
|
||||
/**
|
||||
* test if there is still some search heuristics to use
|
||||
* @return true if there is some neighborhood to explore
|
||||
*/
|
||||
virtual bool cont(EOT& _solution) = 0;
|
||||
|
||||
/**
|
||||
* put on the first search heuristics
|
||||
*/
|
||||
virtual void init(EOT& _solution) = 0;
|
||||
|
||||
/**
|
||||
* put the next search heuristics
|
||||
*/
|
||||
virtual void next(EOT& _solution) = 0;
|
||||
|
||||
/**
|
||||
* Get the current "shake" operator based on the current neighborhood
|
||||
*
|
||||
* @return current shake operator
|
||||
*/
|
||||
virtual eoMonOp<EOT> & getShake() = 0;
|
||||
|
||||
/**
|
||||
* Get the current local search based on the current neighborhood
|
||||
*
|
||||
* @return current local search
|
||||
*/
|
||||
virtual eoMonOp<EOT> & getLocalSearch() = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
108
mo/src/neighborhood/moVectorVNSelection.h
Normal file
108
mo/src/neighborhood/moVectorVNSelection.h
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
<moVectorVNSelection.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 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 _moVectorVNSelection_h
|
||||
#define _moVectorVNSelection_h
|
||||
|
||||
#include <neighborhood/moVariableNeighborhoodSelection.h>
|
||||
#include <eoOp.h>
|
||||
|
||||
/**
|
||||
* This class is used for the Variable Neighborhood Search explorer inherits from moVariableNeighborhoodSelection
|
||||
* The search heuristics are saved in vectors
|
||||
* The way to croos the vector is not defined here
|
||||
*
|
||||
*/
|
||||
template< class EOT >
|
||||
class moVectorVNSelection: public moVariableNeighborhoodSelection<EOT>{
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Default constructor with first search heuristics
|
||||
*
|
||||
* @param _firstLS first local search
|
||||
* @param _firstShake first heuristic which perturbs the solution
|
||||
*/
|
||||
moVectorVNSelection(eoMonOp<EOT>& _firstLS, eoMonOp<EOT>& _firstShake){
|
||||
LSvector.push_back(&_firstLS);
|
||||
shakeVector.push_back(&_firstShake);
|
||||
|
||||
current = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add some search heuristics
|
||||
*
|
||||
* @param _otherLS the added local search
|
||||
* @param _otherShake the added heuristic which perturbs the solution
|
||||
*/
|
||||
void add(eoMonOp<EOT>& _otherLS, eoMonOp<EOT>& _otherShake){
|
||||
LSvector.push_back(&_otherLS);
|
||||
shakeVector.push_back(&_otherShake);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the class id.
|
||||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const {
|
||||
return "moVectorVNSelection";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current "shake" operator based on the current neighborhood
|
||||
*
|
||||
* @return current shake operator
|
||||
*/
|
||||
virtual eoMonOp<EOT> & getShake() {
|
||||
return *(shakeVector[current]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current local search based on the current neighborhood
|
||||
*
|
||||
* @return current local search
|
||||
*/
|
||||
virtual eoMonOp<EOT> & getLocalSearch() {
|
||||
return *(LSvector[current]);
|
||||
}
|
||||
|
||||
protected:
|
||||
// vector of local searches
|
||||
std::vector<eoMonOp<EOT>* > LSvector;
|
||||
// vector of "shake" heiristics which perturbs the current solution
|
||||
std::vector<eoMonOp<EOT>* > shakeVector;
|
||||
// index of the current search heuristics which is applied
|
||||
unsigned int current;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue