From e70e6d0631388b4c2da6b3f58a3eaf2514ae29ad Mon Sep 17 00:00:00 2001 From: ametama Date: Thu, 18 Dec 2025 00:02:34 +0100 Subject: [PATCH] fix(params): remove global params --- src/swarm.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/swarm.c b/src/swarm.c index 3fe83ff..fbf9280 100644 --- a/src/swarm.c +++ b/src/swarm.c @@ -3,10 +3,6 @@ #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; } @@ -41,7 +37,7 @@ void swarm_velocity_update(swarm *sw) { 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]; -- 2.34.1