## 4 Problem Formulation
### Algorithm for Determining Optimal Settings for APF
This restriction, along with constraints given by the EN 50160 standard (specifying limit values for only the first 12 odd-order harmonics), models APFs as real-life devices that can be used in the algorithm for determining the optimal settings of APFs in the modeled test network. All mentioned constraints are applied to the APF model and are crucial for optimization. Using the APF model with the same limitations as the actual APF prevents the algorithm from compensating for odd-order harmonics above the 25 th order. The optimization process is conducted using the PSO metaheuristic method. Once the bus and APF are selected, the algorithm initiates the optimization method to determine the optimal APF settings by adjusting the relative amplitude and the phase angle of each odd harmonic across all three phases. The optimization method, following the objective function defined in expression (7), monitors the \(\mathit{THD_{V}}\) values at all buses of the test network, aiming to reduce its level. This method first adjusts the relative amplitude and phase angle in all three phases, generating currents from the APF to counteract the effect of the third harmonic while continuously monitoring the \(\mathit{THD_{V}}\) levels across all buses in the test network. When a further reduction in \(\mathit{THD_{V}}\) through the amplitude and angle of the third harmonic is no longer possible or when convergence is reached, the optimization process repeats the procedure, initially for all triplen harmonics, which is followed by all other odd harmonics in ascending order: 5 th, 7 th, and so on. After fully utilizing the capacity of the first APF, the optimization process repeats the entire selection procedure for the next APF in the same defined manner. According to the steps defined above, the algorithm for determining the optimal APF settings in the test network is executed 24 times within the optimization process (corresponding to 24 time intervals). This defined number of iterations is related to hourly load variations throughout the day in each test network bus. The load variations in this paper are applied to all modeled controllable and uncontrollable loads and at DGs with corresponding harmonic spectra (applying relative amplitudes and phase angles in all phases for all odd harmonics from the 3 rd to the 40 th order). For implementing the proposed algorithm, the application of APF is customized according to load levels in the test network, the penetration of DGs, and the usage of electric vehicle household charging stations. Considering daily variability, different network states can be represented along with the associated load levels, which can serve as the basis for assessing the condition of asymmetrical low-voltage networks. These network states are defined below:  
1. _Underloaded state of the test network_ This defined network state refers to the relative load of all connection elements, which predominantly occurs during the lower tariff period with minor stochastic load fluctuations. This state enables the implementation of APFs to reduce harmonics at all buses in the test network that physically (positionally) permit it. The underloaded state of the test network allows the algorithm to select APF devices with higher nominal values and potentially implement a larger number of APFs in the test network. In this network state, the optimization process has sufficient energy capacity to reduce harmonic currents successfully. 2. _Additional underloaded state of network_ This additional network state occurs when the network's \(\mathit{IHD}\) and \(\mathit{THD_{V}}\) values are within the limits prescribed by standards. In this state, the optimization process is not required. 3. _Normal state of the test network_ The normal state of the test network is classified as the most common network condition, where the relative load on all connection elements is between 60% and 85%. This state typically has substantial stochastic load variations during the higher tariff period.