所以我有一个问题,当它处理打印变量时,它可以得到一个结果,但不能打印变量
I是月份,J是产品名称,所以我的设置变量
w_permanent = M.addVars (J , I , lb=0 , vtype=GRB.INTEGER, obj=salary)
w_temporary = M.addVars (J , I , lb=0 , vtype=GRB.INTEGER , obj=salary )
w_hire = M.addVars ( I , lb=0 , vtype=GRB.INTEGER , obj=cost_hire[j])
w_fire = M.addVars ( I , lb=0 , vtype=GRB.INTEGER , obj=cost_fire[j])
Stock = M.addVars (J , I , lb=0 , vtype=GRB.CONTINUOUS , obj=b)
if M.status == GRB.Status.OPTIMAL:
print ('Total cost : %10.2f euro' % M.objVal)
print ('')
print ('All decision variables:\n')
print ('Stock per month per product:\n')
for i in I:
for j in J:
print('x1 = %f' % w_permanent[i,j].w_permanent)发布于 2018-10-26 06:15:45
使用.X属性获取当前解决方案中变量的值:
print('x1 = %f' % w_permanent[i,j].X)https://stackoverflow.com/questions/52993370
复制相似问题