-
Notifications
You must be signed in to change notification settings - Fork 94
[Test] Minor fixes in nonlinear tests #1599
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
Conversation
- NLPBlockDual: Check correctness of dual variables with KKT stationarity condition - Fix issue in definition of FeasibilityEvaluator - Nonlinear tests now passes with Knitro
I just fixed an issue with the sign when the sense is set to I am not sure to understand the issue with the
The problem is a bit obscure to me. If I comment out these lines, then I don't get an error (but test is breaking because by default |
Try adding this MathOptInterface.jl/src/Test/test_variable.jl Lines 219 to 220 in ddbb343
|
Indeed, it looks better now. The test has been modified to include the dual solutions for the variable constraints as well: MOI.Utilities.mock_optimize!(
mock,
config.optimal_status,
[
1.1,
1.5735520521364397,
2.6746837915674373,
5.4,
],
(MOI.VariableIndex, MOI.GreaterThan{Float64}) =>
[28.590703804861093, 0.0, 0.0, 0.0],
(MOI.VariableIndex, MOI.LessThan{Float64}) =>
[0.0, 0.0, 0.0, -5.582550550234756],
)
MOI.set(mock, MOI.NLPBlockDual(), [0.178761800, 0.985000823]) (the primal and dual values are computed with Ipopt). Without the two lines you pointed me before: model.eval_variable_constraint_dual = false
return () -> model.eval_variable_constraint_dual = true the test is breaking again. But I am not sure to understand what these two lines are doing exactly. |
See the formatting failure. The two lines are just some magic that we need for the mock optimizer. It's a bit of a pain to remember to add it, but it's not user-facing. |
Minor fixes to make the nonlinear tests pass both with Knitro and MadNLP.
NLPBlockDual
: Check correctness of dual variables directly with KKT stationary conditionAs the problem HS071 is nonconvex, solvers can return a different values than the one previously specified in
test_nonlinear_hs071_NLPBlockDual
:For instance, both Knitro and MadNLP return
[0.0, 0.4058829]
there. Using directly the KKT stationary condition avoids this problem.FeasibilitySenseEvaluator
When using the
FeasibilitySenseEvaluator
, we test that the primal variable returned is equal to 1:However, this is inconsistent with the definition of the upper and lower bounds:
Indeed, the constraint specified inside the
FeasibilitySenseEvaluator
is then1 <= x^2 <= 2
, andx
can be any value between1.0
andsqrt(2)
(or-sqrt(2)
and-1.0
). To avoid this, we change the upper bound to1.0
so the constraint now specified isx^2 == 1.0
, consistent with theFeasibilitySenseEvaluator
's docstring: