How to resolve ambiguity in solve_result_num codes when using Gurobi solver?

54 views
Skip to first unread message

hamish

unread,
Feb 23, 2015, 3:12:28 AM2/23/15
to am...@googlegroups.com

Hi,

When using the Gurobi solver and a user imposed time limit on the solution time is reached solver_result_num returns 403 as expected, but how do I differentiate between the two cases in which a feasible solution is found or not?

My first thought was to check the finiteness of the objective function value, but it seems that when a feasible solution is not found the objective function value is returned as 0 which is a possible objective function value for a feasible solution in my problem. I would have thought that plus or minus Inifinity would have been more appropriate as a return value in this case depending upon the objective function sense.

Thanks,
Hamish

Robert Fourer

unread,
Feb 24, 2015, 1:13:56 PM2/24/15
to am...@googlegroups.com
The AMPL-Gurobi interface calls GRBoptimize(...) which just returns GRB_TIME_LIMIT when Gurobi runs out of time, without distinguishing the cases of feasible solution found and feasible solution not found. However you can always check for infeasibility of the current solution in AMPL with a test like

if min( {i in 1.._ncons} _con[i].slack,
{j in 1.._nvars} _var[j].slack ) < -1e-6 then ...

When the time limit is reached before any MIP feasible solution has been found, Gurobi does not return any solution, and the solution in AMPL remains the same as it was before Gurobi was called. (By default all variables are zero.) Any reference to the objective function value in AMPL is computed from the variable values, so the objective value is not helpful if no solution has been returned. Supposedly Gurobi will return an infinite gap value when no integer-feasible solution has been found, but that feature does not seem to be working properly and I am looking into it.

Bob Fourer
am...@googlegroups.com

=======

Robert Fourer

unread,
Feb 27, 2015, 2:14:08 PM2/27/15
to am...@googlegroups.com
Here's an update on this question. We have updated the behavior of AMPL's Gurobi interface when handling the following option in the gurobi_options string:

return_mipgap Whether to return mipgap suffixes or include mipgap values
(|objective - best_bound|) in the solve_message: sum of
1 = return relmipgap suffix (relative to |obj|);
2 = return absmipgap suffix (absolute mipgap);
4 = suppress mipgap values in solve_message.
Default = 0. The suffixes are on the objective and problem.
Returned suffix values are +Infinity if no integer-feasible
solution has been found, in which case no mipgap values are
reported in the solve_message.

When a time limit or other stopping condition occurs before any integer-feasible solution has been found, the .relmipgap and/or .absmipgap suffix now reports a gap of Infinity. When the stopping condition occurs after an integer-feasible solution has been found, these gaps are reported as finite.

For example, if you add 'return_mipgap 2' to the gurobi_options string, and your AMPL objective function is Total_Cost, then Total_Cost.absmipgap will be Infinity if and only if no integer-feasible solution was found.

Bob Fourer
am...@googlegroups.com


Hamish Waterer

unread,
Feb 27, 2015, 5:56:16 PM2/27/15
to am...@googlegroups.com
Most appreciated. Thank you.
> --
> You received this message because you are subscribed to a topic in the Google Groups "AMPL Modeling Language" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/ampl/hSprxUufuRk/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to ampl+uns...@googlegroups.com.
> To post to this group, send email to am...@googlegroups.com.
> Visit this group at http://groups.google.com/group/ampl.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages