import numpy as np
import cvxpy as cp
n = 2
x = cp.Variable(n,integer = True)
A1 = np.array([[0,5],
[6,2],
[1,1]])
b1 = np.array([15,24,5])
A2 = np.array([[1,0],
[0,1]])
b2 = np.array([0,0])
c = np.array([2,1])
prob = cp.Problem(cp.Maximize(c.T @ x),
[A1 @ x <= b1,
A2 @ x >= b2])
ans = prob.solve(solver='GLPK_MI')
print("目標函式最大值:", ans)
print(x.value)
3022