Skip to content

Commit ac44d67

Browse files
authored
Fix issue 287 (#288)
1 parent 7a33052 commit ac44d67

File tree

2 files changed

+29
-19
lines changed

2 files changed

+29
-19
lines changed

src/MOI_wrapper.jl

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2077,22 +2077,6 @@ function _store_solution(model::Optimizer, ret::HighsInt)
20772077
resize!(x.rowdual, numRows)
20782078
x.model_status = Highs_getModelStatus(model)
20792079
statusP = Ref{HighsInt}()
2080-
certificates = MOI.get(model, ComputeInfeasibilityCertificate())
2081-
if certificates && x.model_status == kHighsModelStatusInfeasible
2082-
ret = Highs_getDualRay(model, statusP, x.rowdual)
2083-
# Don't `_check_ret(ret)` here, just bail is there isn't a dual ray.
2084-
x.has_dual_ray = (ret == kHighsStatusOk) && (statusP[] == 1)
2085-
if x.has_dual_ray
2086-
_compute_farkas_variable_dual(model, x.coldual)
2087-
end
2088-
elseif certificates && x.model_status == kHighsModelStatusUnbounded
2089-
ret = Highs_getPrimalRay(model, statusP, x.colvalue)
2090-
# Don't `_check_ret(ret)` here, just bail is there isn't a dual ray.
2091-
x.has_primal_ray = (ret == kHighsStatusOk) && (statusP[] == 1)
2092-
end
2093-
if x.has_dual_ray || x.has_primal_ray
2094-
return # If a ray is present, we don't query the solution
2095-
end
20962080
Highs_getIntInfoValue(model, "primal_solution_status", statusP)
20972081
x.primal_solution_status = statusP[]
20982082
Highs_getIntInfoValue(model, "dual_solution_status", statusP)
@@ -2106,6 +2090,25 @@ function _store_solution(model::Optimizer, ret::HighsInt)
21062090
Highs_getBasis(model, x.colstatus, x.rowstatus)
21072091
end
21082092
end
2093+
if !MOI.get(model, ComputeInfeasibilityCertificate())
2094+
return
2095+
end
2096+
if x.model_status == kHighsModelStatusInfeasible
2097+
ret = Highs_getDualRay(model, statusP, x.rowdual)
2098+
# Don't `_check_ret(ret)` here, just bail is there isn't a dual ray.
2099+
x.has_dual_ray = (ret == kHighsStatusOk) && (statusP[] == 1)
2100+
if x.has_dual_ray
2101+
_compute_farkas_variable_dual(model, x.coldual)
2102+
x.dual_solution_status = kHighsSolutionStatusNone
2103+
end
2104+
elseif x.model_status == kHighsModelStatusUnbounded
2105+
ret = Highs_getPrimalRay(model, statusP, x.colvalue)
2106+
# Don't `_check_ret(ret)` here, just bail is there isn't a dual ray.
2107+
x.has_primal_ray = (ret == kHighsStatusOk) && (statusP[] == 1)
2108+
if x.has_primal_ray
2109+
x.primal_solution_status = kHighsSolutionStatusNone
2110+
end
2111+
end
21092112
return
21102113
end
21112114

test/MOI_wrapper.jl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -870,11 +870,8 @@ function test_infeasible_point()
870870
MOI.optimize!(model)
871871
@test MOI.get(model, MOI.TerminationStatus()) == MOI.INFEASIBLE
872872
@test MOI.get(model, MOI.PrimalStatus()) == MOI.INFEASIBLE_POINT
873-
dual_stat = MOI.get(model, MOI.DualStatus())
874-
@test dual_stat in (MOI.INFEASIBLE_POINT, MOI.NO_SOLUTION)
875873
@test MOI.get(model, MOI.ResultCount()) == 1
876874
@test MOI.get(model, MOI.VariablePrimal(), x) isa Vector{Float64}
877-
@test MOI.get(model, MOI.ConstraintDual(), ci) isa Float64
878875
return
879876
end
880877

@@ -1178,6 +1175,16 @@ function test_ConstraintName()
11781175
return
11791176
end
11801177

1178+
function test_issue_287()
1179+
model = HiGHS.Optimizer()
1180+
x, _ = MOI.add_constrained_variable(model, MOI.ZeroOne())
1181+
MOI.add_constraint(model, 1.0 * x, MOI.EqualTo(0.5))
1182+
MOI.optimize!(model)
1183+
@test MOI.get(model, MOI.TerminationStatus()) == MOI.INFEASIBLE
1184+
@test MOI.get(model, MOI.PrimalStatus()) == MOI.NO_SOLUTION
1185+
return
1186+
end
1187+
11811188
end # module
11821189

11831190
TestMOIHighs.runtests()

0 commit comments

Comments
 (0)