0

最近我想尝试一些开源求解器而不是 CPLEX。我发现 PICOS + zibopt 可能是一个不错的选择。但是,我只能找到有关如何使 zibopt 在 windows 下正确使用 python 的说明。我下载了scip的windows库(.dll文件),并尝试根据命令“python setup.py install”安装python-zibopt。总是弹出错误“ blockmemshell/memory.h no such file”。我觉得是因为我的编译器VS120COMNTOOL没有找到scip求解器。我现在有没有机会让 scip 在 Windows 下工作?

4

1 回答 1

0

你看过 SCIP 3.1.0 当前的 python 界面了吗?它使用 SCIP 优化套件中的库,因此您不必将另一个 LP 求解器链接到 SCIP。在 Windows 上,请尝试这个修改后的 setup.py 文件:

import sys, os, readline, glob, platform
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
from Cython.Build import cythonize

BASEDIR = os.path.dirname(os.path.abspath(__file__))
BASEDIR = os.path.dirname(BASEDIR)
BASEDIR = os.path.dirname(BASEDIR)
INCLUDEDIR = os.path.join(BASEDIR,'src')
BASEDIR = os.path.dirname(BASEDIR)

#identify compiler version
prefix = "MSC v."
i = sys.version.find(prefix)
if i == -1:
  raise Exception('cannot determine compiler version')
i = i + len(prefix)
s, rest = sys.version[i:].split(" ", 1)
majorVersion = int(s[:-2]) - 6
minorVersion = int(s[2:3]) / 10.0

if platform.architecture()[0].find('64')>=0:
  LIBDIR  = os.path.join(BASEDIR,'vc'+str(majorVersion),'scip_spx','x64','Release')
else:
  LIBDIR  = os.path.join(BASEDIR,'vc'+str(majorVersion),'scip_spx','Release')
print('BASEDIR='+ BASEDIR)
print('INCLUDEDIR='+ INCLUDEDIR)
print('LIBDIR='+ LIBDIR)

def complete(text, state):
  return (glob.glob(text+'*')+[None])[state]

readline.set_completer_delims(' \t\n;')
readline.parse_and_bind("tab: complete")
readline.set_completer(complete)

libscipopt = 'lib/libscipopt.so'
includescip = 'include/scip'

ext_modules = []

ext_modules += [Extension('pyscipopt.scip', [os.path.join('pyscipopt', 'scip.pyx')],
                      #extra_compile_args=['-g', '-O0', '-UNDEBUG'],
                      include_dirs=[INCLUDEDIR],
                      library_dirs=[LIBDIR],
                      #runtime_library_dirs=[os.path.abspath('lib')],
                      libraries=['spx', 'scip_spx'])]
                      #libraries=['scipopt', 'readline', 'z', 'gmp', 'ncurses', 'm'])]

setup(
  name = 'pyscipopt',
  version = '0.1',
  description = 'wrapper for SCIP in Python',
  author = 'Zuse Institute Berlin',
  author_email = 'scip@zib.de',
  license = 'MIT',
  cmdclass = {'build_ext' : build_ext},
  ext_modules = ext_modules,
  packages=['pyscipopt']
)
于 2014-11-03T12:26:33.260 回答