//----------------------------------------------------------------------------- // t-eoRingTopology.cpp //----------------------------------------------------------------------------- #include typedef eoRealParticle < double >Indi; //Evaluation function double f (const Indi & _indi) { double sum = 0; for (unsigned i = 0; i < _indi.size (); i++) sum += pow(_indi[i],2); return (-sum); } int main_function(int argc, char **argv) { //Parameters const unsigned int VEC_SIZE = 2; const unsigned int POP_SIZE = 10; const unsigned int NEIGHBORHOOD_SIZE= 3; rng.reseed (33); eoEvalFuncPtr plainEval(f); eoEvalFuncCounter < Indi > eval (plainEval); eoUniformGenerator < double >uGen (0., 5.); eoInitFixedLength < Indi > random (VEC_SIZE, uGen); eoUniformGenerator < double >sGen (-1., 1.); eoVelocityInitFixedLength < Indi > veloRandom (VEC_SIZE, sGen); eoFirstIsBestInit < Indi > localInit; eoPop < Indi > pop; pop.append (POP_SIZE, random); ::apply(eval, pop); ::apply < Indi > (veloRandom, pop); ::apply < Indi > (localInit, pop); eoRingTopology topology(NEIGHBORHOOD_SIZE); topology.setup(pop); std::cout<<"\n\n\nPopulation :\n\n"<