> 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.



_______________________________________________
Help-glpk mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-glpk

Reply via email to