问题
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). I'm using the most recent Anaconda install with Python 3.5.
Pyomo can make use of AMPL libraries. From http://prod.sandia.gov/techlib/access-control.cgi/2015/155584.pdf I'm trying to run the following example:
`# 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
To make that work I should use the executable pathampl (PATH solver for AMPL) and put it in my $PATH. I did that with two versions of it (available from the PATH website):
The mac os x version seems to be made for PowerPC it displays something along the line of "Wrong CPU version".
Alternatively I tried the Linux version, however the pyomo command returns Solver (path) returned non-zero return code (-1)
. Calling pathampl by itself it shows /usr/local/bin/pathampl: cannot execute binary file
.
Does anybody have an idea of how to make it work? Thanks!
回答1:
If the name of the executable on your system is 'pathampl', you need to be using that as the solver name for Pyomo. The reasoning for this has to do with how Pyomo interfaces with solvers that it does not recognize.
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. When this happens, it assumes the solver name that you provided is the name of some executable on your system.
来源:https://stackoverflow.com/questions/36809878/using-path-ampl-solver-with-pyomo-on-intel-mac-os-x