# 两阶段随机优化

两阶段随机优化是运筹学的一种方法，它将决策分为两个阶段：在不确定性消解之前采取的第一阶段行动，以及在观测到随机数据之后采取的第二阶段补偿行动，目标是最小化第一阶段成本加期望补偿成本。

| 关键事实 | 详情 |
|---|---|
| 目标 | \( \min \; c^{\top} \cdot x + \mathbb{E}[Q(x,\xi)] \)，约束于 \( A \cdot x = b,\ x \ge 0 \)，其中 \( Q(x,\xi) \) 是第二阶段问题的最优值 <sup>[1](https://epubs.siam.org/doi/10.1137/1.9780898718751.ch2)</sup> |
| 决策划分 | 第一阶段变量是“此时此地”决策；第二阶段变量是观测数据的“观望等待”函数 <sup>[2](https://bpb-us-e1.wpmucdn.com/sites.gatech.edu/dist/4/1470/files/2021/03/SPbook.pdf)</sup> |
| 矩阵 | \( W \) 是补偿矩阵，\( T \) 是技术矩阵；逐情景展开的完整问题称为确定性等价形式，或称展开形式 <sup>[3](https://canli1.github.io/images/preprint/2021Frontiers.pdf)</sup> |
| 不可行性约定 | 若第二阶段问题对某些 \( x \) 和 \( \xi \) 不可行，则按定义 \( Q(x,\xi) = +\infty \) <sup>[1](https://epubs.siam.org/doi/10.1137/1.9780898718751.ch2)</sup> |
| 有限终止性 | 在线性情形下，L形方法在有限步内终止并给出最优解 <sup>[4](http://cermics.enpc.fr/~delara/TEACHING/slides_l-shaped.pdf)</sup> |
| 样本复杂度 | SAA估计量的收敛速度为 \( O_p(N^{-1/2}) \)；相对精度 \( \nu = 10^{-3} \) 需要百万量级的样本量 <sup>[5](https://optimization-online.org/wp-content/uploads/2004/10/978.pdf)</sup> |
| 困难性壁垒 | 当补偿为整数时，计算期望第二阶段值 \( Q(x) \) 是#P难的 <sup>[6](https://ir.cwi.nl/pub/23271/23271D.pdf)</sup> |

## 工作原理

该模型假设决策者先选择第一阶段活动 \( x \)，然后观测到随机事件 \( \xi \)，最后被允许采取纠正行动 \( y \)，以最小化补偿成本。<sup>[7](https://www.math.ucdavis.edu/~rjbw/mypage/Stochastic_Optimization_files/Wets66_complete.pdf)</sup> 形式上，问题是 \( \min \; c^{\top} \cdot x + \mathbb{E}_{\xi}[Q(x,\xi)] \)，约束于 \( A \cdot x = b \)，其中 \( Q(x,\xi) = \min_y \{ q^{\top} \cdot y \mid T \cdot x + W \cdot y = h,\ y \ge 0 \} \)，随机向量为 \( \xi = (q, h, T, W) \)。<sup>[1](https://epubs.siam.org/doi/10.1137/1.9780898718751.ch2)</sup> 对于具有情景 \( \xi_s \) 和概率 \( \pi_s \) 的离散分布，补偿函数为 \( Q(x) = \sum_s \pi_s Q(x, \xi_s) \)。<sup>[8](https://pantuso.sites.ku.dk/files/2023/02/tutorial_stochastic_programming_part1.pdf)</sup>

可行性是模型的一部分：对不可行补偿约定 \( Q(x,\xi) = +\infty \)，以此惩罚那些在某些情景下无法修复的第一阶段决策。<sup>[1](https://epubs.siam.org/doi/10.1137/1.9780898718751.ch2)</sup> 当第二阶段问题对数据的每一个实现都可行时，称问题具有相对完全补偿。<sup>[2](https://bpb-us-e1.wpmucdn.com/sites.gatech.edu/dist/4/1470/files/2021/03/SPbook.pdf)</sup> 基本的建模假设是随机数据的概率分布不受决策影响；决策依赖性通常会破坏分析所依赖的凸结构。<sup>[2](https://bpb-us-e1.wpmucdn.com/sites.gatech.edu/dist/4/1470/files/2021/03/SPbook.pdf)</sup>

## 求解方法

**L形分解。** 在相对完全补偿下，每个情景的值函数可通过强对偶性写成对偶变量上的极大化，\( Q_s(u_0) = \max_{\lambda_s} \{ \lambda_s \cdot (h_s - T_s \cdot u_0) \mid (W_s)^{\top} \cdot \lambda_s \le q_s \} \)，因此它是多面体函数。<sup>[4](http://cermics.enpc.fr/~delara/TEACHING/slides_l-shaped.pdf)</sup> 最优性割由最优对偶解 \( \lambda_s^k \) 构造，令 \( \alpha_s^k := -(T_s)^{\top} \cdot \lambda_s^k \)，\( \beta_s^k := (\lambda_s^k)^{\top} \cdot h_s \)，得到 \( Q_s(u_0) \ge \alpha_s^k \cdot u_0 + \beta_s^k \)，在生成点处取等号；主问题的值是下界，而 \( UB = c^{\top} \cdot u_0 + \sum_s \pi_s Q_s(u_0) \) 是上界。<sup>[4](http://cermics.enpc.fr/~delara/TEACHING/slides_l-shaped.pdf)</sup> 若无相对完全补偿，则需加入可行性割：若 \( Q_s(u_0^k) = +\infty \)，则存在无界对偶射线，可容许性要求 \( \lambda^k \cdot (h_s - T_s \cdot u_0) \le 0 \)。<sup>[4](http://cermics.enpc.fr/~delara/TEACHING/slides_l-shaped.pdf)</sup> 在线性情形下只能加入有限多个割，因此算法在有限步内终止并得到最优解。<sup>[4](http://cermics.enpc.fr/~delara/TEACHING/slides_l-shaped.pdf)</sup> 同样的割平面方案在一般大规模优化中称为Benders分解，在随机规划中称为L形算法。<sup>[9](https://www.mdpi.com/1999-4893/15/4/103)</sup>

**样本平均近似。** SAA用 \( K \) 个抽样情景上的平均值代替期望，\( z^K = \min \; c^{\top} \cdot x + \frac{1}{K}\sum_{k=1}^{K} Q(x, \xi^k) \)；估计量 \( f^K(\bar{x}) \) 是无偏且一致的，标准差为 \( \mathrm{Std}[Q(\bar{x},\xi)]/\sqrt{K} \)。<sup>[8](https://pantuso.sites.ku.dk/files/2023/02/tutorial_stochastic_programming_part1.pdf)</sup> 该过程生成 \( N \) 个独立同分布实现样本，求解所得的确定性问题，并重复直至满足停止准则。<sup>[10](http://www.im-uff.mat.br/puc-rio/disciplinas/2006.1/soe/arquivos/kleywegt-shapiro-homem-de-melo-siam-2001.pdf)</sup> \( \mathbb{E}[z^K] \le z^* \) 是真实最优值的统计下界，而评估候选解则给出统计上界；在一定条件下 \( z^K \to z^* \) 以指数速度收敛。<sup>[8](https://pantuso.sites.ku.dk/files/2023/02/tutorial_stochastic_programming_part1.pdf)</sup> SAA最优解是真实离散问题精确最优解的概率，随着 \( N \) 增大以指数速度趋近于1。<sup>[10](http://www.im-uff.mat.br/puc-rio/disciplinas/2006.1/soe/arquivos/kleywegt-shapiro-homem-de-melo-siam-2001.pdf)</sup> SAA本身不是一种算法：一旦样本抽取完毕，SAA问题就是一个具有 \( N \) 个等概率情景的确定性规划，仍须求解。<sup>[5](https://optimization-online.org/wp-content/uploads/2004/10/978.pdf)</sup>

## 起源

该领域可追溯至1955年的两篇论文：George B. Dantzig（乔治·B·丹齐格）发表于《管理科学》的《不确定性下的线性规划》<sup>[11](https://doi.org/10.1287/mnsc.1.3-4.197)</sup>，以及E. M. L. Beale（E·M·L·比尔）发表于《皇家统计学会杂志B辑》的《关于在线性不等式约束下最小化凸函数》。<sup>[12](https://doi.org/10.1111/j.2517-6161.1955.tb00191.x)</sup> 综述文章将该领域的根源描述为20世纪50年代丹齐格和比尔的工作<sup>[13](https://www.math.uwaterloo.ca/~cswamy/papers/FSTTCS-survey.pdf)</sup>，已发表的记述也写道，带补偿的两阶段随机规划由比尔和丹齐格开创。<sup>[5](https://optimization-online.org/wp-content/uploads/2004/10/978.pdf)</sup> 韦茨还指出其基本方法是在需求不确定下将飞机分配到航线。<sup>[7](https://www.math.ucdavis.edu/~rjbw/mypage/Stochastic_Optimization_files/Wets66_complete.pdf)</sup>

另一种不确定性建模方式——机会约束规划——由A. Charnes（A·查恩斯）和W. W. Cooper（W·W·库珀）于1959年在《管理科学》上提出<sup>[14](https://doi.org/10.1287/mnsc.6.1.73)</sup>，随后1963年《运筹学》上给出了机会约束的确定性等价形式<sup>[15](https://doi.org/10.1287/opre.11.1.18)</sup>；同年，Shinji Kataoka（片冈真二）的《一个随机规划模型》发表于《计量经济学》。<sup>[16](https://doi.org/10.2307/1910956)</sup> Roger Wets（罗杰·韦茨）1966年的论文定义了“完全”（简单补偿）问题，并推导出具有相同最优解集的等价凸规划。<sup>[17](https://doi.org/10.1007/bf00539117)</sup> David W. Walkup（大卫·W·沃尔卡普）和罗杰·韦茨于1967年将模型推广到 \( c \)、\( q \)、\( T \)、\( W \) 和 \( p \) 均为随机的一般情形，称之为带补偿的随机规划，并证明其自然的等价确定性形式是一个凸规划。<sup>[18](https://doi.org/10.1137/0115113)</sup>

## 变体

**整数补偿。** 当第二阶段变量为整数时，第二阶段值函数是非凸的且往往不连续；仅第一阶段变量为整数、补偿为连续时，并不破坏这种凸性。<sup>[19](https://www2.isye.gatech.edu/~sahmed/eorms_sip.pdf)</sup> Gilbert Laporte（吉尔伯特·拉波特）和François V. Louveaux（弗朗索瓦·V·卢沃）于1993年在《运筹学快报》上针对具有完全补偿的随机整数规划提出了整数L形方法<sup>[20](https://doi.org/10.1016/0167-6377%2893%2990002-x)</sup>；对于二值第一阶段变量，它用割来近似第二阶段值函数，这些割在生成二值解处精确，在其他处则低估，且需要先将第二阶段整数问题求解至最优才能产生有效割。<sup>[19](https://www2.isye.gatech.edu/~sahmed/eorms_sip.pdf)</sup> 卢沃和Maarten H. van der Vlerk（马尔滕·H·范德弗勒克）于1993年同样在《数学规划》上研究了带简单整数补偿的随机规划<sup>[21](https://doi.org/10.1007/bf01582153)</sup>；简单整数补偿是连续简单补偿模型的整数推广，当 \( \omega \) 的分布为支撑具有整数长度的均匀分布的凸组合时，其期望值函数是凸的。<sup>[22](https://optimization-online.org/wp-content/uploads/2025/11/SMIP_Survey.pdf)</sup> Suvrajeet Sen（苏夫拉吉特·森）和Julia L. Higle（朱莉娅·L·海格尔）的D2算法通过依次凸化值函数，将Benders型分解推广到混合整数情形。<sup>[23](https://doi.org/10.1007/s10107-004-0566-z)</sup>

**风险度量。** 用风险泛函代替期望会改变结构和算法；Rüdiger Schultz（吕迪格·舒尔茨）和Stephan Tiedemann（斯蒂芬·蒂德曼）于2005年研究了具有混合整数补偿的随机规划中的条件风险价值<sup>[24](https://doi.org/10.1007/s10107-005-0658-4)</sup>，其基础是R. Tyrrell Rockafellar（R·泰瑞尔·罗卡费拉尔）和Stanislav Uryasev（斯坦尼斯拉夫·乌里亚塞夫）定义的一般损失分布的CVaR泛函。<sup>[25](https://doi.org/10.1016/s0378-4266%2802%2900271-6)</sup>

**多阶段。** 推广到 \( T \) 个阶段时，SAA型过程所需的情景数按 \( \varepsilon^{-2T} \) 增长，因此计算量随阶段数呈指数爆炸。<sup>[5](https://optimization-online.org/wp-content/uploads/2004/10/978.pdf)</sup> 多阶段问题的情景生成依赖于树构造<sup>[26](https://doi.org/10.1287/mnsc.47.2.295.9834)</sup>、矩匹配启发式<sup>[27](https://doi.org/10.1023/a:1021853807313)</sup>，以及在控制概率度量距离的同时删除情景的情景约简算法。<sup>[28](https://doi.org/10.1023/a:1021805924152)</sup>

## 应用

已记载的应用包括过程网络，在最小化约定下，随机解的价值计算为 \( \mathrm{VSS} = EEV - RP \)，因此是非负的。<sup>[3](https://canli1.github.io/images/preprint/2021Frontiers.pdf)</sup> 两阶段随机整数模型应用于能源规划，包括电力生产规划中的随机火电机组组合<sup>[29](https://www.gams.com/~svigerske/publications/RoemVigPSH.pdf)</sup>，以及制造业和物流。<sup>[19](https://www2.isye.gatech.edu/~sahmed/eorms_sip.pdf)</sup> 随机路径问题（具有随机旅行时间或弧失效的最短路径，以及随机巡游）构成另一类问题；在一项SAA研究中，多达 \( 2^{1694} \) 个情景的实例被求解至与最优值的估计差距在1.0%以内，且由于平均割数不随样本量增长，运行时间仅随 \( N \) 线性增长。<sup>[30](https://bpb-us-e1.wpmucdn.com/sites.gatech.edu/dist/8/1346/files/2020/09/StochRouting.pdf)</sup>

## 局限性与替代方法

**整数补偿。** 由于整数规划的值函数是非凸的且往往不连续，期望第二阶段成本在 \( x \) 上是非凸的；在连续分布下，计算它需要对整数规划的值函数积分，这通常是不可能的。<sup>[19](https://www2.isye.gatech.edu/~sahmed/eorms_sip.pdf)</sup> 对固定 \( x \) 计算 \( Q(x) \) 是#P难的，而具有连续分布参数的两阶段随机规划也是#P难的。<sup>[6](https://ir.cwi.nl/pub/23271/23271D.pdf)</sup> 经典Benders分解和Lagrangean分解在其经典形式下无法将整数补偿问题求解至最优，且Lagrangean分解即使在连续补偿下也不保证收敛，通常会留下对偶间隙。<sup>[3](https://canli1.github.io/images/preprint/2021Frontiers.pdf)</sup>

**不可行补偿与抽样。** 若无相对完全补偿，SAA解对未见情景可能不可行；解的可补偿概率 \( \phi(x) = \mathbb{P}(F(x,\xi) < \infty) \) 低于 \( 1-\varepsilon \) 的概率随样本量增大以指数速度趋于零。<sup>[31](https://ar5iv.labs.arxiv.org/html/1912.13078)</sup> 情景离散化引入偏差，可通过情景约简来缓解，后者将最优值的变化界定为 \( |z(P) - z(Q)| \le L \, d(P,Q) \)。<sup>[8](https://pantuso.sites.ku.dk/files/2023/02/tutorial_stochastic_programming_part1.pdf)</sup> 经典样本量界与相对精度倒数 \( 1/\nu \) 的平方成正比：即使情景数天文级，求解至 \( \nu = 10\% \) 或 \( 1\% \) 仍可行，但 \( \nu = 10^{-3} \) 需要百万量级样本，\( \nu = 10^{-5} \) 需要数百亿量级。<sup>[5](https://optimization-online.org/wp-content/uploads/2004/10/978.pdf)</sup>

**替代方法。** 随机规划是风险中性的，优化期望结果，而机会约束规划和鲁棒优化在风险厌恶程度和不确定性刻画上有所不同。<sup>[3](https://canli1.github.io/images/preprint/2021Frontiers.pdf)</sup> 在大规模机组组合实例上的比较发现，鲁棒优化计算成本最低但难以参数化且补偿成本最高，而两阶段方法因补偿决策起补偿作用而在鲁棒性上表现不佳；其总计算成本最高，这表明两阶段的灵活性与鲁棒性在实践中可能是正交的概念。<sup>[32](https://ideas.repec.org/a/spr/eurjco/v5y2017i1d10.1007_s13675-015-0051-x.html)</sup>

## References

1. [Lectures on Stochastic Programming, Ch. 2: Two-Stage Problems (Shapiro, Dentcheva, Ruszczyński)](https://epubs.siam.org/doi/10.1137/1.9780898718751.ch2)
2. [Shapiro, Dentcheva, Ruszczyński, Lectures on Stochastic Programming (book preface/intro PDF)](https://bpb-us-e1.wpmucdn.com/sites.gatech.edu/dist/4/1470/files/2021/03/SPbook.pdf)
3. [A Review of Stochastic Programming Methods for Optimization of Process Systems under Uncertainty (2021)](https://canli1.github.io/images/preprint/2021Frontiers.pdf)
4. [V. Leclère, 'The L-Shaped Method' (Cermics, Ecole des Ponts ParisTech, 2019)](http://cermics.enpc.fr/~delara/TEACHING/slides_l-shaped.pdf)
5. [On complexity of stochastic programming problems (Shapiro, Optimization Online 2004)](https://optimization-online.org/wp-content/uploads/2004/10/978.pdf)
6. [Approximation in two-stage stochastic integer programming (CWI)](https://ir.cwi.nl/pub/23271/23271D.pdf)
7. [R. Wets, 'Programming Under Uncertainty: The Complete Problem' (1966)](https://www.math.ucdavis.edu/~rjbw/mypage/Stochastic_Optimization_files/Wets66_complete.pdf)
8. [Pantuso, 'Stochastic Programming: A tutorial – Part I'](https://pantuso.sites.ku.dk/files/2023/02/tutorial_stochastic_programming_part1.pdf)
9. [A Review on the Performance of Linear and Mixed Integer Two-Stage Stochastic Programming Software (Algorithms, 2022)](https://www.mdpi.com/1999-4893/15/4/103)
10. [The Sample Average Approximation Method for Stochastic Discrete Optimization (Kleywegt, Shapiro, Homem-de-Mello, SIAM J. Optimization 12(2):479-502, 2002)](http://www.im-uff.mat.br/puc-rio/disciplinas/2006.1/soe/arquivos/kleywegt-shapiro-homem-de-melo-siam-2001.pdf)
11. [George B. Dantzig (1955). Linear Programming under Uncertainty. Management Science.](https://doi.org/10.1287/mnsc.1.3-4.197)
12. [E. M. L. Beale (1955). On Minimizing a Convex Function Subject to Linear Inequalities. Journal of the Royal Statistical Society Series B (Statistical Methodology).](https://doi.org/10.1111/j.2517-6161.1955.tb00191.x)
13. [Approximation Algorithms for 2-Stage Stochastic Optimization Problems (LNCS 4337 survey)](https://www.math.uwaterloo.ca/~cswamy/papers/FSTTCS-survey.pdf)
14. [A. Charnes, W. W. Cooper (1959). Chance-Constrained Programming. Management Science.](https://doi.org/10.1287/mnsc.6.1.73)
15. [A. Charnes, W. W. Cooper (1963). Deterministic Equivalents for Optimizing and Satisficing under Chance Constraints. Operations Research.](https://doi.org/10.1287/opre.11.1.18)
16. [Shinji Kataoka (1963). A Stochastic Programming Model. Econometrica.](https://doi.org/10.2307/1910956)
17. [Roger Wets (1966). Programming under uncertainty: The complete problem. Probability Theory and Related Fields.](https://doi.org/10.1007/bf00539117)
18. [David W. Walkup, Roger J.-B. Wets (1967). Stochastic Programs with Recourse. SIAM Journal on Applied Mathematics.](https://doi.org/10.1137/0115113)
19. [Two-Stage Stochastic Integer Programming: A Brief Introduction (Shabbir Ahmed, Wiley Encyclopedia of OR/MS)](https://www2.isye.gatech.edu/~sahmed/eorms_sip.pdf)
20. [The integer L-shaped method for stochastic integer programs with complete recourse (Operations Research Letters, 1993)](https://doi.org/10.1016/0167-6377%2893%2990002-x)
21. [François V. Louveaux, Maarten H. van der Vlerk (1993). Stochastic programming with simple integer recourse. Mathematical Programming.](https://doi.org/10.1007/bf01582153)
22. [Stochastic Mixed-Integer Programming: A Survey (Romeijnders, Zhang, Sen, 2025 preprint)](https://optimization-online.org/wp-content/uploads/2025/11/SMIP_Survey.pdf)
23. [Suvrajeet Sen, Julia L. Higle (2005). The C3 Theorem and a D2 Algorithm for Large Scale Stochastic Mixed-Integer Programming: Set Convexification. Mathematical Programming.](https://doi.org/10.1007/s10107-004-0566-z)
24. [Rüdiger Schultz, Stephan Tiedemann (2005). Conditional Value-at-Risk in Stochastic Programs with Mixed-Integer Recourse. Mathematical Programming.](https://doi.org/10.1007/s10107-005-0658-4)
25. [Conditional value-at-risk for general loss distributions (Journal of Banking & Finance, 2002)](https://doi.org/10.1016/s0378-4266%2802%2900271-6)
26. [Kjetil Høyland, Stein W. Wallace (2001). Generating Scenario Trees for Multistage Decision Problems. Management Science.](https://doi.org/10.1287/mnsc.47.2.295.9834)
27. [Kjetil Høyland, Michal Kaut, Stein W. Wallace (2003). A Heuristic for Moment-Matching Scenario Generation. Computational Optimization and Applications.](https://doi.org/10.1023/a:1021853807313)
28. [Holger Heitsch, Werner Römisch (2003). Scenario Reduction Algorithms in Stochastic Programming. Computational Optimization and Applications.](https://doi.org/10.1023/a:1021805924152)
29. [Recent progress in two-stage mixed-integer stochastic programming with applications to power production planning](https://www.gams.com/~svigerske/publications/RoemVigPSH.pdf)
30. [The Sample Average Approximation Method Applied to Stochastic Routing Problems: A Computational Study (Verweij, Ahmed, Kleywegt, Nemhauser, Shapiro)](https://bpb-us-e1.wpmucdn.com/sites.gatech.edu/dist/8/1346/files/2020/09/StochRouting.pdf)
31. [On sample average approximation for two-stage stochastic programs without relatively complete recourse (arXiv 1912.13078)](https://ar5iv.labs.arxiv.org/html/1912.13078)
32. [A comparison of four approaches from stochastic programming for large-scale unit-commitment (Computational Management Science, 2017)](https://ideas.repec.org/a/spr/eurjco/v5y2017i1d10.1007_s13675-015-0051-x.html)

---
*Initially written Sep 29, 2026 · Edited: Oct 15, 2026*

Topic: 物质世界与数学 › 数学与统计学 › 统计学与概率论

Copyright 2026 Edgepedia

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

Source: https://www.edgepedia.org/zh/two-stage-stochastic-optimization

English original: https://www.edgepedia.org/two-stage-stochastic-optimization
