# Compliance of Distribution System Reactive Flows with Transmission System Requirements
## 2 Problem Formulation
### Model Formulation
#### 2.2.2 Expanding (23)  
Having established how to reformulate any max function, we implement Figure 1 in detail. The complexity in this case is that the requirement of the TSO is not a smooth function. We can write it as follows:  
\[J_{\tau}=c_{\ell}\cdot\begin{cases}\max\left\{Q_{G1}-\overline{Q}_{1,\tau},0 \right\}+\max\left\{\overline{Q}_{1,\tau}-Q_{G}),0\right\}&\text{if }P_{min}\geq \overline{P}_{1,\tau}\\ \max\left\{\left(Q_{D1}+\overline{P}_{1,\tau}\frac{Q_{0}-Q_{D1}}{P_{min}} \right)-\overline{Q}_{1,\tau},0\right\}+\max\left(\{\overline{Q}_{1,\tau}-Q_{ G}),0\right\},&\text{if }P_{min}\leq\overline{P}_{1,\tau}\leq 0\\ \max\left\{Q_{D1}-\overline{Q}_{1,\tau},0\right\}+\max\left\{(\overline{Q}_{1, \tau}-Q_{D}),0\right\},&\text{if }0\leq\overline{P}_{1,\tau}\leq P^{\ast}\\ \max\left\{0.04\overline{P}_{1,\tau}-\overline{Q}_{1,\tau},0\right\}+\max\left\{ \overline{Q}_{1,\tau}-0.16\overline{P}_{1,\tau},0\right\},&\text{if }\overline{P}_{1,\tau}\geq P^{\ast}\end{cases} \tag{24}\]  
where \(Q_{D},Q_{D1},Q_{G},Q_{G1}\) are parameters provided by the TSO and are external to the problem. The conditional objective of (24) is not in a form that can be solved by an optimisation solver. We introduce \(r\) to refer to each of the four regions, see also Figure 3. We employ four binary parameters, \(u_{r}\), corresponding to the regions of the conditional Equation (24) and a large constant \(M\).  
\[\overline{P}_{1,\tau}-P_{min} \geq(1-u_{1})M \tag{25}\] \[P_{min}-\overline{P}_{1,\tau} \geq(1-u_{2})M\] (26) \[\overline{P}_{1,\tau} \geq(1-u_{2})M\] (27) \[-\overline{P}_{1,\tau} \geq(1-u_{3})M\] (28) \[\overline{P}_{1,\tau}-P^{*} \geq(1-u_{3})M\] (29) \[P^{*}-\overline{P}_{1,\tau} \geq(1-u_{4})M\] (30) \[u_{1}+u_{2}+u_{3}+u_{4} =1\] (31) \[u_{r} \in\{0,1\},\;\forall r\in\{1,2,3,4\} \tag{32}\]  
The above set of equations makes sure that \(\overline{P}_{1,\tau}\) lies in only one of the four distinct regions and then, and only then, the binary \(u_{r}\) becomes equal to 1. This allows for objective (24) to be written as  
\[\min_{\mathbf{q},\overline{Q}_{1},\mathbf{Q},\mathbf{V}}c_{\ell}\sum_{r=1}^{4 }u_{r}\big{[}y_{r}^{min}+y_{r}^{max}\big{]} \tag{33}\]  
Objective (33), along with constraints (8)-(17) and (25)-(32), define a problem with infinite solutions if the usage of reactive power from DERs is without cost. Therefore, additionally to the main objective, we add a **very small penalty**\(c_{p}\) to the usage of \(q_{i,\tau}\). This is done in order to force the model to choose the solution with the least utilisation of \(q_{i,t}\) among the infinite equivalent solutions. A value of \(c_{p}=0.001\) is chosen in this paper to ensure that the objective of minimising limit violations is always prioritised by the model.  
The **proposed model** which is the core of the proposed method becomes  
Figure 3: Regions of the TSO guidelines regarding power exchange with a DN.  
\[\min_{\mathbf{q}\overline{\mathcal{Q}}_{1,\mathbf{Q}\mathbf{V}}}c_{t} \sum_{r=1}^{4}u_{r}\big{[}y_{r}^{min}+y_{r}^{max}\big{]}+c_{p}\sum_{t\in T_{r}} \sum_{i\in\mathcal{I}}q_{i,t}^{2} \tag{34}\] \[s.t\;\forall r\in\{1,2,3,4\}:\] \[y_{r}^{min} \geq 0\] (35) \[y_{r}^{min} \geq\Phi^{min}(\overline{P}_{1,\tau})-\overline{\mathcal{Q}}_{1,\tau}\] (36) \[y_{r}^{max} \geq 0\] (37) \[y_{r}^{max} \geq\overline{\mathcal{Q}}_{1,\tau}-\Phi^{max}(\overline{P}_{1, \tau}) \tag{38}\]  
The **proposed model** is (34)-(38), (8)-(17), (25)-(32). (34) is the **objective function** and (8)-(17), (25)-(32), (35)-(38) are the **constraints**.  
Thus, the objective at each step \(\tau\) is the _level of violation of the constraint set in Figure 1_, which depends on which region of the plane we project it to end up at the end of the horizon, which in turn depends on the average active power exchange, \(\overline{P}_{1,\tau}\), and a very small penalty on reactive power support utilisation.