1

通常当我尝试用 IPOPT 解决某事时,即使问题不可行,IPOPT 也会显示运行过程,例如显示问题有多少约束以及问题的其他一般信息,但这次我遇到了一个奇怪的问题。我第一次解决问题时它什么也没显示,但第二次解决它时,IPOPT 返回最佳解决方案。像这样:

-> ampl.eval('option solver ipopt ;'); 
-> ampl.solve()

(它在这里什么都不返回!!!!)

-> solve_result  = ampl.getValue('solve_result_num')
solve_result = -1

所以在这里,我再次运行代码:

 -> ampl.solve()
Ipopt 3.12.4: 
******************************************************************************
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.12.4, running with linear solver mumps.
NOTE: Other linear solvers might be more efficient (see Ipopt documentation).
Number of nonzeros in equality constraint Jacobian...:     4439
Number of nonzeros in inequality constraint Jacobian.:     7888
Number of nonzeros in Lagrangian Hessian.............:       50
Total number of variables............................:     1610
                 variables with only lower bounds:        0
            variables with lower and upper bounds:       70
                 variables with only upper bounds:        0
Total number of equality constraints.................:     1360  
Total number of inequality constraints...............:     2585
    inequality constraints with only lower bounds:        0
inequality constraints with lower and upper bounds:     2585
    inequality constraints with only upper bounds:        0
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
0  5.0001000e+03 1.31e+00 8.32e-02  -1.0 0.00e+00    -  0.00e+00 0.00e+00   0
1  5.0079602e+03 1.31e+00 2.71e+01  -1.0 1.68e+01    -  1.05e-02 7.73e-04f  1
2  3.9278729e+03 1.17e+00 9.17e+00  -1.0 1.24e+00    -  3.65e-02 9.32e-02f  1
3  2.7624370e+03 9.13e-01 2.49e+01  -1.0 4.52e-01    -  7.04e-01 1.99e-01f  1
4  1.6350590e+03 7.87e-02 2.17e+01  -1.0 6.17e-01    -  2.98e-01 7.82e-01f  1
5  8.6271513e+02 3.73e-13 2.34e-01  -1.0 1.53e-01    -  9.90e-01 1.00e+00f  1
6  1.0292941e+03 1.98e-13 8.49e-13  -1.0 1.03e-01    -  1.00e+00 1.00e+00f  1
7  1.0259140e+03 1.86e-13 6.85e-13  -2.5 6.57e-04    -  1.00e+00 1.00e+00f  1
8  9.1964915e+02 2.02e-13 7.11e-04  -3.8 1.84e-02    -  9.96e-01 1.00e+00f  1
9  3.5639825e+02 2.30e-13 4.23e-02  -5.7 9.45e-02    -  7.68e-01 1.00e+00f  1
 iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls

10  7.9479322e+01 2.23e-13 9.26e-03  -5.7 1.85e-01    -  8.95e-01 1.00e+00f  1
11  1.9247063e+01 2.72e-13 2.80e-14  -5.7 1.19e-01    -  1.00e+00 1.00e+00f  1
12  6.9889052e+00 3.55e-13 9.99e-05  -8.6 4.59e-02    -  9.33e-01 1.00e+00f  1
13  1.2789711e+00 4.20e-13 4.22e-04  -8.6 2.96e-01    -  4.85e-01 8.98e-01f  1
14  2.9354384e-01 2.00e-13 6.84e-06  -8.6 4.49e-02    -  9.92e-01 1.00e+00f  1
15  1.0626050e-01 2.41e-13 7.17e-14  -8.6 9.55e-03    -  1.00e+00 1.00e+00h  1
16  6.3028082e-02 3.77e-13 5.27e-14  -8.6 1.37e-03    -  1.00e+00 1.00e+00h  1
17  4.3933480e-03 3.27e-13 6.90e-08 -11.0 2.32e-03    -  9.99e-01 1.00e+00h  1
18  1.1280540e-03 2.81e-13 8.08e-14 -11.0 1.02e-04    -  1.00e+00 1.00e+00h  1
19  3.9735544e-04 3.93e-13 5.46e-14 -11.0 5.59e-05    -  1.00e+00 1.00e+00h  1
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
20  2.2989758e-04 3.19e-13 1.68e-14 -11.0 2.72e-05    -  1.00e+00 1.00e+00h  1
Number of Iterations....: 20
                               (scaled)                 (unscaled)
Objective...............:   2.4678359201693643e-10    2.2989757642660348e-04
Dual infeasibility......:   1.6794654637445761e-14    1.5645490717250029e-08
Constraint violation....:   2.7491418973006631e-15    3.1883523599063324e-13
Complementarity.........:   5.3838886983188674e-11    5.0154994235157414e-05
Overall NLP error.......:   5.3838886983188674e-11    5.0154994235157414e-05
Number of objective function evaluations             = 21
Number of objective gradient evaluations             = 21
Number of equality constraint evaluations            = 21
Number of inequality constraint evaluations          = 21
Number of equality constraint Jacobian evaluations   = 21
Number of inequality constraint Jacobian evaluations = 21
Number of Lagrangian Hessian evaluations             = 20
Total CPU secs in IPOPT (w/o function evaluations)   =      0.295
Total CPU secs in NLP function evaluations           =      0.004
EXIT: Optimal So 
Ipopt 3.12.4: Optimal Solution Found
suffix ipopt_zU_out OUT;
suffix ipopt_zL_out OUT;
-> solve_result  = ampl.getValue('solve_result_num')
solve_result =  0

所以谁能知道为什么会发生这种情况,这是什么意思?

4

0 回答 0