## 3 Stochastic MPC Approach for Coordinated Scheduling Optimization of MES
### Model of MPC Based Optimal Scheduling  
MPC strategies are quite appealing for energy scheduling of MES, since they allow for the implementation of control actions that anticipate future events such as variations of EVs availability, heat demand and electricity demand. The MPC rolling optimization method usually involves three time sequences: scheduling time sequence, predicting time sequence and controlling time sequence, which is based on iterative, finite-horizon optimization of the controlled model. The rolling optimization method guarantees the optimization of real-time control action by sampling and calculating online [20]. Two 0-1 binary variables \(B_{\text{ch}}\) and \(B_{\text{disch}}\) and two continuous variables \(X_{\text{ch}}(0\leq X_{\text{ch}}\leq 1)\) and \(X_{\text{disch}}\) (\(0\leq X_{\text{disch}}\leq 1\)) are introduced for describing the SOC and charging/discharging power of the aggregated EVs' batteries. The charging/discharging power and SOC of EVs are modelled as follows:  
\[P_{\text{EVs}}^{\text{s}}(t+i|t)\ =\ -X_{\text{ch}}^{\text{s}}(t+i|t)DAN^{ \text{s}}(t+i)P_{\text{EV-max}}+X_{\text{disch}}^{\text{s}}(t+i|t)DAN^{\text{ s}}(t+i)P_{\text{EV-max}},i\ =\ 1,\cdots,T, \tag{14}\]  
\[X_{\text{ch}}^{\text{s}}(t+i|t)\leq B_{\text{ch}}^{\text{s}}(t+i|t),i\ =\ 1, \cdots,T, \tag{15}\]  
\[X_{\text{disch}}^{\text{s}}(t+i|t)\leq B_{\text{disch}}^{\text{s}}(t+i|t),i\ =\ 1, \cdots,T, \tag{16}\]  
\[B_{\text{ch}}^{\text{s}}(t+i|t)+B_{\text{disch}}^{\text{s}}(t+i|t)\leq 1,i\ =\ 1, \cdots,T, \tag{17}\]  
\[\text{SOC}^{\text{s}}(t+i|t)\ =\ \text{SOC}^{\text{s}}(t+i-1|t)+X_{\text{ch}}^{ \text{s}}(t+i|t)P_{\text{EV-max}}\eta_{\text{ch}}/Cg_{\text{EV}}+X_{\text{ disch}}^{\text{s}}(t+i|t)P_{\text{EV-max}}/Cg_{\text{EV}}/\eta_{\text{disch}},\ \ i=1,\cdots,T. \tag{18}\]  
\(P_{\text{EVs}}^{\text{s}}(t+i|t)\) is \(i\)-step-ahead dispatched discharging (\(P_{\text{EVs}}^{\text{s}}(t+i|t)>0\))/charging (\(P_{\text{EVs}}^{\text{s}}(t+i|t)<0\)) power of the aggregated EVs. \(SOC^{\text{s}}(t+i|t)\) is \(i\)-step-ahead dispatched state of charge of aggregated EVs, \(P_{\text{EV-max}}\) is the maximum charging/discharging power of a EV, \(Cap_{\text{EV}}\) is the capacity of a EVbattery in kWh, and \(\eta_{\rm ch}\) and \(\eta_{\rm disch}\) are charging and discharging efficiency of EV. The \(SOC\) is limited by its upper and lower boundaries  
\[SOC_{\rm min}\leq SOC^{\rm s}(t+i|t)\leq SOC_{\rm max},i\ =\ 0,\cdots,T-1. \tag{19}\]  
Operational cost can be employed as one of the main objective functions in MES scheduling. The purpose of MES scheduling optimization is to determine the amount of energy generated by the controlled units in the presence of uncontrolled units in a way that the operational cost is minimized while complying with the various operational constraints [30; 31]. The optimization objective is to minimize the expected value of the total operating cost during the predictive horizon:  
\[\min\!\sum_{s}p_{s}\sum_{i\ =\ 1}^{T}c_{Grid}(t+i|t)\,P^{s}_{Grid}(t+i|t)+c_{Gas} V(t+i|t)+C^{s}_{\rm AEVs}L^{s}_{\rm loss}(t+i|t), \tag{20}\]  
where \(T\) denotes the length of prediction horizon, \(i\) is the index of time step in the prediction horizon with \(i\) = 0 being the current time, \(P^{s}_{\rm Grid}(t+i|t)\) is \(i\)-step-ahead scheduled electricity power exchange between the MES and the external grid, \(c_{\rm Grid}(t+i|t)\) is the \(i\)-step-ahead predictive price of exchanged electricity, \(c_{\rm Gas}\) is the cost of natural gas, \(V(t+i|t)\) is the \(i\)-step-ahead scheduled value of natural gas consumption, \(C^{s}_{\rm AEVs}\) is the initial investment cost of the available EVs in scenario \(s\), \(L^{s}_{\rm loss}(t+i|t)\) is the EVs' batteries life loss proportion of total investment cost, and \(p_{s}\) is the probability of scenario \(s\) after scenarios reduction. The service life of EVs' batteries usually degrades when subjected to repeated charge/discharge cycles.