- Main Page
- Classes
- Files

- Search for |

# moeoParetoPhenDist.h

    00001 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
    00002
    00003 //-----------------------------------------------------------------------------
    00004 // moeoParetoPhenDist.h
    00005 // (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2006
    00006 /*
    00007     This library...
    00008
    00009     Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
    00010  */
    00011 //-----------------------------------------------------------------------------
    00012
    00013 #include<eoParetoFitness.h>
    00014
    00015 template < class EOT, class DistType > class moeoParetoPhenDist
    00016 {
    00017 public:
    00018   virtual DistType operator  ()(const EOT & eopf1, const EOT & eopf2) = 0;
    00019
    00020 };
    00021
    00022
    00023
    00024 //Euclidien distance
    00025
    00026 template < class EOT, class DistType =
    00027   double >class moeoParetoEuclidDist:public moeoParetoPhenDist < EOT,
    00028   DistType >
    00029 {
    00030
    00031 public:
    00032   DistType operator  () (const EOT & eopf1, const EOT & eopf2)
    00033   {
    00034     double res = 0.0;
    00035     double max = 0.0;
    00036     double temp;
    00037     for (unsigned i = 0; i < eopf1.fitness ().size (); ++i)
    00038       {
    00039         temp =
    00040           (eopf1.fitness ().operator[](i) -
    00041            eopf2.fitness ().operator[](i)) * (eopf1.fitness ().operator[](i) -
    00042                                               eopf2.fitness ().operator[](i));
    00043         if (temp > max)
    00044           max = temp;           /* for normalization */
    00045         res = res + temp;
    00046       }
    00047     return sqrt (res / max);
    00048   }
    00049
    00050 };