Multi-dimensional JuMP variable - setting the name

jump
#1

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?

0 Likes

#2

Maybe something like:

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?

0 Likes

#3

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).

0 Likes