0

我正在尝试在 Windows10 x64 上使用 anaconda 安装 ipopt。

conda install -c conda-forge ipopt我已经在 anaconda 提示符(版本=3.13.4)中通过“”安装了 ipopt 。

我在 python 中构建了一个小测试脚本来检查我的安装:

import pyomo.environ as pe
import pyomo.opt as po

M = pe.ConcreteModel()

M.x = pe.Var()
M.y = pe.Var(bounds=(0, None))

M.obj = pe.Objective(expr=M.x+M.y, sense=pe.minimize)

M.c1 = pe.Constraint(expr=(M.x >=4)) // this constraint expr will be replaced by M.x**2 >= 4 to test nonlinear problems
M.c2 = pe.Constraint(expr=(M.y >= M.x))

solver = po.SolverFactory('ipopt')
results = solver.solve(M, tee=True)

print(pe.value(M.x), pe.value(M.y))

运行脚本,我收到以下错误消息: ApplicationError: No executable found for solver 'ipopt'

我可以解决这个问题,从https://ampl.com/products/solvers/open-source/下载 64 位 Windows 的 zip 文件夹并将文件提取到我正在工作的 anaconda 环境的“库”文件夹中上。

再次运行线性问题的测试脚本,问题解决了,但我得到以下信息:

This is Ipopt version 3.12.13, running with linear solver mumps.
NOTE: Other linear solvers might be more efficient (see Ipopt documentation).

然而,非线性测试问题无法解决,因为仍然应用了线性 mumps 求解器。

EXIT: Maximum Number of Iterations Exceeded.
WARNING: Loading a SolverResults object with a warning status into
    model.name="unknown";
      - termination condition: maxIterations
      - message from solver: Ipopt 3.12.13\x3a Maximum Number of Iterations
        Exceeded.
M.x=-281240.49215541 M.y=13.01195537079578

如何确保 ipopt 也解决非线性问题?我知道在 stackoverflow 上有一些类似的问题,但我还不能解决我的问题。

(我也尝试按照https://coin-or.github.io/Ipopt/INSTALL.htmlconfigure: error: no acceptable C compiler found in $PATH的安装指南进行操作,但是当我尝试安装 ASL 或 HSL 时,在 MSYS2 控制台中遇到了消息“ ”“”,甚至虽然我按照描述安装了 gcc 并将包含 gcc.exe 的文件夹包含到我的 PATH 变量中。)

4

1 回答 1

1

conda-forge 包可能不包含 Pyomo 所需的 AMPL 接口和 ipopt 可执行文件(至少,https: //anaconda.org/conda-forge/ipopt/3.13.4/download 是这种情况/win-64/ipopt-3.13.4-hf6be2e5_0.tar.bz2)。

如果 Ipopt 未能解决 min x+y st x>=4, y>=x,则 MUMPS 不应该是原因。需要检查 Ipopt 日志以查看问题所在。

如果您觉得来自 ampl.com 的可执行文件太旧,您可以尝试 Ipopt 版本附带的那些,例如https://github.com/coin-or/Ipopt/releases/download/releases%2F3 .14.1/Ipopt-3.14.1-win64-msvs2019-md.zip获取最新版本。除了 MUMPS 之外,它们还包括来自 MKL 的 Pardiso。

要检查编译器在 msys2 下检入 configure 失败的原因,请查看由 configure 生成的文件 config.log。

于 2021-06-28T07:47:15.630 回答