diff --git a/eo/src/eoDualFitness.h b/eo/src/eoDualFitness.h index f51ebb9a6..4d8831799 100644 --- a/eo/src/eoDualFitness.h +++ b/eo/src/eoDualFitness.h @@ -146,7 +146,7 @@ public: //! Copy operator from another eoDualFitness template - eoDualFitness & operator=(const eoDualFitness& other ) + eoDualFitness & operator=(const eoDualFitness& other ) { if (this != &other) { this->_value = other._value; @@ -215,9 +215,15 @@ public: // (for minimizing and maximizing) //! Add a given fitness to the current one - template - // friend - eoDualFitness & operator+=( /*eoDualFitness & from,*/ const eoDualFitness & that ) + template + eoDualFitness & operator+=( const T that ) + { + this->_value += that; + return *this; + } + + //! Add a given fitness to the current one + eoDualFitness & operator+=( const eoDualFitness & that ) { // from._value += that._value; this->_value += that._value; @@ -230,8 +236,15 @@ public: } //! Substract a given fitness to the current one - template - eoDualFitness & operator-=( const eoDualFitness & that ) + template + eoDualFitness & operator-=( const T that ) + { + this->_value -= that; + return *this; + } + + //! Substract a given fitness to the current one + eoDualFitness & operator-=( const eoDualFitness & that ) { this->_value -= that._value; @@ -241,27 +254,17 @@ public: return *this; } + //! Add a given fitness to the current one - template - eoDualFitness & operator+=( const T that ) + template + eoDualFitness & operator/=( T that ) { - this->_value += that; + this->_value /= that; return *this; } - //! Substract a given fitness to the current one - template - eoDualFitness & operator-=( const T that ) - { - this->_value -= that; - return *this; - } - - - //! Add a given fitness to the current one - template - eoDualFitness & operator/=( const eoDualFitness & that ) + eoDualFitness & operator/=( const eoDualFitness & that ) { this->_value /= that._value; @@ -271,61 +274,69 @@ public: return *this; } - - //! Add a given fitness to the current one - template - eoDualFitness & operator/=( T that ) + template + eoDualFitness operator+( T that ) { - this->_value /= that; - + this->_value += that; return *this; } // Add this fitness's value to that other, and return a _new_ instance with the result. - template - eoDualFitness operator+(const eoDualFitness & that) + eoDualFitness operator+( const eoDualFitness & that ) { - eoDualFitness from( *this ); + eoDualFitness from( *this ); return from += that; } - // Add this fitness's value to that other, and return a _new_ instance with the result. - template - eoDualFitness operator-(const eoDualFitness & that) + template + eoDualFitness operator-( T that ) { - eoDualFitness from( *this ); + this->_value -= that; + return *this; + } + + // Add this fitness's value to that other, and return a _new_ instance with the result. + eoDualFitness operator-( const eoDualFitness & that ) + { + eoDualFitness from( *this ); return from -= that; } - // Add this fitness's value to that other, and return a _new_ instance with the result. - template - eoDualFitness operator/(const eoDualFitness & that) + template + eoDualFitness operator/( T that ) { - eoDualFitness from( *this ); + this->_value /= that; + return *this; + } + + // Add this fitness's value to that other, and return a _new_ instance with the result. + eoDualFitness operator/( const eoDualFitness & that ) + { + eoDualFitness from( *this ); return from /= that; } //! Print an eoDualFitness instance as a pair of numbers, separated by a space - template - std::ostream& operator<<(std::ostream& os) + friend + std::ostream& operator<<( std::ostream& os, const eoDualFitness & fitness ) { - os << this->_value << " " << this->_is_feasible; + os << fitness._value << " " << fitness._is_feasible; return os; } //! Read an eoDualFitness instance as a pair of numbers, separated by a space - template - std::istream& operator>>(std::istream& is) + friend + std::istream& operator>>( std::istream& is, eoDualFitness & fitness ) { - F value; + BaseType value; is >> value; bool feasible; is >> feasible; - this->_value = value; - this->_is_feasible = feasible; + fitness._value = value; + fitness._is_feasible = feasible; return is; } };