## 2 Materials and Methods
### Stage 2. Successive Quadratic Programming-Based OPF
#### 2.2.2 The Successive Quadratic Programming-Based Optimization Algorithm  
The successive quadratic programming (SQP) involves transforming the OPF problem into a nonlinear programming problem characterized by the quadratic objective function and linear equality and inequality constraints [39; 40]. Thus, the OPF problem can be written compressed [41]:  
\[min\{F([X])\} \tag{10}\]  
\[h_{Ai}([X])=0,\quad i=1,\ldots,p \tag{11}\]  
\[h_{Ij}([X])\leq 0,\quad j=1,\ldots,q \tag{12}\]  
where \([X]=[x_{1},x_{2},\ldots,x_{n}]\) represent the optimization variables, and \(n=p+q\). The necessary condition \(n>p\) is met for the analyzed OPF problem. If a feasible starting point \([X^{(0)}]=[x_{1}{}^{(0)},x_{2}{}^{(0)},\ldots,x_{n}{}^{(0)}]\) is considered and developed in the Taylor series of the objective function (keeping the first three terms) and the constraints (using only the first two terms), the following quadratic programming (QP) problem results:  
\[min(Z([\Delta X]))=min\bigg{(}F^{(0)}+[\
abla F]_{t}\cdot[\Delta X]+\frac{1}{ 2}\cdot[\Delta X]_{t}\cdot[H]\cdot[\Delta X]\bigg{)} \tag{13}\]  
\[[h_{A}^{(0)}]+[J_{A}]\cdot[\Delta X]=0 \tag{14}\]  
\[[h_{I}^{(0)}]+[J_{I}]\cdot[\Delta X]\leq 0 \tag{15}\]  
where:  
\(Z([\Delta X])\) is the objective function of the QP problem, approximately equal to \(F([X])\),  
\[Z(\Delta X])\cong F([X]) \tag{16}\]  
\[[X]=[X^{(0)}]+[\Delta X] \tag{17}\]  
\([\Delta X]\)--the vector of the optimization variables associated with the QP problem, the size of \(n\times 1\);  
\([H]\)--the Hessian of the objective function, the size of \(n\times n\);  
\(F^{(0)}\)--the value of the objective function \(F\) calculated at the starting point \([X^{(0)}]\), the size of \(1\times n\);  
\([\
abla F]\)--the gradient of the objective function calculated at the starting point \([X^{(0)}]\), the size of \(n\times 1\);  
\([h_{A}{}^{(0)}]\)--the vector of the active constraints at the starting point \([X^{(0)}]\), the size of \(1\times p\);  
\([h_{I}{}^{(0)}]\)--the vector of the inactive constraints at the starting point \([X^{(0)}]\), the size of \(1\times q\);  
\([J_{A}]\)--the Jacobian of the active constraints, the size of \(p\times n\);  
\([J_{I}]\)--the Jacobian of the inactive constraints, the size of \(q\times n\);The conjugate-reduced gradient method is proposed to solve the problem due to the equality relationships and the choice of the search directions towards the optimal solution. The method is applied to solve the quadratic programming model (13)-(15) based on the argument given by the principle of the state and control variables, such that the load flow equations provide the possibility to eliminate the state variables. It helps in obtaining a reduced problem in the space of the control variables with the load flow equations and eliminating the associated state variables. The method reduces the dimension of the problem by representing a part of the variable, called dependent, through a subset of independent variables. Thus, two sets of variables are distinguished in the algorithm if a non-degeneracy assumption holds, \(m\) dependent variables, \([\Delta Y]\) and \((n-m)\) independent variables \([\Delta Z]\). The GR algorithm develops a linear approximation to the gradient at a given point \([\Delta X]\). The gradients of the objective function and constraints can be simultaneously solved because the gradient of the objective function is calculated considering the gradients of the constraints. Thus, the search can proceed in a feasible direction, and the dimension of the search region is reduced. This algorithm is general for any nonlinear problem with equality and inequality constraints, all functions being continuous and differentiable. Therefore, it is suitable for realistically sized optimal load flow problems and was chosen for model implementation. Thus, the optimization variables \([\Delta X]\) are divided into control variables (independent) \([\Delta Z]\) and state variables (dependent) \([\Delta Y]\):  
\[[\Delta X]=\left[ \begin{array}{c}[\Delta Z]\\ [\Delta Y]\end{array}