import cvxpy as cp
from numpy import array
c=array([40,90])
a=array([[9,7],[-7,-20]])
b=array([56,-70])
x=cp.Variable(2,integer=True)
obj=cp.Minimize(c*x)
cons=[a*x<=b,x>=0]
prob.solve(solver='GLPK_MI',verbose=True)
print("最优解为:",print.value)
print("最优解为:\n",x.value)
最后显示prob这个名字没有定义,但是已经安装了prob库,是因为这个库的版本还是安装有问题呢?
没用过这个库,不过显然你的代码里没有导入这个库嘛!可能是import prob,这个你自己查查文档