[Top][All Lists]

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

Re: [Help-glpk] glp_get_col_prim() problem

From: Andrew Makhorin
Subject: Re: [Help-glpk] glp_get_col_prim() problem
Date: Thu, 22 Apr 2010 15:31:37 +0400

>> I'm having troubles while trying to get the solution variables via C
>> API. Below is the code I use in my program:
>>       return (int) glp_get_col_prim(lp, i);
> Please note that glp_get_col_prim returns a floating-point value, so
> it would be better to write:
>    return (int) (glp_get_col_prim(lp, i) + .5);

Yes, this may cause incorrect results. Imagine that x = 0.999999 due
to round-off errors in the simplex solver. Then

   (int)x -> 0 (incorrect)


   (int)(x + .5) -> 1 (correct)

reply via email to

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