使用HiGHS求解器与highspy和pyomo。

huangapple go评论135阅读模式
英文:

using HiGHS solver with highspy and pyomo

问题

我正在尝试使用Python/Pyomo运行多个模型,使用HiGHS求解器。几个月前的某个时候,我成功运行了一些东西,但现在似乎陷入了困境,无法使它们正常工作。我正在运行一个较旧的mac,macOS版本是11.7。

到目前为止的操作:

我按照这些说明(v1.5.3)从源代码安装了HiGHS求解器,并且可以通过命令行提供.mps模型并获得结果,所以这部分是有效的。

但是,当我安装了PyPi上的highspy时,似乎安装成功,但在导入时崩溃:

  1. ~ % pip3 show highspy
  2. Name: highspy
  3. Version: 1.5.3
  4. Summary: Python interface to HiGHS
  5. Home-page: https://github.com/ergo-code/highs
  6. Author:
  7. Author-email:
  8. License: MIT
  9. Location: /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages
  10. Requires:
  11. Required-by:
  12. ~ % python3
  13. Python 3.11.0 (v3.11.0:deaf509e8f, Oct 24 2022, 14:43:23) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
  14. Type "help", "copyright", "credits" or "license" for more information.
  15. >>> import highspy
  16. Traceback (most recent call last):
  17. File "<stdin>", line 1, in <module>
  18. File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/highspy/__init__.py", line 1, in <module>
  19. from .highs import (
  20. File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/highspy/highs.py", line 1, in <module>
  21. from .highs_bindings import (
  22. ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/highspy/highs_bindings.cpython-311-darwin.so, 2): Symbol not found: __ZN5Highs10clearModelEv
  23. Referenced from: /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/highspy/highs_bindings.cpython-311-darwin.so
  24. Expected in: flat namespace
  25. in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/highspy/highs_bindings.cpython-311-darwin.so
  26. >>>

我认为可能存在与Python 3.11的集成问题,因此我在Python 3.10的虚拟环境中尝试了相同的操作,并获得了相同的结果。

我相当确定(尽管不知道为什么,因为在命令行中可用可执行文件...)我需要在pyomo模型内部import highspy以连接到求解器。我尝试了一个带有和不带有该导入的简单模型,两者都失败了。导入失败的原因如上所述,而没有导入的模型会出现以下错误:

  1. pyomo.common.errors.ApplicationError: Solver <class 'pyomo.contrib.appsi.base.SolverFactoryClass.register.<locals>.decorator.<locals>.LegacySolver'> is not available (NotFound).
英文:

I'm attempting to run several models using the HiGHS solver with python/pyomo. At some point a few months back, I had a few things running, but now it seems I'm at a standstill trying to get things working. I'm running an older mac with macOS 11.7

Actions so far:

I installed the HiGHS solver from source using these instructions (v1.5.3) and I can feed it .mps models from the command line and get results, so that is working.

However, when I installed highspy from PyPi, it appears to install OK, but crashes on import:

  1. ~ % pip3 show highspy
  2. Name: highspy
  3. Version: 1.5.3
  4. Summary: Python interface to HiGHS
  5. Home-page: https://github.com/ergo-code/highs
  6. Author:
  7. Author-email:
  8. License: MIT
  9. Location: /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages
  10. Requires:
  11. Required-by:
  12. ~ % python3
  13. Python 3.11.0 (v3.11.0:deaf509e8f, Oct 24 2022, 14:43:23) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
  14. Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
  15. &gt;&gt;&gt; import highspy
  16. Traceback (most recent call last):
  17. File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;
  18. File &quot;/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/highspy/__init__.py&quot;, line 1, in &lt;module&gt;
  19. from .highs import (
  20. File &quot;/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/highspy/highs.py&quot;, line 1, in &lt;module&gt;
  21. from .highs_bindings import (
  22. ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/highspy/highs_bindings.cpython-311-darwin.so, 2): Symbol not found: __ZN5Highs10clearModelEv
  23. Referenced from: /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/highspy/highs_bindings.cpython-311-darwin.so
  24. Expected in: flat namespace
  25. in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/highspy/highs_bindings.cpython-311-darwin.so
  26. &gt;&gt;&gt;

I figured there might be an integration issue w/ Python 3.11, so I tried the same in a Python 3.10 venv and got same result.

I'm pretty sure (though I'm not sure why as the executable is available on the CLI...) that I need to import highspy within a pyomo model to get connectivity to the solver. I attempted a trivial model with/without that import and both failed. The "import" one failed for reasons above and the non-import one coughs up:

  1. pyomo.common.errors.ApplicationError: Solver &lt;class &#39;pyomo.contrib.appsi.base.SolverFactoryClass.register.&lt;locals&gt;.decorator.&lt;locals&gt;.LegacySolver&#39;&gt; is not available (NotFound).

答案1

得分: 0

我认为经过一些调查,我认为这表明了问题:

https://github.com/ERGO-Code/HiGHS/issues/1119

听起来像是旧一代OS X构建的1.5.3版本的发行版可能缺少一些包含文件,并且正在进行修复。

英文:

After a little digging, I think this indicates the problem:

https://github.com/ERGO-Code/HiGHS/issues/1119

It sounds like distro versions of 1.5.3 for older generation OS X builds may be missing some include files and a fix is in-work.

huangapple
  • 本文由 发表于 2023年6月15日 00:17:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/76475638.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定