# 二次规划

二次规划（QP）是在线性等式与不等式约束下优化二次目标函数的问题。<sup>[1](https://community.wvu.edu/~krsubramani/courses/sp15/optfin/lecnotes/QPtheory.pdf)</sup> 在标准形式中，凸二次规划最小化 \( \tfrac{1}{2} x^{T} P x + q^{T} x \)，约束为 \( l \le A x \le u \)，其中 \( x \in \mathbf{R}^{n} \) 是决策变量，\( P \) 是半正定矩阵。<sup>[2](https://osqp.org/docs/)</sup> 当目标矩阵为半正定时，问题是凸的，每个局部最优都是全局最优；当它不定时，问题是非凸的，通常要困难得多。<sup>[1](https://community.wvu.edu/~krsubramani/courses/sp15/optfin/lecnotes/QPtheory.pdf)</sup>

| 关键事实 | 细节 |
|---|---|
| 标准形式 | 最小化 \( \tfrac{1}{2} x^{T} P x + q^{T} x \)，约束为 \( l \le A x \le u \)，凸情形下要求 \( P \succeq 0 \)<sup>[2](https://osqp.org/docs/)</sup> |
| 最优性 | 对凸二次规划，Karush-Kuhn-Tucker（KKT）条件既是全局最优的必要条件，也是充分条件<sup>[1](https://community.wvu.edu/~krsubramani/courses/sp15/optfin/lecnotes/QPtheory.pdf)</sup> |
| 首个专用算法 | Frank 与 Wolfe，《二次规划的一种算法》，《海军研究后勤季刊》3(1-2)：95-110，1956年<sup>[3](https://onlinelibrary.wiley.com/doi/10.1002/nav.3800030109)</sup> |
| 主要算法族 | 有效集方法、多项式时间内点法、算子分裂方法（如 OSQP 与 ADMM），以及针对非凸情形的半定松弛<sup>[4](https://doi.org/10.56764/hpu2.jos.2025.4.03.80-96)</sup> |
| 内点法规模 | 内点法在约束与变量数低于一百万的问题上具有竞争力，在数百万规模的问题上尤其有效<sup>[5](https://www.sciencedirect.com/science/article/pii/S0377221711008204)</sup> |
| 基准规模 | OSQP 基准库包含 1,400 个生成问题，非零元数量从 100 到 10,000,000 不等<sup>[6](https://github.com/osqp/osqp_benchmarks)</sup> |
| 标志性应用 | Markowitz 均值-方差投资组合选择、支持向量机训练，以及模型预测控制<sup>[7](https://onlinelibrary.wiley.com/doi/abs/10.1111/j.1540-6261.1952.tb01525.x)</sup><sup> • </sup><sup>[8](https://nlp.stanford.edu/IR-book/html/htmledition/support-vector-machines-the-linearly-separable-case-1.html)</sup><sup> • </sup><sup>[9](https://link.springer.com/article/10.1007/s00170-021-07682-3)</sup> |

## 问题陈述与最优性条件

一般二次规划优化形如 \( \tfrac{1}{2} x^{T} Q x + c^{T} x \) 的函数，约束为线性约束。<sup>[1](https://community.wvu.edu/~krsubramani/courses/sp15/optfin/lecnotes/QPtheory.pdf)</sup> 矩阵 \( Q \) 决定问题的性质。若 \( Q \) 为半正定，目标函数在可行多面体上是凸的，问题具有全局最优解，标准算法能够可靠地找到它。若 \( Q \) 不定或负定，问题是非凸的；一篇关于二次规划与二次约束二次规划的综述将半定规划松弛视为处理这些非凸情形的第四大范式。<sup>[4](https://doi.org/10.56764/hpu2.jos.2025.4.03.80-96)</sup>

**KKT 条件。** 对于写成约束 \( A x = b \) 与 \( x \ge 0 \) 的凸二次规划，Karush-Kuhn-Tucker 定理指出：若 \( x \) 是局部最优且 \( Q \) 为半正定，则存在向量 \( y \) 与 \( s \) 满足原始可行性（\( A x = b \)，\( x \ge 0 \)）、对偶可行性（\( A^{T} y - Q x + s = c \)，\( s \ge 0 \)）与互补松弛性（对每个 \( i \) 有 \( x_{i} s_{i} = 0 \)）。反之，任何满足这些条件的三元组 \( (x, y, s) \) 都是全局最优解，因此这五个条件合在一起既必要又充分。<sup>[1](https://community.wvu.edu/~krsubramani/courses/sp15/optfin/lecnotes/QPtheory.pdf)</sup> 对凸二次规划而言，拉格朗日函数 Hessian 的半正定性条件是自动满足的，因此不作为单独要求出现。<sup>[1](https://community.wvu.edu/~krsubramani/courses/sp15/optfin/lecnotes/QPtheory.pdf)</sup>

## 算法

四种算法范式主导了这一领域。<sup>[4](https://doi.org/10.56764/hpu2.jos.2025.4.03.80-96)</sup>

**有效集方法**具有有限收敛性质：它们在一系列约束集之间移动，在有限步内终止于精确解。它们适合中小规模问题以及热启动，这正是有效集求解器 qpOASES 被用于实时控制的原因，不过其稠密线性代数使其不适合大规模二次规划。<sup>[4](https://doi.org/10.56764/hpu2.jos.2025.4.03.80-96)</sup><sup> • </sup><sup>[10](https://web.stanford.edu/~boyd/papers/pdf/osqp.pdf)</sup>

**内点法**沿中心路径穿过可行域内部，具有多项式最坏情况复杂度保证。一篇25年回顾性综述将其实际速度归因于快速收敛和处理超大规模问题的能力，并指出它们在约一百万约束与变量以下具有竞争力，在数百万维问题上尤其有效。<sup>[5](https://www.sciencedirect.com/science/article/pii/S0377221711008204)</sup> 斯坦福大学管理科学与工程教授叶荫宇与 Edison Tse 将 Karmarkar 投影算法早期推广到凸二次规划的工作，于1989年发表在《数学规划》上。<sup>[11](https://dblp.uni-trier.de/rec/journals/mp/YeT89.html)</sup>

**算子分裂方法**包括 OSQP，它通过交替方向乘子法（ADMM）求解凸二次规划，所用分裂要求在几乎每次迭代中求解一个系数矩阵相同的拟定线性系统。该方法除凸性外对问题数据不作任何要求，例如不要求目标函数正定或约束线性无关，通常报告比竞争的内点法快十倍，在使用分解缓存或热启动时有时快得多。<sup>[12](https://arxiv.org/abs/1711.08013)</sup> OSQP 还能检测原始与对偶不可行性，其文档称这是一阶二次规划求解器中的首创，并能生成不可行性证书。<sup>[2](https://osqp.org/docs/)</sup>

**半定规划松弛**通过将非凸实例提升为凸问题来处理它们，其解可以界定或恢复原问题的解。<sup>[4](https://doi.org/10.56764/hpu2.jos.2025.4.03.80-96)</sup>

## 历史

该领域的专用算法可追溯到20世纪50年代中期。Marguerite Frank 与 Philip Wolfe 于1956年在《海军研究后勤季刊》第3卷第95至110页发表了《二次规划的一种算法》。<sup>[3](https://onlinelibrary.wiley.com/doi/10.1002/nav.3800030109)</sup> 当时任职于密歇根州立大学的 Clifford Hildreth 一年后在同一期刊第4卷第79至85页发表了《一种二次规划方法》。<sup>[13](https://onlinelibrary.wiley.com/doi/pdf/10.1002/nav.3800040113)</sup> Philip Wolfe 于1959年在《计量经济学》上贡献了二次规划的单纯形方法。<sup>[4](https://doi.org/10.56764/hpu2.jos.2025.4.03.80-96)</sup> 应用背景出现得更早：Harry Markowitz 1952年发表在《金融学刊》第7卷第77至91页的论文《投资组合选择》奠定了均值-方差投资组合理论，其优化问题即为二次规划。<sup>[7](https://onlinelibrary.wiley.com/doi/abs/10.1111/j.1540-6261.1952.tb01525.x)</sup>

## 应用

**投资组合优化。** Markowitz 均值-方差分析将投资组合选择表述为在期望收益与方差之间权衡的二次参数优化问题，至今对金融领域的研究者与从业者仍具有重要意义。<sup>[14](https://www.sciencedirect.com/science/article/pii/S0377221713002105)</sup> 一项关于有限资产投资组合模型的计算研究发现，出乎意料的是，用他们的算法求解二次 LAM 模型比用商业混合整数线性规划代码 CPLEX 求解线性 LACVaR 与 LAMAD 模型更容易。<sup>[15](https://arxiv.org/abs/1105.3594)</sup>

**支持向量机。** 训练线性支持向量机（SVM）——一种大间隔分类器——是一个凸二次规划：在每一条带标签样本对应一个线性分类约束的条件下，最小化权重向量的范数。其对偶问题也是二次规划，在其解中大多数拉格朗日乘子为零；非零乘子识别出支持向量，即决定分类器的输入。<sup>[8](https://nlp.stanford.edu/IR-book/html/htmledition/support-vector-machines-the-linearly-separable-case-1.html)</sup> 序列最小优化等专用分解方法利用这一特定二次规划的结构，而不是用通用库来求解。<sup>[8](https://nlp.stanford.edu/IR-book/html/htmledition/support-vector-machines-the-linearly-separable-case-1.html)</sup>

**模型预测控制。** 在模型预测控制（MPC）中，控制器在滚动时域上反复求解约束优化问题；在有限时域下，线性估计问题可以表述为二次规划，这在早期应用中具有计算上的优势。<sup>[9](https://link.springer.com/article/10.1007/s00170-021-07682-3)</sup> 一篇关于非线性 MPC 二次规划算法的综述指出，二次规划求解器位于大多数线性与非线性 MPC 控制器的核心，而利用问题结构使 MPC 能在极高采样率下运行。<sup>[16](https://awesco.tudelft.nl/publication/kouzoupis-2018/)</sup> 在足式机器人中，二次规划支撑着逆动力学、MPC 与全身控制，其解必须在嵌入式平台上紧张的时序与能量预算内到达；一篇近期综述推荐对长时域 MPC 使用稀疏内点法，对高频全身控制使用稠密有效集求解器。<sup>[17](https://arxiv.org/abs/2510.21773)</sup>

## 求解器版图与基准

商业与开源求解器以不同方式覆盖凸与非凸情形。Gurobi 使用单纯形法或障碍法求解连续变量与线性约束的凸二次规划，而具有非凸二次目标的模型即使没有显式离散元素也会被路由到混合整数规划求解器。<sup>[18](https://docs.gurobi.com/projects/optimizer/en/current/concepts/modeling/objectives.html)</sup> 对于非凸二次约束，Gurobi 的算法探索整个搜索空间并提供最优目标的全局有效下界，而其他非凸二次求解器往往只能找到局部最优解。<sup>[19](https://docs.gurobi.com/projects/optimizer/en/current/concepts/modeling/constraints.html)</sup>

OSQP 基准套件在 1,400 个随机生成的问题上比较求解器，涵盖随机二次规划、等式约束二次规划、投资组合、lasso、Huber 拟合、支持向量机与约束最优控制等类别，非零元从 100 到 10,000,000。其平移几何平均运行时间将 OSQP 列为 1.0，MOSEK 为 2.52，GUROBI 为 4.28，ECOS 为 28.85，qpOASES 为 149.93。<sup>[6](https://github.com/osqp/osqp_benchmarks)</sup> 然而在困难的 Maros-Mészáros 测试集上，低精度下 GUROBI 以平移几何平均 1.0 领先，OSQP 为 1.46，MOSEK 为 6.12；OSQP 论文作者将该比较中的 qpOASES 排除在外，因为其稠密有效集方法无法求解大多数大规模问题。<sup>[6](https://github.com/osqp/osqp_benchmarks)</sup><sup> • </sup><sup>[10](https://web.stanford.edu/~boyd/papers/pdf/osqp.pdf)</sup> Maros-Mészáros 集合包含 138 个二次规划，其中有由数值病态、秩亏或缩放不良引起的困难实例，所有求解器至少在其中某个子集上失败。<sup>[20](https://link.springer.com/article/10.1007/s12532-026-00320-7)</sup> 在同一研究中，内点法求解器 Clarabel 原生处理二次目标，而不通过上图重构将问题改写为二阶锥形式；它在该集合上除 Gurobi 外比所有求解器都快，避免重构在速度与可解问题数量上都带来了显著好处。<sup>[20](https://link.springer.com/article/10.1007/s12532-026-00320-7)</sup>

这些基准呈现的规律是：没有单一算法占主导地位；一阶分裂方法在热启动与廉价迭代重要的大规模稀疏问题上领先，内点法与分支定界代码在困难、缩放不良的实例上领先，而稠密有效集方法仍是嵌入式控制中以千赫兹速率求解小规模问题的选择。<sup>[6](https://github.com/osqp/osqp_benchmarks)</sup><sup> • </sup><sup>[10](https://web.stanford.edu/~boyd/papers/pdf/osqp.pdf)</sup><sup> • </sup><sup>[17](https://arxiv.org/abs/2510.21773)</sup>

## References

1. [Quadratic Programming: Theory and Algorithms, course notes, West Virginia University](https://community.wvu.edu/~krsubramani/courses/sp15/optfin/lecnotes/QPtheory.pdf)
2. [OSQP solver documentation](https://osqp.org/docs/)
3. [Frank, M. and Wolfe, P. (1956). An algorithm for quadratic programming. Naval Research Logistics Quarterly 3(1-2): 95-110.](https://onlinelibrary.wiley.com/doi/10.1002/nav.3800030109)
4. [Quadratic programming and quadratically constrained quadratic programming: theory, algorithms, and applications. HPU2 Journal of Science (2025)](https://doi.org/10.56764/hpu2.jos.2025.4.03.80-96)
5. [Interior point methods 25 years later. European Journal of Operational Research](https://www.sciencedirect.com/science/article/pii/S0377221711008204)
6. [OSQP benchmarks repository, GitHub](https://github.com/osqp/osqp_benchmarks)
7. [Markowitz, H. (1952). Portfolio Selection. The Journal of Finance 7(1): 77-91.](https://onlinelibrary.wiley.com/doi/abs/10.1111/j.1540-6261.1952.tb01525.x)
8. [Support vector machines: the linearly separable case. Stanford NLP, Introduction to Information Retrieval](https://nlp.stanford.edu/IR-book/html/htmledition/support-vector-machines-the-linearly-separable-case-1.html)
9. [Schwenzer, M. et al. (2021). Review on model predictive control: an engineering perspective. The International Journal of Advanced Manufacturing Technology 117: 1327-1349.](https://link.springer.com/article/10.1007/s00170-021-07682-3)
10. [Stellato, B. et al. OSQP: an operator splitting solver for quadratic programs](https://web.stanford.edu/~boyd/papers/pdf/osqp.pdf)
11. [Ye, Y. and Tse, E. (1989). An extension of Karmarkar's projective algorithm for convex quadratic programming. Math. Program. 44: 157-179, dblp record](https://dblp.uni-trier.de/rec/journals/mp/YeT89.html)
12. [OSQP: An Operator Splitting Solver for Quadratic Programs, arXiv:1711.08013](https://arxiv.org/abs/1711.08013)
13. [Hildreth, C. (1957). A quadratic programming procedure. Naval Research Logistics Quarterly 4(1): 79-85.](https://onlinelibrary.wiley.com/doi/pdf/10.1002/nav.3800040113)
14. [On the equivalence of quadratic optimization problems commonly used in portfolio theory. European Journal of Operational Research](https://www.sciencedirect.com/science/article/pii/S0377221713002105)
15. [Portfolio selection problems in practice: a comparison between linear and quadratic optimization models, arXiv:1105.3594](https://arxiv.org/abs/1105.3594)
16. [Kouzoupis, D., Frison, G., Zanelli, A., Diehl, M. (2018). Recent advances in quadratic programming algorithms for nonlinear model predictive control](https://awesco.tudelft.nl/publication/kouzoupis-2018/)
17. [Dinh, V. N. (2025). Real-Time QP Solvers: A Concise Review and Practical Guide Towards Legged Robots, arXiv:2510.21773](https://arxiv.org/abs/2510.21773)
18. [Objectives, Gurobi Optimizer Reference Manual](https://docs.gurobi.com/projects/optimizer/en/current/concepts/modeling/objectives.html)
19. [Constraints, Gurobi Optimizer Reference Manual](https://docs.gurobi.com/projects/optimizer/en/current/concepts/modeling/constraints.html)
20. [Clarabel: An interior-point solver for conic programs with quadratic objectives. Mathematical Programming Computation](https://link.springer.com/article/10.1007/s12532-026-00320-7)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 30, 2026; Oct 15, 2026 · Edited: Sep 30, 2026; Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 物质世界与数学 › 数学与统计学 › 数学分析与数学模型 › Numerical analysis and computation

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/quadratic-programming

English original: https://www.edgepedia.org/quadratic-programming
