# JuMP @Variable

Hi,
I am solving an optimization problem with jump using the following table:

``````Row │ time  room_1   room_2   room_3   w_day
│ Float64  Float64  Float64  Float64  String
─────┼─────────────────────────────────────────────
1 │    10.0      2.0      1.0      5.0  Monday
2 │    11.0      3.0      1.0      6.0  Monday

``````

I need to create a binary variable x[time,room,w_day], my problem is that for time 10 I can only have courses 2, 1 and 5. that would get me x[10,2,Monday], x[10,1,Monday] and x[10,5,Monday].
Usually I make the variable, like:

``````@variable(model, x[10,[1,2,5],"Monday"], Bin)
``````

But JuMP is interpreting the string as a list of strings and giving me the following:

``````x[10,1,M] binary
x[10,2,M] binary
x[10,5,M] binary
x[10,1,o] binary
x[10,2,o] binary
x[10,5,o] binary
x[10,1,n] binary
x[10,2,n] binary
x[10,5,n] binary
x[10,1,d] binary
x[10,2,d] binary
``````

What am I doing wrong?
Thank you!

JuMP interprets `"Monday"` as an index set (it’s an iterable object). If you want a one-element set, write `["Monday"]` instead, i.e., `@variable(model, x[10,[1,2,5],["Monday"]], Bin)`.

3 Likes

Thank you! I knew I was missing something.

1 Like