【发布时间】:2017-06-05 08:41:39
【问题描述】:
我想比较一下 Gurobi 和 Scipy 的线性编程工具,比如 linprog。 Scipy 需要在 matrix-list-vector-form 中指定问题,而 Gurobi 的工作方式类似于 here 这样
m = Model()
m.addVar(...) %for variables
m.addConstr(..>) %for constraints
m.update() %for updating the model
m.optimize % for optimizing the model
m.params %for getting parameters
m._vars %for getting variables
相比之下Scipy
Minimize: c^T * x
Subject to: A_ub * x <= b_ub
A_eq * x == b_eq
c : array_like
Coefficients of the linear objective function to be minimized.
A_ub : array_like, optional
2-D array which, when matrix-multiplied by x, gives the values of the upper-bound inequality constraints at x.
b_ub : array_like, optional
1-D array of values representing the upper-bound of each inequality constraint (row) in A_ub.
A_eq : array_like, optional
2-D array which, when matrix-multiplied by x, gives the values of the equality constraints at x.
b_eq : array_like, optional
1-D array of values representing the RHS of each equality constraint (row) in A_eq.
bounds : sequence, optional
我的目标是只用一种方法编写代码,并且仍然使用两个求解器对结果进行基准测试。为了加快比较求解器:
Scipy 是否存在 Gurobi 风格的 LP 问题模型构建?
是否存在使这两种方法可互换的包(我可以为 Gurobi 编写 scipy 样式或为 Scipy 编写 Gurobi 样式)?
scipy 是否提供任何其他接口来指定线性规划问题?
【问题讨论】:
-
你看过this的回答吗?
-
loannis:谢谢,但它与稀疏矩阵有关,在这里并不真正相关。
标签: python scipy linear-programming solver gurobi