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:
boufaras 2011-07-08 09:37:32 +00:00
commit 1ab2731502

View file

@ -30,7 +30,7 @@
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
*/
#ifndef _moNeighbor_h
#define _moNeighbor_h
@ -43,9 +43,8 @@
/**
* Container of the neighbor informations
*/
template< class EOType, class Fitness=typename EOType::Fitness>
class moNeighbor : public EO<Fitness>
{
template<class EOType, class Fitness = typename EOType::Fitness>
class moNeighbor: public EO<Fitness> {
public:
typedef EOType EOT;
using EO<Fitness>::fitness;
@ -53,14 +52,19 @@ public:
/**
* Default Constructor
*/
moNeighbor():EO<Fitness>() {}
moNeighbor() :
EO<Fitness> () {
}
/**
* Copy Constructor
* @param _neighbor to copy
*/
moNeighbor(const moNeighbor<EOT, Fitness>& _neighbor) {
if (!(_neighbor.invalid()))
fitness(_neighbor.fitness());
else
(*this).invalidate();
}
/**
@ -68,8 +72,13 @@ 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, Fitness>& operator=(
const moNeighbor<EOT, Fitness>& _neighbor) {
if (!(_neighbor.invalid()))
fitness(_neighbor.fitness());
else
(*this).invalidate();
return (*this);
}
@ -77,14 +86,14 @@ public:
* Move a solution
* @param _solution the related solution
*/
virtual void move(EOT & _solution) = 0 ;
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) {
virtual bool equals(moNeighbor<EOT, Fitness> & _neighbor) {
return false;
}