# Nonlinear Optimization with Many Constraints + Autodifferentiation: Which Julia Solution?

**URL:** https://discourse.julialang.org/t/nonlinear-optimization-with-many-constraints-autodifferentiation-which-julia-solution/110678
**Category:** Optimization (Mathematical)
**Tags:** jump, ipopt, nonlinear-optimizati
**Created:** [February 24, 2024, 12:00am UTC](https://discourse.julialang.org/t/nonlinear-optimization-with-many-constraints-autodifferentiation-which-julia-solution/110678 "2024-02-24T00:00:30Z")
**Posts on this page:** 1
**Showing post:** 10

<div class="post-metadata">

### Author: ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)
#### Post date: [February 24, 2024, 9:02pm UTC](https://discourse.julialang.org/t/nonlinear-optimization-with-many-constraints-autodifferentiation-which-julia-solution/110678/10 "2024-02-24T21:02:38Z")

</div>

> [@SebKrantz](#):
>
> This example works, but it seems it is hard-coding the values of auxdata in the constraints.

I think you could directly do

```julia
@constraint(model, auxdata * x[1:n] .<= 0)

```

to avoid closures over global variables.

> [@SebKrantz](#):
>
> My real constraints function is significantly more complex

One of the things I like about JuMP is that it lets you add tons of small constraints instead of a single big one. So maybe if your function is too complex you can decompose it?

> [@SebKrantz](#):
>
> there this gives an error.

What kind of error? Can you give the stack trace and the line where it occurs? It is hard to help you with this level of detail.

> [@Please read: make it easier to help you](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757):
>
> Welcome to the Julia Discourse! We are enthusiastic about helping Julia programmers, both beginner and experienced. This public service announcement (PSA) outlines best practices when asking for help. Following these points makes it easier for us to help you and more likely you’ll get a prompt, useful answer. Keywords are highlighted to make it easier to refer to specific points. Choose a descriptive title that captures the key part of your question, eg “plots with multiple axes” instead of …

> [@SebKrantz](#):
>
> In any case, not really concinved that the interface is suitable to put large scale tasks into production.

I have personally helped put large tasks into production using JuMP, so I respectfully disagree 😉 Happy to help you debug yours as best I can though!

---

_[View the full topic](https://discourse.julialang.org/t/nonlinear-optimization-with-many-constraints-autodifferentiation-which-julia-solution/110678)._
