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

_OPTIMIZE_WARNED status? #105

Closed
grahamgill opened this issue Apr 3, 2022 · 0 comments · Fixed by #108
Closed

_OPTIMIZE_WARNED status? #105

grahamgill opened this issue Apr 3, 2022 · 0 comments · Fixed by #108
Assignees

Comments

@grahamgill
Copy link

grahamgill commented Apr 3, 2022

I find it a bit heavy that model.solution.status is set to _OPTIMIZE_ERRORED for any nonzero return value of Highs_run, at

x.status = ret == 0 ? _OPTIMIZE_OK : _OPTIMIZE_ERRORED
. Highs_run return value of 1 indicates a warning, -1 indicates an error.

Locally I've made the change below, adding an _OPTIMIZE_WARNED status to the _OptimizeStatus enum. In the case of a Highs_run warning, this lets me see more easily the MOI.TerminationStatus and MOI.RawStatusString, and act on the result. In my use case, I'm frequently encountering an optimal solution but with a warning. I'd like to know there's a warning and see the solver result rather than have it be shunted into MOI.OTHER_ERROR.

diff --git a/src/MOI_wrapper.jl b/src/MOI_wrapper.jl
index e485382..4aff9d3 100644
--- a/src/MOI_wrapper.jl
+++ b/src/MOI_wrapper.jl
@@ -162,7 +162,7 @@ function _set(c::_ConstraintInfo)
     end
 end
 
-@enum(_OptimizeStatus, _OPTIMIZE_NOT_CALLED, _OPTIMIZE_OK, _OPTIMIZE_ERRORED)
+@enum(_OptimizeStatus, _OPTIMIZE_NOT_CALLED, _OPTIMIZE_OK, _OPTIMIZE_ERRORED, _OPTIMIZE_WARNED)
 
 """
     _Solution
@@ -1553,7 +1553,7 @@ Get the solution from a run of HiGHS.
 """
 function _store_solution(model::Optimizer, ret::HighsInt)
     x = model.solution
-    x.status = ret == 0 ? _OPTIMIZE_OK : _OPTIMIZE_ERRORED
+    x.status = ret == kHighsStatusOk ? _OPTIMIZE_OK : ret == kHighsStatusWarning ? _OPTIMIZE_WARNED : _OPTIMIZE_ERRORED
     x.primal_solution_status = kHighsSolutionStatusNone
     x.dual_solution_status = kHighsSolutionStatusNone
     x.has_dual_ray = false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants