From 23ed9804370d20bb23a1adb9c6e2f0453df3ad7a Mon Sep 17 00:00:00 2001 From: OscarSotoSanchez Date: Sun, 19 Jul 2026 11:10:42 +0200 Subject: [PATCH] Fix inverted observer return-value javadoc in addNewSolutionObserver The method-level javadoc claimed the observer returns true "if the algorithm should stop immediately", which is backwards. The C++ core run loop implements the opposite convention: bool run = true; while (run) { ... run &= callback(status); // false -> run=false -> stop } So returning true keeps the optimization running and false stops it. This matches NewSolutionObserver.onNewSolution's @return, the native bridge comment ("non-zero to keep running"), the MainComplete examples, and docs/GUIDE.md. Align the javadoc with the actual behavior. --- brkga_mp_ipr_java/src/main/java/brkga/BrkgaMpIpr.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/brkga_mp_ipr_java/src/main/java/brkga/BrkgaMpIpr.java b/brkga_mp_ipr_java/src/main/java/brkga/BrkgaMpIpr.java index 3f11fc1..6cb8e6e 100644 --- a/brkga_mp_ipr_java/src/main/java/brkga/BrkgaMpIpr.java +++ b/brkga_mp_ipr_java/src/main/java/brkga/BrkgaMpIpr.java @@ -249,9 +249,9 @@ public BrkgaMpIpr(Brkga brkga, Decoder decoder, Sense sense, int seed, /** * Adds a callback called when the best solution is improved. * - *

The observer receives an {@link AlgorithmStatus} and returns {@code true} if - * the algorithm should stop immediately. You may add as many observers as you - * want; they are called in the order they are added. + *

The observer receives an {@link AlgorithmStatus} and returns {@code true} to + * keep the optimization running, or {@code false} to stop it immediately. You may + * add as many observers as you want; they are called in the order they are added. * * @param observer the {@link NewSolutionObserver} callback to be invoked on each * improvement of the best solution.