【问题标题】:After compiling scip with IPOPT=true make SHARED=true scipoptlib, cannot run from pyscipopt.scip import Model使用 IPOPT=true make SHARED=true scipoptlib 编译 scip 后,无法从 pyscipopt.scip 导入模型运行
【发布时间】:2023-03-14 10:59:01
【问题描述】:

我已经编译了 scip:

$ IPOPT=true make SHARED=true scipoptlib

它已经编译成功,我运行python接口的python setup.py install。 但是,当我在 Python 中运行 from pyscipopt.scip import Model 时,我收到以下错误消息:

ImportError: scip-3.2.1/interfaces/python/lib/libscipopt.so: undefined symbol: _ZTIN5Ipopt7JournalE

【问题讨论】:

  • 由于某种原因,当我从 zimpl 读取 scip 中的问题时,它仍然显示二次约束处理程序没有用于特征值计算的 LAPACK。为什么即使我已经使用 IPOPT 编译,我也不能通过 LAPACK 库进行优化?
  • 我的终极问题是如何通过 IPOPT 和 scip python 接口使用 lapack
  • 顺便说一下,正确的导入命令是from pyscipopt import Model

标签: python interface scip ipopt


【解决方案1】:

您需要调整 setup.py 以将 Ipopt 作为要链接到的库。

它接近文件末尾,在 Cython extension 的定义中称为 libraries

【讨论】:

  • 嗨,我做了相应的调整,但弹出了同样的错误消息。我修改了 setup.py 文件的两个地方。 if usesharedlib: libraries=['readline', 'z', 'gmp', 'ncurses', 'm','Ipopt'])] 和 else 之后:libraries=['readline', 'z', 'gmp ', 'ncurses', 'm','Ipopt'])] 我的编辑是否正确?
  • 我用 IPOPT 重新编译了 scip 并调整了 setup.py(我在库中添加了 'ipopt')。这次运行 python setup.py install 时,我收到错误消息 /usr/bin/ld: cannot find -lipopt Collect2:error: ld returned 1 exit status error:command 'gcc' failed with exit status 1
  • 您可能希望使用 VERBOSE=true 构建 scip 可执行文件,以检查哪些链接器标志用于链接 Ipopt。非常相似的应该传递给 python setup.py 中的链接器调用。一般来说,如果“scipoptlib”已经记录了它的依赖关系可能会更好,这样 Python 接口设置就不必猜测了。
  • 请确认setup.py 已正确执行。另外,请删除pyscipopt/scip.c 以强制从头开始构建界面。
  • 非常感谢您的回复!如何确保 scipoptlib 包含其所有依赖项?当我构建时,我使用了 $make IPOPT=true SHARED=true scipoptlib。并添加了软链接,我还需要做什么?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-04-26
  • 1970-01-01
  • 1970-01-01
  • 2017-11-15
  • 2015-01-24
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多