## 4 Problem Formulation
### Algorithm Results over 24 \(H\)
* **Second state of test network (4:00 a.m.-7:00 a.m.)**  
The second state describes the state of the test network during the low-tariff period, specifically in the time intervals from 4:00 a.m. to 7:00 a.m. In these time intervals, the test network considers uncontrollable and controllable loads in single-phase models, while three-phase controllable loads remain inactive. The load on the test network during this time is minimal, ranging from 22.2% to 35.9%. For this second state, the analysis is focused on the characteristic buses for the 4:00 a.m. interval, as shown in Figure 8. Other time intervals for this state are not presented, since the results are very similar. For this state of the test network, \(\mathit{HHD}_{V}\) values at all characteristic terminals and buses are within the prescribed limits, meeting the requirements of the EN 50160 Standard. The \(\mathit{THD}_{V}\) levels in all test network buses and phase A buses (illustrated in Figure 9) remain below the values mandated by the EN 5160 standard [2]. The maximum \(\mathit{THD}_{V}\) value occurred at bus 74 in phase A, with a value of 1.23%, while a relative line load was 36.8%. This observed state of the test network, along with the corresponding voltage harmonic spectra, aligns with network loading that, in this paper, is defined as the underloaded state of the network. The algorithm for determining the optimal settings of APF and the associated optimization process was not necessary for this state of the test network. All indicators of harmonic distortion were satisfactory, meaning their values in all buses of the test network were below the maximum values prescribed by the EN 50160 standard. * **Third state of test network (at 7:00 a.m., 8:00 a.m., 10:00 a.m., 11:00 a.m., 5:00 p.m., 6:00 p.m., 9:00 p.m., and 10:00 p.m.)**  
The most frequent network state during the 24 time intervals is defined as the third state of the test network. Although this state appears during high and low tariff periods, it is detected more often during the high tariff period. The observed time intervals correspond to the test network load at 7:00 a.m., 8:00 a.m., 10:00 a.m., 11:00 a.m., 5:00 p.m., 6:00 p.m., 9:00 p.m., and 10:00 p.m., during which the optimization process assigned two APFs to the test network. Loads from uncontrollable loads models and PV system models primarily  
Figure 8: The test network state at 4:00 a.m. on the characteristic terminal. form the network loads during the peak tariff period. During the low tariff period, the third network state occurs when the loads from uncontrollable load models are very high and single-phase controllable load models start operating. The load on the test network during this period ranges from 60.3% to a maximum of 74.3%. The analysis is conducted for the time interval during the high tariff period, which is characterized by significant stochastic variations in load and low production from the DGs (PV systems). As in the previous cases, this observed time interval is very similar to all the other intervals mentioned above, so only the interval occurring at 5:00 p.m. is presented. Figure 10a shows the state of the test network (voltage harmonic spectrum) before the algorithm for determining the optimal settings of APF are executed on the characteristic terminal at 5:00 p.m. The state of the test network at 5:00 p.m. on the characteristic terminal after the optimization process is given in Figure 10b. The results obtained after the optimization process for the third state of the test network confirm that the optimization method successfully determined the parameters and optimal settings of the APFs. The optimization process took an average of 4:35 h and assigned two APFs to the test network at buses 41 (rated current 70 A) and 25 (rated current 30 A), successfully minimizing the THDV on all buses. The results can be noticed comparing Figure 10a,b, where in Figure 10b, the values of \(IHD_{V}\) have significantly decreased.