# Converting Expr into constr

**URL:** <https://discourse.julialang.org/t/converting-expr-into-constr/6589>\
**Category:** Optimization (Mathematical)\
**Tags:** question\
**Created:** [October 20, 2017, 10:00pm UTC](https://discourse.julialang.org/t/converting-expr-into-constr/6589 "2017-10-20T22:00:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wikunia](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wikunia/32/2180_2.png) [@Wikunia](https://discourse.julialang.org/u/Wikunia)\
**Post date:** [October 20, 2017, 10:00pm UTC](https://discourse.julialang.org/t/converting-expr-into-constr/6589/1 "2017-10-20T22:00:16Z")

</div>

I would like to do something simple as that

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

```

Looks like this:

```julia
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.

---

<div class="post-metadata">

**Author:** ![Wikunia](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wikunia/32/2180_2.png) [@Wikunia](https://discourse.julialang.org/u/Wikunia)\
**Post date:** [October 20, 2017, 11:25pm UTC](https://discourse.julialang.org/t/converting-expr-into-constr/6589/2 "2017-10-20T23:25:26Z")

</div>

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](https://github.com/lanl-ansi/POD.jl/blob/6b6f1dab7775d71f218d5a36937c3bb5aff9120e/src/nlexpr.jl#L233-L247)
