chiark / gitweb /
fudge the {n,m}_max_frags to deal with rounding errors in glpk results
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 9 Mar 2014 18:20:26 +0000 (18:20 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 9 Mar 2014 18:20:26 +0000 (18:20 +0000)
main.c

diff --git a/main.c b/main.c
index c5a49918869d9c8c1b07d865353cb856ece2c61f..f0bb84f497f12d91f9a1f4416643d80aee002c09 100644 (file)
--- a/main.c
+++ b/main.c
@@ -138,9 +138,13 @@ static void set_best(double new_best) {
    *   <=>       frags <   |  n / best  |
    *                        _          _
    *   <=>       frags <=  |  n / best  | - 1
    *   <=>       frags <   |  n / best  |
    *                        _          _
    *   <=>       frags <=  |  n / best  | - 1
+   *
+   * But best values from glpk are slightly approximate, so we
+   * subtract a fudge factor from our target.
    */
    */
-  n_max_frags = ceil(n / best) - 1;
-  m_max_frags = ceil(m / best) - 1;
+  double near_best = best * 0.98 - 0.02;
+  n_max_frags = ceil(n / near_best) - 1;
+  m_max_frags = ceil(m / near_best) - 1;
 }
 
 /*----- multicore support -----*/
 }
 
 /*----- multicore support -----*/