## 4 Problem Formulation
### Optimization Problem Formulation  
In this paper, the authors presented the optimization problem for determining the optimal settings of APF in an LV distribution network with a defined objective function shown in expression (7), the associated decision variables, expression (9), and through the constraints that are defined by expressions (10) to (14). The \(THD_{V}\) for each bus \(m\) is calculated using the total harmonic load according to (8). \[\min f(\textbf{x})=\min\sum_{m=1}^{M}THD_{V}m \tag{7}\]  
\[THD_{V,m}=\frac{\sqrt{\sum_{h}^{H}\left|\left|\textbf{v}_{m,h}^{\text{bus}} \right|^{2}}}{\left|\textbf{v}_{m,1}^{\text{bus}}\right|},\ \forall m\in M,\ \forall h\in H \tag{8}\]  
As in previous expressions, \(m\) defines the bus number, \(THD_{V}m\) represents the value of \(THD_{V}\) at bus \(m\), and \(h\) stands for harmonic order number (according to EN 50160, the 40 th harmonic order is the maximum order considered). \(V_{m,h}^{\text{bus}}\) is set for the voltage value at bus \(m\) for harmonic order number \(h\), while \(V_{m,1}^{\text{bus}}\) presents the voltage value at bus \(m\) at nominal frequency. Decision variable vector \(\textbf{x}\) given in (9) is defined for every phase \(p\) and harmonic order number \(h\) with the associated angle \(\varphi\). \[\textbf{x}=\left[I_{1,1},\ldots,\ I_{p,h},\ \varphi_{1,1},\ \ldots,\varphi_{p,h} \right],\ \ \forall p\in P,\ \forall h\in H \tag{9}\]  
The limitations of the created optimization problem are defined through the physical limitations of the active filters themselves and the observed network as well as the limitations of the network rules or related norms. The physical limitations of APFs specify the use of only three-phase, three-wire APFs capable of generating only the first 12 odd harmonics specifically from the 3 rd harmonic order up to the 25 th harmonic order. This limitation, formulated in Equation (10), is defined because EN 50160 only defines threshold values for the first 25 odd harmonic orders. The remaining odd harmonics (from the 25 th to the 40 th order) are not strictly regulated, as their values are typically low, contributing minimally to the overall voltage harmonic distortion [2]. \[I^{\text{APF}}\ =\sum_{h=3}^{H}I_{h}\ ;\ h=3,5,7,\ldots 25 \tag{10}\]  
where \(I^{\text{APF}}\) represents the current generated by the APF and \(I_{h}\) is the harmonic current. The rated current constraint of APF is considered in the optimization process, which is presented in expression (13). Since only commercially available APF sizes can be selected during the optimization process, this constraint can also be considered a possible decision variable value. This study incorporates a database of market-available devices into the optimization process. \[\left|I_{n}^{\text{APF }rated}\right|\in\left\{\left|I_{min}^{\text{APF}}\right|, \ldots,\left|I^{\text{APF}}\right|,\ldots,\left|I_{max}^{\text{APF}}\right| \right\};\;\forall n\in N \tag{11}\]  
The APF's rated RMS (root mean square) current constraint, as defined in Equation (12), specifies that the total sum of absolute values of individual harmonic currents across all three phases must not exceed the filter's rated current. This constraint is related to the constraint defined in the previous expression (11). Specifically, it allows APFs to generate different effective amplitude values per phase and permits the normalization of the maximum amplitude to 100% of the rated current. \[I_{n}^{\text{APF }rated}\geq\sum_{p=1}^{P}\sum_{h=3}^{H}I_{p,h} \tag{12}\]  
The constraint shown with expression (13) is related to the APF method of generating currents to reduce harmonics. The generating current method implemented in the optimization process of this paper is prioritizing the generation of currents that cancel triplen harmonics (harmonics order of multiple of number 3), which is followed sequentially by the remaining odd harmonics in ascending order, such as the 5 th, 7 th, and so on.