Verify if the neighbor fitness is invalid or not before the copy of fitness, if it is, the neighbor will copy an invalid fitness else the neighbor fitness will be set with the fitness of the copied neighbor
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@2303 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
64e7860817
commit
1ab2731502
1 changed files with 92 additions and 83 deletions
|
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _moNeighbor_h
|
#ifndef _moNeighbor_h
|
||||||
#define _moNeighbor_h
|
#define _moNeighbor_h
|
||||||
|
|
@ -43,9 +43,8 @@
|
||||||
/**
|
/**
|
||||||
* Container of the neighbor informations
|
* Container of the neighbor informations
|
||||||
*/
|
*/
|
||||||
template< class EOType, class Fitness=typename EOType::Fitness>
|
template<class EOType, class Fitness = typename EOType::Fitness>
|
||||||
class moNeighbor : public EO<Fitness>
|
class moNeighbor: public EO<Fitness> {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
typedef EOType EOT;
|
typedef EOType EOT;
|
||||||
using EO<Fitness>::fitness;
|
using EO<Fitness>::fitness;
|
||||||
|
|
@ -53,14 +52,19 @@ public:
|
||||||
/**
|
/**
|
||||||
* Default Constructor
|
* Default Constructor
|
||||||
*/
|
*/
|
||||||
moNeighbor():EO<Fitness>() {}
|
moNeighbor() :
|
||||||
|
EO<Fitness> () {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy Constructor
|
* Copy Constructor
|
||||||
* @param _neighbor to copy
|
* @param _neighbor to copy
|
||||||
*/
|
*/
|
||||||
moNeighbor(const moNeighbor<EOT, Fitness>& _neighbor) {
|
moNeighbor(const moNeighbor<EOT, Fitness>& _neighbor) {
|
||||||
|
if (!(_neighbor.invalid()))
|
||||||
fitness(_neighbor.fitness());
|
fitness(_neighbor.fitness());
|
||||||
|
else
|
||||||
|
(*this).invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -68,8 +72,13 @@ 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, Fitness>& operator=(
|
||||||
|
const moNeighbor<EOT, Fitness>& _neighbor) {
|
||||||
|
if (!(_neighbor.invalid()))
|
||||||
fitness(_neighbor.fitness());
|
fitness(_neighbor.fitness());
|
||||||
|
else
|
||||||
|
(*this).invalidate();
|
||||||
|
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -77,14 +86,14 @@ public:
|
||||||
* Move a solution
|
* Move a solution
|
||||||
* @param _solution the related solution
|
* @param _solution the related solution
|
||||||
*/
|
*/
|
||||||
virtual void move(EOT & _solution) = 0 ;
|
virtual void move(EOT & _solution) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test equality between two neighbors
|
* Test equality between two neighbors
|
||||||
* @param _neighbor a neighbor
|
* @param _neighbor a neighbor
|
||||||
* @return if _neighbor and this one are equals
|
* @return if _neighbor and this one are equals
|
||||||
*/
|
*/
|
||||||
virtual bool equals(moNeighbor<EOT,Fitness> & _neighbor) {
|
virtual bool equals(moNeighbor<EOT, Fitness> & _neighbor) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue