# How to add a constraint with neural network in a JuMP (PowerModels) model

**URL:** <https://discourse.julialang.org/t/how-to-add-a-constraint-with-neural-network-in-a-jump-powermodels-model/64593>\
**Category:** Optimization (Mathematical)\
**Tags:** question, jump\
**Created:** [July 13, 2021, 4:48pm UTC](https://discourse.julialang.org/t/how-to-add-a-constraint-with-neural-network-in-a-jump-powermodels-model/64593 "2021-07-13T16:48:28Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [July 13, 2021, 10:11pm UTC](https://discourse.julialang.org/t/how-to-add-a-constraint-with-neural-network-in-a-jump-powermodels-model/64593/3 "2021-07-13T22:11:48Z")

</div>

Hi there, since it’s your first post, please read [Please read: make it easier to help you](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757). It’s easier to help if you provide a complete minimal working example.

However, there’s some scary stuff in your example that are going to cause issues.

- I don’t think your `get_y_pred` is going to support automatic differentiation. That means you can’t use JuMP to solve this problem. Please read: [https://jump.dev/JuMP.jl/stable/background/should\_i\_use/#Black-box,-derivative-free,-or-unconstrained-optimization](https://jump.dev/JuMP.jl/stable/background/should_i_use/#Black-box,-derivative-free,-or-unconstrained-optimization)
- `@addNLconstraint` is very old syntax. Are you running the latest version of Julia and JuMP?

---

_[View the full topic](https://discourse.julialang.org/t/how-to-add-a-constraint-with-neural-network-in-a-jump-powermodels-model/64593)._
