moeoManhattanDistance.h

00001 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
00002 
00003 //-----------------------------------------------------------------------------
00004 // moeoManhattanDistance.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 MOEOMANHATTANDISTANCE_H_
00014 #define MOEOMANHATTANDISTANCE_H_
00015 
00016 #include <math.h>
00017 #include <distance/moeoNormalizedDistance.h>
00018 
00023 template < class MOEOT >
00024 class moeoManhattanDistance : public moeoNormalizedDistance < MOEOT >
00025 {
00026 public:
00027 
00029     typedef typename MOEOT::ObjectiveVector ObjectiveVector;
00030 
00031 
00037     const double operator()(const MOEOT & _moeo1, const MOEOT & _moeo2)
00038     {
00039         double result = 0.0;
00040         double tmp1, tmp2;
00041         for (unsigned int i=0; i<ObjectiveVector::nObjectives(); i++)
00042         {
00043             tmp1 = (_moeo1.objectiveVector()[i] - bounds[i].minimum()) / bounds[i].range();
00044             tmp2 = (_moeo2.objectiveVector()[i] - bounds[i].minimum()) / bounds[i].range();
00045             result += fabs(tmp1-tmp2);
00046         }
00047         return result;
00048     }
00049 
00050 
00051 private:
00052 
00054     using moeoNormalizedDistance < MOEOT > :: bounds;
00055 
00056 };
00057 
00058 #endif /*MOEOMANHATTANDISTANCE_H_*/

Generated on Fri Jul 6 09:41:04 2007 for ParadisEO-MOEO by  doxygen 1.4.7