moeoReferencePointIndicatorBasedFitnessAssignment.h

00001 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
00002 
00003 //-----------------------------------------------------------------------------
00004 // moeoReferencePointIndicatorBasedFitnessAssignment.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 MOEOREFERENCEPOINTINDICATORBASEDFITNESSASSIGNMENT_H_
00014 #define MOEOREFERENCEPOINTINDICATORBASEDFITNESSASSIGNMENT_H_
00015 
00016 #include <math.h>
00017 #include <eoPop.h>
00018 #include <fitness/moeoFitnessAssignment.h>
00019 #include <metric/moeoNormalizedSolutionVsSolutionBinaryMetric.h>
00020 
00024 template < class MOEOT >
00025 class moeoReferencePointIndicatorBasedFitnessAssignment : public moeoFitnessAssignment < MOEOT >
00026 {
00027 public:
00028 
00030     typedef typename MOEOT::ObjectiveVector ObjectiveVector;
00031 
00037     moeoReferencePointIndicatorBasedFitnessAssignment (ObjectiveVector & _refPoint, moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > & _metric) :
00038             refPoint(_refPoint), metric(_metric)
00039     {}
00040 
00041 
00046     void operator()(eoPop < MOEOT > & _pop)
00047     {
00048         // 1 - setting of the bounds
00049         setup(_pop);
00050         // 2 - setting fitnesses
00051         setFitnesses(_pop);
00052     }
00053 
00054 
00060     void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
00061     {
00062         // nothing to do  ;-)
00063     }
00064 
00065 
00066 protected:
00067 
00069     ObjectiveVector & refPoint;
00071     moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > & metric;
00072 
00073 
00078     void setup(const eoPop < MOEOT > & _pop)
00079     {
00080         double min, max;
00081         for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++)
00082         {
00083             min = refPoint[i];
00084             max = refPoint[i];
00085             for (unsigned int j=0; j<_pop.size(); j++)
00086             {
00087                 min = std::min(min, _pop[j].objectiveVector()[i]);
00088                 max = std::max(max, _pop[j].objectiveVector()[i]);
00089             }
00090             // setting of the bounds for the objective i
00091             metric.setup(min, max, i);
00092         }
00093     }
00094 
00099     void setFitnesses(eoPop < MOEOT > & _pop)
00100     {
00101         for (unsigned int i=0; i<_pop.size(); i++)
00102         {
00103             _pop[i].fitness(- metric(_pop[i].objectiveVector(), refPoint) );
00104         }
00105     }
00106 
00107 };
00108 
00109 #endif /*MOEOREFERENCEPOINTINDICATORBASEDFITNESSASSIGNMENT_H_*/

Generated on Mon Oct 8 10:35:52 2007 for ParadisEO-MOEOMovingObjects by  doxygen 1.4.7