00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef EOSOCIALNEIGHBORHOOD_H_
00026 #define EOSOCIALNEIGHBORHOOD_H_
00027
00028
00029 #include <eoNeighborhood.h>
00030
00031
00037 template < class POT > class eoSocialNeighborhood : public eoNeighborhood<POT>
00038 {
00039 public:
00040
00041 eoSocialNeighborhood(){}
00042
00047 void put(unsigned _oneIndice)
00048 {
00049 indicesList.push_back(_oneIndice);
00050 }
00051
00057 bool contains(unsigned _oneIndice)
00058 {
00059 for (unsigned i=0;i< indicesList.size();i++)
00060 {
00061 if (indicesList[i]==_oneIndice)
00062 return true;
00063 }
00064 return false;
00065 }
00066
00070 std::vector<unsigned> getInformatives()
00071 {
00072 return indicesList;
00073 }
00074
00078 unsigned size()
00079 {
00080 return indicesList.size();
00081
00082 }
00083
00088 unsigned get(unsigned _index)
00089 {
00090 if (_index < size())
00091 return indicesList[_index];
00092 else{
00093 std::string s;
00094 s.append (" Invalid indice in eoSocialNeighborhood ");
00095 throw std::runtime_error (s);
00096 }
00097 }
00098
00103 POT & best()
00104 {
00105 return lBest;
00106 }
00107
00112 void best(POT _particle)
00113 {
00114 lBest=_particle;
00115 }
00116
00117 protected:
00118 std::vector<unsigned> indicesList;
00119 POT lBest;
00120 };
00121
00122
00123 #endif
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134