# Multi-dimensional JuMP variable - setting the name

**URL:** <https://discourse.julialang.org/t/multi-dimensional-jump-variable-setting-the-name/22806>\
**Category:** General Usage\
**Tags:** jump\
**Created:** [April 5, 2019, 4:18pm UTC](https://discourse.julialang.org/t/multi-dimensional-jump-variable-setting-the-name/22806 "2019-04-05T16:18:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sakshi-mishra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sakshi-mishra/32/12975_2.png) [@sakshi-mishra](https://discourse.julialang.org/u/sakshi-mishra)\
**Post date:** [April 5, 2019, 4:18pm UTC](https://discourse.julialang.org/t/multi-dimensional-jump-variable-setting-the-name/22806/1 "2019-04-05T16:18:36Z")

</div>

Creating a JuMP variable using @variable macro in JuMP:  
@variable(model, x[1:87, 1:5, 1:3])

trying to set its name using JuMP.set\_name method.  
Problem:  
able to set the name of one variable in this multi-dimensional variable set using:  
JuMP.set\_name(x[2,1,4], “multiD decision variable”)

but not set this same name for all the variables in this variable set:  
JuMP.set\_name(x, “multiD decision variable”)

error message:  
MethodError: no method matching set\_name(::Array{VariableRed,3}, ::String)

How can this (setting a name for the whole Julia variable x which is bound to all the JuMP variable in the container) be accomplished?

---

<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:** [April 5, 2019, 4:47pm UTC](https://discourse.julialang.org/t/multi-dimensional-jump-variable-setting-the-name/22806/2 "2019-04-05T16:47:11Z")

</div>

Maybe something like:

```julia
m = Model()
@variable(m, x[1:10])
for i in 1:10
    set_name(x[i], "my_var")
end

```

Why do you want to name all the variables to be the same?

---

<div class="post-metadata">

**Author:** ![sakshi-mishra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sakshi-mishra/32/12975_2.png) [@sakshi-mishra](https://discourse.julialang.org/u/sakshi-mishra)\
**Post date:** [April 5, 2019, 5:20pm UTC](https://discourse.julialang.org/t/multi-dimensional-jump-variable-setting-the-name/22806/3 "2019-04-05T17:20:54Z")

</div>

This is helpful. Thank you.

For the energy optimization problem I am working on, all the decision variables for the given Julia variable are the same (e.g. like hourly production from a technology).
