## 2 Mathematical Formulation
### Objectives Formulation
#### 2.3.3 Risk of Shortage  
One of the major advantages of many-objective optimization is that objectives do not have to match their units, as they are compared separately. This means that there is no effort to obtain a monetary cost for shortage, and the risk of shortage can be calculated directly based on the lead time from the suppliers and given the production schedule of how soon a given material is completely consumed.  
The final objective evaluated the risk of the optimized stocks not satisfying the production requirements. This considered the daily material requirements for an horizon of 60 days (\(N_{i,t}\)), the average lead time of the suppliers of each material (\(L_{i}\)), and the standard deviation of the lead time of the materials (\(\sigma_{i}\)). The first step was the calculation of the evolution of the daily stocks \(B_{i,t}\), based on the optimized stocks \(X_{i}\) and on the daily material requirements \(N_{i,t}\). This is shown in expression (11).  
\[B_{i,t}=\left\{\begin{array}{ll}X_{i}-N_{i,t}&t=1\\ B_{i,t-1}-N_{i,t}&t>1\end{array}\right. \tag{11}\]  
This expression simply establishes whether the stock of a material on a given day is positive or negative. The next stage was the calculation of the shortage day of each material \(ShD_{i}\), as shown in expression (12). The function _sign_ was used to collapse the value from \(B_{i,t}\) into either 1 or \(-1\). For consistency of the expression, if a value of \(B_{i,t}\) was 0, the function _sign_ returned the value 1, while the original _sign_ function would return the value 0; this was to ensure that the expression below worked properly if such a case took place.  
\[ShD_{i}=n_{t}-\left[\frac{n_{t}}{2}-\left(\sum_{t=1}^{n_{t}}\frac{sign(B_{i,t} )}{2}\right)-1\right] \tag{12}\]  
After obtaining on which days the stock of each material was exhausted, the calculation of the risk was performed. Three types of risk were considered:  
* The first and gravest type occurred when the shortage day was closer to the day of the optimization than the materials' mean lead time. This means that in average conditions, the stock would not be able to be replenished and there would be material shortage.
* The second type of shortage took place when the shortage day was closer to the day of the optimization than the materials' average lead time with one standard deviation.
* The third type of shortage was inversely proportional to the shortage day of each material without restocking; the further away the day when a material ran out, the smaller the risk.  
If a material had a shortage of the first type, the other two shortages were null; if the material had the second shortage type, the third type was null. This means that for each material, only the gravest type of shortage was considered. The calculation of the 3 types of shortage is shown in expressions (13)-(15).  
\[Sh1_{i}=\max(L_{i}-ShD_{i},0) \tag{13}\]  
\[Sh2_{i}=\left\{\begin{array}{ll}0,&Sh1_{i}>0\\ \max(L_{i}+\sigma_{i}-ShD_{i},0),&Sh1_{i}=0\end{array}\right. \tag{14}\]\[Sh3_{i}=\left\{\begin{array}{ll}0,&Sh1_{i}>0\lor Sh2_{i}>0\lor ShD_{i}=n_{t}+1\\ \left[-\max(-(L_{i}+\sigma_{i}-ShD_{i}),0)+n_{t}\right],&otherwise\end{array}\right. \tag{15}\]  
Finally, the shortage risk was calculated. This calculation weighed the types of risk differently. Generally speaking, the first type of risk should be weighted larger than the second, and the second larger than the third, to prioritize their reduction in the optimization. The calculation of the shortage risk was performed has shown in expression (16).  
\[R_{Sh}=\sum_{i=1}^{n_{i}}\left(Sh1_{i}\cdot SW1+Sh2_{i}\cdot SW2+Sh3_{i}\cdot SW3\right) \tag{16}\]