【发布时间】:2017-02-24 20:54:36
【问题描述】:
谁能告诉我如何将 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 文件夹中,希望它能正常工作。我还有一些其他的东西,但我不记得它们是什么了。
【问题讨论】:
-
评论不用于扩展讨论;这个对话是moved to chat。