# Optimizing Inventory Replenishment for Seasonal Demand with Discrete Delivery Times
## 3 Methodology
Equations (16) and (17) are to define the lot sizes, which are the total average demand for the period covered by the lot, plus the adjustment of the safety stock levels depending on the differences of standard deviations. This adjustment can be positive or negative based on the increase or decrease in the standard deviations. The equal or greater than \"\(>=\)\" is used instead of \"\(=\)\" because the value of \(Q_{ij}\) must be an integer. Equation (17) is necessary in case the first week is covered by a new replenishment. The parameter \(L_{i-1}\) is the standard deviation of the demand in the lot before week \(i\). For example, if \(x_{25}=1\), then \(L_{5}>0\) is the standard deviation of demand during the weeks from 2 to 5. In this case, \(L_{2}\), \(L_{3}\), and \(L_{4}\) must be zeros. To model that, Equations (18) and (19) are used. In Equation (18), the first term is for the first period before the first delivery to find the residual inventory just before the first delivery. It is multiplied by \(1/z\) to cancel the multiplication by \(z\) in Equation (16). In other words, for the first delivery, the lot size is the demand plus safety stock minus the residual inventory at the end of the initial period. That means that \(L_{w}\) in this particular case has a different meaning which is the residual inventory at the end of the initial period divided by \(z\). \(K_{w}\) is a binary variable and is defined in Equation (19). It has the value of 1 only if the week \(w\) is the one before the first delivery. For example, if \(Y_{1}\) and \(Y_{2}=0\) (first delivery occurs at week 1), then \(K_{w}=0\). If \(Y_{1}=1\) and \(Y_{2}=1\) (first delivery is after week 2), then \(K_{1}=0\) too. Only if \(Y_{1}=1\) and \(Y_{2}=0\) (first delivery is in week 2), \(K_{1}=1\). Equation (20) is to define the safety stock sizes, which are the lot sizes plus initial inventory, minus the average total demand until the last week \(j\). Safety stock is only positive if \(x_{ij}\) is positive, otherwise, it is zero. The final Equation (21) is just the non-negativity constraints. However, Equation (20) is nonlinear because it multiples two variables, namely, \(Q_{ij}\) and \(x_{\bar{y}}\). To simplify the model and make it linear, the following equations are used instead of Equation (20):  
\[O=\sum_{i=1}^{T}\sum_{j=i}^{T}x_{ij} \tag{2}\]4  
\[O=\sum_{i=1}^{T}\sum_{j=i}^{T}x_{ij} \tag{2}\]5  
\[O=\sum_{i=1}^{T}\sum_{j=i}^{T}x_{ij} \tag{2}\]6  
\[O=\sum_{i=1}^{T}\sum_{j=i}^{T}x_{ij} \tag{2}\]7  
\(B_{ij}\) can be zero if \(x_{\bar{y}}\) is zero, or it takes the value of all the lot quantities so far until week \(j\). The term (\(M\) (\(1-x_{ij}\))) in Equation (23) is used to enforce the model to assign a positive value for the \(B_{ij}\) when \(x_{ij}\) is 1. On the other hand, Equation (24) is used to enforce the model to assign a zero value for the \(B_{ij}\) when \(x_{\bar{y}}=0\). \(B_{ij}\) cannot be negative as shown by Equation (25). \(P_{w}\) is needed to be found every week. So every week, there must be a review. The difference between this system and the period review system is that there is no need to trigger orders every week. MIP is useful to show the logic and constraints of the study. However, MIP is usually slow, especially if the size of the model is big and the planning horizon is long. To get results faster, dynamic programming (DP) can be utilized. R software was used to model DP. Algorithm 1 shows the heart of the model. To find the whole programming source code, the reader might check the following Supplementary Materials link: (https://gitio./JKmho(accessed on 24 November 2021)). Initial definitions of matrices and variables must be carried out at first before obtaining the code shown. \(T\) is the number of weeks. wi_o [o,j] is to find the weeks of delivery if the number of orders is o and the last considered week is \(j-1\). OF_o [o,j] is to find the value of the objective function also if the number of orders is o and the last considered week is \(j-1\).