# Multivariate nonlinear constrained optimization using JuMP and ForwardDiff (Automatic Differentiation)

**URL:** <https://discourse.julialang.org/t/multivariate-nonlinear-constrained-optimization-using-jump-and-forwarddiff-automatic-differentiation/87338>\
**Category:** Optimization (Mathematical)\
**Tags:** jump\
**Created:** [September 15, 2022, 8:50pm UTC](https://discourse.julialang.org/t/multivariate-nonlinear-constrained-optimization-using-jump-and-forwarddiff-automatic-differentiation/87338 "2022-09-15T20:50:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dhathri](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dhathri/32/38919_2.png) [@dhathri](https://discourse.julialang.org/u/dhathri)\
**Post date:** [September 15, 2022, 8:50pm UTC](https://discourse.julialang.org/t/multivariate-nonlinear-constrained-optimization-using-jump-and-forwarddiff-automatic-differentiation/87338/1 "2022-09-15T20:50:58Z")

</div>

Hi, I am new to Julia and I am trying to understand how to use JuMP/ForwardDiff to transfer a collocation algorithm (nlp problem) written in MATLAB. I use `fmincon` in MATLAB with a nonlinear function that returns a vector of nonlinear constraints. My objective function also operates on an input vector, but returns a scalar. I don’t have my own analytical Gradient of the objective, Jacobian and Hessian of the constraints, I rely on the default finite-difference method used in `fmincon` for those. Now I understand that there is a possibility of using automatic differentiation (ForwardDiff package) in Julia, but from what I understand of the JuMP package, there is no way to define a vector of nonlinear constraints, as well as no way of passing a vector as an argument to the objective function.

Please let me know if my understanding/interpretation is wrong in some way. If I am indeed correct, can someone more knowledgeable about these packages tell me why there are these limitations and if there is a way to extend the packages to build multivariate support into these packages?

Thanks,  
Dhathri

---

<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:** [September 15, 2022, 9:52pm UTC](https://discourse.julialang.org/t/multivariate-nonlinear-constrained-optimization-using-jump-and-forwarddiff-automatic-differentiation/87338/2 "2022-09-15T21:52:17Z")

</div>

Hi there!

The JuMP documentation has a bunch of [tutorials](https://jump.dev/JuMP.jl/stable/tutorials/nonlinear/introduction/) and [manual content](https://jump.dev/JuMP.jl/stable/manual/nlp/) on nonlinear programming with JuMP.

If you’re coming from MATLAB, things are a little different. You should try to write out your objective and constraints as scalar expressions, rather than providing a single large function to optimize.

If you can’t write our your expressions algebraically and you just have a black-box function, JuMP might not be the right tool for the job; see [Should I use JuMP? · JuMP](https://jump.dev/JuMP.jl/stable/should_i_use/#Black-box,-derivative-free,-or-unconstrained-optimization).

It’s often hard to provide general advice without seeing code, so I suggest you read [Please read: make it easier to help you](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757) and provide a simplified minimal reproducible example of the problem that you are trying to solve.
