xuy/pyipopt — Issue #2: Example hs071.py returns wrong solution x
Author: jansb
Created: 2012-01-20 12:22:41+00:00
State: open

Hello,
I have a problem with running the example hs071.py. I have installed Ubuntu (11.10), IPOPT (vers. 3.10.1, the examples work fine), python (2.7.2) and numpy (1.5.1). Installing pyipopt (0.8.1) works without any errors. I can run the example hs071.py. The Output is:

==============================================================================
Going to call solve
[ 1. 5. 5. 1.]

******************************************************************************
This program contains Ipopt, a library for large-scale nonlinear optimization.
Ipopt is released as open source code under the Eclipse Public License (EPL).
For more information visit http://projects.coin-or.org/Ipopt
******************************************************************************

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

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

Total number of variables............................: 4
variables with only lower bounds: 0
variables with lower and upper bounds: 4
variables with only upper bounds: 0
Total number of equality constraints.................: 1
Total number of inequality constraints...............: 1
inequality constraints with only lower bounds: 1
inequality constraints with lower and upper bounds: 0
inequality constraints with only upper bounds: 0

iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls
0 1.6109693e+01 1.12e+01 5.28e-01 0.0 0.00e+00 - 0.00e+00 0.00e+00 0
1 1.7420709e+01 7.49e-01 2.40e+01 -0.3 8.13e-01 - 3.20e-01 1.00e+00f 1
2 1.7120453e+01 2.14e-01 2.00e-01 -0.6 1.02e+00 - 9.97e-01 1.00e+00h 1
3 1.6979032e+01 1.70e-01 8.49e-02 -1.6 1.18e-01 - 9.72e-01 1.00e+00h 1
4 1.6972554e+01 7.69e-02 1.20e-02 -3.2 8.01e-02 - 1.00e+00 1.00e+00h 1
5 1.7013661e+01 6.75e-04 9.50e-03 -4.9 1.00e-02 - 1.00e+00 1.00e+00h 1
6 1.7014018e+01 1.96e-06 3.49e-04 -6.1 1.09e-03 - 1.00e+00 1.00e+00h 1
7 1.7014017e+01 1.47e-09 2.15e-07 -8.2 3.02e-05 - 1.00e+00 1.00e+00h 1
8 1.7014017e+01 7.11e-15 1.69e-09 -11.0 1.17e-08 - 1.00e+00 1.00e+00h 1

Number of Iterations....: 8

(scaled) (unscaled)
Objective...............: 1.7014017140224176e+01 1.7014017140224176e+01
Dual infeasibility......: 1.6853176362439800e-09 1.6853176362439800e-09
Constraint violation....: 7.1054273576010019e-15 7.1054273576010019e-15
Complementarity.........: 1.0002952000760580e-11 1.0002952000760580e-11
Overall NLP error.......: 1.6853176362439800e-09 1.6853176362439800e-09

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

EXIT: Optimal Solution Found.
Solution of the primal variables, x
[ 6.93315118e-310 6.93315118e-310 5.00000000e+000 1.00000000e+000]
Solution of the bound multipliers, z_L and z_U
[ 1.08787121e+00 2.67165388e-12 3.54465533e-12 2.63564701e-11] [ 2.49999763e-12 3.89104702e-11 8.48283408e-12 2.76198339e-12]
Objective value
f(x*) = 17.0140171402
==============================================================================

According to this output the resulting parameter vector is x = [ 6.93315118e-310 6.93315118e-310 5.00000000e+000 1.00000000e+000]. Running the (mathematical similar) example hs071.c from IPOPT returns:

Solution of the primal variables, x
x[0] = 1.000000e+00
x[1] = 4.749269e+00
x[2] = 3.817510e+00
x[3] = 1.367870e+00

This solution differs from from the one derived by pyipopt. However, z_L, z_U and the value of the objective are similar in hs071.c and hs071.py. It seems so, that hs071.py computes the correct x, but does not return it correclty (in my case). When printing x in hs071.py in each evaluation of the objective by adding the line 'print x' to the function 'def eval_f(x, user_data = None):', on the last call during the optimization prozess it returns [ 0.99999999 4.74299964 3.82114998 1.37940829], e.g. the similar solution as hs071.c returns.

It seems that the optimization process works well, but the result will not be passed back to python correctly. Btw. the similar problem also occurs in other testproblems I wrote. Can you reproduce this error? If you need additional informations, just let me know. Thank you.

Anyway, thank you for providing a wrapper from python to IPOPT!

Best regards,
Jan Schumann-Bischoff