# Optimal Siting and Sizing of FACTS in Distribution Networks Using the Black Widow Algorithm
## 2 Mathematical Formulation
### Objective Function Formulation  
The main idea of integrating reactive power compensators in distribution networks is to minimize the annual equivalent operating costs, corresponding to the sum of the expected yearly costs of energy losses and the investment made in reactive power compensators. The expected annual operating costs associated with the energy losses are defined in Equation (1) [25].  
\[z_{1}=C_{kWh}T\sum_{h\in\mathcal{H}}\sum_{k\in\mathcal{N}}\sum_{m\in\mathcal{ N}}Y_{km}v_{kh}v_{mh}\cos(\delta_{kh}-\delta_{mh}-\theta_{km})\Delta h, \tag{1}\]  
where \(z_{1}\) defines the objective function value regarding the annual grid power losses costs  
all network nodes, and \(\mathcal{H}\) is the set associated with the number of periods considered in the daily analysis period.  
Note that the objective function in (1) is the classical representation of the expected power losses in all transmission/distribution lines, as a function of the nodal admittance matrix, the voltage profiles, and the cosine function of the voltage and admittance angles [25]. These power losses are summarized for the daily operation scenario under analysis. With this information, the annual expected costs are also calculated, using the average energy cost rate and the number of days in an ordinary year.  
Equation (2) defines the investment costs regarding the reactive power compensators, which is modeled as a cubic function, as reported by the authors of [28]. The distinctive characteristic of the objective function (2) is its mathematical structure, i.e., it is a non-convex cubic function. However, the main idea of this function structure is to consider a linear component associated with the investment costs per capacity, in addition to the fact that the quadratic and cubic terms are related to the variable reactive power production costs, which can involve factors regarding the maintenance and degradation of the FACTS devices during their useful life.  
\[z_{2}=T\bigg{(}\frac{k_{1}}{k_{2}}\bigg{)}\sum_{k\in\mathcal{N}}\bigg{(} \omega_{1}\bigg{(}q_{k}^{\text{comp}}\bigg{)}^{2}+\omega_{2}q_{k}^{\text{comp }}+\omega_{3}\bigg{)}q_{k}^{\text{comp}}, \tag{2}\]  
where \(z_{2}\) defines the objective function value regarding the investment costs of the shunt power compensators; \(k_{1}\) and \(k_{2}\) are positive constant parameters associated with the annualization of the investment costs of the shunt compensators while considering a planning period of 10 years [27]: \(q_{k}^{\text{comp}}\) is the nominal size of the shunt reactive power compensator located at node \(k\); and \(\omega_{1}\), \(\omega_{2}\), and \(\omega_{3}\) are the cubic, quadratic, and linear coefficients regarding the investment costs of the shunt reactive power compensators.  
Note that \(z_{1}\) and \(z_{2}\) are defined as the objective function for the problem regarding the optimal siting and sizing of FACTS in electrical distribution networks, i.e., the sum of the investment and operating costs in \(z_{\text{cost}}\), as presented in Equation (3) [16].  
\[\min\ z_{\text{cost}}=z_{1}+z_{2}, \tag{3}\]  
**Remark 1**: _The main characteristic of the objective function in (3) is that each one of its components (i.e., \(z_{1}\) and \(z_{2}\)) are non-convex objective functions due to the presence of trigonometric and cubic functions. In order for them to be minimized, they require efficient optimization methodologies that deal with nonlinear non-convex function spaces._