## 2 Problem Outlines
### The Objective Function
#### 2.3.7 Constraints  
The optimization problem is accompanied by a set of technical constraints that restrict the solution space and must be considered in the model. These constraints can be defined as follows:  
The power balance equality constraint during all intervals of a day:  
\[\sum_{t=1}^{24}P_{PV}^{t}+P_{dg}^{t}+P_{bat}^{t}-P_{D\_mic}^{t}=0 \tag{7}\]  
The maximum permissible load shedding in the microgrid:  
\[\sum_{t=1}^{24}P_{sh}^{t}\leq 0.25\times\sum_{t=1}^{24}P_{D\_mic}^{t} \tag{8}\]  
Generation balance in the distribution network must be observed.  
\[\sum_{t=1}^{24}P_{g}^{t}+P_{ex}^{t}+P_{slack}^{t}-P_{loss}^{t}-P_{D\_dis}^{t}=0 \tag{9}\]The boundaries of the photovoltaic panel and diesel generator must be met.  
\[0<P_{PV}<P_{PV}^{\max} \tag{10}\]  
\[0<P_{dg}<P_{dg}^{\max} \tag{11}\]  
The voltage of buses must be restricted within their permissible range.  
\[V_{\min}<V<V_{\max} \tag{12}\]  
The power flow passing through the lines must be restricted.  
\[F_{b}<Limit_{b} \tag{13}\]  
In the above equations, \(P_{PV}^{t}\), \(P_{dg}^{t}\), and \(P_{bat}^{t}\) represent power generation of PV panel, diesel generator, and batteries, respectively. Moreover, \(P_{D\_mic}^{t}\) indicates the consumption of the microgrid at hour \(t\). The shed load of the microgrid is shown by \(P_{sh}^{t}\). In addition, \(P_{g}^{t}\), \(P_{ex}^{t}\), \(P_{slack}^{t}\), \(P_{loss}^{t}\), and \(P_{D\_dis}^{t}\) represent the power generated by the generators in the distribution network, the exchanged power of the microgrid with the distribution network, the power maintains from the slack bus of the distribution network, the power losses in the distribution network, and the consumption of the distribution network at hour \(t\). Moreover, \(P_{PV}^{t}\), \(P_{dg}^{t}\), \(V\), \(V_{min}\), \(V_{max}\), \(F_{b}\), and \(Limit_{b}\) stand for the maximum capable power generation by PV panel, the maximum capable power generation by a diesel generator, bus voltage, the minimum and maximum permissible voltage of buses, the flow passing through branch \(b\), and the thermal limit of branch \(b\).  
The prevailing constraints of the problem can be divided into two general categories of network constraints and storage constraints that must always be observed when seeking for optimal point in the solution space. Network constraints include the following two constraints:  
As the thermal limit constraints express, the feeder power flow is not allowed to violate a specific cap.  
\[S_{k}\leq\text{limit}_{k} \tag{14}\]  
The hourly constraints pertaining to the energy storage unit consist of two constraints of the maximum storage capacity and charge/discharge rate limits. This limitation expresses that the storage charge level must always be below the maximum storage capacity and can be formulated as follows:  
\[P_{min\_ch}\times I_{ch}(t)\leq\ P_{ch}(t)\leq P_{max\_ch}\times I_{ch}(t) \tag{15}\]  
\[P_{min\_chch}\times I_{dch}(t)\leq\ P_{dch}(t)\leq P_{max\_ch}\times I_{dch}(t) \tag{16}\]  
\[SoC_{min}\leq SoC(t)\ \leq SoC_{max} \tag{17}\]  
\[SoC(t+1)=SoC(t)-P_{dch}(t)\times I_{dch}(t)+P_{ch}(t)\times I_{ch}(t) \tag{18}\]  
\[I_{ch}(t)+I_{sch}(t)\leq\ 1 \tag{19}\]  
In this equation, \(t\) represents the time, \(P_{ch}\) and \(P_{ddh}\) denote the charge and discharge rates, and \(SoC\) stands for the state of charge of the storage unit that has a maximum storage capacity limit and a minimum storage capacity boundary owing to the long-run operation and maintenance facets. Each storage unit can be charged or discharged by a limited amount within an hour. The last equation also ensures that the storage unit cannot operate at charge and discharging modes simultaneously. In this equation, \(I(t)\) is a binary variable.