fix(de): convergence counter reassignment
authorametama <ametama@wafflesoft.org>
Thu, 15 Jan 2026 11:10:31 +0000 (12:10 +0100)
committerametama <ametama@wafflesoft.org>
Thu, 15 Jan 2026 11:10:31 +0000 (12:10 +0100)
src/de.c

index 83777874638a8c6f04f1385bab921fd10f0b5e9b..441312b34a1846c7b70ad0502bf66b9b58ee8126 100644 (file)
--- a/src/de.c
+++ b/src/de.c
@@ -25,7 +25,10 @@ void de_optimize(de_parameters *par, double *res) {
                 if (i == r || rands() < par->cr) y[i] = picks[1][i] + par->dw * (picks[2][i] - picks[3][i]);
                 else y[i] = x[i];
             }
-            if (par->f(y) <= par->f(x)) vec_copy(par->dim, y, x);
+            if (par->f(y) < par->f(x)) {
+                vec_copy(par->dim, y, x);
+                conv = 0;
+            }
             else conv++;
         }
     }