Repeated indext at optimization problem in JuMP

The two indices attempt to make a rectangular matrix of variables.

But it seems instead that you want one variable for each row, with the key composed of the 4th and 3rd columns?

I think you want this instead:

using JuMP
df_coord_pq = [
    0 0 "0_0" 1
    0 4 "0_4" 1
    4 0 "4_0" 1
    4 4 "4_4" 1
    0 0 "0_0" 2
    4 0 "4_0" 2
    6 0 "6_0" 2
]
model = Model()
S = [(i, p_q) for (i, p_q) in zip(df_coord_pq[:,4], df_coord_pq[:,3])]
@variable(model, x[S], Bin)
@objective(model, Max, sum(x))
x[(2, "6_0")]

Here is a tutorial which explains things in more detail: Getting started with sets and indexing ยท JuMP

1 Like