Have you benchmarked the different forms? I would assume this depends on the sparsity of r
and c
.
I would do:
using JuMP, SparseArrays
model = Model()
@variable(model, x[1:101, 1:170])
X = 1.0 .* x
r = SparseArrays.sprand(101, 0.1)
c = SparseArrays.sprand(170, 0.1)
# @constraint(model, r' * X * c >= 0)
(r_I, r_V), (c_I, c_V) = SparseArrays.findnz(r), SparseArrays.findnz(c)
@constraint(
model,
sum(
r_v * X[r_i, c_i] * c_v for
(c_i, c_v) in zip(c_I, c_V), (r_i, r_v) in zip(r_I, r_V)
) >= 0
)