I’m having trouble using matrices in an NLobjective
model = Model()
@variable(model, 0 .<= x[1:100, 1:100] .<= 1)
@NLexpression(model,x_con[ii=1:100, jj=1:100], x[ii,jj] * abs(x[ii,jj]))
This works
@NLobjective(model, Min, sum(x_con[ii] for ii in 1:100*100))
while this gives
julia> @NLobjective(model, Min, sum(x_con[ii,jj] for ii in 1:100 for jj in 1:100))
ERROR: UndefVarError: jj not defined
Stacktrace:
[1] macro expansion
@ ~/.julia/packages/JuMP/gVq7V/src/macros.jl:1834 [inlined]
[2] top-level scope
@ REPL[6]:1
I appreciate these are doing the same thing, but it could be helpful for matrix sums to work.