00001 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- 00002 00003 //----------------------------------------------------------------------------- 00004 // moeoAggregativeComparator.h 00005 // (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007 00006 /* 00007 This library... 00008 00009 Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr 00010 */ 00011 //----------------------------------------------------------------------------- 00012 00013 #ifndef MOEOAGGREGATIVECOMPARATOR_H_ 00014 #define MOEOAGGREGATIVECOMPARATOR_H_ 00015 00016 #include <comparator/moeoComparator.h> 00017 00021 template < class MOEOT > 00022 class moeoAggregativeComparator : public moeoComparator < MOEOT > 00023 { 00024 public: 00025 00031 moeoAggregativeComparator(double _weightFitness = 1.0, double _weightDiversity = 1.0) : weightFitness(_weightFitness), weightDiversity(_weightDiversity) 00032 {} 00033 00034 00040 const bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2) 00041 { 00042 return ( weightFitness * _moeo1.fitness() + weightDiversity * _moeo1.diversity() ) < ( weightFitness * _moeo2.fitness() + weightDiversity * _moeo2.diversity() ); 00043 } 00044 00045 00046 private: 00047 00049 double weightFitness; 00051 double weightDiversity; 00052 00053 }; 00054 00055 #endif /*MOEOAGGREGATIVECOMPARATOR_H_*/
1.4.7