Template Fitness dans les Neighbor enlevés. On le déduit de EOT.
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1734 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
b453cef86f
commit
67a701f9ff
17 changed files with 51 additions and 56 deletions
|
|
@ -35,17 +35,17 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
/**
|
/**
|
||||||
* Dummy Evaluation function
|
* Dummy Evaluation function
|
||||||
*/
|
*/
|
||||||
template<class N>
|
template<class Neighbor>
|
||||||
class moDummyEval : public moEval<N>{
|
class moDummyEval : public moEval<Neighbor>{
|
||||||
public:
|
public:
|
||||||
typedef typename N::EOT EOT;
|
typedef typename Neighbor::EOT EOT;
|
||||||
typedef typename EOT::Fitness Fitness;
|
typedef typename EOT::Fitness Fitness;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NOTHING TO DO
|
* NOTHING TO DO
|
||||||
* @param _sol a solution
|
* @param _sol a solution
|
||||||
*/
|
*/
|
||||||
void operator()(EOT& _sol, N& _n){}
|
void operator()(EOT& _sol, Neighbor& _n){}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ class moILSexplorer : public moNeighborhoodExplorer< moDummyNeighbor<typename Ne
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef moNeighborhood<Neighbor> Neighborhood ;
|
typedef moNeighborhood<Neighbor> Neighborhood ;
|
||||||
typedef typename Neighbor::EOT EOT ;
|
typedef typename Neighbor::EOT EOT;
|
||||||
typedef moDummyNeighbor<EOT,typename EOT::Fitness> dummyNeighbor;
|
typedef moDummyNeighbor<EOT,typename EOT::Fitness> dummyNeighbor;
|
||||||
typedef moDummyNeighborhood<dummyNeighbor> dummyNeighborhood;
|
typedef moDummyNeighborhood<dummyNeighbor> dummyNeighborhood;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,8 +40,8 @@
|
||||||
/**
|
/**
|
||||||
* Neighbor with a move back function to use in a moFullEvalByModif
|
* Neighbor with a move back function to use in a moFullEvalByModif
|
||||||
*/
|
*/
|
||||||
template< class EOT , class Fitness >
|
template< class EOT >
|
||||||
class moBackableNeighbor : virtual public moNeighbor<EOT, Fitness>
|
class moBackableNeighbor : virtual public moNeighbor<EOT>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,20 +35,20 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
/**
|
/**
|
||||||
* A variable Neighborhood Search (VNS) in the Backward manner
|
* A variable Neighborhood Search (VNS) in the Backward manner
|
||||||
*/
|
*/
|
||||||
template< class EOT, class Fitness >
|
template< class EOT >
|
||||||
class moBackwardVariableNeighborhood : public moVariableNeighborhood<EOT, Fitness>
|
class moBackwardVariableNeighborhood : public moVariableNeighborhood<EOT>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef moNeighbor<EOT, Fitness> Neighbor;
|
typedef moNeighbor<EOT> Neighbor;
|
||||||
|
|
||||||
using moVariableNeighborhood<EOT, Fitness>::currentNH;
|
using moVariableNeighborhood<EOT>::currentNH;
|
||||||
using moVariableNeighborhood<EOT, Fitness>::neighborhoodVector;
|
using moVariableNeighborhood<EOT>::neighborhoodVector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construction of at least one neighborhood
|
* Construction of at least one neighborhood
|
||||||
* @param _firstNH first neighborhood in the vector
|
* @param _firstNH first neighborhood in the vector
|
||||||
*/
|
*/
|
||||||
moBackwardVariableNeighborhood(moNeighborhood<Neighbor>& _firstNH) : moVariableNeighborhood<EOT, Fitness>(_firstNH) { }
|
moBackwardVariableNeighborhood(moNeighborhood<Neighbor>& _firstNH) : moVariableNeighborhood<EOT>(_firstNH) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the class id.
|
* Return the class id.
|
||||||
|
|
|
||||||
|
|
@ -43,13 +43,13 @@
|
||||||
* Neighbor related to a vector of Bit
|
* Neighbor related to a vector of Bit
|
||||||
*/
|
*/
|
||||||
template< class Fitness >
|
template< class Fitness >
|
||||||
class moBitNeighbor : public moBackableNeighbor<eoBit<Fitness>, Fitness>, public moIndexNeighbor<eoBit<Fitness>, Fitness>
|
class moBitNeighbor : public moBackableNeighbor<eoBit<Fitness> >, public moIndexNeighbor<eoBit<Fitness> >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef eoBit<Fitness> EOT ;
|
typedef eoBit<Fitness> EOT ;
|
||||||
|
|
||||||
using moBackableNeighbor<eoBit<Fitness>, Fitness>::fitness;
|
using moBackableNeighbor<EOT>::fitness;
|
||||||
using moIndexNeighbor<eoBit<Fitness>, Fitness>::key;
|
using moIndexNeighbor<EOT>::key;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* move the solution
|
* move the solution
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,8 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
/**
|
/**
|
||||||
* Dummy Neighborhood
|
* Dummy Neighborhood
|
||||||
*/
|
*/
|
||||||
template< class EOT , class Fitness >
|
template< class EOT >
|
||||||
class moDummyNeighbor : public moNeighbor< EOT,Fitness>{
|
class moDummyNeighbor : public moNeighbor< EOT >{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -35,10 +35,9 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
/**
|
/**
|
||||||
* Dummy Neighborhood
|
* Dummy Neighborhood
|
||||||
*/
|
*/
|
||||||
template< class N >
|
template< class Neighbor >
|
||||||
class moDummyNeighborhood : public moNeighborhood<N>{
|
class moDummyNeighborhood : public moNeighborhood<Neighbor>{
|
||||||
public:
|
public:
|
||||||
typedef N Neighbor;
|
|
||||||
typedef typename Neighbor::EOT EOT;
|
typedef typename Neighbor::EOT EOT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -35,21 +35,21 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
/**
|
/**
|
||||||
* A variable Neighborhood Search (VNS) in the forward manner
|
* A variable Neighborhood Search (VNS) in the forward manner
|
||||||
*/
|
*/
|
||||||
template< class EOT, class Fitness >
|
template< class EOT >
|
||||||
class moForwardVariableNeighborhood : public moVariableNeighborhood<EOT, Fitness>
|
class moForwardVariableNeighborhood : public moVariableNeighborhood<EOT>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef moNeighbor<EOT, Fitness> Neighbor;
|
typedef moNeighbor<EOT> Neighbor;
|
||||||
|
|
||||||
using moVariableNeighborhood<EOT, Fitness>::currentNH;
|
using moVariableNeighborhood<EOT>::currentNH;
|
||||||
using moVariableNeighborhood<EOT, Fitness>::neighborhoodVector;
|
using moVariableNeighborhood<EOT>::neighborhoodVector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construction of at least one neighborhood
|
* Construction of at least one neighborhood
|
||||||
* @param _firstNH first neighborhood in the vector
|
* @param _firstNH first neighborhood in the vector
|
||||||
*/
|
*/
|
||||||
moForwardVariableNeighborhood(moNeighborhood<Neighbor>& _firstNH) : moVariableNeighborhood<EOT, Fitness>(_firstNH) { }
|
moForwardVariableNeighborhood(moNeighborhood<Neighbor>& _firstNH) : moVariableNeighborhood<EOT>(_firstNH) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the class id.
|
* Return the class id.
|
||||||
|
|
|
||||||
|
|
@ -40,30 +40,30 @@
|
||||||
/**
|
/**
|
||||||
* Index Neighbor
|
* Index Neighbor
|
||||||
*/
|
*/
|
||||||
template< class EOT , class Fitness >
|
template< class EOT >
|
||||||
class moIndexNeighbor : virtual public moNeighbor<EOT, Fitness>
|
class moIndexNeighbor : virtual public moNeighbor<EOT>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
using moNeighbor<EOT, Fitness>::fitness;
|
using moNeighbor<EOT>::fitness;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default Constructor
|
* Default Constructor
|
||||||
*/
|
*/
|
||||||
moIndexNeighbor() : moNeighbor<EOT, Fitness>(), key(0) {}
|
moIndexNeighbor() : moNeighbor<EOT>(), key(0) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy Constructor
|
* Copy Constructor
|
||||||
*/
|
*/
|
||||||
moIndexNeighbor(const moIndexNeighbor& _n) : moNeighbor<EOT, Fitness>(_n) {
|
moIndexNeighbor(const moIndexNeighbor& _n) : moNeighbor<EOT>(_n) {
|
||||||
this->key = _n.key ;
|
this->key = _n.key ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assignment operator
|
* Assignment operator
|
||||||
*/
|
*/
|
||||||
virtual moIndexNeighbor<EOT, Fitness> & operator=(const moIndexNeighbor<EOT, Fitness> & _source) {
|
virtual moIndexNeighbor<EOT> & operator=(const moIndexNeighbor<EOT> & _source) {
|
||||||
moNeighbor<EOT, Fitness>::operator=(_source);
|
moNeighbor<EOT>::operator=(_source);
|
||||||
this->key = _source.key ;
|
this->key = _source.key ;
|
||||||
return *this ;
|
return *this ;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,11 +43,12 @@
|
||||||
/**
|
/**
|
||||||
* Container of the neighbor informations
|
* Container of the neighbor informations
|
||||||
*/
|
*/
|
||||||
template< class EOType , class Fitness >
|
template< class EOType >
|
||||||
class moNeighbor : public eoObject, public eoPersistent
|
class moNeighbor : public eoObject, public eoPersistent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef EOType EOT;
|
typedef EOType EOT;
|
||||||
|
typedef typename EOT::Fitness Fitness;
|
||||||
/**
|
/**
|
||||||
* Default Constructor
|
* Default Constructor
|
||||||
*/
|
*/
|
||||||
|
|
@ -57,7 +58,7 @@ public:
|
||||||
* Copy Constructor
|
* Copy Constructor
|
||||||
* @param _neighbor to copy
|
* @param _neighbor to copy
|
||||||
*/
|
*/
|
||||||
moNeighbor(const moNeighbor<EOT, Fitness>& _neighbor) {
|
moNeighbor(const moNeighbor<EOT>& _neighbor) {
|
||||||
repFitness = _neighbor.fitness();
|
repFitness = _neighbor.fitness();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -66,7 +67,7 @@ public:
|
||||||
* @param _neighbor the neighbor to assign
|
* @param _neighbor the neighbor to assign
|
||||||
* @return a neighbor equal to the other
|
* @return a neighbor equal to the other
|
||||||
*/
|
*/
|
||||||
virtual moNeighbor<EOT, Fitness>& operator=(const moNeighbor<EOT, Fitness>& _neighbor) {
|
virtual moNeighbor<EOT>& operator=(const moNeighbor<EOT>& _neighbor) {
|
||||||
repFitness = _neighbor.fitness();
|
repFitness = _neighbor.fitness();
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,21 +40,18 @@
|
||||||
/**
|
/**
|
||||||
* A Ordered Neighborhood
|
* A Ordered Neighborhood
|
||||||
*/
|
*/
|
||||||
template< class N >
|
template< class Neighbor >
|
||||||
class moOrderNeighborhood : public moIndexNeighborhood<N>
|
class moOrderNeighborhood : public moIndexNeighborhood<Neighbor>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define type of a solution corresponding to Neighbor
|
* Define type of a solution corresponding to Neighbor
|
||||||
*/
|
*/
|
||||||
typedef N Neighbor;
|
|
||||||
typedef typename Neighbor::EOT EOT;
|
typedef typename Neighbor::EOT EOT;
|
||||||
|
|
||||||
|
|
||||||
using moIndexNeighborhood<Neighbor>::neighborhoodSize;
|
using moIndexNeighborhood<Neighbor>::neighborhoodSize;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* @param _neighborhoodSize the size of the neighborhood
|
* @param _neighborhoodSize the size of the neighborhood
|
||||||
|
|
|
||||||
|
|
@ -42,18 +42,16 @@
|
||||||
/**
|
/**
|
||||||
* A Random With replacement Neighborhood
|
* A Random With replacement Neighborhood
|
||||||
*/
|
*/
|
||||||
template< class N >
|
template< class Neighbor >
|
||||||
class moRndWithReplNeighborhood : public moIndexNeighborhood<N>, public moRndNeighborhood<N>
|
class moRndWithReplNeighborhood : public moIndexNeighborhood<Neighbor>, public moRndNeighborhood<Neighbor>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define type of a solution corresponding to Neighbor
|
* Define type of a solution corresponding to Neighbor
|
||||||
*/
|
*/
|
||||||
typedef N Neighbor;
|
|
||||||
typedef typename Neighbor::EOT EOT;
|
typedef typename Neighbor::EOT EOT;
|
||||||
|
|
||||||
|
|
||||||
using moIndexNeighborhood<Neighbor>::neighborhoodSize;
|
using moIndexNeighborhood<Neighbor>::neighborhoodSize;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -42,15 +42,14 @@
|
||||||
/**
|
/**
|
||||||
* A Random without replacement Neighborhood
|
* A Random without replacement Neighborhood
|
||||||
*/
|
*/
|
||||||
template< class N >
|
template< class Neighbor >
|
||||||
class moRndWithoutReplNeighborhood : public moIndexNeighborhood<N>, public moRndNeighborhood<N>
|
class moRndWithoutReplNeighborhood : public moIndexNeighborhood<Neighbor>, public moRndNeighborhood<Neighbor>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define type of a solution corresponding to Neighbor
|
* Define type of a solution corresponding to Neighbor
|
||||||
*/
|
*/
|
||||||
typedef N Neighbor;
|
|
||||||
typedef typename Neighbor::EOT EOT;
|
typedef typename Neighbor::EOT EOT;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,12 +38,12 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
/**
|
/**
|
||||||
* A vector of neighborhood for the Variable Neighborhood Search (VNS)
|
* A vector of neighborhood for the Variable Neighborhood Search (VNS)
|
||||||
*/
|
*/
|
||||||
template< class EOT, class Fitness >
|
template< class EOT >
|
||||||
class moVariableNeighborhood : public moNeighborhood<moNeighbor<EOT, Fitness> >
|
class moVariableNeighborhood : public moNeighborhood<moNeighbor<EOT> >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef moNeighbor<EOT, Fitness> Neighbor;
|
typedef moNeighbor<EOT> Neighbor;
|
||||||
/**
|
/**
|
||||||
* Construction of at least one neighborhood
|
* Construction of at least one neighborhood
|
||||||
* @param _firstNH first neighborhood in the vector
|
* @param _firstNH first neighborhood in the vector
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@
|
||||||
#include <eoScalarFitness.h>
|
#include <eoScalarFitness.h>
|
||||||
#include <neighborhood/moOrderNeighborhood.h>
|
#include <neighborhood/moOrderNeighborhood.h>
|
||||||
#include <neighborhood/moBitNeighbor.h>
|
#include <neighborhood/moBitNeighbor.h>
|
||||||
|
#include <neighborhood/moIndexNeighbor.h>
|
||||||
|
|
||||||
#include <utils/eoMonitor.h>
|
#include <utils/eoMonitor.h>
|
||||||
#include <utils/eoUpdater.h>
|
#include <utils/eoUpdater.h>
|
||||||
|
|
@ -63,12 +64,12 @@ typedef moDummyRndNeighborhood bitNeighborhood ;
|
||||||
|
|
||||||
typedef EO<int> Solution;
|
typedef EO<int> Solution;
|
||||||
|
|
||||||
class moDummyNeighborTest : public moNeighbor<Solution,int> {
|
class moDummyNeighborTest : public moNeighbor<Solution> {
|
||||||
public:
|
public:
|
||||||
virtual void move(Solution & _solution) {}
|
virtual void move(Solution & _solution) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class moDummyBackableNeighbor : public moBackableNeighbor<Solution,int> {
|
class moDummyBackableNeighbor : public moBackableNeighbor<Solution> {
|
||||||
public:
|
public:
|
||||||
virtual void move(Solution & _solution) {}
|
virtual void move(Solution & _solution) {}
|
||||||
virtual void moveBack(Solution & _solution) {}
|
virtual void moveBack(Solution & _solution) {}
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ int main(){
|
||||||
std::cout << "[t-moForwardVariableNeighborhood] => START" << std::endl;
|
std::cout << "[t-moForwardVariableNeighborhood] => START" << std::endl;
|
||||||
|
|
||||||
moRndWithoutReplNeighborhood<bitNeighbor> rndNH(8);
|
moRndWithoutReplNeighborhood<bitNeighbor> rndNH(8);
|
||||||
moOrderNeighborhood<moIndexNeighbor<eoBit<eoMinimizingFitness>, eoMinimizingFitness> > orderNH(8);
|
moOrderNeighborhood<moIndexNeighbor<eoBit<eoMinimizingFitness> > >orderNH(8);
|
||||||
|
|
||||||
|
|
||||||
//moForwardVariableNeighborhood<eoBit<eoMinimizingFitness>, eoMinimizingFitness> test(orderNH);
|
//moForwardVariableNeighborhood<eoBit<eoMinimizingFitness>, eoMinimizingFitness> test(orderNH);
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
ADD_SUBDIRECTORY(oneMax)
|
#ADD_SUBDIRECTORY(oneMax)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue