如何解决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.exe
和 libipoptfort.dll
添加到您的环境脚本文件夹中。
如果您需要有关该问题的更多信息,请告诉我。
谢谢!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。