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
|
||||
*/
|
||||
template<class N>
|
||||
class moDummyEval : public moEval<N>{
|
||||
template<class Neighbor>
|
||||
class moDummyEval : public moEval<Neighbor>{
|
||||
public:
|
||||
typedef typename N::EOT EOT;
|
||||
typedef typename Neighbor::EOT EOT;
|
||||
typedef typename EOT::Fitness Fitness;
|
||||
|
||||
/**
|
||||
* NOTHING TO DO
|
||||
* @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:
|
||||
typedef moNeighborhood<Neighbor> Neighborhood ;
|
||||
typedef typename Neighbor::EOT EOT ;
|
||||
typedef typename Neighbor::EOT EOT;
|
||||
typedef moDummyNeighbor<EOT,typename EOT::Fitness> dummyNeighbor;
|
||||
typedef moDummyNeighborhood<dummyNeighbor> dummyNeighborhood;
|
||||
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@
|
|||
/**
|
||||
* Neighbor with a move back function to use in a moFullEvalByModif
|
||||
*/
|
||||
template< class EOT , class Fitness >
|
||||
class moBackableNeighbor : virtual public moNeighbor<EOT, Fitness>
|
||||
template< class EOT >
|
||||
class moBackableNeighbor : virtual public moNeighbor<EOT>
|
||||
{
|
||||
public:
|
||||
|
||||
|
|
|
|||
|
|
@ -35,20 +35,20 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
|||
/**
|
||||
* A variable Neighborhood Search (VNS) in the Backward manner
|
||||
*/
|
||||
template< class EOT, class Fitness >
|
||||
class moBackwardVariableNeighborhood : public moVariableNeighborhood<EOT, Fitness>
|
||||
template< class EOT >
|
||||
class moBackwardVariableNeighborhood : public moVariableNeighborhood<EOT>
|
||||
{
|
||||
public:
|
||||
typedef moNeighbor<EOT, Fitness> Neighbor;
|
||||
typedef moNeighbor<EOT> Neighbor;
|
||||
|
||||
using moVariableNeighborhood<EOT, Fitness>::currentNH;
|
||||
using moVariableNeighborhood<EOT, Fitness>::neighborhoodVector;
|
||||
using moVariableNeighborhood<EOT>::currentNH;
|
||||
using moVariableNeighborhood<EOT>::neighborhoodVector;
|
||||
|
||||
/**
|
||||
* Construction of at least one neighborhood
|
||||
* @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.
|
||||
|
|
|
|||
|
|
@ -43,13 +43,13 @@
|
|||
* Neighbor related to a vector of Bit
|
||||
*/
|
||||
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:
|
||||
typedef eoBit<Fitness> EOT ;
|
||||
|
||||
using moBackableNeighbor<eoBit<Fitness>, Fitness>::fitness;
|
||||
using moIndexNeighbor<eoBit<Fitness>, Fitness>::key;
|
||||
using moBackableNeighbor<EOT>::fitness;
|
||||
using moIndexNeighbor<EOT>::key;
|
||||
|
||||
/**
|
||||
* move the solution
|
||||
|
|
|
|||
|
|
@ -35,8 +35,8 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
|||
/**
|
||||
* Dummy Neighborhood
|
||||
*/
|
||||
template< class EOT , class Fitness >
|
||||
class moDummyNeighbor : public moNeighbor< EOT,Fitness>{
|
||||
template< class EOT >
|
||||
class moDummyNeighbor : public moNeighbor< EOT >{
|
||||
public:
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -35,10 +35,9 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
|||
/**
|
||||
* Dummy Neighborhood
|
||||
*/
|
||||
template< class N >
|
||||
class moDummyNeighborhood : public moNeighborhood<N>{
|
||||
template< class Neighbor >
|
||||
class moDummyNeighborhood : public moNeighborhood<Neighbor>{
|
||||
public:
|
||||
typedef N Neighbor;
|
||||
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
|
||||
*/
|
||||
template< class EOT, class Fitness >
|
||||
class moForwardVariableNeighborhood : public moVariableNeighborhood<EOT, Fitness>
|
||||
template< class EOT >
|
||||
class moForwardVariableNeighborhood : public moVariableNeighborhood<EOT>
|
||||
{
|
||||
public:
|
||||
|
||||
typedef moNeighbor<EOT, Fitness> Neighbor;
|
||||
typedef moNeighbor<EOT> Neighbor;
|
||||
|
||||
using moVariableNeighborhood<EOT, Fitness>::currentNH;
|
||||
using moVariableNeighborhood<EOT, Fitness>::neighborhoodVector;
|
||||
using moVariableNeighborhood<EOT>::currentNH;
|
||||
using moVariableNeighborhood<EOT>::neighborhoodVector;
|
||||
|
||||
/**
|
||||
* Construction of at least one neighborhood
|
||||
* @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.
|
||||
|
|
|
|||
|
|
@ -40,30 +40,30 @@
|
|||
/**
|
||||
* Index Neighbor
|
||||
*/
|
||||
template< class EOT , class Fitness >
|
||||
class moIndexNeighbor : virtual public moNeighbor<EOT, Fitness>
|
||||
template< class EOT >
|
||||
class moIndexNeighbor : virtual public moNeighbor<EOT>
|
||||
{
|
||||
public:
|
||||
|
||||
using moNeighbor<EOT, Fitness>::fitness;
|
||||
using moNeighbor<EOT>::fitness;
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
*/
|
||||
moIndexNeighbor() : moNeighbor<EOT, Fitness>(), key(0) {}
|
||||
moIndexNeighbor() : moNeighbor<EOT>(), key(0) {}
|
||||
|
||||
/**
|
||||
* Copy Constructor
|
||||
*/
|
||||
moIndexNeighbor(const moIndexNeighbor& _n) : moNeighbor<EOT, Fitness>(_n) {
|
||||
moIndexNeighbor(const moIndexNeighbor& _n) : moNeighbor<EOT>(_n) {
|
||||
this->key = _n.key ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assignment operator
|
||||
*/
|
||||
virtual moIndexNeighbor<EOT, Fitness> & operator=(const moIndexNeighbor<EOT, Fitness> & _source) {
|
||||
moNeighbor<EOT, Fitness>::operator=(_source);
|
||||
virtual moIndexNeighbor<EOT> & operator=(const moIndexNeighbor<EOT> & _source) {
|
||||
moNeighbor<EOT>::operator=(_source);
|
||||
this->key = _source.key ;
|
||||
return *this ;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,11 +43,12 @@
|
|||
/**
|
||||
* Container of the neighbor informations
|
||||
*/
|
||||
template< class EOType , class Fitness >
|
||||
template< class EOType >
|
||||
class moNeighbor : public eoObject, public eoPersistent
|
||||
{
|
||||
public:
|
||||
typedef EOType EOT;
|
||||
typedef typename EOT::Fitness Fitness;
|
||||
/**
|
||||
* Default Constructor
|
||||
*/
|
||||
|
|
@ -57,7 +58,7 @@ public:
|
|||
* Copy Constructor
|
||||
* @param _neighbor to copy
|
||||
*/
|
||||
moNeighbor(const moNeighbor<EOT, Fitness>& _neighbor) {
|
||||
moNeighbor(const moNeighbor<EOT>& _neighbor) {
|
||||
repFitness = _neighbor.fitness();
|
||||
}
|
||||
|
||||
|
|
@ -66,7 +67,7 @@ public:
|
|||
* @param _neighbor the neighbor to assign
|
||||
* @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();
|
||||
return (*this);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,21 +40,18 @@
|
|||
/**
|
||||
* A Ordered Neighborhood
|
||||
*/
|
||||
template< class N >
|
||||
class moOrderNeighborhood : public moIndexNeighborhood<N>
|
||||
template< class Neighbor >
|
||||
class moOrderNeighborhood : public moIndexNeighborhood<Neighbor>
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Define type of a solution corresponding to Neighbor
|
||||
*/
|
||||
typedef N Neighbor;
|
||||
typedef typename Neighbor::EOT EOT;
|
||||
|
||||
|
||||
using moIndexNeighborhood<Neighbor>::neighborhoodSize;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param _neighborhoodSize the size of the neighborhood
|
||||
|
|
|
|||
|
|
@ -42,18 +42,16 @@
|
|||
/**
|
||||
* A Random With replacement Neighborhood
|
||||
*/
|
||||
template< class N >
|
||||
class moRndWithReplNeighborhood : public moIndexNeighborhood<N>, public moRndNeighborhood<N>
|
||||
template< class Neighbor >
|
||||
class moRndWithReplNeighborhood : public moIndexNeighborhood<Neighbor>, public moRndNeighborhood<Neighbor>
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Define type of a solution corresponding to Neighbor
|
||||
*/
|
||||
typedef N Neighbor;
|
||||
typedef typename Neighbor::EOT EOT;
|
||||
|
||||
|
||||
using moIndexNeighborhood<Neighbor>::neighborhoodSize;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -42,15 +42,14 @@
|
|||
/**
|
||||
* A Random without replacement Neighborhood
|
||||
*/
|
||||
template< class N >
|
||||
class moRndWithoutReplNeighborhood : public moIndexNeighborhood<N>, public moRndNeighborhood<N>
|
||||
template< class Neighbor >
|
||||
class moRndWithoutReplNeighborhood : public moIndexNeighborhood<Neighbor>, public moRndNeighborhood<Neighbor>
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Define type of a solution corresponding to Neighbor
|
||||
*/
|
||||
typedef N Neighbor;
|
||||
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)
|
||||
*/
|
||||
template< class EOT, class Fitness >
|
||||
class moVariableNeighborhood : public moNeighborhood<moNeighbor<EOT, Fitness> >
|
||||
template< class EOT >
|
||||
class moVariableNeighborhood : public moNeighborhood<moNeighbor<EOT> >
|
||||
{
|
||||
public:
|
||||
|
||||
typedef moNeighbor<EOT, Fitness> Neighbor;
|
||||
typedef moNeighbor<EOT> Neighbor;
|
||||
/**
|
||||
* Construction of at least one neighborhood
|
||||
* @param _firstNH first neighborhood in the vector
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@
|
|||
#include <eoScalarFitness.h>
|
||||
#include <neighborhood/moOrderNeighborhood.h>
|
||||
#include <neighborhood/moBitNeighbor.h>
|
||||
#include <neighborhood/moIndexNeighbor.h>
|
||||
|
||||
#include <utils/eoMonitor.h>
|
||||
#include <utils/eoUpdater.h>
|
||||
|
|
@ -63,12 +64,12 @@ typedef moDummyRndNeighborhood bitNeighborhood ;
|
|||
|
||||
typedef EO<int> Solution;
|
||||
|
||||
class moDummyNeighborTest : public moNeighbor<Solution,int> {
|
||||
class moDummyNeighborTest : public moNeighbor<Solution> {
|
||||
public:
|
||||
virtual void move(Solution & _solution) {}
|
||||
};
|
||||
|
||||
class moDummyBackableNeighbor : public moBackableNeighbor<Solution,int> {
|
||||
class moDummyBackableNeighbor : public moBackableNeighbor<Solution> {
|
||||
public:
|
||||
virtual void move(Solution & _solution) {}
|
||||
virtual void moveBack(Solution & _solution) {}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ int main(){
|
|||
std::cout << "[t-moForwardVariableNeighborhood] => START" << std::endl;
|
||||
|
||||
moRndWithoutReplNeighborhood<bitNeighbor> rndNH(8);
|
||||
moOrderNeighborhood<moIndexNeighbor<eoBit<eoMinimizingFitness>, eoMinimizingFitness> > orderNH(8);
|
||||
moOrderNeighborhood<moIndexNeighbor<eoBit<eoMinimizingFitness> > >orderNH(8);
|
||||
|
||||
|
||||
//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