[Top][All Lists]

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

[Help-glpk] Re: Intermediate solutions

From: Andrew Makhorin
Subject: [Help-glpk] Re: Intermediate solutions
Date: Mon, 30 Jun 2003 15:19:42 +0400

> fprintf(file, "%s %d\n", lpx_get_col_name(lp, col),
>         (int)lpx_get_mip_col(lp, col));
>The (int) is the problem. lpx_get_mip_col returns a double value. if this
>value is printed for some values, it returns a low number (x.xxxE-16). The
>automatic round gives a wrong 1 round when the right value is 0. 
>With the following modification in this line, the intermediate solution
>stored in the file is the right.
> fprintf(file, "%s %d\n", lpx_get_col_name(lp, col),
>         (lpx_get_mip_col(lp,col) > 0.5)?1:0);

(int)x.xxxe-16 is 0, not 1, because (int) truncates the value, i.e. rounds
it toward zero. I guess there was something like (int)0.999... which is 0.
However, if a column (structural variable) is marked as integer, its value
reported by lpx_get_mip_col is always integer in the sense that
value == floor(value), so converting to (int) would give correct result.

reply via email to

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