## 3 Proposed Solution Method
### Master-Slave Optimization Algorithm  
This subsection discusses the master-slave approach, which comprises the GNDO and the successive approximations power flow method.  
Slave Stage: Successive Approximations Power Flow Method  
This power flow method is a well-known approach that reformulates Equations (4) and (5) using a complex equivalent in order to find a solution for radial and meshed distribution networks. This method was initially proposed by [30], who were inspired by the classical Gauss-Seidel power flow approach. The general iterative power flow formula for the successive approximations power flow method is defined in Equation (9). Note that the dimensions of vectors and matrices for the successive approximations power flow method and a numerical example can be consulted in [31].  
\[\mathbb{V}_{dh}^{m+1}=\mathbb{V}_{dd}^{-1}\Big{[}\text{diag}^{-1}\big{(} \mathbb{V}_{dh}^{m,\star}\big{)}(\mathbb{S}_{sth}^{\star}-\mathbb{S}_{dh}^{ \star})-\mathbb{V}_{ds}\mathbb{V}_{sh}\Big{]},\{h\in\mathcal{H}\} \tag{9}\]  
where \(\mathbb{V}_{dh}\) is the vector containing all the voltage demand variables for the period of time \(h\); \(\mathbb{V}_{sh}\) is the vector that contains the slack voltage output in the period of time \(h\); \(\mathbb{V}_{dd}\) represents a square matrix containing the admittance relation of the demand nodes; \(\mathbb{V}_{ds}\) is a rectangular matrix that associates the demand nodes with the slack source regarding their admittance interconnections; \(\mathbb{S}_{sth}^{\star}\) is a vector that contains all the reactive power injections provided by the D-STATCOMs in the nodes where they are connected (note that the reactive power injection is zero at nodes where there are no D-STATCOMs); and \(\mathbb{S}_{dh}^{\star}\) is a complex vector comprising the constant power consumption of the distribution network per period of time \(h\). Note that \(m\) represents the iteration counter, and the recursive power flow formula in Equation (9) converges if the following criterion is met:  
\[\text{max}\Big{\{}\Big{|}\big{|}\mathbb{V}_{dh}^{m+1}\Big{|}-\big{|}\mathbb{V }_{dh}^{m}\big{|}\Big{\}}\leq\epsilon. \tag{10}\]  
It is worth mentioning that in Equation (10), the stopping criterion has to be reached before the maximum number of iterations. Here, \(\epsilon\) is the assigned tolerance.  
**Remark 2**: _The main advantage of using the successive approximations power flow method to deal with the power flow problem in radial and meshed distribution grids is that it ensures convergence to the solution if the grid is connected (there are no isolated areas) and is operating far from the voltage collapse point. Its convergence can be demonstrated by applying the Banach fixed-point theorem [30]._  
Once the recursive power flow formula (9) has converged to the power flow solution, the power generation in the slack source can be calculated as presented in Equation (11).  
\[\mathbb{S}_{sh}^{*}=\text{diag}(\mathbb{V}_{sh}^{*})[\mathbb{Y}_{ss}\mathbb{V}_ {sh}+\mathbb{Y}_{sd}\mathbb{V}_{dh}]\ \forall\{h\in\mathcal{H}\}. \tag{11}\]  
With this solution, it is possible to evaluate the expected annual energy loss cost of the distribution grid (\(f_{1}\)), as stated in the objective function. In addition, the constraint regarding voltage regulation is checked, (i.e., see inequality constraint (6)). If it is fulfilled, then a zero value is added to the objective function; if not, then a penalization regarding the amplitude of the voltage deviation with respect to its upper and lower bounds is added to the objective function value. Note that adding penalty factors to the objective function is a typical approach employed to find feasible solutions while exploring and exploiting the solution space. More details about penalty factors in metaheuristics can be consulted in [32].