TypeOfErrore:AttributeError: 'generator'对象没有属性'Extract'



我正在使用Python中Ortools的GLOP线性规划求解器。我必须定义这种类型的约束:

solver.Add(a_min*D_th_h[i]<=Pth_A1_K[i]+Pth_A2_K[i]+Pth_B[i]<=a_max*D_th_h[i] for i in range(0, T_tot))

但我收到此错误

return constraint.Extract(self, name)
AttributeError: 'generator' object has no attribute 'Extract'

谁能解释我做错了什么?

也许你的意思是这个?

for i in range(0, T_tot):
solver.Add(a_min*D_th_h[i]<=Pth_A1_K[i]+Pth_A2_K[i]+Pth_B[i]<=a_max*D_th_h[i])

最新更新