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

Check feasibility of solutions in PrimalStatus and DualStatus #548

Merged
merged 8 commits into from
Mar 12, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 28 additions & 8 deletions src/MOI_wrapper/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2831,8 +2831,20 @@
valueP = Ref{Cint}()
ret = GRBgetintattr(model, "SolCount", valueP)
_check_ret(model, ret)
return 1 <= attr.result_index <= valueP[] ? MOI.FEASIBLE_POINT :
MOI.NO_SOLUTION
if !(1 <= attr.result_index <= valueP[])
return MOI.NO_SOLUTION
end
if term in (MOI.OPTIMAL, MOI.SOLUTION_LIMIT)
return MOI.FEASIBLE_POINT
end
# Feasibility of solution is unknown. Check for violations.
doubleP = Ref{Cdouble}()
ret = GRBgetdblattr(model, "MaxVio", doubleP)
_check_ret(model, ret)
if doubleP[] < 1e-8
odow marked this conversation as resolved.
Show resolved Hide resolved
return MOI.FEASIBLE_POINT

Check warning on line 2845 in src/MOI_wrapper/MOI_wrapper.jl

View check run for this annotation

Codecov / codecov/patch

src/MOI_wrapper/MOI_wrapper.jl#L2841-L2845

Added lines #L2841 - L2845 were not covered by tests
end
return MOI.UNKNOWN_RESULT_STATUS

Check warning on line 2847 in src/MOI_wrapper/MOI_wrapper.jl

View check run for this annotation

Codecov / codecov/patch

src/MOI_wrapper/MOI_wrapper.jl#L2847

Added line #L2847 was not covered by tests
odow marked this conversation as resolved.
Show resolved Hide resolved
end

function _has_dual_ray(model::Optimizer)
Expand Down Expand Up @@ -2869,18 +2881,26 @@
valueP = Ref{Cint}()
ret = GRBgetintattr(model, "SolCount", valueP)
_check_ret(model, ret)
if valueP[] == 0
if !(1 <= attr.result_index <= valueP[])
return MOI.NO_SOLUTION
end
# But unfortunately, even if SolCount is 1, sometimes a dual solution is not
# available. The only way to check this is to query directly.
valueP = Ref{Cdouble}()
ret = GRBgetdblattrelement(model, "RC", 0, valueP)
if ret == 0
return MOI.FEASIBLE_POINT
else # Something went wrong
doubleP = Ref{Cdouble}()
odow marked this conversation as resolved.
Show resolved Hide resolved
ret = GRBgetdblattrelement(model, "RC", 0, doubleP)
odow marked this conversation as resolved.
Show resolved Hide resolved
if ret != 0 # Something went wrong
return MOI.NO_SOLUTION
end
if term in (MOI.OPTIMAL, MOI.SOLUTION_LIMIT)
return MOI.FEASIBLE_POINT
end
# Feasibility of solution is unknown. Check for violations.
ret = GRBgetdblattr(model, "MaxVio", doubleP)
_check_ret(model, ret)
if doubleP[] < 1e-8
return MOI.FEASIBLE_POINT

Check warning on line 2901 in src/MOI_wrapper/MOI_wrapper.jl

View check run for this annotation

Codecov / codecov/patch

src/MOI_wrapper/MOI_wrapper.jl#L2898-L2901

Added lines #L2898 - L2901 were not covered by tests
end
return MOI.UNKNOWN_RESULT_STATUS

Check warning on line 2903 in src/MOI_wrapper/MOI_wrapper.jl

View check run for this annotation

Codecov / codecov/patch

src/MOI_wrapper/MOI_wrapper.jl#L2903

Added line #L2903 was not covered by tests
end

function _has_primal_ray(model::Optimizer)
Expand Down
Loading