如何总和二维纸浆溶液
我有以下代码切口:
a = range(0, 30)
b = range (0, 88)
Power_consumption = LpVariable.dicts('Power_consumption', (a,b), lowBound=0, upBound=5, cat='Continuous')
...
result= [[]]
for i in a:
for j in b:
print("i:",3, "j:",3, " = ", Power_consumption[i][j].varValue)
result[i][j] = Power_consumption[i][j].varValue
在获得线性编程模型的选择性解决方案后,我想在索引i(i = timeStep,j = device)上总结“ power_ccumpumption”,以便我为每个timeStep“ i”所有设备的功耗。但是,当尝试时,我一直都会获得“ IndexError:列表分配索引范围之外”。所以我想知道我做错了什么,最好的做法是什么?
I have following code cutouts:
a = range(0, 30)
b = range (0, 88)
Power_consumption = LpVariable.dicts('Power_consumption', (a,b), lowBound=0, upBound=5, cat='Continuous')
...
result= [[]]
for i in a:
for j in b:
print("i:",3, "j:",3, " = ", Power_consumption[i][j].varValue)
result[i][j] = Power_consumption[i][j].varValue
After getting the optmimal solution of the Linear Programming Model, I would like to sum up the "Power_consumption" on the index i ( i = timestep, j = device) so that I have for every timestep "i" the power consumption of all devices. But when trying I get all the time "IndexError: list assignment index out of range". So I am wondering what I did wrong and whats the best way of doing so ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您对
a
和b
的变量并不正确。在那里更加明确…I don’t think you are constructing your variable correctly with respect to
a
andb
. Be more explicit there…