moeoAdditiveEpsilonBinaryMetric.h

00001 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
00002 
00003 //-----------------------------------------------------------------------------
00004 // moeoAdditiveEpsilonBinaryMetric.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 MOEOADDITIVEEPSILONBINARYMETRIC_H_
00014 #define MOEOADDITIVEEPSILONBINARYMETRIC_H_
00015 
00016 #include <metric/moeoNormalizedSolutionVsSolutionBinaryMetric.h>
00017 
00023 template < class ObjectiveVector >
00024 class moeoAdditiveEpsilonBinaryMetric : public moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double >
00025 {
00026 public:
00027 
00035     double operator()(const ObjectiveVector & _o1, const ObjectiveVector & _o2)
00036     {
00037         // computation of the epsilon value for the first objective
00038         double result = epsilon(_o1, _o2, 0);
00039         // computation of the epsilon value for the other objectives
00040         double tmp;
00041         for (unsigned int i=1; i<ObjectiveVector::Traits::nObjectives(); i++)
00042         {
00043             tmp = epsilon(_o1, _o2, i);
00044             result = std::max(result, tmp);
00045         }
00046         // returns the maximum epsilon value
00047         return result;
00048     }
00049 
00050 
00051 private:
00052 
00054     using moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > :: bounds;
00055 
00056 
00064     double epsilon(const ObjectiveVector & _o1, const ObjectiveVector & _o2, const unsigned int _obj)
00065     {
00066         double result;
00067         // if the objective _obj have to be minimized
00068         if (ObjectiveVector::Traits::minimizing(_obj))
00069         {
00070             // _o1[_obj] - _o2[_obj]
00071             result = ( (_o1[_obj] - bounds[_obj].minimum()) / bounds[_obj].range() ) - ( (_o2[_obj] - bounds[_obj].minimum()) / bounds[_obj].range() );
00072         }
00073         // if the objective _obj have to be maximized
00074         else
00075         {
00076             // _o2[_obj] - _o1[_obj]
00077             result = ( (_o2[_obj] - bounds[_obj].minimum()) / bounds[_obj].range() ) - ( (_o1[_obj] - bounds[_obj].minimum()) / bounds[_obj].range() );
00078         }
00079         return result;
00080     }
00081 
00082 };
00083 
00084 #endif /*MOEOADDITIVEEPSILONBINARYMETRIC_H_*/

Generated on Tue Jun 26 15:13:04 2007 for ParadisEO-MOEO by  doxygen 1.4.7