有人可以告诉我如何将SCIP模块安装到Spyder(Python 3.6)中 . 顺便说一下,这与anaconda有关 . 我一直试图让这个模块进入这个python 3.6过去两天,我没有得到任何地方 . 这令人沮丧 .
我需要它解决混合整数编程问题 .
老实说,我不在乎我们使用什么编程语言,只要我能解决我的MIP问题 . 但是,最好将SCIP安装到Spyder(Python 3.6)中,因为我熟悉该语言 .
请告诉我最快捷,最简单的方法 . 我也刚刚下载并安装了独立的python 3.6 . 我真的很感激,如果有人可以帮助我 .
谢谢!
我试图运行以下代码:
from zibopt import scip
solver = scip.solver()
# All variables have default lower bounds of 0
x1 = solver.variable(scip.INTEGER)
x2 = solver.variable(scip.INTEGER)
x3 = solver.variable(scip.INTEGER)
# x1 has an upper bound of 2
solver += x1 <= 2
# Add a constraint such that: x1 + x2 + 3*x3 <= 3
solver += x1 + x2 + 3*x3 <= 3
# The objective function is: z = x1 + x2 + 2*x3
solution = solver.maximize(objective=x1 + x2 + 2*x3)
# Print the optimal solution if it is feasible.
if solution:
print('z =', solution.objective)
print('x1 =', solution[x1])
print('x3 =', solution[x2])
print('x2 =', solution[x3])
else:
print('invalid problem')
我得到的错误:
from zibopt import scip
ModuleNotFoundError: No module named 'zibopt'
我已经将scip文件夹放在C:驱动器的site-packages文件夹中,并希望它可以工作 . 我还有其他一些东西,但我不记得它们是什么 .
1 回答
如果你想在Python中使用SCIP,你应该使用这个界面:https://github.com/SCIP-Interfaces/PySCIPOpt
我甚至不知道你是如何找到旧的zibopt软件包而不是绊倒PySCIPOpt的 .
顺便说一句,如果你只想解决一个混合整数程序,你可以简单地为你选择的平台下载SCIP的二进制/可执行文件 . 然后,您需要以某种方式对问题进行建模,例如:使用ZIMPL或简单地作为普通
.lp
文件(有关格式说明,请参阅here) .