我有一个类似的问题/用例。我正在使用 Pyomo.DAE 来集成 PDE(平方问题)。我的模型名为full
.
SolverFactory('ipopt').solve(full, tee=True)
IPOPT 在最后一次迭代中出现恢复失败。
679r 0.0000000e+00 1.86e-09 4.04e+02 -11.0 1.27e-07 -6.0 1.00e+00 4.88e-04f 12
iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls
680r 0.0000000e+00 9.31e-10 1.29e-12 -11.0 1.52e-08 -6.4 1.00e+00 1.00e+00s 36
Restoration phase converged to a point with small primal infeasibility.
Number of Iterations....: 680
(scaled) (unscaled)
Objective...............: 0.0000000000000000e+00 0.0000000000000000e+00
Dual infeasibility......: 1.2866497665187040e-12 1.2866497665187040e-12
Constraint violation....: 3.4197000786662102e-10 9.3132257461547852e-10
Complementarity.........: 9.9004652442607800e-12 9.9004652442607800e-12
Overall NLP error.......: 3.4197000786662102e-10 9.3132257461547852e-10
Number of objective function evaluations = 1800
Number of objective gradient evaluations = 328
Number of equality constraint evaluations = 1800
Number of inequality constraint evaluations = 0
Number of equality constraint Jacobian evaluations = 719
Number of inequality constraint Jacobian evaluations = 0
Number of Lagrangian Hessian evaluations = 681
Total CPU secs in IPOPT (w/o function evaluations) = 479.182
Total CPU secs in NLP function evaluations = 21.007
EXIT: Restoration Failed!
我的模型可能病得很厉害。重新制定正在进行中。不过,我真的很想在最后一次迭代之后检查 IPOPT 解决方案。Pyomo 在 IPOPT 输出后立即抛出此错误:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-23-a1795f441929> in <module>
----> 1 SolverFactory('ipopt').solve(full, tee=True)
/anaconda3/lib/python3.7/site-packages/pyomo/opt/base/solvers.py in solve(self, *args, **kwds)
631 result,
632 select=self._select_index,
--> 633 default_variable_value=self._default_variable_value)
634 result._smap_id = None
635 result.solution.clear()
/anaconda3/lib/python3.7/site-packages/pyomo/core/base/PyomoModel.py in load_from(self, results, allow_consistent_values_for_fixed_vars, comparison_tolerance_for_fixed_vars, ignore_invalid_labels, id, delete_symbol_map, clear, default_variable_value, select, ignore_fixed_vars)
249 raise ValueError("Cannot load a SolverResults object "
250 "with bad status: %s"
--> 251 % str(results.solver.status))
252 if clear:
253 #
ValueError: Cannot load a SolverResults object with bad status: error
我的理解是 Pyomo 是在保护我(用户)免受我自己的伤害,而不是在恢复失败后给我解决方案。有没有办法覆盖这个?