00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef EOSTARTOPOLOGY_H_
00014 #define EOSTARTOPOLOGY_H_
00015
00016
00017 #include <eoTopology.h>
00018 #include <eoSocialNeighborhood.h>
00019
00020
00021
00027 template < class POT > class eoStarTopology:public eoTopology <POT>
00028 {
00029
00030 public:
00031
00035 eoStarTopology ():isSetup(false){}
00036
00037
00044 void setup(const eoPop<POT> & _pop)
00045 {
00046 if (!isSetup){
00047
00048
00049 for (unsigned i=0;i < _pop.size();i++)
00050 neighborhood.put(i);
00051
00052
00053 neighborhood.best(_pop.best_element());
00054
00055 isSetup=true;
00056 }
00057 else
00058 {
00059
00060
00061
00062
00063
00064
00065 }
00066 }
00067
00068
00069
00070
00071
00072
00073
00074 void updateNeighborhood(POT & _po,unsigned _indice)
00075 {
00076
00077 if (_po.fitness() > _po.best())
00078 {
00079 _po.best(_po.fitness());
00080 }
00081
00082 if (_po.fitness() > neighborhood.best().fitness())
00083 {
00084 neighborhood.best(_po);
00085 }
00086 }
00087
00088
00094 POT & best (unsigned _indice) {return (neighborhood.best());}
00095
00096
00102 void printOn()
00103 {
00104 std::cout << "{" ;
00105 for (unsigned i=0;i< neighborhood.size();i++)
00106 std::cout << neighborhood.get(i) << " ";
00107 std::cout << "}" << std::endl;
00108 }
00109
00110
00111 protected:
00112 eoSocialNeighborhood<POT> neighborhood;
00113 bool isSetup;
00114 };
00115
00116 #endif
00117
00118
00119
00120
00121
00122
00123
00124