00001
00002
00003
00004
00005
00006
00007
00008
00009
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;
00107 POT lBest;
00108 };
00109
00110
00111 #endif
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122