Converting Expr into constr

I would like to do something simple as that

constr_expr = MathProgBase.constr_expr(m.d,i)
JuMP.addconstraint(m.model, constr_expr)

Looks like this:

JuMP.addNLconstraint(m, :($(x[1])*$(x[2])*$(x[3])*$(x[4]) >= 25))

would work but I don’t have the $ version of x inside constr_expr.

Getting a constraint and applying it to a model.
It doesn’t work because constr_expr is of type Expr which isn’t supported.

Never worked with Expr so I’m a bit stuck.

Thanks in advance.

If someone else has the problem:

I found a solution here:
https://github.com/lanl-ansi/POD.jl/blob/6b6f1dab7775d71f218d5a36937c3bb5aff9120e/src/nlexpr.jl#L233-L247

1 Like