I would like to get the inventory balance in the oponed facility $\text{C}$ such that, the Inventory at time $t$ is equal to the previous one, plus the inflow minus the outflow. I have tried to create a list with zeroes, but I could not make it automated. The other issue is with indexing in python. For instance, if $t$ which is time in months, and it's range(0,3)
then, $t-1$ is $(-1)$ which gives an error.
$INV_{c,t}$: is the inventory at time $t$.
$INV_{c,t-1}$: is the inventory at time $t-1$.
The equations: $INV_{c,t}=INV_{c,t-1}+\sum{QS}_{c,t}+\sum{QM}_{c,t}-\sum{QG}_{c,t}$
Inventory level decision variable
INV_c= m.addVars(storages,months, name="INV_ct")
Inventory Balance Constraints
m.addConstrs(INV_c[c,t] == INV_c[c,t-1] + sum(QD_wc[w,c,t,p] for w in range(warehouses) for p in range(products)) + sum(QH_hc[h,c,t]\
for h in range(customers)) - sum(QG_co[c,o,t] for o in range(centers)) for c in range(storages) for t in range(months))
I have defined $INV0_{c,t}$ as parameter (an array of 3 by 2 dimension), in which $INV0_{c,t}$ could replace INV_c[c,t-1]
in the above constraint.
I have tried to write a for loop to capture the cumulative inventory at each period, by defining the following code;
INV0_[c,t]=0
for t in range(months):
for c in range(storages):
INV0_[c,t]=INV0_[c,t]+INV_c[c,t]
INV_c[c,t]
andINV_ct0[c,t]
are the same variables and should not be separated into two different variables. Instead, something like that:INV_c[c,t] = INV_c[c,t-1]
. $\endgroup$