Variables multiplication with JuMP.jl

Hi all,
I’m trying to multiply three JuMP variables within a function but getting an error:
LoadError: Cannot multiply a quadratic expression by a variable

Here is the simplified version of code:

using JuMP, Ipopt

f(x,u) = x[1] * u[1] * x[2]

model = Model(Ipopt.Optimizer)
n = 20
@variables(model, begin
    0 <= x[1:n] <= 100          
    0<= u[1:n] <= 1
end)

println(f(x,u))

Is there any way to do this kind of multiplication with variables?

Hi there!

Is there any way to do this kind of multiplication with variables?

Use the nonlinear syntax:

Make sure to read the documentation carefully, because there are lots of differences to linear/quadratic syntax.

3 Likes