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 ?