## 4 Multi-Time Scale Dispatching Model of Active Power and Reactive Power Based on MPC  
### Day-Ahead Optimal Dispatching Model  
The control variables of day-ahead optimal dispatch include the reactive power of wind and PV, the reactive power of Static Var Generator (SVG), the action states of OLTC and CB, and the active and reactive power of GT, VPSSH, and BES. The day-ahead optimal dispatch aims to minimize the distribution network's operation cost and node voltage deviation. The operation cost includes the OLTC operation cost, the CB operation cost, the gas turbine generation cost, the VPSSH and BES maintenance cost, and the active power loss cost. Thus, the objective function expression is:  
\[\min F=\rho_{T}\Delta n_{T}+\rho_{c}\Delta n_{CBs}+C_{GT}+C_{VPSSH}+C_{BES}+ \Gamma P_{loss}+\lambda_{v}\Delta V \tag{9}\]  
where \(\rho_{T}\), \(\rho_{c}\) are OLTC and CBs single-action price; \(\Delta n_{T}\), \(\Delta n_{CBs}\) are OLTC and CBs gear changes, respectively; \(C_{GT}\) is the generating electricity cost of gas turbines; \(C_{VPSSH}\), \(C_{BES}\) are the maintenance costs of VPSSH and BES; \(\Gamma\) is the marginal price of power lost; \(P_{loss}\) is the line active power loss; \(\lambda_{v}\) is the penalty coefficient of voltage deviation; and \(\Delta V\) is the node voltage deviation. Day-ahead optimal dispatch constraints include power flow constraints, safe operation constraints and active power and reactive power constraints of controllable resources in the distribution network. 1. Power flow constraints For radiative networks, the power flow constraint can be expressed as [19]: \[ \begin{array}{c}\sum\limits_{ij\in\Omega_{b}}\left(P_{ij}-r_{ij}i_{ij} \right)=P_{j}+\sum\limits_{jk\in\Omega_{b}}P_{jk}\\ \sum\limits_{ij\in\Omega_{b}}\left(Q_{ij}-x_{ij}i_{ij}\right)=Q_{j}+\sum \limits_{jk\in\Omega_{b}}Q_{jk}\end{array} \] (10) \[ \begin{array}{c}P_{j}=P_{j,pre}^{\text{WT}}+P_{j,pre}^{\text{PV}}+P_{ j}^{\text{GT}}+P_{j}^{\text{VPSSH}}+P_{j}^{\text{BES}}-P_{j}^{\text{load}}\\ Q_{j}=Q_{j}^{\text{WT}}+Q_{j}^{\text{UV}}+Q_{j}^{\text{GT}}+Q_{j}^{\text{VSPSH }}+Q_{j}^{\text{BES}}+Q_{j}^{\text{SVG}}+Q_{j}^{\text{CBs}}-Q_{j}^{\text{load }}\end{array} \] (11) \[ \begin{array}{c}V_{j}^{2}*k_{i\ j}^{2}=V_{i}^{2}-2\left(r_{ij}P_{ij}+x _{ij}Q_{ij}\right)+\left(r_{ij}^{2}+x_{ij}^{2}\right)I_{ij}^{2}\\ V_{i}^{2}I_{ij}^{2}=P_{ij}^{2}+Q_{ij}^{2}\end{array} \] (12)  
where \(P_{ij}\) and \(Q_{ij}\) are the active power and reactive power flowing through branch \(ij\), respectively; \(P_{i}\) and \(Q_{j}\) are the active power and reactive power injection values of node \(j\), respectively; \(P_{j,pre}^{\text{WT}}\), \(P_{j,pre}^{\text{PV}}\), \(P_{j}^{\text{GT}}\), \(P_{j}^{\text{VPSSH}}\), \(P_{j}^{\text{BES}}\), \(P_{j}^{\text{load}}\) are the forecast active power of wind and PV, the active power of GT, VPSSH, BES, and load of node \(j\), respectively; \(Q_{j}^{\text{WT}}\), \(Q_{j}^{\text{PV}}\), \(Q_{j}^{\text{GT}}\), \(Q_{j}^{\text{VPSSH}}\), \(Q_{j}^{\text{BES}}\), \(Q_{j}^{\text{SVSG}}\), \(Q_{j}^{\text{CBs}}\), \(Q_{j}^{\text{load}}\) are the reactive power of wind, PV, GT, VPSSH, BES, and load of node \(j\), respectively; \(r_{ij}\) and \(x_{ij}\) are the resistance and reactance of line \(ij\); \(V_{i}\) is the voltage of node \(i\); \(k\) is the gears of OLTC; and \(I_{ij}\) is the current of line \(ij\). Formulas (10)-(12) are based on Kirchhoff's law. 2. Safe operation constraints \[ \begin{array}{c}V_{i,\min}\leq V_{i}\leq V_{i,\max}\\ 0\leq I_{ij}\leq I_{ij,\max}\end{array} \] (13)where \(V_{i,\min}\) and \(V_{i,\max}\) are the minimum and maximum voltage of node \(i\), respectively; and \(I_{ij,\max}\) is the maximum current of the branch \(ij\). 3. Active power and reactive power constraints of controllable resources
* Active power and reactive power output constraints of wind and PV. In this model, wind and PV active power at the maximum power point, that is, the active power output of wind and PV in the optimization algorithm is its predicted value.