Skip to content

Commit 23596e6

Browse files
authored
Fix computing primal status with a VectorNonlinearOracle (#511)
1 parent cf20541 commit 23596e6

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

ext/IpoptMathOptInterfaceExt/MOI_wrapper.jl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1466,14 +1466,19 @@ end
14661466

14671467
function _manually_evaluated_primal_status(model::Optimizer)
14681468
x, g = model.inner.x, model.inner.g
1469-
m, n = length(g), length(x)
14701469
x_L, x_U = model.variables.lower, model.variables.upper
14711470
g_L, g_U = copy(model.qp_data.g_L), copy(model.qp_data.g_U)
1472-
# Assuming constraints are guaranteed to be in the order [qp_cons, nlp_cons]
1471+
# Assuming constraints are guaranteed to be in the order:
1472+
# [qp_cons, nlp_cons, oracle]
14731473
for bound in model.nlp_data.constraint_bounds
14741474
push!(g_L, bound.lower)
14751475
push!(g_U, bound.upper)
14761476
end
1477+
for (_, cache) in model.vector_nonlinear_oracle_constraints
1478+
append!(g_L, cache.set.l)
1479+
append!(g_U, cache.set.u)
1480+
end
1481+
m, n = length(g_L), length(x)
14771482
# 1e-8 is the default tolerance
14781483
tol = get(model.options, "tol", 1e-8)
14791484
if all(x_L[i] - tol <= x[i] <= x_U[i] + tol for i in 1:n) &&

test/MOI_wrapper.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -936,6 +936,9 @@ function test_vector_nonlinear_oracle()
936936
@test 0.9 < cache.eval_jacobian_timer < 4
937937
@test 0.9 < cache.eval_hessian_lagrangian_timer < 2
938938
end
939+
MOI.set(model, MOI.RawOptimizerAttribute("max_iter"), 0)
940+
MOI.optimize!(model)
941+
@test MOI.get(model, MOI.PrimalStatus()) == MOI.INFEASIBLE_POINT
939942
return
940943
end
941944

0 commit comments

Comments
 (0)