更新时间:2023-11-25 22:31:04
严格来说,如果问题是二进制编程问题,那么它不是线性程序.
Just to be rigorous, if the problem is a binary programming problem, then it is not a linear program.
您可以尝试 CVXOPT .它具有整数编程功能(请参见此).要使您的问题成为二进制程序,您需要添加约束0< = x< = 1.
You can try CVXOPT. It has a integer programming function (see this). To make your problem a binary program, you need to add the constrain 0 <= x <= 1.
编辑:您实际上可以将变量声明为二进制,因此无需添加约束0< = x< = 1.
Edit: You can actually declare your variable as binary, so you don't need to add the constrain 0 <= x <= 1.
cvxopt.glpk.ilp = ilp(...)
Solves a mixed integer linear program using GLPK.
(status, x) = ilp(c, G, h, A, b, I, B)
PURPOSE
Solves the mixed integer linear programming problem
minimize c'*x
subject to G*x <= h
A*x = b
x[I] are all integer
x[B] are all binary