司守奎《数学建模算法与应用》第二版 第一章线性规划1.2
from scipy.optimize import linprog
import numpy as np
if __name__ == "__main__":
f = np.array([[-2, -3, 5]])
A = np.array([[-2,5,-1],[1,3,1]])
b = np.array([[-10,12]]).T
Aeq = np.array([[1,1,1]])
beq = 7
lb = np.zeros(3)
ub = np.array([None]*3)
bound = np.vstack((lb, ub)).T
res = linprog(f,A,b,Aeq,beq,bound)
print("显示目标函数的最小值", res.fun)
print("最优解为",res.x)
# output:显示目标函数的最小值 -14.571428571428571
# 最优解为 [6.42857143 0.57142857 0. ]