37 #include "ISearch.hpp" 39 #define PI (3.141592653589793238462643383279) 41 #define COPY_ARR(orig, dest, sz) for(int _i_=0; _i_ < sz; dest[_i_] = orig[_i_], _i_++); 43 #define RAND_DOUBLE(seed, a, b) ((a==b)?a:(a+(((double)rand_r(&seed))/RAND_MAX)*(b-a))) 45 typedef double (*callback_t)(
double *buf,
int n);
57 double **x, *fit, s1, s2, w, c1, c2, *Gb, Gb_Fit, **pb, *pb_Fit, **v;
59 callback_t fitnessFunction;
62 PSO(callback_t fitnessFunction,
double s1,
double s2,
int p,
int n,
double w,
double c1,
double c2) ;
int getNEvals()
Get the number of fitness function evaluations performed up to the moment.
void next(int M)
Obtain the next improvement.
The interface that the search methods must to implement.
Particle Swarm Optimization.
unsigned int getRandomSeed()
Get a random number to be used as seed for the random number generator.
void startup()
Startup the PSO.
double getFitness()
Get the best fitness value found up to the moment.
int getBestPos(double *_x)
Get the best result obtained up to the moment (global best).
PSO(callback_t fitnessFunction, double s1, double s2, int p, int n, double w, double c1, double c2)
A standard implementation of PSO.