eoSocialNeighborhood.h

00001 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
00002 
00003 //-----------------------------------------------------------------------------
00004 // eoSocialNeighborhood.h
00005 // (c) OPAC 2007
00006 /*
00007     This library...
00008 
00009     Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
00010  */
00011 //-----------------------------------------------------------------------------
00012 
00013 #ifndef EOSOCIALNEIGHBORHOOD_H_
00014 #define EOSOCIALNEIGHBORHOOD_H_
00015 
00016 //-----------------------------------------------------------------------------
00017 #include <eoNeighborhood.h>
00018 //-----------------------------------------------------------------------------
00019 
00025 template < class POT > class eoSocialNeighborhood : public eoNeighborhood<POT>
00026 {
00027 public:
00028 
00029     eoSocialNeighborhood(){}
00030 
00035     void put(unsigned _oneIndice)
00036     {
00037         indicesList.push_back(_oneIndice);
00038     }
00039 
00045     bool contains(unsigned _oneIndice)
00046     {
00047         for (unsigned i=0;i< indicesList.size();i++)
00048         {
00049             if (indicesList[i]==_oneIndice)
00050                 return true;
00051         }
00052         return false;
00053     }
00054 
00058     std::vector<unsigned> getInformatives()
00059     {
00060         return indicesList;
00061     }
00062 
00066     unsigned size()
00067     {
00068         return indicesList.size();
00069 
00070     }
00071 
00076     unsigned get(unsigned _index)
00077     {
00078         if (_index < size())
00079             return indicesList[_index];
00080         else{
00081             std::string s;
00082             s.append (" Invalid indice in eoSocialNeighborhood ");
00083             throw std::runtime_error (s);
00084         }
00085     }
00086 
00091     POT & best()
00092     {
00093         return lBest;
00094     }
00095 
00100     void best(POT _particle)
00101     {
00102         lBest=_particle;
00103     }
00104 
00105 protected:
00106     std::vector<unsigned> indicesList; // The list of particles as a vector of indices
00107     POT lBest; // the best particle of the neighborhood
00108 };
00109 
00110 
00111 #endif /* EOSOCIALNEIGHBORHOOD_H_ */
00112 
00113 
00114 
00115 
00116 
00117 
00118 
00119 
00120 
00121 
00122 

Generated on Fri Jun 22 10:17:02 2007 for EO-PSO by  doxygen 1.4.7