## 4 Formulation of the Proposed Modeling Framework with MESSs
### The PEV-PLs' Constraints  
In this work, many constraints were considered to model the number and location of PEV-PLs among MGs, the capacity of electric vehicles, and the number of electric vehicles. The initial energy of PEVs represents the energy within a PEVs battery when it enters an MG's parking lot station for the charging-discharging process. As a result, the initial energy at PEVs in the first time interval was considered in the planning to estimate the energy of PEVs, as anticipated in (32) and (33). As seen in the (34), the energy stored inside the battery in the final period equals the energy stored in the first time intervals. The energy storage capacity of PEVs was limited by the upper and lower energy stored and the number of PEVs that enter the PLs for charging and discharging as denoted in (35). The limitations of charging and discharging power are represented in (36) and (37), respectively, whereas Equation (38) limits the BESS to choose just one action of the charging or discharging process by using the (M) method for linearization purpose. Constraints (39) and (40), specify the charging and discharging powers in terms of installed maximum power, which should not be greater than the considered maximum power. In addition, constrain (42) is defined as the number of PEVs that should not exceed the maximum permitted number. The deployment of PLs in the MGs is important due to the obvious benefits of PEVs and rising trends in growing PEV penetration into the grid via MGs. In this regard, the binary variable is introduced in Constraint (43) to ensure the PL charging stations support all electric vehicles in the network. For that purpose, (44) restricts the maximum capacity of ith PLs for each MG.  
\[E_{e,t,s}^{Pev}=\Upsilon_{e,t,s}^{PEV}\times E_{e}^{Initial}+E_{e,t-1,s}^{Pev} +\Delta E_{e,t,s}^{Pev}\qquad\forall e\in\mathbb{N},t\in T,s\in\omega \tag{32}\]  
\[\Delta E_{e,t,s}^{Pev}=\eta_{Pev}^{Ch}P_{e,t,s}^{Ch.Pev}-\frac{P_{e,t,s}^{Dis. Pev}}{\eta_{Pev}^{dis}}\qquad\forall e\in\mathbb{N},t\in T,s\in\omega \tag{33}\]  
\[E_{e,t,2}^{Pev}=E_{e,t-1,s}^{Pev}\qquad\forall e\in\mathbb{N},s\in\omega \tag{34}\]  
\[E_{e,t,s}^{Pev}\leq\Upsilon_{e,t,s}^{PEV}\times E_{e}^{Max.Pev}\qquad\forall e \in\mathbb{N},t\in T,s\in\omega \tag{35}\]  
\[P_{e,t,s}^{PEV-Ch}\leq v_{e,t,s}^{Dis}\times M\qquad\forall e\in\mathbb{N},t \in T,s\in\omega \tag{36}\]  
\[P_{e,t,s}^{PEV-Dis}\leq v_{e,t,s}^{Dis}\times M\qquad\forall e\in\mathbb{N},t \in T,s\in\omega \tag{37}\]  
\[v_{e,t,s}^{Ch}+v_{e,t,s}^{Dis}\leq 1\qquad\forall e\in\mathbb{N},t\in T,s\in\omega \tag{38}\]  
\[P_{e,t,s}^{PEV-Ch}\leq p_{e}^{Max.Pev}\times\Upsilon_{e,t,s}^{PEV}\qquad \forall e\in\mathbb{N},t\in T,s\in\omega \tag{39}\]  
\[P_{e,t,s}^{PEV-Dis}\leq P_{e}^{PEV-Max}\times\Upsilon_{e,t,s}^{PEV}\qquad \forall e\in\mathbb{N},t\in T,s\in\omega \tag{40}\]  
\[\sum_{e\in\mathbb{N}}\sum_{t\in T}\sum_{s\in\omega}P_{e,t,s}^{PEV-Ch}\geq\sum _{e\in\mathbb{N}}\sum_{t\in T}\sum_{s\in\omega}P_{e,t,s}^{PEV-Dis} \tag{41}\]  
\[\Delta E_{e,t,s}^{Pev}=\eta_{Pev}^{Ch}P_{e,t,s}^{Ch.Pev}-\frac{P_{e,t,s}^{Dis. Pev}}{\eta_{Pev}^{dis}}\qquad\forall e\in\mathbb{N},t\in T,s\in\omega \tag{33}\]0  
\[\left\{ \begin{array}{c}\sum_{e\in\Phi_{PEV-Dis}}\xi_{e}^{PLS}\in\left\{0,1 \right\}\\ \xi_{e}^{PLS}=0\text{ otherwise}\end{array} \right\} \tag{43}\]  
\[\sum_{e\in\Phi_{PEV-Pl}}\xi_{e}^{PLs}=\mathbb{N}_{PEV-PLs}^{Max} \tag{44}\]  
To achieve the appropriate size and position of PEV-PLs, both binary and integer variables must be satisfied at the same time, which resulted in a nonlinear constraint. Therefore, a linearization factor (\(\zeta\)) was used to indicate the optimal location of PLs as well as the capacity of each PEV-PL that is installed in MG (\(e\)), as expressed in (45) and (46). Constraints (47) and (48) express the limitation of an integer variable by the linearization factor that was considered in the model.