简体   繁体   English

在 Intel Mac OS X 上将 PATH AMPL 求解器与 Pyomo 结合使用

[英]Using PATH AMPL solver with Pyomo on Intel Mac OS X

I'm trying to use the PATH solver ( http://pages.cs.wisc.edu/~ferris/path.html ) together with Pyomo on Mac OS X (10.11, Intel).我正在尝试在 Mac OS X(10.11,Intel)上将 PATH 求解器( http://pages.cs.wisc.edu/~ferris/path.html )与 Pyomo 一起使用。 I'm using the most recent Anaconda install with Python 3.5.我正在使用最新的 Anaconda 安装和 Python 3.5。

Pyomo can make use of AMPL libraries. Pyomo 可以使用 AMPL 库。 From http://prod.sandia.gov/techlib/access-control.cgi/2015/155584.pdf I'm trying to run the following example:http://prod.sandia.gov/techlib/access-control.cgi/2015/155584.pdf我正在尝试运行以下示例:

`# file munson1.py
from pyomo.environ import *
from pyomo.mpec import *
model = ConcreteModel()
model.x1 = Var()
model.x2 = Var()
model.x3 = Var()
model.f1 = Complementarity(expr=
complements(model.x1 >= 0,
model.x1 + 2*model.x2 + 3*model.x3 >= 1))
model.f2 = Complementarity(expr=
complements(model.x2 >= 0,
model.x2 - model.x3 >= -1))
model.f3 = Complementarity(expr=
complements(model.x3 >= 0,
model.x1 + model.x2 >= -1))`

which should be run from bash with pyomo solve --solver=path munson1.py应该使用pyomo solve --solver=path munson1.py从 bash 运行

To make that work I should use the executable pathampl (PATH solver for AMPL) and put it in my $PATH.为了完成这项工作,我应该使用可执行的 pathampl(AMPL 的 PATH 求解器)并将它放在我的 $PATH 中。 I did that with two versions of it (available from the PATH website):我用它的两个版本(可从 PATH 网站获得)做到了这一点:

The mac os x version seems to be made for PowerPC it displays something along the line of "Wrong CPU version". mac os x 版本似乎是为 PowerPC 制作的,它显示了“错误的 CPU 版本”。

Alternatively I tried the Linux version, however the pyomo command returns Solver (path) returned non-zero return code (-1) .或者,我尝试了 Linux 版本,但是 pyomo 命令返回Solver (path) returned non-zero return code (-1) Calling pathampl by itself it shows /usr/local/bin/pathampl: cannot execute binary file .单独调用 pathampl 会显示/usr/local/bin/pathampl: cannot execute binary file

Does anybody have an idea of how to make it work?有没有人知道如何使它工作? Thanks!谢谢!

If the name of the executable on your system is 'pathampl', you need to be using that as the solver name for Pyomo.如果您系统上的可执行文件的名称是“pathampl”,则您需要将其用作 Pyomo 的求解器名称。 The reasoning for this has to do with how Pyomo interfaces with solvers that it does not recognize.这样做的原因与 Pyomo 如何与它无法识别的求解器交互有关。

Pyomo has custom interfaces for certain solvers, but when you ask it to use a solver that it does not recognize (the case for Path), it falls back to a more generic interface that works for any solver executable designed to work with AMPL. Pyomo 具有用于某些求解器的自定义接口,但是当您要求它使用它无法识别的求解器(Path 的情况)时,它会回退到更通用的接口,该接口适用于设计为与 AMPL 一起使用的任何求解器可执行文件。 When this happens, it assumes the solver name that you provided is the name of some executable on your system.发生这种情况时,它假定您提供的求解器名称是系统上某个可执行文件的名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM