0
我得到TypeError:无法乘以类型'浮动'非int的序列。这里是我的代码:Python错误“浮动”
# Define x[i][j] for Gurobi
for i in S:
for j in D:
decvarx[i][j] = m.addVar(lb = 0, obj=c[i][j]*u[i], vtype=GRB.CONTINUOUS, name="x.%d.%d" % (i,j))
我认为有一个问题与你[我],但我不太确定。这里是代码为:[i]:
# u is an array of supply values (indexed on processing facility numbers).
u = []
for i in range(0,max(S)+1):
u.append([]) # Add an empty spot for u[i]
for row in range(0,len(FAC_data)):
i = int(FAC_data[row][0]) # This is the processing facility number
u[i] = 1000*FAC_data[row][2] # This is the supply for this processing facility
谢谢你的任何帮助,你可以提供!!!!
我认为问题出在'c'上,而不是'u'。如果'c [i] [j]'是一个列表或其他东西,你不能用浮点数乘它。 – Kevin 2014-12-05 16:43:44