# Is there a Symbolics.jl interface to Ipopt (or similar)?

**URL:** <https://discourse.julialang.org/t/is-there-a-symbolics-jl-interface-to-ipopt-or-similar/100149>\
**Category:** Modelling & Simulations\
**Tags:** nlp, ipopt, modelling\
**Created:** [June 10, 2023, 8:22pm UTC](https://discourse.julialang.org/t/is-there-a-symbolics-jl-interface-to-ipopt-or-similar/100149 "2023-06-10T20:22:51Z")\
**Posts on this page:** 1\
**Showing post:** 17

<div class="post-metadata">

**Author:** ![votroto](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/votroto/32/224436_2.png) [@votroto](https://discourse.julialang.org/u/votroto)\
**Post date:** [June 14, 2023, 10:04pm UTC](https://discourse.julialang.org/t/is-there-a-symbolics-jl-interface-to-ipopt-or-similar/100149/17 "2023-06-14T22:04:23Z")

</div>

Odow, JuMP cannot directly send DynamicPolynomials or Symbolics to Ipopt, can it?

But even in static cases, let’s say your example is closer to (This example is made up and has no meaning):

```julia
using ModelingToolkit, OptimizationMOI, Ipopt
ADPARAMS = (;grad = true, hess = true, cons_j = true, cons_h = true)

f(p, q) = (1 / sqrt(2π)) * exp(-((p - q)^2) / 2)
total(p, q) = sum(_p * f(i, q) for (i, _p) in enumerate(p))
l1(p, q) = 1 - total(p, q) + 0.5 * total(p, 0.5)
l2(p, q) = total(p, q) - 1
lhs(p, q, _q) = l1(p, q) - l1(p, _q)

function approximate(Q)
    @variables p[1:5] [bounds = (-2.0, 2.0)]
    @variables w [bounds = (-1.0, 3.0)] 
    @variables q [bounds = (-1.0, 3.0)]
    variables = [p; w; q]

    constraints = [w*lhs(p, q, _q) + (1-w)*l2(p, q) ≲ 0 for _q in Q]
    @named os = OptimizationSystem(w, variables, []; constraints)
    prob = OptimizationProblem(os, randn(length(variables)); ADPARAMS...)
    return solve(prob, Ipopt.Optimizer())
end

approximate(-0.8:0.4:0.8)

```

I always struggle in JuMP to model NLPs involving arrays, summations, polynomials, custom multi-argument functions etc. Maybe I’m doing it wrong, idk…

---

_[View the full topic](https://discourse.julialang.org/t/is-there-a-symbolics-jl-interface-to-ipopt-or-similar/100149)._
