# User-defined gradient and hessian ADNLPModels.jl

**URL:** https://discourse.julialang.org/t/user-defined-gradient-and-hessian-adnlpmodels-jl/75940
**Category:** General Usage
**Tags:** optimization, nlopt
**Created:** [February 7, 2022, 9:31am UTC](https://discourse.julialang.org/t/user-defined-gradient-and-hessian-adnlpmodels-jl/75940 "2022-02-07T09:31:13Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![AhmedAlreweny](https://avatars.discourse-cdn.com/v4/letter/a/db5fbb/32.png) [@AhmedAlreweny](https://discourse.julialang.org/u/AhmedAlreweny)
#### Post date: [February 7, 2022, 9:31am UTC](https://discourse.julialang.org/t/user-defined-gradient-and-hessian-adnlpmodels-jl/75940/1 "2022-02-07T09:31:13Z")

</div>

Hello,

I am trying to solve a nonlinear optimization problem using NLPModels.jl. As seen from [here](https://juliasmoothoptimizers.github.io/ADNLPModels.jl/dev/#ADNLPModels.ADNLPModel), the model takes only the objective function and the constraints and compute the gradient and hessian using ForwardDiff. I wonder if there is an easy way to pass the gradient and hessian of the objective function manually.
