# Unable to set\_optimizer\_attribute in BilevelJuMP.jl

**URL:** <https://discourse.julialang.org/t/unable-to-set-optimizer-attribute-in-bileveljump-jl/80240>\
**Category:** Optimization (Mathematical)\
**Tags:** question, package\
**Created:** [April 29, 2022, 6:31am UTC](https://discourse.julialang.org/t/unable-to-set-optimizer-attribute-in-bileveljump-jl/80240 "2022-04-29T06:31:46Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![math\_opt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/math_opt/32/25317_2.png) [@math\_opt](https://discourse.julialang.org/u/math_opt)\
**Post date:** [April 29, 2022, 6:31am UTC](https://discourse.julialang.org/t/unable-to-set-optimizer-attribute-in-bileveljump-jl/80240/1 "2022-04-29T06:31:46Z")

</div>

I am trying to change the `MIPGap` parameter for Guorbi:

```julia
using JuMP, Gurobi, BilevelJuMP

model = BilevelModel(Gurobi.Optimizer, mode = BilevelJuMP.SOS1Mode())
set_optimizer_attribute(model, "MIPGap", 1e-5)

```

Throws error:

```julia
Error: UndefVarError: RawParameter not defined

```

What’s the cause? Any help is appreciated. Thank you.

Julia 1.6.1  
Package versions:  
Gurobi v0.11.1  
JuMP v1.0.0  
BilevelJuMP v0.5.0

---

<div class="post-metadata">

**Author:** ![jd-foster](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jd-foster/32/35824_2.png) [@jd-foster](https://discourse.julialang.org/u/jd-foster)\
**Post date:** [April 29, 2022, 7:32am UTC](https://discourse.julialang.org/t/unable-to-set-optimizer-attribute-in-bileveljump-jl/80240/2 "2022-04-29T07:32:11Z")

</div>

The symbol `RawParameter` has now been changed to `RawOptimizerAttribute` in new versions of JuMP.

Where does the error actually occur?

---

<div class="post-metadata">

**Author:** ![math\_opt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/math_opt/32/25317_2.png) [@math\_opt](https://discourse.julialang.org/u/math_opt)\
**Post date:** [April 29, 2022, 8:04am UTC](https://discourse.julialang.org/t/unable-to-set-optimizer-attribute-in-bileveljump-jl/80240/3 "2022-04-29T08:04:54Z")

</div>

@jd-foster This is the full stack trace. Apparently, it seems to occur in BilevelJuMP.

```julia
ERROR: UndefVarError: RawParameter not defined
Stacktrace:
 [1] set_optimizer_attribute(bm::BilevelModel, name::String, value::Float64)
   @ BilevelJuMP C:\Users\math_opt\.julia\packages\BilevelJuMP\re5gQ\src\jump_attributes.jl:10
 [2] top-level scope
   @ REPL[3]:1

```

Any clue on how to get around this? Thanks!

---

<div class="post-metadata">

**Author:** ![math\_opt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/math_opt/32/25317_2.png) [@math\_opt](https://discourse.julialang.org/u/math_opt)\
**Post date:** [April 29, 2022, 8:08am UTC](https://discourse.julialang.org/t/unable-to-set-optimizer-attribute-in-bileveljump-jl/80240/4 "2022-04-29T08:08:05Z")

</div>

> <https://github.com/joaquimg/BilevelJuMP.jl/blob/b3aa45b2a48b466007c9344e64664dc8515d2d5c/src/jump_attributes.jl#L10>

Replacing `MOI.RawParameter(name)` with `MOI.RawOptimizerAttribute(name)` should work?

---

<div class="post-metadata">

**Author:** ![math\_opt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/math_opt/32/25317_2.png) [@math\_opt](https://discourse.julialang.org/u/math_opt)\
**Post date:** [April 29, 2022, 8:22am UTC](https://discourse.julialang.org/t/unable-to-set-optimizer-attribute-in-bileveljump-jl/80240/5 "2022-04-29T08:22:12Z")

</div>

Apparently there is a recent [pull request](https://github.com/joaquimg/BilevelJuMP.jl/pull/175) for the same issue.  
@joaquimg Any plans on merging the PR anytime soon? Or should I manually make the changes in my locally installed BilevelJuMP package for now? 😅  
Thanks a lot!

---

<div class="post-metadata">

**Author:** ![joaquimg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joaquimg/32/223_2.png) [@joaquimg](https://discourse.julialang.org/u/joaquimg)\
**Post date:** [April 30, 2022, 8:12pm UTC](https://discourse.julialang.org/t/unable-to-set-optimizer-attribute-in-bileveljump-jl/80240/6 "2022-04-30T20:12:43Z")

</div>

Just released BilevelJuMP 0.5.1 with this fix.

---

<div class="post-metadata">

**Author:** ![math\_opt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/math_opt/32/25317_2.png) [@math\_opt](https://discourse.julialang.org/u/math_opt)\
**Post date:** [May 1, 2022, 4:49am UTC](https://discourse.julialang.org/t/unable-to-set-optimizer-attribute-in-bileveljump-jl/80240/7 "2022-05-01T04:49:18Z")

</div>

Works perfectly now. Thanks! 🙂
