00001 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- 00002 00003 // "moFirstImprSelect.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 __moFirstImprSelect_h 00013 #define __moFirstImprSelect_h 00014 00015 #include "moMoveSelect.h" 00016 00018 00023 template < class M > class moFirstImprSelect:public moMoveSelect < M > 00024 { 00025 00026 public: 00027 00029 typedef typename M::EOType::Fitness Fitness; 00030 00032 00035 virtual void init (const Fitness & __fit) 00036 { 00037 00038 valid = false; 00039 init_fit = __fit; 00040 } 00041 00042 00044 00052 bool update (const M & __move, const typename M::EOType::Fitness & __fit) 00053 { 00054 00055 if (__fit > init_fit) 00056 { 00057 00058 best_fit = __fit; 00059 best_move = __move; 00060 valid = true; 00061 00062 return false; 00063 } 00064 else 00065 { 00066 return true; 00067 } 00068 } 00069 00071 00076 void operator () (M & __move, Fitness & __fit) throw (EmptySelection) 00077 { 00078 00079 if (valid) 00080 { 00081 __move = best_move; 00082 __fit = best_fit; 00083 } 00084 else 00085 throw EmptySelection (); 00086 } 00087 00088 private: 00089 00091 bool valid; 00092 00094 M best_move; 00095 00097 Fitness init_fit; 00098 00100 Fitness best_fit; 00101 00102 }; 00103 00104 #endif
1.5.1