## 2 Materials and Methods
### Mathematical Model

Table 1: Sets, subsets, variable and parameters notations. The inlet to the second level of the HCSC (refinery plants and fractionation plant) is then processed and fractionated to its by-products based on the inlet compositions. The by-product flow is then forced to the third level of the HCSC to satisfy the local and international demands N3, Equation (5):  
\[\sum\
olimits_{p}\sum\
olimits_{i\in N1}w_{ijt}^{b}X_{ijt}^{p}=\sum\
olimits_ {k\in N3}\ X_{jkt}^{b}\ \ \ \forall\ \ t\in T,b\in B,\ j\in N2,\ k>\ i \tag{5}\]  
The material balance for the storage tanks belongs to the first and the second levels of the HCSC which are denoted by the two constraints:  
\[\sum\
olimits_{i\in N1}X_{ijt}^{p}+I_{it-1}^{p}=\sum\
olimits_{j\in N2}X_{jkt }^{p}+\sum\
olimits_{j\in N3}X_{jkt}^{p}+I_{it}^{p}\ \ \ \forall\ \ t\in T,p\in P,\ j\in S1,\ k>\ i \tag{6}\]  
The inlet flows from the upstream plants to each store tanks plus inventory left from the previous period (t - 1) equal to the outlet from the store tank plus inventory level at time period \(t\):  
\[\sum\
olimits_{i\in N2}X_{ijt}^{b}+I_{it-1}^{b}=+\sum\
olimits_{j\in N3}X_{ jkt}^{b}+I_{it}^{b}\ \ \forall\ \ t\in T,b\in B,\ j\in S2,\ k>\ i \tag{7}\]  
The inlet flows from plants located at the second level to each store tanks plus inventory left from the previous period (\(t-1\)) equal to the outlet from store tank plus inventory level at time period \(t\). The inlet to any petroleum plant is limited to the plant's capacity. If a plant is in maintenance, the capacity is dropped to zero. Equations (8) and (9) represent the capacity constraints for the plants belong to the first and the second levels of HCSC, respectively:  
\[\sum\
olimits_{t\in R}Y_{it}^{r}\leq\bigg{(}1-\sum\
olimits_{\tau=t-n_{t}+1} ^{t}St_{i\tau}\bigg{)}Ca_{it}\ \ \ \forall\ \ i\in N1,t\in T \tag{8}\]  
\[\sum\
olimits_{i\in N1}\sum\limits_{p\in P}X_{ijt}^{p}\leq\bigg{(}1-\sum \
olimits_{\tau=t-n_{j}+1}^{t}St_{j\tau}\bigg{)}Ca_{it}\ \ \ \forall\ \ j\in N2,t\in T \tag{9}\]  
The storage tanks' capacities are restricted by the following two constraints:  
\[CS_{j}^{min}\leq I_{ji}^{p}\leq CS_{j}^{max}\ \ \ \forall\ \ j\in S1,\ p\in P,\ t\in T \tag{10}\]  
\[CS_{j}^{min}\leq I_{ji}^{b}\leq CS_{j}^{max}\ \ \ \forall\ \ j\in S2,b\in B,t\in T \tag{11}\]  
Exportation volumes from each crude oil type should not exceed the quota specified by OPEC to each member in the Organization of the Petroleum Exporting Countries, Equation (12). In this study, maintenance was carried out on a weekly basis, while demand is on a monthly basis. Therefore, \(Dp_{t}\) represents the set of time periods included in the demand period starting at time \(t\), and dt denotes the duration of the demand period:  
\[\sum\
olimits_{i\in N1}\sum\
olimits_{j\in N3}\sum\
olimits_{p\in P}\sum \
olimits_{t\in Dp_{t}}\ X_{ijt}^{p}\leq OPEC_{t}\ \ \ \forall\ \ Dp_{t}=\{t,\ldots,t+d_{t}\} \tag{12}\]  
Equations (13) and (14) denote that the amount of sales plus shortages minus excess equals demand at any time period \(t\):  
\[\sum\
olimits_{i\in N1}\sum\
olimits_{t\in Dp_{t}}\ X_{ijt}^{p}+X_{it}^{p+}-X_{ it}^{p-}=D_{jit}^{p}\ \ \ \forall\ \ j\in N3,p\in P,Dp_{t}=\{t,\ldots,t+d_{t}\} \tag{13}\]  
\[\sum\
olimits_{p}\sum\
olimits_{i\in N1}w_{ijt}^{b}X_{ijt}^{p}=\sum\
olimits_ {k\in N3}\ X_{jkt}^{b}\ \ \ \forall\ \ t\in T,b\in B,\ j\in N2,\ k>\ i \tag{5}\]0The profit Equation (15) involves two main parts: the revenue obtained minus expenses, which includes maintenance costs, processing costs, transportation costs, holding costs, and the penalty costs of producing over and under the specified demand. \[