## 2 Problem Statement  
In this research, the objective function in the optimization of PEVs smart charging and discharging is to minimize the cost function subject to the network constraint:  
\[\sum_{s=1}^{10}\sum_{t=1}^{24}\left\{[OCa_{s}(t)\times Ra_{s}(t)+OCr_{s}(t) \times Rr_{s}(t)+DEC_{s}(t)]\right\}\times Pr(s) \tag{1}\]where \(Ra_{s}(t)\) is the active and \(Rr_{s}(t)\) is the reactive part of the power supplied in the scenario \(s\) at time \(t\). Indices \(s\) and \(t\) are presenting scenario number and time respectively, where \(s\) ranges from 1 to 10 to consider all 10 scenarios in this study, and \(t\) ranges from 1 to 24, to include all hours in a single day. OC\(a_{s}(t)\) and OC\(r_{s}(t)\) are the price for active and reactive power, and \(DEC_{s}(t)\) is PEVs fleet total battery degradation cost in the scenario \(s\), respectively. The probability of each scenario is presented by \(Pr(s)\). The load and generation equation can be written as follows [16]:  
\[\sum_{s}^{10}\sum_{t}^{24}Ra_{s}(t)+\sum_{s}^{10}\sum_{t}^{24}Wa_{s }(t) =\sum_{s}^{10}\sum_{t}^{24}La_{s}(t)+\sum_{s}^{10}\sum_{t}^{24}PEVa _{s}(t)+\sum_{s}^{10}\sum_{t}^{24}Plosa_{s}(t) \tag{2}\] \[\sum_{s}^{10}\sum_{t}^{24}Rr_{s}(t)+\sum_{s}^{10}\sum_{t}^{24}Wr_ {s}(t) =\sum_{s}^{10}\sum_{t}^{24}Lr_{s}(t)+\sum_{s}^{10}\sum_{t}^{24}PEVr _{s}(t)+\sum_{s}^{10}\sum_{t}^{24}Plossr_{s}(t) \tag{3}\]  
where \(Wa_{s}(t)\) is the active power that the wind turbines produce, \(La_{s}(t)\) is the real part of load demand, and \(PEVa_{s}(t)\) is the absorbed or injected active power by PEVs in time \(t\) and scenario \(s\). \(Wr_{s}(t)\) is the reactive power produced by the wind turbines, \(Lr_{s}(t)\) is the reactive part of the demand and \(PEVr_{s}(t)\) is the absorbed reactive power that is consumed by the charging equipment. _Plossa\({}_{s}(t)\)_ and _Plossr\({}_{s}(t)\)_ are power loss in a transmission line that can be calculated using Equations (4) and (5) [19]:  
\[\textit{Plossa}_{s}(t)=\sum_{i=1}^{n}V_{s}(i,j,t)\times\sum_{j=1}^{n}V_{s}(i, j,t)\times\{G(i,j)\times\cos(\theta_{s,i,t}-\theta_{s,j,t})+B(i,j)\times\sin( \theta_{s,i,t}-\theta_{s,j,t})\} \tag{4}\]  
\[\textit{Plossr}_{s}(t)=\sum_{i=1}^{n}V_{s}(i,j,t)\times\sum_{j=1}^{n}V_{s}(i, j,t)\times\{G(i,j)\times\cos(\theta_{s,i,t}-\theta_{s,j,t})-B(i,j)\times\sin( \theta_{s,j,t}-\theta_{s,j,t})\} \tag{5}\]  
where \(i\) and \(j\) are indices of buses and \(n\) is the number of buses. \(G\) and \(B\) are the real and imaginary part of the admittance matrix, and \(\theta\) is the voltage angle in this equation. \(V_{s}(i,j,t)\) is the voltage difference between buses \(i\) and \(j\) at time \(t\) in scenario \(s\). In this framework, power and constraint of all nodes such as a voltage of nodes and frequency of system should not surpass the boundaries limitation. The nodes' constraints are introduced in Equations (6) and (7) [20]. \[ \begin{split}& P^{u}(t)\leq P^{u}_{\max},\;Q^{u}(t)\leq Q^{u}_{ \max}\\ & u=1,2,\ldots,n_{eq},\;n_{eq}=\textit{total number of buses}\\ & V_{\min}\leq V_{l}(t)\leq V_{\max},\\ & l=1,2,\ldots,n_{LD}\;t=1,2,\ldots,24\qquad n_{LD}=\textit{ total number of load nodes}\end{split}  \tag{6}\]  
\(P^{u}(t)\) and \(Q^{u}(t)\) represent active and reactive consumed power by the equipment \(u\), which must not pass the equipment's maximum active and reactive power that are presented by \(P^{u}_{\max}\) and \(Q^{u}_{\max}\). Voltage magnitude of all nodes \(V_{l}(t)\) must stay between the minimum and maximum value of them, which are presented by \(V_{\min},V_{\max}\). The most significant restraint in PEVs charging and discharging problem is the state of charge (SOC) of the batteries which should fulfill the minimum boundaries at the moment of departure. This constraint is presented in Equation (8) [19]:  
\[ \begin{split}& SOC_{p,s}(t_{dep})\geq SOC_{dep}\\ & p=1,2,\ldots,N_{PEV}\qquad N_{PEV}=\textit{total number of PEVs}\end{split}  \tag{8}\]In this study, for customers convenience, it is assumed that the \(SOC_{dp}\) is at least 80 percent of the total capacity [19].