Skip to content

Commit 93cc698

Browse files
authored
Fix sign errors in Farkas dual when solution is degenerate (#161)
1 parent 6c8fb69 commit 93cc698

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/MOI_wrapper/infeasibility_certificates.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,15 @@ function _get_infeasibility_ray(model::Optimizer, ray::Vector{Float64})
4040
if unbounded_index == 0
4141
return false # Something went wrong finding an unbounded ray.
4242
end
43-
primal = if unbounded_index <= m
44-
glp_get_row_prim(model, unbounded_index)
43+
# If the primal value exceeds the upper bound, then the unbounded_index
44+
# wants to increase. Otherwise, it must want to decrease.
45+
scale = if unbounded_index <= m
46+
primal = glp_get_row_prim(model, unbounded_index)
47+
primal > glp_get_row_ub(model, unbounded_index) ? 1 : -1
4548
else
46-
glp_get_col_prim(model, unbounded_index - m)
49+
primal = glp_get_col_prim(model, unbounded_index - m)
50+
primal > glp_get_col_ub(model, unbounded_index - m) ? 1 : -1
4751
end
48-
scale = xor(glp_get_obj_dir(model) == GLP_MAX, primal > 0) ? -1 : 1
4952
if unbounded_index <= m
5053
ray[unbounded_index] = scale
5154
end

0 commit comments

Comments
 (0)