# 罚函数法

罚函数法是一种数值优化技术，它通过在目标函数中加入惩罚项来强制满足约束最小化问题的约束条件，从而转而求解一系列无约束问题。每个子问题按照罚参数的比例对约束违反进行惩罚；随着参数增大，无约束问题的解趋近于原约束问题的解。<sup>[1](https://pages.cs.wisc.edu/~solodov/izmsol22penalty.pdf)</sup> 该方法在精度与数值条件之间进行权衡：较大的罚参数带来较小的约束违反，但使每个子问题更难求解。<sup>[2](https://ocw.mit.edu/courses/ids-338j-multidisciplinary-system-design-optimization-spring-2010/3745f01dbdd2a70f9c3867d945f431d7_MITESD_77S10_lec08.pdf)</sup>

| 关键事实 | 详情 |
|---|---|
| 罚目标函数 | \( \phi_{c}(x) = f(x) + c\,\psi(x) \)，罚参数 \( c > 0 \)，其中 \( \psi \) 在可行集上恰好为零，在可行集外为正<sup>[1](https://pages.cs.wisc.edu/~solodov/izmsol22penalty.pdf)</sup><sup> • </sup><sup>[3](https://www.stat.cmu.edu/~ryantibs/convexopt-F13/scribes/lec16.pdf)</sup> |
| 极限行为 | 当 \( c \to \infty \) 时，子问题全局解的每个聚点都是约束问题的全局解<sup>[1](https://pages.cs.wisc.edu/~solodov/izmsol22penalty.pdf)</sup> |
| 精度 | 在线性无关约束规范（LICQ）、严格互补性和二阶充分性下，\( x_{c} - \bar{x} = O(1/c) \)；仅在二阶充分性下为 \( O(1/c^{1/2}) \)<sup>[1](https://pages.cs.wisc.edu/~solodov/izmsol22penalty.pdf)</sup> |
| 条件性 | 罚海森矩阵的条件数随罚参数增大而增长，因此较大的参数带来较小的约束违反，但子问题的条件数更差<sup>[4](https://www.math.ntnu.no/emner/TMA4180/2011v/notes/PenaltyBarrier2010.pdf)</sup> |
| 外点与内点 | 外点罚函数允许不可行初始点并能处理等式约束；内点（障碍）罚函数要求可行初始点，且不经繁琐修改无法处理等式约束<sup>[5](https://mat.uab.cat/~alseda/MasterOpt/const_opt.pdf)</sup> |
| 精确罚函数 | 非光滑 \( \ell_{1} \) 罚函数在有限罚值处即可恢复精确的约束解，避免了无限序列<sup>[6](https://hua-zhou.github.io/media/pdf/ZhouLange15ConvProgPath.pdf)</sup> |
| 现代背景 | 罚函数表述在约束深度学习中仍然常见，因为它们适配无约束优化器，尽管固定罚系数受到了批评<sup>[7](https://arxiv.org/html/2505.20628v3)</sup> |

## 工作原理

给定一个目标为 \( f \)、约束由违反度量 \( \psi \) 概括的约束问题，该方法对递增的参数序列 \( c \) 求解 \( \min_{x} \phi_{c}(x) = f(x) + c\,\psi(x) \)。<sup>[1](https://pages.cs.wisc.edu/~solodov/izmsol22penalty.pdf)</sup> 罚函数满足：对所有 \( x \) 有 \( \psi(x) \geq 0 \)，且 \( \psi(x) = 0 \) 恰好在可行集上成立，因此违反约束会带来高昂代价。<sup>[3](https://www.stat.cmu.edu/~ryantibs/convexopt-F13/scribes/lec16.pdf)</sup> 对于等式约束上的二次损失外点罚函数，\( \psi(x) = \tfrac{1}{2}\sum_{j} h_{j}(x)^{2} \)。<sup>[8](https://siko1056.github.io/optim-2021/nlo-lecture-09-penalty.html)</sup>

收敛保证是分层的。罚收敛定理仅要求 \( f \)、约束和罚函数连续：子问题解的任意极限点都是原问题的解。<sup>[9](https://ocw.mit.edu/courses/15-084j-nonlinear-programming-spring-2004/13b4c46d590cf3df94475e0ae1a815c3_lec10_penalty_mt.pdf)</sup> 在LICQ、严格互补性和二阶充分性下，收敛速率为 \( O(1/c) \)；仅在二阶充分性下退化为 \( O(1/c^{1/2}) \)。<sup>[1](https://pages.cs.wisc.edu/~solodov/izmsol22penalty.pdf)</sup>

## 实施方法

二次罚算法取初始参数 \( c_{0} > 0 \)、非负容差序列 \( \tau_{k} \to 0 \) 和一个初始点；在每次迭代中，从上一个解出发近似最小化 \( \phi_{c_{k}}(x) \)，当 \( \|\nabla_{x} \phi_{c_{k}}(x_{k})\| \leq \tau_{k} \) 时停止，然后增大罚参数。<sup>[10](https://wiki.math.ntnu.no/_media/tma4180/2022v/lecture19withnotes.pdf)</sup> 用上一个解对每个子问题进行热启动，是使该序列可处理的延拓策略。<sup>[11](https://homel.vsb.cz/~ber95/Methods_of_Optimization/Literature/Ascher/chap10.pdf)</sup>

从一开始就将参数设为非常大的值会失败：大的 \( c \) 在约束边界处造成极其陡峭的峡谷，带来严重的收敛困难。合理的策略是从一个不可行点出发，以相对较小的 \( c \) 开始，每次迭代将 \( c \) 乘以大于1的增长因子，当 \( \|x_{k-1} - x_{k}\| \) 或目标值的变化低于容差时停止。<sup>[5](https://mat.uab.cat/~alseda/MasterOpt/const_opt.pdf)</sup> 这种权衡不可避免：小参数易于最小化但产生大的约束违反，大参数几乎满足约束但数值条件很差，而过早停止会留下不可行的设计。<sup>[2](https://ocw.mit.edu/courses/ids-338j-multidisciplinary-system-design-optimization-spring-2010/3745f01dbdd2a70f9c3867d945f431d7_MITESD_77S10_lec08.pdf)</sup>

## 起源

通过罚函数求解约束问题最早由R. Courant在《平衡与振动问题求解的变分方法》（《美国数学会通报》，1943年）中考虑。<sup>[12](https://doi.org/10.1090/s0002-9904-1943-07818-4)</sup> 二十多年后，Anthony V. Fiacco和Garth P. McCormick在《非线性规划的顺序无约束最小化技术：一种原始-对偶方法》（《管理科学》，1964年）中发展了完整的技术SUMT，其建立在Charles W. Carroll在《优化非线性受约束系统的创建响应面技术》（《运筹学》，1961年）中提出的想法之上。<sup>[13](https://doi.org/10.1287/mnsc.10.2.360)</sup><sup> • </sup><sup>[14](https://doi.org/10.1287/opre.9.2.169)</sup> SUMT生成原始可行点和对偶可行点，并使原始目标函数值单调递减。<sup>[13](https://doi.org/10.1287/mnsc.10.2.360)</sup> Willard I. Zangwill的《通过罚函数的非线性规划》（《管理科学》，1967年）给出了一个算法，其收敛性证明对非凹函数也成立。<sup>[15](https://doi.org/10.1287/mnsc.13.5.344)</sup> Tomasz Pietrzykowski的《约束极大值的精确势函数方法》（《SIAM数值分析杂志》，1969年）被认为提出了1-范数精确罚函数，<sup>[16](https://doi.org/10.1137/0706028)</sup> 此后这一发展脉络经由R. Fletcher的《带不等式非线性规划的精确罚函数》（《数学规划》，1973年）、<sup>[17](https://doi.org/10.1007/bf01580117)</sup> G. di Pillo和L. Grippo的连续可微精确罚函数（《SIAM控制与优化杂志》，1985年）、<sup>[18](https://doi.org/10.1137/0323007)</sup> J. V. Burke的平静性分析（《SIAM控制与优化杂志》，1991年）、<sup>[19](https://doi.org/10.1137/0329027)</sup> 以及Waltraud Huyer和Arnold Neumaier的《一种新的精确罚函数》（《SIAM优化杂志》，2003年）延续。<sup>[20](https://doi.org/10.1137/s1052623401390537)</sup>

## 变体

**二次罚函数。** 经典的外点罚函数对每个约束违反取平方。它连续可微且易于实现，但不是精确的：由于违反函数在零违反处的导数为零，没有任何有限罚参数能使其最小化子成为约束最小化子。<sup>[21](https://www.math.ncu.edu.tw/~cchsiao/Course/Optimization_122/Exact%20Penalty%20Functions%20in%20Nonlinear%20Programming.pdf)</sup> 需要求解参数递增的子问题序列，且仅在极限处获得可行解。<sup>[22](https://friedlander.io/files/pdf/2020aEstrinFriedlanderOrbanSaunders.pdf)</sup>

**精确（ℓ1）罚函数。** 将平方违反替换为绝对值，\( f(x) + c \sum_{i} |h_{i}(x)| + c \sum_{j} \max\{0, g_{j}(x)\} \)，在有限参数下即可得到精确解，避免了无限子问题序列，代价是不可微。<sup>[6](https://hua-zhou.github.io/media/pdf/ZhouLange15ConvProgPath.pdf)</sup><sup> • </sup><sup>[23](https://solmaz.eng.uci.edu/Teaching/MAE206/Lecture14.pdf)</sup>

**光滑精确罚函数。** 这些方法在保持可微的同时实现精确性，通常通过用乘子估计增广问题来实现；由此产生的约束解与无约束最小化之间的等价性支持全局和超线性收敛的算法，但求值需要高阶导数。<sup>[18](https://doi.org/10.1137/0323007)</sup><sup> • </sup><sup>[22](https://friedlander.io/files/pdf/2020aEstrinFriedlanderOrbanSaunders.pdf)</sup>

**增广拉格朗日。** 该变体将二次罚函数加到拉格朗日函数而非目标函数上，乘子估计在外层循环中更新。在最优解处它与拉格朗日函数重合，因此罚参数不再需要很小，且该方法在有限参数值下恢复精确解，同时保持可微，不同于 \( \ell_{1} \) 罚函数。<sup>[11](https://homel.vsb.cz/~ber95/Methods_of_Optimization/Literature/Ascher/chap10.pdf)</sup><sup> • </sup><sup>[24](https://vtechworks.lib.vt.edu/server/api/core/bitstreams/51c1978f-2806-40b0-a392-8f2304439029/content)</sup>

## 应用

在有限元接触力学中，经典罚函数法易于实现，广泛用于强制非穿透条件，但它仅近似地强制约束，增大罚参数会导致切刚度矩阵的条件数变差。那里的精确罚正则化直接从位移计算拉格朗日乘子，消除了增广拉格朗日方案昂贵的外层迭代，并在鲁棒性、效率和精度方面得到了正面评价。<sup>[25](https://csml.berkeley.edu/Preprints/text20a.pdf)</sup>

在约束机器学习中，罚函数表述仍然流行，因为它们将约束训练转化为与Adam和学习率调度器兼容的无约束问题；当约束从小批量估计时，障碍法会失效，因为可行性评估因批次而异。<sup>[7](https://arxiv.org/html/2505.20628v3)</sup>

## 局限与替代方案

**条件数变差。** 核心失效模式是罚海森矩阵的条件数随参数趋近其极限而增长。<sup>[26](https://klaus-schittkowski.de/eolss.pdf)</sup>

**其他失效模式。** 当参数太小时，罚问题可能下方无界：对于 \( \min -5x_{1}^{2} + x_{2}^{2} \) 受约束于 \( x_{1} = 1 \)，二次罚函数在 \( c < 10 \) 时无界，迭代发散。<sup>[27](https://www.cs.nthu.edu.tw/~cherung/teaching/2011cs5321/handout9.pdf)</sup><sup> • </sup><sup>[28](https://inc.kmutt.ac.th/~sudchai.boo/Teaching/inc491s/Lecture7_Constrained2_2024.pdf)</sup> 反之，参数太大会使达到可行性压倒降低目标函数值的要求，可能导致在远离最优解时过早终止；根据每个约束的违反程度为其分配单独参数是一种有效的补救措施。<sup>[24](https://vtechworks.lib.vt.edu/server/api/core/bitstreams/51c1978f-2806-40b0-a392-8f2304439029/content)</sup>

**替代方案。** 增广拉格朗日方法通过引入显式乘子估计避免了条件数变差，因此无需将罚参数推向极限即可达到精确解；它们至少以线性速率收敛，且速率优于二次罚方法。<sup>[24](https://vtechworks.lib.vt.edu/server/api/core/bitstreams/51c1978f-2806-40b0-a392-8f2304439029/content)</sup><sup> • </sup><sup>[28](https://inc.kmutt.ac.th/~sudchai.boo/Teaching/inc491s/Lecture7_Constrained2_2024.pdf)</sup> 内点（障碍）方法，包括倒数障碍和对数障碍，从可行侧惩罚对边界的接近，当目标在可行域外定义不良时是可取的，但它们要求可行初始点，且不经繁琐修改无法处理等式约束。<sup>[5](https://mat.uab.cat/~alseda/MasterOpt/const_opt.pdf)</sup><sup> • </sup><sup>[28](https://inc.kmutt.ac.th/~sudchai.boo/Teaching/inc491s/Lecture7_Constrained2_2024.pdf)</sup> 序列二次规划求解一系列带线性化约束的二次子问题，在工程应用中广泛使用，尽管从不可行点出发时必须处理不可行的线性化子问题。<sup>[29](https://smdogroup.github.io/ae6310/jupyter/Constrained_Optimization_Algorithms.html)</sup><sup> • </sup><sup>[2](https://ocw.mit.edu/courses/ids-338j-multidisciplinary-system-design-optimization-spring-2010/3745f01dbdd2a70f9c3867d945f431d7_MITESD_77S10_lec08.pdf)</sup> 总体而言，乘子（增广拉格朗日）方法和精确罚方法在实践中已基本取代了纯罚函数方法。<sup>[30](https://encyclopediaofmath.org/wiki/Penalty_functions,_method_of)</sup>

## References

1. [Convergence rate estimates for penalty methods revisited](https://pages.cs.wisc.edu/~solodov/izmsol22penalty.pdf)
2. [ESD.77 Lecture 8, Numerical Optimization II (MIT OCW, de Weck & Willcox)](https://ocw.mit.edu/courses/ids-338j-multidisciplinary-system-design-optimization-spring-2010/3745f01dbdd2a70f9c3867d945f431d7_MITESD_77S10_lec08.pdf)
3. [Lecture 16: Penalty Methods (CMU 10-725 Convex Optimization)](https://www.stat.cmu.edu/~ryantibs/convexopt-F13/scribes/lec16.pdf)
4. [Penalty and Barrier Methods, A Summary (NTNU TMA4180 course notes)](https://www.math.ntnu.no/emner/TMA4180/2011v/notes/PenaltyBarrier2010.pdf)
5. [Algorithms for Constrained Optimization (textbook chapter, Bazaraa-style)](https://mat.uab.cat/~alseda/MasterOpt/const_opt.pdf)
6. [Path following in the exact penalty method of convex programming (Zhou & Lange)](https://hua-zhou.github.io/media/pdf/ZhouLange15ConvProgPath.pdf)
7. [Position: Adopt Constraints Over Penalties in Deep Learning (arXiv, 2025)](https://arxiv.org/html/2505.20628v3)
8. [Penalty methods, Selected Topics in Mathematical Optimization (lecture notes)](https://siko1056.github.io/optim-2021/nlo-lecture-09-penalty.html)
9. [Penalty and Barrier Methods for Constrained Optimization (MIT 15.084J, Lecture 10)](https://ocw.mit.edu/courses/15-084j-nonlinear-programming-spring-2004/13b4c46d590cf3df94475e0ae1a815c3_lec10_penalty_mt.pdf)
10. [TMA4180 Optimization: Lecture 19, Quadratic Penalty Method (NTNU)](https://wiki.math.ntnu.no/_media/tma4180/2022v/lecture19withnotes.pdf)
11. [Chapter 10: Penalty, barrier and augmented Lagrangian (Ascher et al., graduate textbook chapter)](https://homel.vsb.cz/~ber95/Methods_of_Optimization/Literature/Ascher/chap10.pdf)
12. [R. Courant (1943). Variational methods for the solution of problems of equilibrium and vibrations. Bulletin of the American Mathematical Society.](https://doi.org/10.1090/s0002-9904-1943-07818-4)
13. [Anthony V. Fiacco, Garth P. McCormick (1964). The Sequential Unconstrained Minimization Technique for Nonlinear Programing, a Primal-Dual Method. Management Science.](https://doi.org/10.1287/mnsc.10.2.360)
14. [Charles W. Carroll (1961). The Created Response Surface Technique for Optimizing Nonlinear, Restrained Systems. Operations Research.](https://doi.org/10.1287/opre.9.2.169)
15. [Willard I. Zangwill (1967). Non-Linear Programming Via Penalty Functions. Management Science.](https://doi.org/10.1287/mnsc.13.5.344)
16. [Tomasz Pietrzykowski (1969). An Exact Potential Method for Constrained Maxima. SIAM Journal on Numerical Analysis.](https://doi.org/10.1137/0706028)
17. [R. Fletcher (1973). An exact penalty function for nonlinear programming with inequalities. Mathematical Programming.](https://doi.org/10.1007/bf01580117)
18. [G. di Pillo, L. Grippo (1985). A Continuously Differentiable Exact Penalty Function for Nonlinear Programming Problems with Inequality Constraints. SIAM Journal on Control and Optimization.](https://doi.org/10.1137/0323007)
19. [J. V. Burke (1991). Calmness and Exact Penalization. SIAM Journal on Control and Optimization.](https://doi.org/10.1137/0329027)
20. [Waltraud Huyer, Arnold Neumaier (2003). A New Exact Penalty Function. SIAM Journal on Optimization.](https://doi.org/10.1137/s1052623401390537)
21. [Exact penalty functions in nonlinear programming (Han & Mangasarian, Mathematical Programming, 1979)](https://www.math.ncu.edu.tw/~cchsiao/Course/Optimization_122/Exact%20Penalty%20Functions%20in%20Nonlinear%20Programming.pdf)
22. [Implementing a Smooth Exact Penalty Function for Equality-Constrained Nonlinear Optimization (Estrin, Friedlander, Orban, Saunders, SIAM J. Sci. Comput., 2020)](https://friedlander.io/files/pdf/2020aEstrinFriedlanderOrbanSaunders.pdf)
23. [Lecture 14: Penalty Function Method (Solmaz Kia, UC Irvine MAE206)](https://solmaz.eng.uci.edu/Teaching/MAE206/Lecture14.pdf)
24. [Virginia Tech dissertation chapter on exterior penalty and augmented Lagrangian (ALAG) methods](https://vtechworks.lib.vt.edu/server/api/core/bitstreams/51c1978f-2806-40b0-a392-8f2304439029/content)
25. [On the finite element solution of frictionless contact problems using an exact penalty approach](https://csml.berkeley.edu/Preprints/text20a.pdf)
26. [NONLINEAR PROGRAMMING (Schittkowski, EOLSS review article)](https://klaus-schittkowski.de/eolss.pdf)
27. [Numerical Optimization Unit 9: Penalty Method and Interior Point Method (NTHU)](https://www.cs.nthu.edu.tw/~cherung/teaching/2011cs5321/handout9.pdf)
28. [Constrained Optimization II: Penalty Method (KMUTT lecture notes, 2024)](https://inc.kmutt.ac.th/~sudchai.boo/Teaching/inc491s/Lecture7_Constrained2_2024.pdf)
29. [Constrained Optimization Algorithms, AE6310 Course Notes (Georgia Tech SDM group)](https://smdogroup.github.io/ae6310/jupyter/Constrained_Optimization_Algorithms.html)
30. [Penalty functions, method of, Encyclopedia of Mathematics](https://encyclopediaofmath.org/wiki/Penalty_functions,_method_of)

---
*Initially written Sep 29, 2026 · Reviewed: Sep 30, 2026 · Edited: Sep 30, 2026 · Last review: Sep 30, 2026*

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

Copyright 2026 Edgepedia

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

Source: https://www.edgepedia.org/zh/penalty-method

English original: https://www.edgepedia.org/penalty-method
