Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GUROBI status map #103

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

klin333
Copy link

@klin333 klin333 commented Nov 19, 2021

Fixes issue #99

Looking at the Gurobi docs, there are status codes which indicate user limits reached. It appears to me suboptimal solution may and often exist in these cases. https://www.gurobi.com/documentation/6.5/refman/optimization_status_codes.html#sec:StatusCodes

I played around with these Gurobi user limits, and indeed when time, iteration and solution limits are hit (in my single test case of a mixed integer programming problem), suboptimal solutions are returned from Gurobi solver, and can be successfully unpacked by CVXR.

I suggest we relax what CVXR considers suboptimal solutions to include these user limit solutions. I made the change for GUROBI_CONIC as well, though I didn't bother testing that.

I did not use USER_LIMIT for these user limits status codes because USER_LIMIT is not included in SOLUTION_PRESENT, which would have caused no solution unpacking. I'm not sure if it's wise to add USER_LIMIT to SOLUTION_PRESENT, so I did not use USER_LIMIT.

@klin333
Copy link
Author

klin333 commented Jan 17, 2022

@bnaras hi, any chance you can review this super simple PR. It's very important to me

@bnaras bnaras self-requested a review February 15, 2023 02:27
@bnaras bnaras self-assigned this Feb 15, 2023
@bnaras
Copy link
Collaborator

bnaras commented Feb 15, 2023

@bnaras hi, any chance you can review this super simple PR. It's very important to me

Sorry this is a bit late, but please see the branch WIP_gurobi_solver_status. That implements a more general solution and provides descriptive messages; for example:

> result <- solve(problem, solver = "GUROBI")
> result$status
[1] "optimal"
attr(,"gurobi_status_code")
[1] "OPTIMAL"
attr(,"gurobi_status_desc")
[1] "Model was solved to optimality (subject to tolerances), and an optimal solution is available."

> result <- solve(problem, solver = "GUROBI", TimeLimit=1) ## optional valid parameter
> result$status
[1] "optimal"
attr(,"gurobi_status_code")
[1] "OPTIMAL"
attr(,"gurobi_status_desc")
[1] "Model was solved to optimality (subject to tolerances), and an optimal solution is available."

> result <- solve(problem, solver = "GUROBI", TimeLimit=0) ## optional valid parameter that should not proceed
> result$status
[1] "user_limit"
attr(,"gurobi_status_code")
[1] "TIME_LIMIT"
attr(,"gurobi_status_desc")
[1] "Optimization terminated because the time expended exceeded the value specified in the TimeLimit parameter."

> result <- solve(problem, solver = "GUROBI", TimeLimit1=1) ## optional INVALID parameter
Error in status_map(object, solution$status) : 
  GUROBI status unrecognized: SOLVER_ERROR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants