How to specify gradient in Pyomo with IPOPT
Pyomo provides first and second derivative information using the automatic differentiation features in the Ampl Solver Library (ASL). When calling IPOPT, Pyomo outputs your model using the '.nl' file format which is read by the ASL and linked to IPOPT. So you don't have to do anything to provide gradient information, this is done automatically.
Primary Question
When solving a NLP in Pyomo, using IPOPT as the solver, how can I tell IPOPT what the gradient of the objective function and/or constraints are? I have to pass a callable function that returns objective values--can I likewise pass a callable function that evaluates the gradient as well?
Secondary Question
How does Pyomo+IPOPT handle this by default? When I solve a simple NLP with Pyomo+IPOPT, part of the IPOPT output includes "number of objective gradient evaluations"...but how is it evaluating the gradient? Numerically with finite differences, or something?
I'm using Pyomo 5.6 with Python 3.6 and IPOPT 3.7.