## 2 Materials and Methods
### Objective Functions (OFs)
#### 2.1.1 Objective 1: Minimizing the Total Costs of Operating in MG  
The total expenses of operation in MG consist of the fuel costs of the power plant units and their costs of start-up and shut-down. The result of this part is a collection of optimal load flow from energy resources to the loads economically for a specific time period. Storage system options, in addition to distributed generations (DGs), can be utilized to compensate expensive power buying from the company and storing power in off-peakhours to predict the increasing projected prices. In this way, we can formulate the first OF as follows:  
\[\begin{split}\text{Minf}_{1}(\text{X})=\sum_{t=1}^{\text{T}}\text{ Cost}^{t}=\sum_{t=1}^{\text{T}}\{\sum_{a=1}^{\text{N}_{g}}[\text{u}_{1}(t)\text{P}_{Gi}(t) \text{B}_{Gi}(t)+\text{S}_{Gi}|\text{u}_{1}(t)-\text{u}_{i}\left(t-1\right)|]+ \\ \sum_{i=1}^{\text{N}_{g}}[\text{u}_{j}(t)\text{P}_{\text{s}j}(t) \text{B}_{\text{s}j}(t)+\text{S}_{\text{s}j}|\text{u}_{j}(t)-\text{u}_{j}\left( t-1\right)|+\text{P}_{Grid}(t)\text{B}_{Grid}(t)\}.\end{split} \tag{1}\]  
where \(B_{Gi}(t)\) represents the bids from the DG resources, \(B_{\text{s}j}(t)\) is the storing options at hour t, \(S_{Gi}\) is the start-up expenses for \(ith\) DG and \(jth\) storage component, \(S_{sj}\) gives the shut-down expenses for \(ith\) DG and \(jth\) storage component; \(P_{Grid}(t)\) also represents the active power that is purchased/sold from/to the companies at time \(t\); \(B_{Grid}(t)\) represents the bid of company at \(t\); \(X\) also gives the vector of state variables such as active powers of power plants and their related states which can be defined as the following equations:  
\[\begin{split}\text{X}=\left[\text{P}_{g},\;\text{U}_{g}\right]_{1 \times\text{2 nT}}\\ \text{P}_{g}=\left[\text{P}_{G},\;\text{P}_{s}\right]\\ \text{n}=\text{N}_{g}+\text{N}_{s}+1\end{split} \tag{2}\]  
where in the Equation (2), \(T\) represents the total hours number in the tested time period; \(n\) gives the state variables number; \(N_{g}\) also represents the DGs' total number, and \(N_{s}\) gives the storage total number of power plant units; \(P_{g}\) represents the all DG units' active power; \(U_{g}\) also gives the state vector defining the position of ON/OFF states for all power plant units in every hour of a day. All of these variables are given in Equations (3) and (4).  
\[\begin{split}\text{P}_{G}=\left[\text{P}_{G1},\;\text{P}_{G2}, \;\ldots,\;\text{P}_{G,N_{g}}\right]\\ \text{P}_{Gi}=\left[\text{P}_{Gi}(1),\;\text{P}_{Gi}(2),\;\ldots, \text{P}_{Gi}(t),\;\ldots,\;\text{P}_{Gi}(T)\right]\text{; }\text{ i}=1,\;2,\;\ldots,\;\text{N}_{g}+1\\ \text{P}_{s}=\left[\text{P}_{\text{s}1},\;\text{P}_{s2},\;\ldots, \;\text{P}_{s,N_{g}}\right]\\ \text{P}_{\text{s}j}=\left[\text{P}_{\text{s}j}(1),\;\text{P}_{ \text{s}j}(2),\;\ldots,\text{P}_{\text{s}j}(t),\;\ldots,\;\text{P}_{\text{s}j }(T)\right]\text{; }\text{ j}=1,\;2,\;\ldots,\;\text{N}_{s}\end{split} \tag{3}\]  
where in the Equation (3), \(P_{Gi}(t)\) and \(P_{sj}(t)\) represent the outputs power for \(ith\) generator and \(jth\) storage at time \(t\).  
\[\begin{split}\text{U}_{g}=\left[\text{u}_{1},\;\text{u}_{2},\; \ldots,\;\text{u}_{n}\right]=\left\{\text{u}_{i}\right\}_{1\times\text{n}} \varepsilon\{0,\;1\};\\ \text{u}_{k}=\left[\text{u}_{k}(1),\;\text{u}_{k}(2),\;\ldots,\; \text{u}_{k}(t),\;\ldots,\;\text{u}_{k}(T)\right]\text{; }\text{ k}=1,\;2,\;\ldots,\;\text{n}\end{split} \tag{4}\]  
where \(u_{k}(t)\) gives the unit status \(k\) at hour \(t\).