## 2 Materials and Methods
### Stage 2. Successive Quadratic Programming-Based OPF
#### 2.2.2 The Successive Quadratic Programming-Based Optimization Algorithm
\right] \tag{18}\]  
The discrete control variable regarding the tap-changer positions is treated as continuous variables. Then they are rounded off to their nearest discrete values [42]. Considering expression (18), the QP problem can be rewritten:  
\[min(\Phi([\Delta Z],[\Delta Y]))=min\bigg{(} \begin{array}{c}F^{(0)}+[\
abla F _{Z}]_{t}\cdot[\Delta Z]+[\
abla F_{Y}]_{t}\cdot[\Delta Y]+\frac{1}{2}\cdot[ \Delta Z]_{t}\cdot[H_{ZZ}]\cdot[\Delta Z]+\\ \frac{1}{2}\cdot[\Delta Y]_{t}\cdot[H_{YY}]\cdot[\Delta Y]+[\Delta Z]_{t}\cdot [H_{ZY}]\cdot[\Delta Y]\end{array} \bigg{)} \tag{19}\]  
\[[h_{A}^{(0)}]+[J_{AZ}]\cdot[\Delta Z]+[J_{AY}]\cdot[\Delta Y]=0 \tag{20}\]  
\[[h_{I}^{(0)}]+[J_{IZ}]\cdot[\Delta Z]+[J_{YY}]\cdot[\Delta Y]\leq 0 \tag{21}\]  
The matrices with indices \(Z\) and \(Y\) are associated with the partition of the matrices from the expressions (13)-(15), considering the expression (18). The reduced gradient with respect to independent variables \([\Delta Z]\) can be calculated with the expression:  
\[[\
abla\Phi]=[\
abla Z_{\Delta Z}]-[J_{AZ}]_{t}\cdot[J_{AY}]_{t}^{-1}\cdot[ \
abla F_{\Delta Y}] \tag{22}\]  
Thus, the conjugate search direction in iteration \(k\) can be determined using the expression:  
\[[d^{(k)}]=-[\
abla\Phi^{(k)}]+\frac{[\
abla\Phi^{(k)}]_{t}\cdot[\
abla\Phi^{( k)}]}{[\
abla\Phi^{(k-1)}]\cdot[\
abla\Phi^{(k-1)}]}\cdot d^{(k-1)}\,,\quad k\geq 1 \tag{23}\]  
where:  
\[[d^{(0)}]=-[\
abla\Phi^{(0)}] \tag{24}\]  
The optimal value of step size, \(\alpha^{(k)}_{opt}\), should be determined to avoid repeated searches. An admissible value of the step size, \(\alpha^{(k)}_{adm}\), should be identified such that the constraints are not violated. The reasoning is applied by solving the system of equations for each inactive constraint to obtain the admissible step size relative to the constraint \(j\),  
\[\alpha_{j}^{(k)}=\frac{[h_{l}^{(0)}]+[J_{IZ,j}]\cdot[\Delta Z^{(k)}]+[J_{IY,j}] \cdot[\Delta Y^{(k)}]}{[J_{IY,j}]\cdot[J_{AX}]^{-1}\cdot[J_{AZ}]\cdot[d^{(k)}]-[ J_{IZ,j}]\cdot[d^{(k)}]},\quad j=1,\ldots,q \tag{25}\]  
and the admissible step size in iteration \(k\),  
\[\alpha_{adm}^{(k)}=\underset{j}{min}\Big{\{}\alpha_{j}^{(k)}\Big{\}},\quad j= 1,\ldots,q \tag{26}\]  
The expression for the optimal step size is obtained if the reduced gradient of the objective function, \(\Phi\), is written in the point:  
\[[\
abla\[PERSON](Z^{\prime})]=[\
abla\[PERSON](Z^{(0)})]+[H]\cdot\big{[}\Delta Z^{\prime }]=[\
abla\[PERSON](Z^{(0)})]+[H]\cdot\big{[}\Delta Z^{(k)}\big{]}+\alpha^{\prime} \cdot[H]\cdot[d^{(k)}] \tag{27}\]  
\[[\
abla\[PERSON]([PERSON]^{\prime})]=[\
abla\[PERSON]([PERSON]^{(k)})]+\alpha^{\prime}\cdot[H]\cdot[d ^{(k)}] \tag{28}\]  
A quadratic expression of the objective function can be reached according to step \(\alpha^{(k)}\):  
\[\[PERSON]^{(k+1)}(\alpha^{(k)})=\[PERSON]^{(k)}+[\
abla\[PERSON]^{(k)}]_{t}\cdot[d^{(k)}]+ \frac{{(\alpha^{(k)})}^{2}}{2}\cdot[d^{(k)}]_{t}\cdot[H]\cdot[d^{(k)}] \tag{29}\]  
For this second-degree function, the optimal step in iteration \(k\) is obtained with the expression:  
\[[h_{I}^{(0)}]+[J_{IZ}]\cdot[\Delta Z]+[J_{YY}]\cdot[\Delta Y]\leq 0 \tag{21}\]0  
In this case, the reduced gradient of the quadratic objective function \(\Phi\) must be calculated for a random displacement by one step \(\alpha^{\prime}\), from iteration \(k\) to iteration \(k+1\), to determine the optimal step size. The determination of the step size is performed as follows:  
* if \(\alpha_{j}^{(k)}\leq 0\), then the inactive constraint \(j,j=1,\ldots,q\), is exceeded at the starting point and is transformed into an active constraint. Further, the number of the independent variable will decrease with 1;
* if \(\alpha_{opt}^{(k)}<\alpha_{adm}^{(k)}\), then \(\alpha^{(k)}=\alpha_{opt}^{(k)}\);
* if \(\alpha_{opt}^{(k)}>\alpha_{adm}^{(k)}\) then \(\alpha^{(k)}=\alpha_{adm}^{(k)}\).