## 3 Master-Slave Optimization Framework
### Slave Stage: Load Flow Problem via Successive Approximations  
In the proposed optimization-based solving approach, the MVO algorithm functions as the master stage, generating candidate operating schedules for the battery energy storage system (BESS) over a 24 h horizon. Each particle represents a potential combination of hourly charging and discharging power values for the BESS. The slave stage is responsible for evaluating the technical feasibility and overall performance of each candidate solution provided by the MVO, considering both the objective function and constraints. This evaluation is carried out through a sequential, hour-by-hour power flow analysis using the Successive Approximation (SA) method [36]. The SA method is an approximate numerical technique used to solve the Load Flow Problem (LFP). It operates iteratively, without requiring derivatives or the matrix inversion of non-diagrid-dependent blocks, making it computationally more efficient compared to methods like Newton-Raphson (NR) and Fixed-Point Iteration (FPI) [37]. The iterative process is described by the following formulation:  
\[\mathbb{V}_{d}^{t+1}=-\mathbb{Z}dd\left[\mathbb{Y}_{ds}\mathbb{V}_{s}+diag^{-1 }(\mathbb{V}_{d}^{t,*})\mathbb{S}_{d}^{*}\right] \tag{29}\]  
where \(\mathbb{Z}_{dd}\) is the impedance matrix (inverse of \(\mathbb{Y}_{dd}\)), and \(\mathbb{Y}_{ds}\) represents the admittances between the generation and demand nodes. The process starts with the slack node voltage (\(|\mathbb{V}_{s}|=1\)\(p.u.\), \(\delta_{s}=0^{\circ}\)) and iterates until convergence, incorporating the conjugate of the complex power demand \(\mathbb{S}_{d}^{*}\). Figure 2 depicts the step-by-step iterative algorithm employed in the Successive Approximations method, represented as a structured flowchart. On the other hand, the evaluation procedure involves the following steps:  
1. **Data preparation for each hour**: For every time step \(h\in\{1,2,...,24\}\), gather the following information: * The electrical demand at each load bus; * The power generation profile from photovoltaic (PV) sources; * The BESS charging or discharging schedule proposed by the MVO algorithm. Figure 2: Flowchart of the LFP solution using the Successive Approximations method. 2. **Execution of load flow analysis**: Apply the Successive Approximation (SA) method to solve the network's load flow equations and obtain the voltage levels and line load flows at each node. \[\mathbb{V}_{d,h}^{t+1}=-\mathbb{Z}_{dd}\Big{[}\mathbb{Y}_{ds}\mathbb{V}_{s,h}+ diag^{-1}(\mathbb{V}_{d}^{t,*})\mathbb{S}_{d,h}^{*}\Big{]}\] (30)
3. **Operational constraint validation**: Each candidate solution generated by the optimization algorithms (PMVO, PVSA, and CBGA) is validated through an hourly power flow analysis based on the Successive Approximations method. This evaluation ensures compliance with all technical and operational constraints, including (i) maintaining voltage levels within acceptable bounds at each bus (\(\pm 10\%\)), (ii) ensuring that current flows remain within the thermal ratings of the distribution lines, and (iii) verifying that the BESS units operate within their charging and discharging power limits. Additionally, in the self-powered mode, the diesel generator is constrained to operate strictly within its predefined dispatch range in accordance with its rated capacity and technical requirements. It is also ensured that this generator does not store energy since, by design, it can only inject active power into the system. To guarantee that candidate solutions are technically feasible, all battery-related constraints, such as minimum and maximum SoC levels, charging/discharging power bounds, and initial and final SoC values, are directly encoded into the decision variables. This approach restricts the search space to physically admissible schedules and avoids the generation of infeasible operating states.