Hi people,

Can I formulate an expression in Julia and use an integer variable as an index of an input matrix?

@variable(m, 1 <= t[1:3, 1:3] <= 8, Int)

P = [ 90 80 60 70 50 30 10 0]

for i = 1:3

for j = 1:3

M[i,j] = P[t[i,j]] # M is a matrix 3x3 filled with P values based on t indices

end

end

and I am using M in an expression for optimization.

Thank you in advance!