## 2 The Mathematical Modeling of OPF Objective Function
### Constraints
#### 2.2.2 Inequality Constraints  
Regardless that the power flow relations seem to be represented in simple equations as shown in Equations (6) and (7), solving these inequalities requires complicated computational mathematics due to the numerous constraints of each system component's operating limits. The system components' constraints are listed below:  
* Generator constraints: \[V_{min}^{G_{i}}\leq V_{G_{i}}\leq V_{max}^{G_{i}},\quad i=1,\ \ldots,\ \text{NG}\] (9) \[P_{min}^{G_{i}}\leq P_{G_{i}}\leq P_{max}^{G_{i}},\quad i=2,\ \ldots,\ \text{NG}\] (10) \[Q_{min}^{G_{i}}\leq Q_{G_{i}}\leq Q_{max}^{G_{i}},\quad i=1,\ \ldots,\ \text{NG}\] (11) where \(V_{min}^{G_{i}}\), \(V_{max}^{G_{i}}\) indicates the lowest and highest voltage boundaries for the ith bus, \(P_{min}^{G_{i}}\), \(P_{max}^{G_{i}}\) defines the active power limits of each ith generator, and the same for \(Q_{min}^{G_{i}}\), \(Q_{max}^{G_{i}}\) but for reactive power. * Transformer constraints: \[T_{min}^{i}\leq T_{i}\leq T_{max}^{i},\quad i=1,\ \ldots,\ \text{NT}\] (12) where \(T_{min}^{i}\) and \(T_{max}^{i}\) represents the minimum and maximum values of the ith tap changer transformer \(T_{i}\). * Shunt VAR compensators constraints: \[Q_{min}^{G_{i}}\leq Q_{C_{i}}\leq Q_{max}^{G_{i}},\quad i=1,\ \ldots,\ \text{NC}\] (13) where \(Q_{min}^{G_{i}}\) is lower limit and \(Q_{max}^{G_{i}}\) is the maximum one for each compensator connected to bus \(i\). * Security constraints: \[V_{min}^{L_{i}}\leq V_{L_{i}}\leq V_{max}^{L_{i}},\quad i=1,\ \ldots,\ \text{NL}\] (14) \[S_{li}\leq S_{max}^{li},\quad i=1,\ \ldots,\ \text{NTL}\] (15) where \(S_{li}\) and \(S_{max}^{li}\) are the min and max limit of the apparent power of the ith transmission line, \(V_{min}^{L_{i}}\) and \(V_{max}^{L_{i}}\) are the voltage limits for the same transmission line. It is worth mentioning that the state vector \(\mathbf{u}\), which determines the status of the power system, contains inequality constraints that affect the general objective mentioned in Equation (1) as a penalty factor. The u vector inequality constraints are illustrated below in Equations (16)-(1  
\[Q_{Gi}^{lim}= \begin{cases}Q_{Gi}^{min},&Q_{Gi}<Q_{Gi}^{min}\\ Q_{Gi}^{max},&Q_{Gi}>Q_{Gi}^{max}\\ Q_{Gi},&Q_{Gi}^{min}\ \leq Q_{Gi}\leq Q_{Gi}^{max}\end{cases}  \tag{18}\] \[S_{Gsl}^{lim}= \begin{cases}S_{li}^{max},&S_{ii}>S_{li}^{max}\\ S_{li},&S_{li}\ \leq\ S_{li}^{max}\end{cases}  \tag{19}\]  
where \(P_{Gsl}\) is the active power generation at the slack bus, \(V_{Li}\) is load bus voltages, \(Q_{Gi}\) is reactive power generation, and \(S_{li}\) is branch apparent power flow. Thus, the new expanded objective function to be solved is shown in Equation (20):  
\[ \begin{split} Fp(x,u)&=F(x,u)+\lambda_{V}\sum\limits_{i=1} ^{NL}\left(V_{L_{i}}-V_{Ilim}^{L_{i}}\right)^{2}+\lambda_{P}\left(P_{G_{sl}}-P_ {Ilim}^{G_{sl}}\right)^{2}\\ +\lambda_{Q}\sum\limits_{i=1}^{NG}\left(Q_{Gi}-Q_{lim}^{G_{i}} \right)^{2}+\lambda_{S}\sum\limits_{i=1}^{NL}\left(S_{l_{i}}-S_{llim}^{l_{i} }\right)^{2}\end{split}  \tag{20}\]  
where \(\lambda_{V}\), \(\lambda_{P}\), \(\lambda_{Q}\) and \(\lambda_{S}\) are the penalty factors for voltage, active, reactive and apparent power, \(Fp(x,u)\) stands for the augmented objective function of the system optimization, where an original function \(F(x,\mu)\) includes a basic optimization goal. The additional terms, weighted by the Lagrange multipliers \(\lambda_{V}\), \(\lambda_{P}\), \(\lambda_{Q}\) and \(\lambda_{S}\) serve as penalty terms designed to enforce constraints related to voltage \(V\), active power \(P\), reactive power \(Q\), and apparent power \(S\). The approach used to derive this equation follows a penalty function method in optimization. By incorporating quadratic penalty terms, the optimization process can handle both the main objective and constraint enforcement within the same framework.