add equal comparator between 2 neighbors and between 1 sol and 1 neighbor
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@2020 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
2eb04d2eff
commit
6095a66005
8 changed files with 157 additions and 9 deletions
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
<moEqualNeighborComparator.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 _moEqualNeighborComparator_h
|
||||
#define _moEqualNeighborComparator_h
|
||||
|
||||
#include <neighborhood/moNeighbor.h>
|
||||
#include <comparator/moNeighborComparator.h>
|
||||
|
||||
/**
|
||||
* Comparator of two neighbors : a neighbor is better if the fitness is higher or equal
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moEqualNeighborComparator : public moNeighborComparator<Neighbor, Neighbor>
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Compare two neighbors
|
||||
* @param _neighbor1 the first neighbor
|
||||
* @param _neighbor2 the second neighbor
|
||||
* @return true if the neighbor2 is better or equal than neighbor1
|
||||
*/
|
||||
virtual bool operator()(const Neighbor& _neighbor1, const Neighbor& _neighbor2) {
|
||||
return (_neighbor1.fitness() <= _neighbor2.fitness());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the class Name
|
||||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const {
|
||||
return "moEqualNeighborComparator";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
<moEqualSolNeighborComparator.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 _moEqualSolNeighborComparator_h
|
||||
#define _moEqualSolNeighborComparator_h
|
||||
|
||||
#include <EO.h>
|
||||
#include <eoFunctor.h>
|
||||
|
||||
#include <neighborhood/moNeighbor.h>
|
||||
#include <comparator/moSolNeighborComparator.h>
|
||||
|
||||
|
||||
/**
|
||||
* Comparator of a solution and its neighbor : a neighbor is better if the fitness is higher or equal
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moEqualSolNeighborComparator : public moSolNeighborComparator<Neighbor>
|
||||
{
|
||||
public:
|
||||
typedef typename Neighbor::EOT EOT ;
|
||||
|
||||
/**
|
||||
* Compare two neighbors
|
||||
* @param _sol the solution
|
||||
* @param _neighbor the neighbor
|
||||
* @return true if the neighbor is better or equal than sol
|
||||
*/
|
||||
virtual bool operator()(const EOT& _sol, const Neighbor& _neighbor) {
|
||||
return (_sol.fitness() <= _neighbor.fitness());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the class Name
|
||||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const {
|
||||
return "moEqualSolNeighborComparator";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
|
||||
/**
|
||||
* Comparator of two neighbors
|
||||
* Comparator of a solution and its neighbor
|
||||
*/
|
||||
template< class Neighbor >
|
||||
class moSolNeighborComparator : public moComparator<typename Neighbor::EOT, Neighbor>
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public :
|
|||
/**
|
||||
* Default Constructor
|
||||
*/
|
||||
moBooleanStat(bool & _b): moStat<EOT, bool>(_b, "boolean"), b(_b) {
|
||||
moBooleanStat(bool * _b): moStat<EOT, bool>(*_b, "boolean"), b(_b) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -57,7 +57,7 @@ public :
|
|||
* @param _sol a solution
|
||||
*/
|
||||
virtual void init(EOT & _sol) {
|
||||
value() = b;
|
||||
value() = *b;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -65,7 +65,7 @@ public :
|
|||
* @param _sol a solution
|
||||
*/
|
||||
virtual void operator()(EOT & _sol) {
|
||||
value() = b;
|
||||
value() = *b;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -76,7 +76,7 @@ public :
|
|||
}
|
||||
|
||||
private:
|
||||
bool & b;
|
||||
bool * b;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public :
|
|||
/**
|
||||
* Default Constructor
|
||||
*/
|
||||
moUnsignedStat(unsigned int & _b): moStat<EOT, unsigned int>(_b, "unsigned"), b(_b) {
|
||||
moUnsignedStat(unsigned int * _b): moStat<EOT, unsigned int>(*_b, "unsigned"), b(_b) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -57,7 +57,7 @@ public :
|
|||
* @param _sol a solution
|
||||
*/
|
||||
virtual void init(EOT & _sol) {
|
||||
value() = b;
|
||||
value() = *b;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -65,7 +65,7 @@ public :
|
|||
* @param _sol a solution
|
||||
*/
|
||||
virtual void operator()(EOT & _sol) {
|
||||
value() = b;
|
||||
value() = *b;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -76,7 +76,7 @@ public :
|
|||
}
|
||||
|
||||
private:
|
||||
unsigned int & b;
|
||||
unsigned int * b;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -127,6 +127,8 @@ public:
|
|||
//apply the local search on the copy
|
||||
ls(current);
|
||||
|
||||
// std::cout << "(solution)\t" << current << std::endl;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -111,6 +111,7 @@ public:
|
|||
* @param _solution
|
||||
*/
|
||||
virtual void operator()(EOT & _solution) {
|
||||
|
||||
//Test if _solution has a Neighbor
|
||||
if (neighborhood.hasNeighbor(_solution)) {
|
||||
//init the first neighbor
|
||||
|
|
|
|||
|
|
@ -57,8 +57,10 @@
|
|||
|
||||
#include <comparator/moComparator.h>
|
||||
#include <comparator/moNeighborComparator.h>
|
||||
#include <comparator/moEqualNeighborComparator.h>
|
||||
#include <comparator/moSolComparator.h>
|
||||
#include <comparator/moSolNeighborComparator.h>
|
||||
#include <comparator/moEqualSolNeighborComparator.h>
|
||||
|
||||
#include <continuator/moAverageFitnessNeighborStat.h>
|
||||
#include <continuator/moBestSoFarStat.h>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue