00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef MOEOGDOMINANCEOBJECTIVEVECTORCOMPARATOR_H_
00014 #define MOEOGDOMINANCEOBJECTIVEVECTORCOMPARATOR_H_
00015
00016 #include <comparator/moeoObjectiveVectorComparator.h>
00017
00024 template < class ObjectiveVector >
00025 class moeoGDominanceObjectiveVectorComparator : public moeoObjectiveVectorComparator < ObjectiveVector >
00026 {
00027 public:
00028
00033 moeoGDominanceObjectiveVectorComparator(ObjectiveVector & _ref) : ref(_ref)
00034 {}
00035
00036
00042 const bool operator()(const ObjectiveVector & _objectiveVector1, const ObjectiveVector & _objectiveVector2)
00043 {
00044 unsigned int flag1 = flag(_objectiveVector1);
00045 unsigned int flag2 = flag(_objectiveVector2);
00046 if (flag2==0)
00047 {
00048
00049 return false;
00050 }
00051 else if ( (flag2==1) && (flag1==0) )
00052 {
00053
00054 return true;
00055 }
00056 else
00057 {
00058
00059 return paretoComparator(_objectiveVector1, _objectiveVector2);
00060 }
00061 }
00062
00063
00064 private:
00065
00067 ObjectiveVector & ref;
00069 moeoParetoObjectiveVectorComparator < ObjectiveVector > paretoComparator;
00070
00071
00076 unsigned int flag(const ObjectiveVector & _objectiveVector)
00077 {
00078 unsigned int result=1;
00079 for (unsigned int i=0; i<ref.nObjectives(); i++)
00080 {
00081 if (_objectiveVector[i] > ref[i])
00082 {
00083 result=0;
00084 }
00085 }
00086 if (result==0)
00087 {
00088 result=1;
00089 for (unsigned int i=0; i<ref.nObjectives(); i++)
00090 {
00091 if (_objectiveVector[i] < ref[i])
00092 {
00093 result=0;
00094 }
00095 }
00096 }
00097 return result;
00098 }
00099
00100 };
00101
00102 #endif