add a typedef + update the use of comparator
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@323 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
5b29f7621e
commit
199f122349
1 changed files with 16 additions and 27 deletions
|
|
@ -24,26 +24,28 @@
|
|||
* but it can be replaced at will by any other class that implements the static functions defined therein.
|
||||
* Some static funtions to access to the traits characteristics are re-defined in order not to write a lot of typedef's.
|
||||
*/
|
||||
template < class ObjectiveVectorTraits, class Type >
|
||||
class moeoObjectiveVector : public std::vector < Type >
|
||||
template < class ObjectiveVectorTraits, class ObjectiveVectorType >
|
||||
class moeoObjectiveVector : public std::vector < ObjectiveVectorType >
|
||||
{
|
||||
public:
|
||||
|
||||
/** The traits of objective vectors */
|
||||
typedef ObjectiveVectorTraits Traits;
|
||||
/** The type of an objective value */
|
||||
typedef ObjectiveVectorType Type;
|
||||
|
||||
|
||||
/**
|
||||
* Ctor
|
||||
*/
|
||||
/**
|
||||
* Ctor
|
||||
*/
|
||||
moeoObjectiveVector(Type _value = Type()) : std::vector < Type > (ObjectiveVectorTraits::nObjectives(), _value)
|
||||
{}
|
||||
|
||||
|
||||
/**
|
||||
* Ctor from a vector of Type
|
||||
* @param _v the std::vector < Type >
|
||||
*/
|
||||
/**
|
||||
* Ctor from a vector of Type
|
||||
* @param _v the std::vector < Type >
|
||||
*/
|
||||
moeoObjectiveVector(std::vector < Type > & _v) : std::vector < Type > (_v)
|
||||
{}
|
||||
|
||||
|
|
@ -123,7 +125,7 @@ public:
|
|||
bool dominates(const moeoObjectiveVectorDouble < ObjectiveVectorTraits > & _other) const
|
||||
{
|
||||
moeoParetoObjectiveVectorComparator < moeoObjectiveVectorDouble<ObjectiveVectorTraits> > comparator;
|
||||
return comparator(*this, _other);
|
||||
return comparator(_other, *this);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -161,21 +163,8 @@ public:
|
|||
*/
|
||||
bool operator<(const moeoObjectiveVectorDouble < ObjectiveVectorTraits > & _other) const
|
||||
{
|
||||
for (unsigned i=0; i < size(); i++)
|
||||
{
|
||||
if ( fabs(operator[](i) - _other[i]) > ObjectiveVectorTraits::tolerance() )
|
||||
{
|
||||
if (operator[](i) < _other[i])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
moeoObjectiveObjectiveVectorComparator < moeoObjectiveVectorDouble < ObjectiveVectorTraits > > cmp;
|
||||
return cmp(*this, _other);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue