moSimpleSolutionTabuList.h

00001 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
00002 
00003 // "moSimpleSolutionTabuList.h"
00004 
00005 // (c) OPAC Team, LIFL, 2003-2007
00006 
00007 /* LICENCE TEXT 
00008    
00009    Contact: paradiseo-help@lists.gforge.inria.fr
00010 */
00011 
00012 #ifndef __moSimpleSolutionTabuList_h
00013 #define __moSimpleSolutionTabuList_h
00014 
00015 #include <list>
00016 #include <iterator>
00017 
00018 #include "moTabuList.h"
00019 
00021 template <class M>
00022 class moSimpleSolutionTabuList: public moTabuList < M >
00023 {
00024   
00025 public:
00026 
00028   typedef typename M::EOType EOT;
00029   
00031 
00034   moSimpleSolutionTabuList(unsigned __size): maxSize(__size)
00035   {
00036     currentSize=0;
00037   }
00038   
00040 
00045   bool operator () (const M & __move, const EOT & __sol) 
00046   {
00047     typename std::list<EOT>::iterator it;
00048   
00049     M _move=(M)__move;
00050     EOT _sol=(EOT) __sol;
00051 
00052     _move(_sol);
00053   
00054     it=tabuList.begin();
00055     while(it!=tabuList.end()&&(!((*it)==_sol)))
00056       {
00057         it++;
00058       }
00059     
00060     return it!=tabuList.end();
00061   }
00062   
00063   void
00064   add (const M & __move, const EOT & __sol)
00065   {
00066     M _move=(M)__move;
00067     EOT _sol=(EOT) _sol;
00068     
00069     _move(_sol);
00070     
00071     tabuList.push_back(_sol);
00072     
00073     if(currentSize==maxSize)
00074       {
00075         tabuList.erase(tabuList.begin());
00076       }
00077     else
00078       {
00079         currentSize++;
00080       }
00081   }
00082 
00083   void
00084   update ()
00085   {
00086     //nothing to do
00087   }
00088 
00089   void
00090   init ()
00091   {
00092     //nothing to do
00093   }
00094 
00095 private:
00096   
00098   unsigned maxSize;
00099 
00101   unsigned currentSize;
00102   
00104   std::list<EOT> tabuList;
00105 };
00106 
00107 #endif

Generated on Thu Apr 19 15:16:09 2007 for PARADISEO-MO by  doxygen 1.5.1