I am new to Julia, and I am trying to define an optimization problem with JuMP. I have a lot of variables (x1,x2,x3....
) that I am trying to define using a for
loop. I want to have the code:
@variable(m, x1>=0)
@variable(m, x2>=0) ...
However I wanted to use a for
loop so I did not have to define every variable manually.
Here is what I have so far:
m = Model()
for i = 1:2
@variable(m,string('x',i)>=0)
end
I know the string('x',i)
part is not right but I am not sure how to do this using Julia.