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):

```
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…