00001 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- 00002 00003 // "moBestImprSelect.h" 00004 00005 // (c) OPAC Team, LIFL, 2003-2006 00006 00007 /* LICENCE TEXT 00008 00009 Contact: paradiseo-help@lists.gforge.inria.fr 00010 */ 00011 00012 #ifndef __moBestImprSelect_h 00013 #define __moBestImprSelect_h 00014 00015 #include "moMoveSelect.h" 00016 00018 00022 template < class M > class moBestImprSelect:public moMoveSelect < M > 00023 { 00024 00025 public: 00026 00028 typedef typename M::EOType::Fitness Fitness; 00029 00031 void init (const Fitness & __fit) 00032 { 00033 00034 first_time = true; 00035 } 00036 00037 00039 00047 bool update (const M & __move, const Fitness & __fit) 00048 { 00049 if ((first_time) || (__fit > best_fit)) 00050 { 00051 best_fit = __fit; 00052 best_move = __move; 00053 00054 first_time = false; 00055 } 00056 return true; 00057 } 00058 00060 00065 void operator () (M & __move, Fitness & __fit) throw (EmptySelection) 00066 { 00067 00068 if (!first_time) 00069 { 00070 __move = best_move; 00071 __fit = best_fit; 00072 } 00073 else 00074 throw EmptySelection (); 00075 } 00076 00077 private: 00078 00080 bool first_time; 00081 00083 M best_move; 00084 00086 Fitness best_fit; 00087 }; 00088 00089 #endif
1.5.2