[Top][All Lists]

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

Re: [Help-glpk] About glp_set_col_bnds()

From: Andrew Makhorin
Subject: Re: [Help-glpk] About glp_set_col_bnds()
Date: Sun, 06 Apr 2014 13:01:01 +0400

> My name is Nan Hu. Now I’m using GLPK for a LP problem and facing a
> potential bug. 
> My code is like 
> glp_simplex(ilp, NULL);
> double tmp = glp_get_col_prim(ilp, index);
> while(tmp != 0) {
>     glp_set_col_bnds(ilp, index, GLP_FX, 0.0, 0.0);
>     glp_simplex(ilp, NULL);
>     tmp = glp_get_col_prim(ilp, index);
> }
> Sometimes when the value of tmp is very small (e.g. 1e-20), this loop
> will never stop and the value of tmp stays the same... Is there
> anything wrong with my code? 

Fixing a variable at zero does not guarantee that its value in basic
solution will be exact zero. If the variable is basic (this may happen
if the basis is primal degenerate), its value that glp_get_col_prim
returns being computed in inexact (floating point) arithmetic will be
zero only within a tolerance, i.e. approximately, so the test like
while(fabs(tmp) > 1e-6) would be more appropriate. Besides, it is
recommended to check the code returned by glp_simplex and to check the
solution status with glp_get_status.

reply via email to

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