chiark / gitweb /
add one missing call to FOR_BITS (no functional change)
[matchsticks-search.git] / main.c
diff --git a/main.c b/main.c
index de880e9c356936fa2e847cce8d166ffa9941f6eb..b7aae53e43007901eb4a547a2d52a188eb61efc2 100644 (file)
--- a/main.c
+++ b/main.c
@@ -119,8 +119,18 @@ static void progress_eol(void) {
 
 static void set_best(double new_best) {
   best = new_best;
-  n_max_frags = floor(n / best);
-  m_max_frags = floor(m / best);
+  /*
+   * When computing n_max_frags, we want to set a value that will skip
+   * anything that won't provide strictly better solutions.  So we
+   * want
+   *             frags <      n / best
+   *                        _          _
+   *   <=>       frags <   |  n / best  |
+   *                        _          _
+   *   <=>       frags <=  |  n / best  | - 1
+   */
+  n_max_frags = ceil(n / best) - 1;
+  m_max_frags = ceil(m / best) - 1;
 }
 
 /*----- multicore support -----*/
@@ -502,7 +512,7 @@ static void optimise(bool doprint) {
   glp_set_obj_coef(prob, X_minimum, 1);
 
   for (i=0; i<n; i++) {
-    for (j=0, jbit=1; j<m; j++, jbit<<=1) {
+    FOR_BITS(j,m) {
       if (!(adjmatrix[i] & jbit))
        continue;
       /* x_total_i += x_minimum */