使用 PYOMO 将 SCIP 设置为求解器时出错

Error when setting SCIP as solver with PYOMO

我正在尝试解决在 PYOMO 中使用 SCIP 作为求解器设置的 MILP 问题。 我 运行 使用 python ANACONDA 解释器从 PyDev 内部解决问题。

我可以 运行 并使用其他求解器解决问题,即 CBC、GLPK 和 IPOPT。

但是,当使用 SCIP 作为求解器时,它不起作用。 SCIP/AMPL 界面似乎有问题...有人可以帮忙吗?

下面是错误提示和系统配置的一些详细信息。


我试过 'scip' 和 'scipampl'。

和'scip'

opt = SolverFactory('scip')
instance = model.create_instance("test1.dat")
results = opt.solve(instance)
instance.display()

WARNING: "[base]/site-packages/pyomo/solvers/plugins/solvers/SCIPAMPL.py", 68, _default_executable Could not locate the 'scipampl' executable, which is required for solver scip Traceback (most recent call last): File "/home/alessandro/Documents/Eclipse workspace/test1/src/test1.py", line 48, in results = opt.solve(instance) # solves and updates instance File "/home/alessandro/anaconda3/lib/python3.6/site-packages/pyomo/opt/base/solvers.py", line 539, in solve self.available(exception_flag=True) File "/home/alessandro/anaconda3/lib/python3.6/site-packages/pyomo/opt/solver/shellcmd.py", line 122, in available raise ApplicationError(msg % self.name) pyutilib.common._exceptions.ApplicationError: No executable found for solver 'scip'

和'scipampl'

opt = SolverFactory('scipampl')
instance = model.create_instance("test1.dat")
results = opt.solve(instance)
instance.display()

WARNING: "[base]/site-packages/pyomo/opt/base/solvers.py", 202, solver_call Failed to create solver with name 'scipampl': Failed to set executable for solver asl. File with name=scipampl either does not exist or it is not executable. To skip this validation, call set_executable with validate=False. Traceback (most recent call last): File "/home/alessandro/Documents/Eclipse workspace/test1/src/test1.py", line 48, in results = opt.solve(instance) File "/home/alessandro/anaconda3/lib/python3.6/site-packages/pyomo/opt/base/solvers.py", line 127, in solve self._solver_error('solve') File "/home/alessandro/anaconda3/lib/python3.6/site-packages/pyomo/opt/base/solvers.py", line 155, in _solver_error + "\n\toptions: %s" % ( self.options, ) ) RuntimeError: Attempting to use an unavailable solver.

The SolverFactory was unable to create the solver "scipampl" and returned an UnknownSolver object. This error is raised at the point where the UnknownSolver object was used as if it were valid (by calling method "solve").

The original solver was created with the following parameters: executable: scipampl type: scipampl _args: () options: {}

Eclipse 版本为"Oxygen.1 (4.7.1)",PyDev 版本为“6.0.0”。

python、pyomo、solvers版本如下:

~$ python
Python 3.6.2 |Anaconda custom (64-bit)| (default, Sep 30 2017, 18:42:57) [GCC 7.2.0] on linux

~$ pyomo --version
Pyomo 5.2 (CPython 3.6.2 on Linux 4.10.0-35-generic)

~$ cbc
Welcome to the CBC MILP Solver 
Version: 2.9.9 
Build Date: Jul  6 2017

~$ glpsol
GLPSOL: GLPK LP/MIP Solver, v4.63

~$ ipopt
No stub!
usage: ipopt [options] stub [-AMPL] [<assignment> ...]

~$ scip 
SCIP version 4.0.1 [precision: 8 byte] [memory: block] [mode: optimized] [LP solver: SoPlex 3.0.1] [GitHash: 8a04b84]
Copyright (C) 2002-2017 Konrad-Zuse-Zentrum fuer Informationstechnik Berlin (ZIB)
External codes: 
SoPlex 3.0.1         Linear Programming Solver developed at Zuse Institute Berlin (soplex.zib.de) [GitHash: 24cffa9]
CppAD 20160000.1     Algorithmic Differentiation of C++ algorithms developed by B. Bell (www.coin-or.org/CppAD)
ZLIB 1.2.8           General purpose compression library by J. Gailly and M. Adler (zlib.net)
GMP 6.1.0            GNU Multiple Precision Arithmetic Library developed by T. Granlund (gmplib.org)
ZIMPL 3.3.4          Zuse Institute Mathematical Programming Language developed by T. Koch (zimpl.zib.de)
Ipopt 3.12.8         Interior Point Optimizer developed by A. Waechter et.al. (www.coin-or.org/Ipopt)
user parameter file <scip.set> not found - using default parameters
SCIP> ^C

我安装了 CBC、GLPK 和 IPOT 包如下:

conda install -c conda-forge coincbc
conda install -c conda-forge glpk
conda install -c conda-forge ipopt

我使用 Linux-Debian 软件包安装了最新的 SCIPOPTSUITE 版本“4.0.1”"SCIPOptSuite-4.0.1-Linux.deb"

我还安装了AMPL-MP SCIPOPTLIB和PYSCIPOPT如下:

conda install -c conda-forge ampl-mp
conda install -c leethargo scipoptlib
conda install -c leethargo pyscipopt

编辑: 请遵循以下说明:http://zverovich.net/2012/08/07/using-scip-with-ampl.html

几件可能有帮助的事情:

  • leethargo处的conda包不是官方conda包(因为有none)
  • 首先尝试通过 pip 安装和 运行 PySCIPOpt
  • PySCIPOpt 未与 PYOMO 接口,因此您很可能需要依赖 AMPL 来支持 SCIP
  • PYOMO 是否支持 SCIP?我无法从他们的文档中弄清楚这一点

啊,看我谷歌搜索后发现了什么 "pyomo scip":

因此,PYOMO 仅通过 AMPL 接口 (ASL) 支持 SCIP。