# Optimization with JuMP: an affine expression enters a nonlinear constraint (dynamic discrete choice)

**URL:** <https://discourse.julialang.org/t/optimization-with-jump-an-affine-expression-enters-a-nonlinear-constraint-dynamic-discrete-choice/54230>\
**Category:** Optimization (Mathematical)\
**Tags:** question, jump\
**Created:** [January 29, 2021, 9:36pm UTC](https://discourse.julialang.org/t/optimization-with-jump-an-affine-expression-enters-a-nonlinear-constraint-dynamic-discrete-choice/54230 "2021-01-29T21:36:36Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [January 29, 2021, 10:36pm UTC](https://discourse.julialang.org/t/optimization-with-jump-an-affine-expression-enters-a-nonlinear-constraint-dynamic-discrete-choice/54230/2 "2021-01-29T22:36:00Z")

</div>

User-defined functions cannot return a vector output.

This example suggests a work-around: [https://jump.dev/JuMP.jl/stable/examples/nlp\_tricks/#User-defined-functions-with-vector-outputs](https://jump.dev/JuMP.jl/stable/examples/nlp_tricks/#User-defined-functions-with-vector-outputs).

If you have lots of functions, you will need to use the raw-expression syntax: [Registering an array of functions and using them in constraints and objectives - #2 by odow](https://discourse.julialang.org/t/registering-an-array-of-functions-and-using-them-in-constraints-and-objectives/53294/2) (more docs: [https://jump.dev/JuMP.jl/stable/nlp/#Raw-expression-input](https://jump.dev/JuMP.jl/stable/nlp/#Raw-expression-input)).

---

_[View the full topic](https://discourse.julialang.org/t/optimization-with-jump-an-affine-expression-enters-a-nonlinear-constraint-dynamic-discrete-choice/54230)._
