chiark / gitweb /
Fix hang during output of (7,6).
authorSimon Tatham <anakin@pobox.com>
Sat, 15 Mar 2014 16:48:02 +0000 (16:48 +0000)
committerSimon Tatham <anakin@pobox.com>
Sat, 15 Mar 2014 16:48:02 +0000 (16:48 +0000)
I had rather hoped that GLPK would always output a min fragment
slightly _less_ than the true rational value, on the basis that some
of its minima would be slightly below the right value and some
slightly above. Sadly, (7,6) consistently guesses high, so I must fall
back to the usual 1e10 bodge to round to rationals.

main.c

diff --git a/main.c b/main.c
index 5850860559113dd0bbd0b1de3de12437ebca167c..96f945cf0efd8f91a425997222536638d75e1ef1 100644 (file)
--- a/main.c
+++ b/main.c
@@ -796,7 +796,7 @@ static void report(void) {
           if (ai[i][j] > 0 && ai[i][j] < imin)
             imin = ai[i][j];
 
-      if ((double)imin / d < min)
+      if (abs((double)imin / d - min) > 1e-10)
         goto next_d;
 
       /*