# [Ipopt] Derivative check program returns eps

Takafumi Usui u.takafumi at gmail.com
Sat Jun 16 17:30:54 EDT 2018

```Dear all,

I am using IPOPT (3.12.9) from python via pyipopt to solve a stochastic optimization problem.
I am struggling with a derivative check error, which do not show up when I solve a similar but even harder problem though.

When I perform the IPOPT provided derivative check program, it returns eps, while my Jacobian shows different numbers.

When I introduce an additional constraint, overflowed errors, which you can observe in my log file below,  show up.  Without this constraint, my Jacobian and the derivative check program return almost the same numbers.
I also know that this constraint works correctly with harder examples.

I guess that the derivative check program perturbates x to calculate numerically approximated derivatives but I am not sure from which point the program starts.  Is it from user provided starting point?

The derivative check program seems to crash in my example below.  What kind of problems could induce these differences between the user and the IPOPT provided derivative checker?

I know that this kind of issues are problem specific, but if someone has an idea or experience to solve this kind of problem, I would appreciate your help.

Thank you in advance for your help and I hope to hear from you soon.

Best regards,

Takafumi

*****************************************************************************
List of options:

Name   Value                # times used
derivative_test = first-order               1
derivative_test_print_all = yes                       1
hessian_approximation = limited-memory            7
print_level = 7                         2

******************************************************************************
This program contains Ipopt, a library for large-scale nonlinear optimization.
Ipopt is released as open source code under the Eclipse Public License (EPL).
******************************************************************************

This is Ipopt version 3.12.9, running with linear solver ma27.

Starting derivative checker for first derivatives.

grad_f[          0] =  0.0000000000000000e+00    ~  0.0000000000000000e+00  [ 0.000e+00]
* jac_g [    0,    0] =  8.0112183553637806e-01 v  ~ 3.9525251667299724e-313  [ 8.011e-01]
* jac_g [    1,    0] = -1.4579448759377556e-04 v  ~ 2.3715151000379834e-314  [ 1.458e-04]
* jac_g [    2,    0] =  1.0000000161269895e+00 v  ~ 2.3715151000379834e-314  [ 1.000e+00]
* jac_g [    3,    0] =  3.3598603899065438e+00 v  ~ -4.7430302000759668e-314  [ 3.360e+00]
jac_g [    4,    0] =  0.0000000000000000e+00 v  ~ 2.0157878350322859e-313  [2.016e-313]
jac_g [    5,    0] =  0.0000000000000000e+00 v  ~ 5.9287877500949585e-314  [5.929e-314]
* jac_g [    6,    0] = -5.7511222451012145e-01 v  ~ -2.3715151000379834e-314  [ 5.751e-01]
grad_f[          1] =  0.0000000000000000e+00    ~  0.0000000000000000e+00  [ 0.000e+00]
* jac_g [    0,    1] =  2.6980906397966464e-01 v  ~ 1.7214366718091040e-314  [ 2.698e-01]
* jac_g [    1,    1] =  1.8005731350356768e-01 v  ~ 1.5492930037882820e-315  [ 1.801e-01]
jac_g [    2,    1] =  0.0000000000000000e+00 v  ~ -1.0328620041724068e-315  [1.033e-315]
jac_g [    3,    1] =  0.0000000000000000e+00 v  ~ -1.0328620041724068e-315  [1.033e-315]
* jac_g [    4,    1] =  1.0000000827403710e+00 v  ~ 5.1643099961587518e-316  [ 1.000e+00]
* jac_g [    5,    1] =  5.6548944971090975e+00 v  ~ 1.1361482031074506e-314  [ 5.655e+00]
* jac_g [    6,    1] = -9.8093595468640160e-01 v  ~ 2.0657240083448136e-315  [ 9.809e-01]
grad_f[          2] =  0.0000000000000000e+00    ~  0.0000000000000000e+00  [ 0.000e+00]
* jac_g [    0,    2] =  5.7511222451012145e-01 v  ~ 4.6234271373410638e-314  [ 5.751e-01]
* jac_g [    1,    2] =  9.8093595468640160e-01 v  ~ 2.7740562821081989e-314  [ 9.809e-01]
jac_g [    2,    2] =  0.0000000000000000e+00 v  ~  0.0000000000000000e+00  [ 0.000e+00]
jac_g [    3,    2] =  0.0000000000000000e+00 v  ~ -1.3870281403130010e-315  [1.387e-315]
jac_g [    4,    2] =  0.0000000000000000e+00 v  ~ -4.1610844258796594e-315  [4.161e-315]
jac_g [    5,    2] =  0.0000000000000000e+00 v  ~ 8.3221688468186624e-315  [8.322e-315]
* jac_g [    6,    2] =  2.0003376732802280e-02 v  ~ 9.7091969871316634e-315  [ 2.000e-02]
grad_f[          3] =  0.0000000000000000e+00    ~  0.0000000000000000e+00  [ 0.000e+00]
* jac_g [    0,    3] = -1.0000000827403710e+00 v  ~ 1.1763956867539469e-313  [ 1.000e+00]
jac_g [    1,    3] =  0.0000000000000000e+00 v  ~ 1.4116748239268727e-314  [1.412e-314]
jac_g [    2,    3] =  0.0000000000000000e+00 v  ~ 3.5291870585820176e-315  [3.529e-315]
* jac_g [    3,    3] = -3.1445930304130343e+00 v  ~ 5.6466992962015564e-314  [ 3.145e+00]
jac_g [    4,    3] =  0.0000000000000000e+00 v  ~ -3.5291870585820176e-315  [3.529e-315]
jac_g [    5,    3] =  0.0000000000000000e+00 v  ~ 7.0583741221046916e-315  [7.058e-315]
jac_g [    6,    3] =  0.0000000000000000e+00 v  ~ -3.1762683542060128e-314  [3.176e-314]
grad_f[          4] =  0.0000000000000000e+00    ~  0.0000000000000000e+00  [ 0.000e+00]
jac_g [    0,    4] =  0.0000000000000000e+00 v  ~ 6.9895653955592695e-314  [6.990e-314]
* jac_g [    1,    4] = -9.9999999392252903e-01 v  ~  0.0000000000000000e+00  [ 1.000e+00]
jac_g [    2,    4] =  0.0000000000000000e+00 v  ~ 3.7743653137107000e-314  [3.774e-314]
jac_g [    3,    4] =  0.0000000000000000e+00 v  ~  0.0000000000000000e+00  [ 0.000e+00]
jac_g [    4,    4] =  0.0000000000000000e+00 v  ~  0.0000000000000000e+00  [ 0.000e+00]
* jac_g [    5,    4] = -3.1338184269813496e-01 v  ~ 8.3874784754616284e-315  [ 3.134e-01]
jac_g [    6,    4] =  0.0000000000000000e+00 v  ~ -4.1937392352604860e-315  [4.194e-315]

Derivative checker detected 17 error(s).

Number of nonzeros in equality constraint Jacobian...:       25
Number of nonzeros in inequality constraint Jacobian.:       10
Number of nonzeros in Lagrangian Hessian.............:        0

Hessian approximation will be done in the space of all 5 x variables.

Scaling parameter for objective function = 1.000000e+00
objective scaling factor = 1
No x scaling provided
No c scaling provided
No d scaling provided
Moved initial values of x sufficiently inside the bounds.
Moved initial values of s sufficiently inside the bounds.
Total number of variables............................:        5
variables with only lower bounds:        0
variables with lower and upper bounds:        5
variables with only upper bounds:        0
Total number of equality constraints.................:        5
Total number of inequality constraints...............:        2
inequality constraints with only lower bounds:        2
inequality constraints with lower and upper bounds:        0
inequality constraints with only upper bounds:        0

Convergence Check:
overall_error = 5.1119232457805285e-313   IpData().tol()   =  1.0000000000000000e-08
dual_inf      =  1.0000000000000000e+00   dual_inf_tol_    = 1.0000000000000001e+300
constr_viol   = 5.1119232457805285e-313   constr_viol_tol_ =  1.0000000000000000e-04
compl_inf     =  9.9990001010000000e+01   compl_inf_tol_   = 1.0000000000000001e+300

**************************************************
*** Summary of Iteration: 0:
**************************************************

iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
0  0.0000000e+00 5.11e-313 1.00e+00   0.0 0.00e+00    -  0.00e+00 0.00e+00   0 s

**************************************************
*** Beginning Iteration 0 from the following point:
**************************************************

Current barrier parameter mu = 1.0000000000000000e+00
Current fraction-to-the-boundary parameter tau = 0.0000000000000000e+00

||curr_x||_inf   = 2.3870770173449724e+01
||curr_s||_inf   = 9.9999900000000003e-03
||curr_y_c||_inf = 0.0000000000000000e+00
||curr_y_d||_inf = 0.0000000000000000e+00
||curr_z_L||_inf = 1.0000000000000000e+00
||curr_z_U||_inf = 1.0000000000000000e+00
||curr_v_L||_inf = 1.0000000000000000e+00
||curr_v_U||_inf = 0.0000000000000000e+00

No search direction has been computed yet.

***Current NLP Values for Iteration 0:

(scaled)                 (unscaled)
Objective...............:   0.0000000000000000e+00    0.0000000000000000e+00
Dual infeasibility......:   1.0000000000000000e+00    1.0000000000000000e+00
Constraint violation....:  5.1119232457805285e-313   5.1119232457805285e-313
Complementarity.........:   9.9990001010000000e+01    9.9990001010000000e+01
Overall NLP error.......:  5.1119232457805285e-313    9.9990001010000000e+01

In Ma27TSolverInterface::InitializeStructure: Using overestimation factor LiwFact = 2.000000e+00
Return values from MA27AD: IFLAG = 0, IERROR = 0
Size of integer work space recommended by MA27 is 104
Setting integer work space size to 520
Size of doublespace recommended by MA27 is 148
Setting double work space size to 740
Return values from MA27BD: IFLAG = 0, IERROR = 0
Number of doubles for MA27 to hold factorization (INFO(9)) = 71
Number of integers for MA27 to hold factorization (INFO(10)) = 33
Factorization successful.

Number of Iterations....: 0

(scaled)                 (unscaled)
Objective...............:   0.0000000000000000e+00    0.0000000000000000e+00
Dual infeasibility......:   0.0000000000000000e+00    0.0000000000000000e+00
Constraint violation....:  5.1119232457805285e-313   5.1119232457805285e-313
Complementarity.........:   0.0000000000000000e+00    0.0000000000000000e+00
Overall NLP error.......:  5.1119232457805285e-313   5.1119232457805285e-313

Number of objective function evaluations             = 1
Number of objective gradient evaluations             = 1
Number of equality constraint evaluations            = 1
Number of inequality constraint evaluations          = 1
Number of equality constraint Jacobian evaluations   = 1
Number of inequality constraint Jacobian evaluations = 1
Number of Lagrangian Hessian evaluations             = 0
Total CPU secs in IPOPT (w/o function evaluations)   =      0.009
Total CPU secs in NLP function evaluations           =      0.003

EXIT: Optimal Solution Found.

```