Pyomo 的 Mindtpy 算法生成已弃用的切割

问题描述

这是我在 stackoverflow 上的第一篇文章,所以如果我的问题缺少信息,请告诉我。我正在尝试使用 Pyomo 的 MindtPy 算法来解决混合整数非线性程序。但是,当我尝试解决问题时,在 MindtPy 解决期间出现以下错误(以及 Mindtpy 详细日志消息):

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
..\..\hybrid\dispatch\hybrid_dispatch.py:161: in mindtpy_solve_call
    tee=True)
..\..\..\HOPP_env\lib\site-packages\pyomo\contrib\mindtpy\MindtPy.py:251: in solve
    MindtPy_iteration_loop(solve_data,config)
..\..\..\HOPP_env\lib\site-packages\pyomo\contrib\mindtpy\iterate.py:90: in MindtPy_iteration_loop
    handle_NLP_subproblem_optimal(fixed_nlp,solve_data,config)
..\..\..\HOPP_env\lib\site-packages\pyomo\contrib\mindtpy\nlp_solve.py:178: in handle_NLP_subproblem_optimal
    add_oa_cuts(solve_data.mip,dual_values,config)
..\..\..\HOPP_env\lib\site-packages\pyomo\contrib\mindtpy\cut_generation.py:164: in add_oa_cuts
    if constr.has_ub() and constr.has_lb() and constr.upper == constr.lower and config.use_dual:
pyomo\core\expr\numvalue.pyx:751: in pyomo.core.expr.numvalue.NumericValue.__eq__
    ???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

>   ???
E   TypeError: Relational expression used in an unexpected Boolean context.
E   
E           The inequality expression:
E               0.0  <  - (battery_initial_soc -0.1)
E           contains non-constant terms (variables) that were evaluated in an
E           unexpected Boolean context at
E             File 'C:\Users\WHamilt2\Documents\GitHub\HOPP_env\lib\site-packages\pyomo\contrib\mindtpy\iterate.py',line 88:
E       solve_data,config)
E   
E           Evaluating Pyomo variables in a Boolean context,e.g.
E               if expression <= 5:
E           is generally invalid.  If you want to obtain the Boolean value of the
E           expression based on the current variable values,explicitly evaluate the
E           expression using the value() function:
E               if value(expression) <= 5:
E           or
E               if value(expression <= 5):

pyomo\core\expr\logical_expr.pyx:373: TypeError
---------------------------- Captured stderr call -----------------------------
pyomo.core  : WARNING  DEPRECATED: Chained inequalities are deprecated. Use the inequality()
function to express ranged inequality expressions.
(called from C:\Users\WHamilt2\Documents\GitHub\HOPP_env\lib\site-packages\pyomo\contrib\mindtpy\nlp_solve.py:83)
------------------------------ Captured log call ------------------------------
INFO     pyomo.contrib.mindtpy:MindtPy.py:148 ---Starting MindtPy---
INFO     pyomo.contrib.mindtpy:util.py:366 Original model has 768 constraints (96 nonlinear) and 0 disjunctions,with 432 variables,of which 96 are binary,0 are integer,and 336 are continuous.
INFO     pyomo.contrib.mindtpy:initialization.py:84 rNLP is the initial strategy being used.

INFO     pyomo.contrib.mindtpy:initialization.py:118 NLP 1: Solve relaxed integrality
INFO     pyomo.contrib.mindtpy:initialization.py:147 NLP 1: OBJ: 11682.68625614203  LB: -inf  UB: inf
INFO     pyomo.contrib.mindtpy:iterate.py:57 ---MindtPy Master Iteration 0---
INFO     pyomo.contrib.mindtpy:mip_solve.py:51 MIP 1: Solve master problem.
INFO     pyomo.contrib.mindtpy:mip_solve.py:195 MIP 1: OBJ: 11682.685728992079  LB: -inf  UB: 11682.685728992079
INFO     pyomo.contrib.mindtpy:nlp_solve.py:55 NLP 2: Solve subproblem for fixed binaries.
WARNING  pyomo.core:deprecation.py:72 DEPRECATED: Chained inequalities are deprecated. Use the inequality()
function to express ranged inequality expressions.
(called from C:\Users\WHamilt2\Documents\GitHub\HOPP_env\lib\site-packages\pyomo\contrib\mindtpy\nlp_solve.py:83)
INFO     pyomo.contrib.mindtpy:nlp_solve.py:159 NLP 2: OBJ: 11682.68625221387  LB: 11682.68625221387  UB: 11682.685728992079

在我看来 Mindtpy 正在尝试使用 Pyomo Deprecated 方法生成剪辑。

要重现此错误,请在 test_detailed_battery_dispatch() github 存储库的 hybrid/test_dispatch.py 分支中的 merge_dispatch 中运行 https://github.com/NREL/HOPP 测试。您必须将 ipopt.exelibipoptfort.dll 添加到您的环境脚本文件夹中。

如果您需要有关该问题的更多信息,请告诉我。

谢谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)