# Convert model with anonymous variables to "readable" form

**URL:** <https://discourse.julialang.org/t/convert-model-with-anonymous-variables-to-readable-form/36594>\
**Category:** Optimization (Mathematical)\
**Created:** [March 27, 2020, 12:30pm UTC](https://discourse.julialang.org/t/convert-model-with-anonymous-variables-to-readable-form/36594 "2020-03-27T12:30:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![richard046](https://avatars.discourse-cdn.com/v4/letter/r/f07891/32.png) [@richard046](https://discourse.julialang.org/u/richard046)\
**Post date:** [March 27, 2020, 12:30pm UTC](https://discourse.julialang.org/t/convert-model-with-anonymous-variables-to-readable-form/36594/1 "2020-03-27T12:30:33Z")

</div>

Hello,

I have a code(written by others) that builds a JuMP model, but I can’t see what are the constraints, becouse it has \_\_anon\_\_ variables, like this:

Min \_\_anon\_\_ + \_\_anon\_\_  
Subject to  
\_\_anon\_\_ - \_\_anon\_\_ == 0.5  
\_\_anon\_\_ - \_\_anon\_\_ == 0.5  
\_\_anon\_\_ - 1000 \_\_anon\_\_ + 800 \_\_anon\_\_ \<= 0  
\_\_anon\_\_ - 1000 \_\_anon\_\_ \>= -800  
…  
Is it possible to create a model with named variables from this?

---

<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:** [March 27, 2020, 1:02pm UTC](https://discourse.julialang.org/t/convert-model-with-anonymous-variables-to-readable-form/36594/2 "2020-03-27T13:02:43Z")

</div>

```nohighlight
for (i, x) in enumerate(all_variables(model))
    set_name(x, "v$(i)")
end
```

---

<div class="post-metadata">

**Author:** ![richard046](https://avatars.discourse-cdn.com/v4/letter/r/f07891/32.png) [@richard046](https://discourse.julialang.org/u/richard046)\
**Post date:** [March 27, 2020, 1:56pm UTC](https://discourse.julialang.org/t/convert-model-with-anonymous-variables-to-readable-form/36594/3 "2020-03-27T13:56:20Z")

</div>

I get ERROR: UndefVarError: all\_variables not defined. This applies to the other methods on the [Variables · JuMP](http://www.juliaopt.org/JuMP.jl/dev/variables/) site like lower\_bound(), num\_variables() etc.

---

<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:** [March 27, 2020, 2:04pm UTC](https://discourse.julialang.org/t/convert-model-with-anonymous-variables-to-readable-form/36594/4 "2020-03-27T14:04:31Z")

</div>

1. You need JuMP 0.20 or 0.21.
2. If you have `import JuMP`, you need to prefix `JuMP.all_variables`. Alternatively, use `using JuMP`.

---

<div class="post-metadata">

**Author:** ![richard046](https://avatars.discourse-cdn.com/v4/letter/r/f07891/32.png) [@richard046](https://discourse.julialang.org/u/richard046)\
**Post date:** [March 27, 2020, 2:24pm UTC](https://discourse.julialang.org/t/convert-model-with-anonymous-variables-to-readable-form/36594/5 "2020-03-27T14:24:23Z")

</div>

for some reason it installs 0.18, tried updating,removing and reinstalling, nothing  
edit: it seems like ConditionalJuMP won’t allow higher version of JuMP

---

<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:** [March 27, 2020, 2:29pm UTC](https://discourse.julialang.org/t/convert-model-with-anonymous-variables-to-readable-form/36594/6 "2020-03-27T14:29:34Z")

</div>

Correct. ConditionalJuMP has not been updated. There’s an open issue: [JuMP v0.19 support · Issue #48 · rdeits/ConditionalJuMP.jl · GitHub](https://github.com/rdeits/ConditionalJuMP.jl/issues/48). It looks like they need some help.
