# Optimal Siting and Sizing of FACTS in Distribution Networks Using the Black Widow Algorithm
## 2 Mathematical Formulation
### Set of Constraints  
The constraints associated with the problem under study include active and reactive power balance, voltage regulation bounds, and limitations regarding the reactive power injected with the FACTS, among others. The set of considered constraints is listed from (4) to (9).  
Equations (4) and (5) represent the active and reactive power equilibrium per node and period of time, which are obtained after combining [PERSON]'s first and second laws while using [PERSON]'s theorem [25].  
\[p_{kh}^{g}-P_{kh}^{d}=\sum_{k\in\mathcal{N}}\sum_{m\in\mathcal{N}}Y_{km}v_{kh }v_{mh}\cos(\delta_{kh}-\delta_{mh}-\theta_{km}),\{\forall k\in\mathcal{N},h \in\mathcal{H}\}, \tag{4}\]  
\[q_{kh}^{g}+q_{kh}^{\text{comp}}-Q_{kh}^{d}=\sum_{k\in\mathcal{N}}\sum_{m\in \mathcal{N}}Y_{km}v_{kh}v_{mh}\sin(\delta_{kh}-\delta_{mh}-\theta_{km}),\{ \forall k\in\mathcal{N},h\in\mathcal{H}\}, \tag{5}\]  
where \(p_{kh}^{g}\) and \(P_{kh}^{d}\) represent the active power generation and the power demanded at \(k\) in the period \(h\); \(q_{kh}^{g}\) corresponds to the reactive power generation at node \(k\) in the period \(h\); \(q_{kh}^{\text{comp}}\) represents the reactive power injection in the FACTS device connected at node \(k\) and time \(h\); and \(Q_{kh}^{d}\) denotes the reactive power consumed at node \(k\) in the period \(h\).  
The box-type constraint defined in (6) is known as the _voltage regulation constraint_ in the specialized literature, and it is typically imposed by regulatory entities in order to ensure a service of good quality for all end users connected to the electrical system [31].  
\[V_{\min}\leq v_{kh}\leq V_{\max},\{\forall k\in\mathcal{N},h\in\mathcal{H}\}, \tag{6}\]  
where \(V_{\min}\) and \(V_{\min}\) are the minimum and maximum voltage limits that can be assigned to the variable \(v_{kh}\) for each node and period.  
To adequately integrate compensation devices into distribution networks, it is necessary to define their nominal operating sizes within the typical ranges available. At medium-voltage levels, distribution grids are typically designed to supply between 3 and 10 MVA. The sizes of the FACTS are limited by the box-type constraint (7) [16].  
\[y_{k}Q_{\min}^{\text{comp}}\leq q_{k}^{\text{comp}}\leq y_{k}Q_{\max}^{\text{ comp}},\{\forall k\in\mathcal{N}\}, \tag{7}\]  
where \(y_{k}\) is a binary variable that defines the location (\(y_{k}=1\)) or not (\(y_{k}=0\)) of a shunt reactive power compensator at node \(k\); and \(Q_{\min}^{\text{comp}}\) and \(Q_{\max}^{\text{comp}}\) represent the minimum and maximum sizes allowed for the FACTS devices in the distribution network, which are typically between 0 and 2000 kvar [25].  
Once the nominal sizes of the FACTS devices are defined, the next step in their optimal operation is defining the power injection for each period of time. This box-type constraint is defined in (8) [32]. In addition, the amount of FACTS devices available for installation is defined in (9) [25].  
\[-q_{k}^{\text{comp}}\leq q_{kh}^{\text{comp}}\leq q_{k}^{\text{comp}},\{\forall k \in\mathcal{N},h\in\mathcal{H}\}, \tag{8}\]  
\[\sum_{k\in\mathbb{N}}y_{k}\leq N_{A}^{\text{comp}}, \tag{9}\]  
where \(N_{A}^{\text{comp}}\) is a constant parameter that defines the number of FACTS available for installation in the distribution network.