# Parameter support is broken used with direct\_model

**URL:** <https://discourse.julialang.org/t/parameter-support-is-broken-used-with-direct-model/115266>\
**Category:** Optimization (Mathematical)\
**Created:** [June 6, 2024, 3:31am UTC](https://discourse.julialang.org/t/parameter-support-is-broken-used-with-direct-model/115266 "2024-06-06T03:31:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![metab0t](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/metab0t/32/15551_2.png) [@metab0t](https://discourse.julialang.org/u/metab0t)\
**Post date:** [June 6, 2024, 3:31am UTC](https://discourse.julialang.org/t/parameter-support-is-broken-used-with-direct-model/115266/1 "2024-06-06T03:31:34Z")

</div>

```julia
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`

```julia
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

```

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [June 6, 2024, 3:47am UTC](https://discourse.julialang.org/t/parameter-support-is-broken-used-with-direct-model/115266/2 "2024-06-06T03:47:27Z")

</div>

This is a bug in Ipopt.jl: [MOI.is\_valid is wrong for parameter constraints · Issue #414 · jump-dev/Ipopt.jl · GitHub](https://github.com/jump-dev/Ipopt.jl/issues/414)

Fix incoming: [Fix MOI.is\_valid for ConstraintIndex{VariableIndex,Parameter} by odow · Pull Request #415 · jump-dev/Ipopt.jl · GitHub](https://github.com/jump-dev/Ipopt.jl/pull/415)
