Automatic differentiation / derivative calculation options in AMPL and KNITRO

Hi!

We are trying to use AMPL and KNITRO to solve an optimization problem. Specifically, we use Python/pandas to process data, and AMPL to formulate the problem and specify the solver (KNITRO). Then we use the amplpy package to pass the data from Python to AMPL, and AMPL calls the solver to take care of the rest.

In our problem, we do not have the functional forms for the derivative information, and would like AMPL to derive it automatically. Two questions are as follows:

First, we notice that there are several KNITRO options (e.g., gradopt, hessopt, etc.) regarding derivative calculation. In our case, how should we specify KNITRO options (maybe AMPL options as well) so that we make sure AMPL performs automatic differentiation and feeds that information to KNITRO? Note that this means KNITRO does not perform derivative calculation, but instead, uses that information provided by AMPL.

Second, we also notice that even if we do not provide derivative information, specifying gradopt and hessopt to be 1 still makes the program run and converge. In this case, what is the assumption on the derivative information?

Thank you very much for your help!

1 Like

Knitro’s default derivative computation options are as follows:

  • gradopt=1: use exact gradient values
  • hessopt=1: use exact Hessian values

When AMPL invokes Knitro with these options, the derivative values are computed by AMPL’s Knitro interface via automatic differentiation. There is nothing else that you need to specify. Since these are the default settings, when you do not specify any gradopt or hessopt value, you still get full first and second derivative computations performed by AMPL.

The hessopt=5 option also uses AMPL’s automatic differentiation, to compute exact Hessian-vector products. All of the other gradopt and hessopt options specify first or second derivatives computed by approximations, which do not require AD computations from AMPL.

(Where the Knitro general reference manual says “User provides a routine for computing” derivatives of some kind, you should think of the “user” as being AMPL, and the “routine” as being AMPL’s AD implementation.)

2 Likes