Suppress warnings when compiling MOEO functions returning const

When compiling whith --Wignored-qualifiers, g++ no more warns about
ignoring const in methods *returning* a const, which isn't logical.
This commit is contained in:
Johann Dreo 2013-03-20 17:42:04 +01:00
commit bda48533e8
14 changed files with 36 additions and 37 deletions

View file

@ -62,7 +62,7 @@ class moeoAggregativeComparator : public moeoComparator < MOEOT >
* @param _moeo1 the first solution * @param _moeo1 the first solution
* @param _moeo2 the second solution * @param _moeo2 the second solution
*/ */
const bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2) bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2)
{ {
return ( weightFitness * _moeo1.fitness() + weightDiversity * _moeo1.diversity() ) < ( weightFitness * _moeo2.fitness() + weightDiversity * _moeo2.diversity() ); return ( weightFitness * _moeo1.fitness() + weightDiversity * _moeo1.diversity() ) < ( weightFitness * _moeo2.fitness() + weightDiversity * _moeo2.diversity() );
} }

View file

@ -53,7 +53,7 @@ class moeoDiversityThenFitnessComparator : public moeoComparator < MOEOT >
* @param _moeo1 the first solution * @param _moeo1 the first solution
* @param _moeo2 the second solution * @param _moeo2 the second solution
*/ */
const bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2) bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2)
{ {
if (_moeo1.diversity() == _moeo2.diversity()) if (_moeo1.diversity() == _moeo2.diversity())
{ {

View file

@ -60,7 +60,7 @@ public:
* @param _objectiveVector1 the first objective vector * @param _objectiveVector1 the first objective vector
* @param _objectiveVector2 the second objective vector * @param _objectiveVector2 the second objective vector
*/ */
const bool operator()(const ObjectiveVector & _objectiveVector1, const ObjectiveVector & _objectiveVector2) bool operator()(const ObjectiveVector & _objectiveVector1, const ObjectiveVector & _objectiveVector2)
{ {
for (unsigned int i=0; i<ObjectiveVector::nObjectives(); i++) for (unsigned int i=0; i<ObjectiveVector::nObjectives(); i++)
{ {

View file

@ -54,7 +54,7 @@ class moeoFitnessComparator : public moeoComparator < MOEOT >
* @param _moeo1 the first solution * @param _moeo1 the first solution
* @param _moeo2 the second solution * @param _moeo2 the second solution
*/ */
const bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2) bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2)
{ {
return _moeo1.fitness() < _moeo2.fitness(); return _moeo1.fitness() < _moeo2.fitness();
} }

View file

@ -53,7 +53,7 @@ class moeoFitnessThenDiversityComparator : public moeoComparator < MOEOT >
* @param _moeo1 the first solution * @param _moeo1 the first solution
* @param _moeo2 the second solution * @param _moeo2 the second solution
*/ */
const bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2) bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2)
{ {
if (_moeo1.fitness() == _moeo2.fitness()) if (_moeo1.fitness() == _moeo2.fitness())
{ {

View file

@ -64,7 +64,7 @@ class moeoGDominanceObjectiveVectorComparator : public moeoObjectiveVectorCompar
* @param _objectiveVector1 the first objective vector * @param _objectiveVector1 the first objective vector
* @param _objectiveVector2 the second objective vector * @param _objectiveVector2 the second objective vector
*/ */
const bool operator()(const ObjectiveVector & _objectiveVector1, const ObjectiveVector & _objectiveVector2) bool operator()(const ObjectiveVector & _objectiveVector1, const ObjectiveVector & _objectiveVector2)
{ {
unsigned int flag1 = flag(_objectiveVector1); unsigned int flag1 = flag(_objectiveVector1);
unsigned int flag2 = flag(_objectiveVector2); unsigned int flag2 = flag(_objectiveVector2);

View file

@ -53,7 +53,7 @@ class moeoObjectiveObjectiveVectorComparator : public moeoObjectiveVectorCompara
* @param _objectiveVector1 the first objective vector * @param _objectiveVector1 the first objective vector
* @param _objectiveVector2 the second objective vector * @param _objectiveVector2 the second objective vector
*/ */
const bool operator()(const ObjectiveVector & _objectiveVector1, const ObjectiveVector & _objectiveVector2) bool operator()(const ObjectiveVector & _objectiveVector1, const ObjectiveVector & _objectiveVector2)
{ {
for (unsigned int i=0; i<ObjectiveVector::nObjectives(); i++) for (unsigned int i=0; i<ObjectiveVector::nObjectives(); i++)
{ {

View file

@ -66,7 +66,7 @@ class moeoOneObjectiveComparator : public moeoComparator < MOEOT >
* @param _moeo1 the first solution * @param _moeo1 the first solution
* @param _moeo2 the second solution * @param _moeo2 the second solution
*/ */
const bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2) bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2)
{ {
return _moeo1.objectiveVector()[obj] < _moeo2.objectiveVector()[obj]; return _moeo1.objectiveVector()[obj] < _moeo2.objectiveVector()[obj];
} }

View file

@ -53,7 +53,7 @@ class moeoParetoObjectiveVectorComparator : public moeoObjectiveVectorComparator
* @param _objectiveVector1 the first objective vector * @param _objectiveVector1 the first objective vector
* @param _objectiveVector2 the second objective vector * @param _objectiveVector2 the second objective vector
*/ */
const bool operator()(const ObjectiveVector & _objectiveVector1, const ObjectiveVector & _objectiveVector2) bool operator()(const ObjectiveVector & _objectiveVector1, const ObjectiveVector & _objectiveVector2)
{ {
bool dom = false; bool dom = false;
for (unsigned int i=0; i<ObjectiveVector::nObjectives(); i++) for (unsigned int i=0; i<ObjectiveVector::nObjectives(); i++)

View file

@ -29,31 +29,30 @@
*/ */
template < class MOEOT > template < class MOEOT >
class moeoPtrComparator : public eoBF < const MOEOT *, const MOEOT *, const bool > class moeoPtrComparator : public eoBF < const MOEOT *, const MOEOT *, bool >
{ {
public: public:
/** /**
* Ctor with a comparator * Ctor with a comparator
* @param _cmp comparator to be employed * @param _cmp comparator to be employed
*/
moeoPtrComparator( moeoComparator<MOEOT> & _cmp) : cmp(_cmp) {}
*/ /** compare two const individuals */
moeoPtrComparator( moeoComparator<MOEOT> & _cmp) : cmp(_cmp) {} bool operator() (const MOEOT *ptr1, const MOEOT *ptr2)
{
return cmp(*ptr1, *ptr2);
}
/** compare two const individuals */ /** compare two non const individuals */
const bool operator() (const MOEOT *ptr1, const MOEOT *ptr2) bool operator() (MOEOT *ptr1, MOEOT *ptr2)
{ {
return cmp(*ptr1, *ptr2); return cmp(*ptr1, *ptr2);
} }
/** compare two non const individuals */ private:
const bool operator() (MOEOT *ptr1, MOEOT *ptr2) moeoComparator<MOEOT> &cmp;
{ };
return cmp(*ptr1, *ptr2);
}
private:
moeoComparator<MOEOT> &cmp;
};
#endif /*MOEOPTRCOMPARATOR_H_*/ #endif /*MOEOPTRCOMPARATOR_H_*/

View file

@ -53,7 +53,7 @@ public:
* @param _objectiveVector1 the first objective vector * @param _objectiveVector1 the first objective vector
* @param _objectiveVector2 the second objective vector * @param _objectiveVector2 the second objective vector
*/ */
const bool operator()(const ObjectiveVector & _objectiveVector1, const ObjectiveVector & _objectiveVector2) bool operator()(const ObjectiveVector & _objectiveVector1, const ObjectiveVector & _objectiveVector2)
{ {
for (unsigned int i=0; i<ObjectiveVector::nObjectives(); i++) for (unsigned int i=0; i<ObjectiveVector::nObjectives(); i++)
{ {

View file

@ -53,7 +53,7 @@ public:
* @param _objectiveVector1 the first objective vector * @param _objectiveVector1 the first objective vector
* @param _objectiveVector2 the second objective vector * @param _objectiveVector2 the second objective vector
*/ */
const bool operator()(const ObjectiveVector & _objectiveVector1, const ObjectiveVector & _objectiveVector2) bool operator()(const ObjectiveVector & _objectiveVector1, const ObjectiveVector & _objectiveVector2)
{ {
for (unsigned int i=0; i<ObjectiveVector::nObjectives(); i++) for (unsigned int i=0; i<ObjectiveVector::nObjectives(); i++)
{ {

View file

@ -62,19 +62,19 @@ class moeoManhattanDistance : public moeoObjSpaceDistance < MOEOT >
@param _normalizer the normalizer used for every ObjectiveVector @param _normalizer the normalizer used for every ObjectiveVector
*/ */
moeoManhattanDistance (moeoObjectiveVectorNormalizer<MOEOT> &_normalizer):normalizer(_normalizer) moeoManhattanDistance (moeoObjectiveVectorNormalizer<MOEOT> &_normalizer):normalizer(_normalizer)
{} {}
/** /**
default ctr default ctr
*/ */
moeoManhattanDistance ():normalizer(defaultNormalizer) moeoManhattanDistance ():normalizer(defaultNormalizer)
{} {}
/** /**
* Returns the Manhattan distance between _obj1 and _obj2 in the objective space * Returns the Manhattan distance between _obj1 and _obj2 in the objective space
* @param _obj1 the first objective vector * @param _obj1 the first objective vector
* @param _obj2 the second objective vector * @param _obj2 the second objective vector
*/ */
const double operator()(const ObjectiveVector & _obj1, const ObjectiveVector & _obj2) double operator()(const ObjectiveVector & _obj1, const ObjectiveVector & _obj2)
{ {
double result = 0.0; double result = 0.0;
double tmp1, tmp2; double tmp1, tmp2;

View file

@ -151,7 +151,7 @@ class moeoDominanceDepthFitnessAssignment : public moeoDominanceBasedFitnessAssi
* @param _moeo1 the first solution * @param _moeo1 the first solution
* @param _moeo2 the second solution * @param _moeo2 the second solution
*/ */
const bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2) bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2)
{ {
return cmp(_moeo1.objectiveVector(), _moeo2.objectiveVector()); return cmp(_moeo1.objectiveVector(), _moeo2.objectiveVector());
} }