Hello,
I am trying to reproduce a model from a mosel file in JuMP. The mosel file uses a loop to iteratively define variables at specific indices. However, in JuMP, it seems I can’t find how to add variables with the same name but at different indices.
forall(j in 2..N-2, p in j+1..N-1, q in p+1..N) do
create(y(j,p,q)); y(j,p,q) is_binary;
create(y(p,j,q)); y(p,j,q) is_binary;
create(y(q,j,p)); y(q,j,p) is_binary;
y(j,p,q)+y(p,j,q)+y(q,j,p)=1
end-do
The last line creates a constraint, that I can do in another @constraint
macro. I tried this:
idxs = [(j,p,q) for j in TAXA[1:end-2], p in TAXA[1:end-1], q in TAXA if p>j && q>p]
@variable(model, y[(j,p,q) in idxs], Bin)
@variable(model, y[(p,j,q) in idxs], Bin)
@variable(model, y[(q,j,p) in idxs], Bin)
but it says y is already registered.