#include "swarm.h"
#include "vector.h"
-double c = 2.05;
-double s = 2.05;
-double w = 0.8;
-
double rands() {
return (double) rand() / RAND_MAX;
}
for (int p = 0; p < sw->params.particlec; p++) {
particle *pt = &sw->particles[p];
for (int d = 0; d < sw->params.dim; d++)
- pt->velocity[d] = w * pt->velocity[d] + c * rands() * (pt->best.x[d] - pt->current.x[d]) + s * rands() * (sw->global_best->current.x[d] - pt->current.x[d]);
+ pt->velocity[d] = sw->params.w * pt->velocity[d] + sw->params.c * rands() * (pt->best.x[d] - pt->current.x[d]) + sw->params.s * rands() * (sw->global_best->current.x[d] - pt->current.x[d]);
}
for (int p = 0; p < sw->params.particlec; p++) {
particle *pt = &sw->particles[p];