[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-glpk] Re[2]: [Help-glpk] Incorrect result (bug) or programming issu

From: Andrew Makhorin
Subject: [Bug-glpk] Re[2]: [Help-glpk] Incorrect result (bug) or programming issue?
Date: Mon, 21 Mar 2005 15:54:41 +0300

To fix the bug please replace line 4990 in file glpmpl3.c (glpk 4.8):

   write_text(mpl, from, (int)(value + 0.5));

by the following one:

   write_text(mpl, from, (int)floor(value + 0.5));

and then recompile/reinstall the package in a usual way.

Note that the bug will be fixed in a next release of Glpk.

The bug appears if the value to be printed is negative and %d format
specifier is used. The value should be properly rounded to the nearest
integer while it was simply truncated.

So, in your case it was (int)(-6 + 0.5) = (int)(-5.5) = -5 while the
correct answer is obviously -6.

Andrew Makhorin

Reading model section from bug.mod...
23 lines were read
Generating r1...
Generating r2...
Generating r3...
Generating r4...
Generating obj...
Model has been successfully generated
lpx_simplex: original LP has 5 rows, 4 columns, 13 non-zeros
lpx_simplex: presolved LP has 4 rows, 4 columns, 9 non-zeros
lpx_adv_basis: size of triangular part = 4
*     0:   objval =   0.000000000e+00   infeas =   0.000000000e+00 (0)
*     3:   objval =   1.750000000e+01   infeas =   0.000000000e+00 (0)
Integer optimization begins...
Objective function is integral
+     3: mip =     not found yet <=              +inf        (1; 0)
+     4: mip =   1.700000000e+01 <=   1.700000000e+01   0.0% (2; 0)
+     4: mip =   1.700000000e+01 <=     tree is empty   0.0% (0; 3)
Time used:   0.0 secs
Memory used: 0.1M (151244 bytes)
x1=0, x2=5, x3=-6, x4=9
(obj: 17)
Model has been successfully processed

reply via email to

[Prev in Thread] Current Thread [Next in Thread]