# eoParetoRanking.h

    00001
    00025 //-----------------------------------------------------------------------------
    00026
    00027 #ifndef eoParetoRanking_h
    00028 #define eoParetoRanking_h
    00029
    00030 #include <eoPerf2Worth.h>
    00031 #include <eoDominanceMap.h>
    00032
    00039 template <class EOT>
    00040 class eoParetoRanking : public eoPerf2WorthCached<EOT, double>
    00041 {
    00042 public:
    00043
    00044     using eoPerf2WorthCached<EOT, double>::value;
    00045
    00046     eoParetoRanking(eoDominanceMap<EOT>& _dominanceMap)
    00047         : eoPerf2WorthCached<EOT, double>(), dominanceMap(_dominanceMap)
    00048         {}
    00049
    00050     void calculate_worths(const eoPop<EOT>& _pop)
    00051     {
    00052       dominanceMap(_pop);
    00053       value() = dominanceMap.sum_dominators(); // get rank: 0 means part of current front
    00054
    00055       // calculate maximum
    00056       double maxim = *std::max_element(value().begin(), value().end());
    00057
    00058       // higher is better, so invert the value
    00059       for (unsigned i = 0; i < value().size(); ++i)
    00060       {
    00061         value()[i] = maxim - value()[i];
    00062       }
    00063
    00064     }
    00065
    00066   private :
    00067
    00068   eoDominanceMap<EOT>& dominanceMap;
    00069 };
    00070
    00071 #endif