Parameter support is broken used with direct_model

using JuMP, Ipopt

model = direct_model(Ipopt.Optimizer());
set_silent(model)


x = @variable(model, lower_bound = 0.0)
@variable(model, p in Parameter(1.0), set_string_name=false)
@objective(model, Min, x^2)
con = @constraint(model, x - p >= 0)


optimize!(model)
set_parameter_value(p, 5.0)
optimize!(model)

It throws error when calling set_parameter_value

ERROR: LoadError: Variable _[67553994410557440] is not a parameter.
Stacktrace:
 [1] error(s::String)
   @ Base .\error.jl:35
 [2] ParameterRef
   @ C:\Users\yangyue\.julia\packages\JuMP\Gwn88\src\variables.jl:1617 [inlined]
 [3] set_parameter_value(x::VariableRef, value::Float64)
   @ JuMP C:\Users\yangyue\.julia\packages\JuMP\Gwn88\src\variables.jl:1689
 [4] top-level scope
   @ E:\codeworkspace\julia_try\nlp_param\t.jl:14
 [5] include(fname::String)
   @ Base.MainInclude .\client.jl:489
 [6] top-level scope
   @ REPL[2]:1
1 Like

This is a bug in Ipopt.jl: MOI.is_valid is wrong for parameter constraints · Issue #414 · jump-dev/Ipopt.jl · GitHub

Fix incoming: Fix MOI.is_valid for ConstraintIndex{VariableIndex,Parameter} by odow · Pull Request #415 · jump-dev/Ipopt.jl · GitHub