[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:27:39 +0400 |

>* is there*
>* any parallel implementation of GLPK? My other 23 cores are sitting*
>* idle.]*
Currently not.
>* 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);
>* The problem is, while above program outputs:*
>* * 13: obj = 2.000000000e+00 infeas = 0.000e+00 (0)*
>* OPTIMAL SOLUTION FOUND*
>* xs[12]: 0 0 0 0 0 0 0 0 0 0 0 0*
>* ys[3]: 0 0 0*
>* glpsol gives a different result.*
>* + 2: mip = 2.000000000e+00 <= tree is empty 0.0% (0; 1)*
>* INTEGER OPTIMAL SOLUTION FOUND*
>* And the results returned by glpsol are the right ones. What might I be*
>* missing in the C code? (To be honest, I'm in a quite hurry and any*
>* replies will be really really appreciated.)*
Most likely your instance has multiple optima, so your program finds
one optimal solution while glpsol finds another. As you can see the
optimal objective value is the same in both cases.
Note that to solve mip you need to call glp_simplex (to find optimal
solution to lp relaxation) and *then* call glp_intopt (to find integer
optimal solution), in which case the column values should be obtained
with glp_mip_col_val, not with glp_get_col_prim. It happened that for
your particular instance optimal solution to lp relaxation is integer
feasible and therefore integer optimal; however, in a general case
glp_intopt should be used. For details please see the glpk reference
manual.