-
Notifications
You must be signed in to change notification settings - Fork 7
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
Invalid variable ordering with old nonlinear interface #146
Comments
Smaller example is julia> using JuMP, Ipopt
julia> import ParametricOptInterface as POI
julia> function main()
model = Model(() -> POI.Optimizer(Ipopt.Optimizer()))
@variable(model, z in Parameter(0))
@variable(model, x)
@NLobjective(model, Min, x)
optimize!(model)
end
main (generic function with 1 method)
julia> main()
This is Ipopt version 3.14.14, running with linear solver MUMPS 5.6.2.
Number of nonzeros in equality constraint Jacobian...: 0
Number of nonzeros in inequality constraint Jacobian.: 0
Number of nonzeros in Lagrangian Hessian.............: 0
ERROR: BoundsError: attempt to access 1-element Vector{Float64} at index [2]
Stacktrace:
[1] getindex
@ ./essentials.jl:13 [inlined]
[2] _forward_eval(f::MathOptInterface.Nonlinear.ReverseAD._FunctionStorage, d::MathOptInterface.Nonlinear.ReverseAD.NLPEvaluator, x::Vector{…}) This looks like a mismatch caused by shuffling the variable indices with I don't think there is a simple fix for this. The But you can switch to the new nonlinear interface: julia> function main_expr()
model = Model(() -> POI.Optimizer(Ipopt.Optimizer()))
set_silent(model)
@variable(model, z in Parameter(10.0))
@variable(model, x)
@variable(model, y)
@constraint(model, x >= z)
@constraint(model, x + y >= z)
@objective(model, Min, x^2 + y^2)
optimize!(model)
@show objective_value(model)
set_parameter_value(z, 2.0)
optimize!(model)
@show objective_value(model)
return
end
main_expr (generic function with 1 method)
julia> main_expr()
objective_value(model) = 99.99999800270126
objective_value(model) = 3.999999926847757 but if you're using Ipopt, it supports julia> function main_ipopt()
model = Model(Ipopt.Optimizer)
set_silent(model)
@variable(model, z in Parameter(10.0))
@variable(model, x)
@variable(model, y)
@constraint(model, x >= z)
@constraint(model, x + y >= z)
@objective(model, Min, x^2 + y^2)
optimize!(model)
@show objective_value(model)
set_parameter_value(z, 2.0)
optimize!(model)
@show objective_value(model)
return
end
main_ipopt (generic function with 1 method)
julia> main_ipopt()
objective_value(model) = 99.99999980286509
objective_value(model) = 3.999999962453093 |
Perhaps |
That makes sense. Without using The minimum working case is a bit convoluted but simple to run.
|
Ah. We probably need to throw an error if parameters are combined with the old nonlinear API. I don't know if that is tested. |
See jump-dev/Ipopt.jl#406. You just can't mix the two. |
I am trying to get the dual of the parameter when using Ipopt but failing miserably. Modifying @odow example a little bit:
I get (as expected) the error:
But none of these work (e.g., In POI I normally run: But Ipopt is not currently working with POI on a non-linear problem. If I set the solver like:
I get:
But I am a bit lost on where to start to solve this. |
Could and should I try implementing something like the ParametricOptInterface.jl/src/duals.jl Line 96 in 4ec565a
|
MathOptInterface does not support computing the dual of a |
I changed the parameters that I need the dual to a constraint instead but I think this breaks POI:
I am avoiding the |
To get the dual of a particular parameter, you really need to use |
I have found an error when modifying one of the test cases:
If a parameter is created before the other variables, the model errors when optimizing.
This errors, while the following doesn't:
The text was updated successfully, but these errors were encountered: