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,13 +24,15 @@
|
||||||
* but it can be replaced at will by any other class that implements the static functions defined therein.
|
* 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.
|
* 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 >
|
template < class ObjectiveVectorTraits, class ObjectiveVectorType >
|
||||||
class moeoObjectiveVector : public std::vector < Type >
|
class moeoObjectiveVector : public std::vector < ObjectiveVectorType >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/** The traits of objective vectors */
|
/** The traits of objective vectors */
|
||||||
typedef ObjectiveVectorTraits Traits;
|
typedef ObjectiveVectorTraits Traits;
|
||||||
|
/** The type of an objective value */
|
||||||
|
typedef ObjectiveVectorType Type;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -123,7 +125,7 @@ public:
|
||||||
bool dominates(const moeoObjectiveVectorDouble < ObjectiveVectorTraits > & _other) const
|
bool dominates(const moeoObjectiveVectorDouble < ObjectiveVectorTraits > & _other) const
|
||||||
{
|
{
|
||||||
moeoParetoObjectiveVectorComparator < moeoObjectiveVectorDouble<ObjectiveVectorTraits> > comparator;
|
moeoParetoObjectiveVectorComparator < moeoObjectiveVectorDouble<ObjectiveVectorTraits> > comparator;
|
||||||
return comparator(*this, _other);
|
return comparator(_other, *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -161,21 +163,8 @@ public:
|
||||||
*/
|
*/
|
||||||
bool operator<(const moeoObjectiveVectorDouble < ObjectiveVectorTraits > & _other) const
|
bool operator<(const moeoObjectiveVectorDouble < ObjectiveVectorTraits > & _other) const
|
||||||
{
|
{
|
||||||
for (unsigned i=0; i < size(); i++)
|
moeoObjectiveObjectiveVectorComparator < moeoObjectiveVectorDouble < ObjectiveVectorTraits > > cmp;
|
||||||
{
|
return cmp(*this, _other);
|
||||||
if ( fabs(operator[](i) - _other[i]) > ObjectiveVectorTraits::tolerance() )
|
|
||||||
{
|
|
||||||
if (operator[](i) < _other[i])
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue