将SCIP设置为求解器时发生错误与PYOMO

问题描述:

我想解决在PYOMO中设置SCIP求解器的MILP问题。 我使用python ANACONDA解释器从PyDev中运行该问题。将SCIP设置为求解器时发生错误与PYOMO

我可以运行并解决与其他求解器,即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”。

蟒蛇,pyomo和求解器版本如下:

~$ 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 

我安装了最新SCIPOPTSUITE版本“4.0 .1“与Linux-Debian软件包”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是不是官方畅达包(因为没有)
  • 尝试通过pip首先安装并运行PySCIPOpt
  • PySCIPOpt没有与PYOMO接口,因此您很可能需要依赖AMP L为SCIP支持
  • PYOMO甚至支持SCIP吗?我不明白这一点从它们的文档

啊,看看我在Google上搜寻 “pyomo SCIP” 后发现:

所以,PYOMO只通过AMPL接口(ASL)支持SCIP。

+0

那么,这是否意味着我需要完全访问AMPL(我没有许可证)或者是否有其他方法来解决问题?我很喜欢SCIP,因为它对学术界来说是快速和免费的,但不得不使用MATLAB。然后我开始使用pyomo,如果我可以继续使用scip,woulde会很棒...... – sasap

+0

不,你不需要AMPL。按照这些说明为PYOMO生成必要的'scipampl'可执行文件。它看起来有点模糊,但我只是用最新的SCIP 4.0.1试过,它仍然有效。 – mattmilten

+0

我不能看到说明,它是否缺少链接? – sasap