help-glpk
[Top][All Lists]
Advanced

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

Re: [Help-glpk] Finding minimum and maximum objective value


From: Andrew Makhorin
Subject: Re: [Help-glpk] Finding minimum and maximum objective value
Date: Fri, 20 Nov 2009 07:33:01 +0300

> I am currently using glpk. Thank you for the good documentation, the
> "Brief example" in section 1.3.1 really helped me to start using the
> library quickly. I have a question however. I would like to find both
> the minimum and the maximum objective value for the same objective
> function, constraints and bounds. I have tried:

> [...]
> glp_set_obj_dir(lp, GLP_MIN);
> glp_simplex(lp, NULL);
> min= glp_get_obj_val(lp);
> glp_set_obj_dir(lp, GLP_MAX);
> glp_simplex(lp, NULL);
> max= glp_get_obj_val(lp);

> but then max == min. Is there something that I have to clear/reset after
> changing obj_dir before solving again?

You need to check the solution status after a call to glp_simplex.
The solution is optimal if glp_get_status returns GLP_OPT. Or print
the solution to a file with glp_print_sol. Most likely in the second
case your lp is unbounded, i.e. has no finite maximum.






reply via email to

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