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 00050 if (first_time || __fit > best_fit) 00051 { 00052 00053 best_fit = __fit; 00054 best_move = __move; 00055 00056 first_time = false; 00057 } 00058 00059 return true; 00060 } 00061 00063 00068 void operator () (M & __move, Fitness & __fit) throw (EmptySelection) 00069 { 00070 00071 if (!first_time) 00072 { 00073 __move = best_move; 00074 __fit = best_fit; 00075 } 00076 else 00077 throw EmptySelection (); 00078 } 00079 00080 private: 00081 00083 bool first_time; 00084 00086 M best_move; 00087 00089 Fitness best_fit; 00090 00091 }; 00092 00093 #endif
1.5.1