Sparse variables in JuMP

Hi all,

I’m facing a nice large problem and I would like to reduce the model by creating only the needed variables.

Is there anything close to:

@variable(model, x[u in 1:n, v in 1:n; if c[u,v] > 0.0], Bin)

I get the following message:

@variable(model, x[u in 1:n, v in 1:n; if c[u,v] > 0.0], Bin); 
#                                                     ╙ ── unexpected `]`

Thanks for your support.
M.

1 Like

Hi, you probably want:

@variable(model, x[u in 1:n, v in 1:n; c[u,v] > 0.0], Bin)
1 Like

Hi Marc, see this part of the documentation: