# KKT条件

KKT条件是非线性规划最佳解的必要条件，KKT条件将拉格朗日乘数法所处理的等式约束优化问题推广到不等式。

## 等式约束优化问题

\begin{aligned} &\min \qquad f(x) \\ & s.t. \qquad g(x)=0 \end{aligned}

$L(x,\lambda) = f(x) + \lambda g(x)$

$\mathop{\min}\limits_{x,\lambda} L(x,\lambda)$

\begin{aligned} &\nabla_{x}L=\frac{\partial L}{\partial x} = \nabla f + \lambda \nabla_{g} = 0\\ &\nabla_{\lambda}L=\frac{\partial L}{\partial \lambda} = g(x) = 0 \\ \end{aligned}

## 不等式约束优化问题

\begin{aligned} &\min \qquad f(x) \\ &s.t. \qquad g(x) \leq 0 \end{aligned}

\begin{aligned} &\min \qquad f(x) \\ &s.t. \qquad g(x) +a^2 = 0 \end{aligned}

$L(x,a,\lambda) = f(x) + \lambda(g(x) + a^2)$

$\begin{cases} \frac{\partial L}{\partial x} = \frac{\partial f}{\partial x} + \lambda \frac{\partial g}{\partial x} = 0 \\ \frac{\partial L}{\partial \lambda} = g(x) + a^2 =0 \\ \frac{\partial L}{\partial a} = 2\lambda a = 0 \\ \lambda \geq 0 \end{cases}$

1. $\lambda = 0, a \neq 0$：此时，由于乘子$\lambda=0$，因此g(x)与其相乘，得到的结果均为0，可以理解为约束不起作用，且有$g(x)=-a^2<0$
2. $a=0, \lambda \geq 0$:此时，由于$g(x) + a^2 = 0，且a=0$，所以g(x)=0，这时可以理解为约束g(x)在起作用。

$\begin{cases} \frac{\partial L}{\partial x} = \frac{\partial f}{\partial x} + \lambda \frac{\partial g}{\partial x} = 0 \\ \lambda g(x) = 0 \\ \lambda \geq 0 \end{cases}$

\begin{aligned} &\min \quad f(x) \\ &s.t. \quad g_j(x) \leq 0, \quad j=1,2,...,m \end{aligned}

$\begin{cases} \frac{\partial f}{\partial x_i} + \sum_{j=1}^{m}\lambda_j\frac{\partial g_j(x)}{\partial x_i} = 0, \quad i=1,2...n \\ \lambda_jg_j(x) = 0 \quad j=1,2,...,m \\ \lambda_j \geq 0 \quad j=1,2,...m \end{cases}$

\begin{aligned} &\min \quad f(x) \\ &s.t.\quad g_j(x) \leq 0, \quad j=1,2,...,m \\ & \qquad h_k(x) = 0, \quad k=1,2,...,p \\ \end{aligned}

$L(x,\lambda_j, \mu_k) = f(x) + \sum_{j=1}^{m}\lambda_jg_j(x) + \sum_{k=1}^p\mu_kh_k(x)$

\begin{aligned} &\nabla_xL = 0 \\ &h_k(x) =0, \quad k=1,2,...,p \\ &g_j(x) \leq 0, \quad j=1,2,...,m\\ &\lambda_j \geq 0,\quad j=1,2,...,m \\ &\lambda_jg_j(x)=0,\quad j=1,2,...,m \end{aligned}

• 拉格朗日函数的定长方程式：$\nabla_x L = 0$
• 原始可行性：$h_k(x) =0,g_j(x) \leq 0$
• 对偶可行性：$\lambda_j \geq 0$
• 互补松弛性：$\lambda_jg_j(x)=0$

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客