Hi,
As the title says, I’m getting an error trying to create an array of quadratic expressions in JuMP. I’m using julia v1.1.0 and JuMP v0.20.1. Minimal example:
using JuMP
model = Model()
@variables(model, begin
0 <= x[1:3] <= 30, Int
end)
c = [1,2]
@expression(model, q_expr[k=1:2], sum([sum([x[i]*x[j]*c[k] for i in 1:3]) for j in 1:3]))
This produces the output
julia> @expression(model, q_expr[k=1:2], sum([sum([x[i]*x[j]*c[k] for i in 1:3]) for j in 1:3]))
ERROR: Collection of expressions with @expression must be linear. For quadratic expressions, use your own array.
I don’t understand the error message here. In contrast,
julia> @expression(model, q_expr, sum([sum([x[i]*x[j]*c[1] for i in 1:3]) for j in 1:3]))
x[1]² + 2 x[1]*x[2] + 2 x[1]*x[3] + x[2]² + 2 x[2]*x[3] + x[3]²
works just fine. Any hope there’s a quick fix/workaround?