Recent from talks
Nothing was collected or created yet.
Stochastic programming
View on WikipediaIn the field of mathematical optimization, stochastic programming is a framework for modeling optimization problems that involve uncertainty. A stochastic program is an optimization problem in which some or all problem parameters are uncertain, but follow known probability distributions.[1][2] This framework contrasts with deterministic optimization, in which all problem parameters are assumed to be known exactly. The goal of stochastic programming is to find a decision which both optimizes some criteria chosen by the decision maker, and appropriately accounts for the uncertainty of the problem parameters. Because many real-world decisions involve uncertainty, stochastic programming has found applications in a broad range of areas ranging from finance to transportation to energy optimization.[3][4]
Methods
[edit]Several stochastic programming methods have been developed:
- Scenario-based methods including sample average approximation
- Stochastic integer programming for problems in which some variables must be integers
- Chance constrained programming for dealing with constraints that must be satisfied with a given probability
- Stochastic dynamic programming
- Markov decision process
- Benders decomposition
Two-stage problem definition
[edit]The basic idea of two-stage stochastic programming is that (optimal) decisions should be based on data available at the time the decisions are made and cannot depend on future observations. The two-stage formulation is widely used in stochastic programming. The general formulation of a two-stage stochastic programming problem is given by: where is the optimal value of the second-stage problem
The classical two-stage linear stochastic programming problems can be formulated as
where is the optimal value of the second-stage problem
In such formulation is the first-stage decision variable vector, is the second-stage decision variable vector, and contains the data of the second-stage problem. In this formulation, at the first stage we have to make a "here-and-now" decision before the realization of the uncertain data , viewed as a random vector, is known. At the second stage, after a realization of becomes available, we optimize our behavior by solving an appropriate optimization problem.
At the first stage we optimize (minimize in the above formulation) the cost of the first-stage decision plus the expected cost of the (optimal) second-stage decision. We can view the second-stage problem simply as an optimization problem which describes our supposedly optimal behavior when the uncertain data is revealed, or we can consider its solution as a recourse action where the term compensates for a possible inconsistency of the system and is the cost of this recourse action.
The considered two-stage problem is linear because the objective functions and the constraints are linear. Conceptually this is not essential and one can consider more general two-stage stochastic programs. For example, if the first-stage problem is integer, one could add integrality constraints to the first-stage problem so that the feasible set is discrete. Non-linear objectives and constraints could also be incorporated if needed.[5]
Distributional assumption
[edit]The formulation of the above two-stage problem assumes that the second-stage data is modeled as a random vector with a known probability distribution. This would be justified in many situations. For example, the distribution of could be inferred from historical data if one assumes that the distribution does not significantly change over the considered period of time. Also, the empirical distribution of the sample could be used as an approximation to the distribution of the future values of . If one has a prior model for , one could obtain a posteriori distribution by a Bayesian update.
Scenario-based approach
[edit]Discretization
[edit]To solve the two-stage stochastic problem numerically, one often needs to assume that the random vector has a finite number of possible realizations, called scenarios, say , with respective probability masses . Then the expectation in the first-stage problem's objective function can be written as the summation: and, moreover, the two-stage problem can be formulated as one large linear programming problem (this is called the deterministic equivalent of the original problem, see section § Deterministic equivalent of a stochastic problem).
When has an infinite (or very large) number of possible realizations the standard approach is then to represent this distribution by scenarios. This approach raises three questions, namely:
- How to construct scenarios, see § Scenario construction;
- How to solve the deterministic equivalent. Optimizers such as CPLEX, and GLPK can solve large linear/nonlinear problems. The NEOS Server,[6] hosted at the University of Wisconsin, Madison, allows free access to many modern solvers. The structure of a deterministic equivalent is particularly amenable to apply decomposition methods,[7] such as Benders' decomposition or scenario decomposition;
- How to measure quality of the obtained solution with respect to the "true" optimum.
These questions are not independent. For example, the number of scenarios constructed will affect both the tractability of the deterministic equivalent and the quality of the obtained solutions.
Stochastic linear programming
[edit]A stochastic linear program is a specific instance of the classical two-stage stochastic program. A stochastic LP is built from a collection of multi-period linear programs (LPs), each having the same structure but somewhat different data. The two-period LP, representing the scenario, may be regarded as having the following form:
The vectors and contain the first-period variables, whose values must be chosen immediately. The vector contains all of the variables for subsequent periods. The constraints involve only first-period variables and are the same in every scenario. The other constraints involve variables of later periods and differ in some respects from scenario to scenario, reflecting uncertainty about the future.
Note that solving the two-period LP is equivalent to assuming the scenario in the second period with no uncertainty. In order to incorporate uncertainties in the second stage, one should assign probabilities to different scenarios and solve the corresponding deterministic equivalent.
Deterministic equivalent of a stochastic problem
[edit]With a finite number of scenarios, two-stage stochastic linear programs can be modelled as large linear programming problems. This formulation is often called the deterministic equivalent linear program, or abbreviated to deterministic equivalent. (Strictly speaking a deterministic equivalent is any mathematical program that can be used to compute the optimal first-stage decision, so these will exist for continuous probability distributions as well, when one can represent the second-stage cost in some closed form.) For example, to form the deterministic equivalent to the above stochastic linear program, we assign a probability to each scenario . Then we can minimize the expected value of the objective, subject to the constraints from all scenarios:
We have a different vector of later-period variables for each scenario . The first-period variables and are the same in every scenario, however, because we must make a decision for the first period before we know which scenario will be realized. As a result, the constraints involving just and need only be specified once, while the remaining constraints must be given separately for each scenario.
Scenario construction
[edit]In practice it might be possible to construct scenarios by eliciting experts' opinions on the future. The number of constructed scenarios should be relatively modest so that the obtained deterministic equivalent can be solved with reasonable computational effort. It is often claimed that a solution that is optimal using only a few scenarios provides more adaptable plans than one that assumes a single scenario only. In some cases such a claim could be verified by a simulation. In theory some measures of guarantee that an obtained solution solves the original problem with reasonable accuracy. Typically in applications only the first stage optimal solution has a practical value since almost always a "true" realization of the random data will be different from the set of constructed (generated) scenarios.
Suppose contains independent random components, each of which has three possible realizations (for example, future realizations of each random parameters are classified as low, medium and high), then the total number of scenarios is . Such exponential growth of the number of scenarios makes model development using expert opinion very difficult even for reasonable size . The situation becomes even worse if some random components of have continuous distributions.
Monte Carlo sampling and sample average approximation (SAA) method
[edit]A common approach to reduce the scenario set to a manageable size is by using Monte Carlo simulation. Suppose the total number of scenarios is very large or even infinite. Suppose further that we can generate a sample of realizations of the random vector . Usually the sample is assumed to be independent and identically distributed (i.i.d sample). Given a sample, the expectation function is approximated by the sample average
and consequently the first-stage problem is given by
This formulation is known as the sample average approximation method. The SAA problem is a function of the considered sample and in that sense is random. For a given sample the SAA problem is of the same form as a two-stage stochastic linear programming problem with the scenarios ., , each taken with the same probability .
Statistical inference
[edit]Consider the following stochastic programming problem
Here is a nonempty closed subset of , is a random vector whose probability distribution is supported on a set , and . In the framework of two-stage stochastic programming, is given by the optimal value of the corresponding second-stage problem.
Assume that is well defined and finite valued for all . This implies that for every the value is finite almost surely.
Suppose that we have a sample of realizations of the random vector . This random sample can be viewed as historical data of observations of , or it can be generated by Monte Carlo sampling techniques. Then we can formulate a corresponding sample average approximation
By the law of large numbers we have that, under some regularity conditions converges pointwise with probability 1 to as . Moreover, under mild additional conditions the convergence is uniform. We also have , i.e., is an unbiased estimator of . Therefore, it is natural to expect that the optimal value and optimal solutions of the SAA problem converge to their counterparts of the true problem as .
Consistency of SAA estimators
[edit]Suppose the feasible set of the SAA problem is fixed, i.e., it is independent of the sample. Let and be the optimal value and the set of optimal solutions, respectively, of the true problem and let and be the optimal value and the set of optimal solutions, respectively, of the SAA problem.
- Let and be a sequence of (deterministic) real valued functions. The following two properties are equivalent:
- for any and any sequence converging to it follows that converges to
- the function is continuous on and converges to uniformly on any compact subset of
- If the objective of the SAA problem converges to the true problem's objective with probability 1, as , uniformly on the feasible set . Then converges to with probability 1 as .
- Suppose that there exists a compact set such that
- the set of optimal solutions of the true problem is nonempty and is contained in
- the function is finite valued and continuous on
- the sequence of functions converges to with probability 1, as , uniformly in
- for large enough the set is nonempty and with probability 1
- then and with probability 1 as . Note that denotes the deviation of set from set , defined as
In some situations the feasible set of the SAA problem is estimated, then the corresponding SAA problem takes the form
where is a subset of depending on the sample and therefore is random. Nevertheless, consistency results for SAA estimators can still be derived under some additional assumptions:
- Suppose that there exists a compact set such that
- the set of optimal solutions of the true problem is nonempty and is contained in
- the function is finite valued and continuous on
- the sequence of functions converges to with probability 1, as , uniformly in
- for large enough the set is nonempty and with probability 1
- if and converges with probability 1 to a point , then
- for some point there exists a sequence such that with probability 1.
- then and with probability 1 as .
Asymptotics of the SAA optimal value
[edit]Suppose the sample is i.i.d. and fix a point . Then the sample average estimator , of , is unbiased and has variance , where is supposed to be finite. Moreover, by the central limit theorem we have that
where denotes convergence in distribution and has a normal distribution with mean and variance , written as .
In other words, has asymptotically normal distribution, i.e., for large , has approximately normal distribution with mean and variance . This leads to the following (approximate) % confidence interval for :
where (here denotes the cdf of the standard normal distribution) and
is the sample variance estimate of . That is, the error of estimation of is (stochastically) of order .
Applications and examples
[edit]Biological applications
[edit]Stochastic dynamic programming is frequently used to model animal behaviour in such fields as behavioural ecology.[8][9] Empirical tests of models of optimal foraging, life-history transitions such as fledging in birds and egg laying in parasitoid wasps have shown the value of this modelling technique in explaining the evolution of behavioural decision making. These models are typically many-staged, rather than two-staged.
Economic applications
[edit]Stochastic dynamic programming is a useful tool in understanding decision making under uncertainty. The accumulation of capital stock under uncertainty is one example; often it is used by resource economists to analyze bioeconomic problems[10] where the uncertainty enters in such as weather, etc.
Example: multistage portfolio optimization
[edit]The following is an example from finance of multi-stage stochastic programming. Suppose that at time we have initial capital to invest in assets. Suppose further that we are allowed to rebalance our portfolio at times but without injecting additional cash into it. At each period we make a decision about redistributing the current wealth among the assets. Let be the initial amounts invested in the n assets. We require that each is nonnegative and that the balance equation should hold.
Consider the total returns for each period . This forms a vector-valued random process . At time period , we can rebalance the portfolio by specifying the amounts invested in the respective assets. At that time the returns in the first period have been realized so it is reasonable to use this information in the rebalancing decision. Thus, the second-stage decisions, at time , are actually functions of realization of the random vector , i.e., . Similarly, at time the decision is a function of the available information given by the history of the random process up to time . A sequence of functions , , with being constant, defines an implementable policy of the decision process. It is said that such a policy is feasible if it satisfies the model constraints with probability 1, i.e., the nonnegativity constraints , , , and the balance of wealth constraints,
where in period the wealth is given by
which depends on the realization of the random process and the decisions up to time .
Suppose the objective is to maximize the expected utility of this wealth at the last period, that is, to consider the problem
This is a multistage stochastic programming problem, where stages are numbered from to . Optimization is performed over all implementable and feasible policies. To complete the problem description one also needs to define the probability distribution of the random process . This can be done in various ways. For example, one can construct a particular scenario tree defining time evolution of the process. If at every stage the random return of each asset is allowed to have two continuations, independent of other assets, then the total number of scenarios is
In order to write dynamic programming equations, consider the above multistage problem backward in time. At the last stage , a realization of the random process is known and has been chosen. Therefore, one needs to solve the following problem
where denotes the conditional expectation of given . The optimal value of the above problem depends on and and is denoted .
Similarly, at stages , one should solve the problem
whose optimal value is denoted by . Finally, at stage , one solves the problem
Stagewise independent random process
[edit]For a general distribution of the process , it may be hard to solve these dynamic programming equations. The situation simplifies dramatically if the process is stagewise independent, i.e., is (stochastically) independent of for . In this case, the corresponding conditional expectations become unconditional expectations, and the function , does not depend on . That is, is the optimal value of the problem
and is the optimal value of
for .
Software tools
[edit]Modelling languages
[edit]All discrete stochastic programming problems can be represented with any algebraic modeling language, manually implementing explicit or implicit non-anticipativity to make sure the resulting model respects the structure of the information made available at each stage. An instance of an SP problem generated by a general modelling language tends to grow quite large (linearly in the number of scenarios), and its matrix loses the structure that is intrinsic to this class of problems, which could otherwise be exploited at solution time by specific decomposition algorithms. Extensions to modelling languages specifically designed for SP are starting to appear, see:
- AIMMS – supports the definition of SP problems
- EMP SP (Extended Mathematical Programming for Stochastic Programming) – a module of GAMS created to facilitate stochastic programming (includes keywords for parametric distributions, chance constraints and risk measures such as Value at risk and Expected shortfall).
- SAMPL – a set of extensions to AMPL specifically designed to express stochastic programs (includes syntax for chance constraints, integrated chance constraints and robust optimization problems)
They both can generate SMPS instance level format, which conveys in a non-redundant form the structure of the problem to the solver.
See also
[edit]References
[edit]- ^ Shapiro, Alexander; Dentcheva, Darinka; Ruszczyński, Andrzej (2009). Lectures on stochastic programming: Modeling and theory (PDF). MPS/SIAM Series on Optimization. Vol. 9. Philadelphia, PA: Society for Industrial and Applied Mathematics and the Mathematical Programming Society. pp. xvi+436. ISBN 978-0-89871-687-0. MR 2562798. Archived from the original (PDF) on 2020-03-24. Retrieved 2010-09-22.
- ^ Birge, John R.; Louveaux, François (2011). Introduction to Stochastic Programming. Springer Series in Operations Research and Financial Engineering. doi:10.1007/978-1-4614-0237-4. ISBN 978-1-4614-0236-7. ISSN 1431-8598.
- ^ Stein W. Wallace and William T. Ziemba (eds.). Applications of Stochastic Programming. MPS-SIAM Book Series on Optimization 5, 2005.
- ^ Applications of stochastic programming are described at the following website, Stochastic Programming Community.
- ^ Shapiro, Alexander; Philpott, Andy. A tutorial on Stochastic Programming (PDF).
- ^ "NEOS Server for Optimization".
- ^ Ruszczyński, Andrzej; Shapiro, Alexander (2003). Stochastic Programming. Handbooks in Operations Research and Management Science. Vol. 10. Philadelphia: Elsevier. p. 700. ISBN 978-0444508546.
- ^ Mangel, M. & Clark, C. W. 1988. Dynamic modeling in behavioral ecology. Princeton University Press ISBN 0-691-08506-4
- ^ Houston, A. I & McNamara, J. M. 1999. Models of adaptive behaviour: an approach based on state. Cambridge University Press ISBN 0-521-65539-0
- ^ Howitt, R., Msangi, S., Reynaud, A and K. Knapp. 2002. "Using Polynomial Approximations to Solve Stochastic Dynamic Programming Problems: or A "Betty Crocker " Approach to SDP." University of California, Davis, Department of Agricultural and Resource Economics Working Paper.
Further reading
[edit]- John R. Birge and François V. Louveaux. Introduction to Stochastic Programming. Springer Verlag, New York, 1997.
- Kall, Peter; Wallace, Stein W. (1994). Stochastic programming. Wiley-Interscience Series in Systems and Optimization. Chichester: John Wiley & Sons, Ltd. pp. xii+307. ISBN 0-471-95158-7. MR 1315300.
- G. Ch. Pflug: Optimization of Stochastic Models. The Interface between Simulation and Optimization. Kluwer, Dordrecht, 1996.
- András Prékopa. Stochastic Programming. Kluwer Academic Publishers, Dordrecht, 1995.
- Andrzej Ruszczynski and Alexander Shapiro (eds.) (2003) Stochastic Programming. Handbooks in Operations Research and Management Science, Vol. 10, Elsevier.
- Shapiro, Alexander; Dentcheva, Darinka; Ruszczyński, Andrzej (2009). Lectures on stochastic programming: Modeling and theory (PDF). MPS/SIAM Series on Optimization. Vol. 9. Philadelphia, PA: Society for Industrial and Applied Mathematics and the Mathematical Programming Society. pp. xvi+436. ISBN 978-0-89871-687-0. MR 2562798. Archived from the original (PDF) on 2020-03-24. Retrieved 2010-09-22.
- Stein W. Wallace and William T. Ziemba (eds.) (2005) Applications of Stochastic Programming. MPS-SIAM Book Series on Optimization 5
- King, Alan J.; Wallace, Stein W. (2012). Modeling with Stochastic Programming. Springer Series in Operations Research and Financial Engineering. New York: Springer. ISBN 978-0-387-87816-4.
External links
[edit]Stochastic programming
View on GrokipediaIntroduction
Definition and Basic Concepts
Stochastic programming is a mathematical optimization paradigm designed to make optimal decisions in the presence of uncertainty, where some or all problem parameters are modeled as random variables following known probability distributions. Unlike deterministic optimization, which assumes fixed parameters, stochastic programming incorporates probabilistic elements to evaluate decisions based on expected outcomes or risk-adjusted measures, enabling robust solutions for real-world applications such as resource allocation, supply chain management, and financial planning.[1] The general formulation of a stochastic program seeks to minimize the expected value of an objective function involving uncertain parameters, expressed as , where represents the decision variables, is a random vector with a specified distribution, and denotes the expectation operator. This expectation integrates over all possible realizations of , weighted by their probabilities, to capture the average performance of the decision . Probabilistic constraints may also be included, such as , ensuring that constraints hold with high probability . These elements replace fixed parameters in deterministic models with distributional information, shifting the focus from point estimates to expected value optimization that accounts for variability.[1][8] Central to stochastic programming are key concepts like here-and-now decisions, which are first-stage choices made before the uncertainty is realized, and wait-and-see decisions, or recourse actions, implemented after observing . Non-anticipativity constraints enforce that decisions at each stage depend only on information available up to that point, preventing the use of future revelations in earlier choices and ensuring feasible, implementable policies. For instance, in a two-stage setting, here-and-now decisions commit resources upfront, while wait-and-see adjustments adapt to realized outcomes.[9][3] Uncertainty in stochastic programming is modeled using discrete distributions, represented by finite scenarios each with associated probabilities, or continuous distributions approximated via sampling methods. Beyond expected value, risk measures such as conditional value-at-risk (CVaR) provide introductory tools to quantify tail risks by focusing on the expected loss exceeding a value-at-risk threshold, promoting more conservative decisions in volatile environments.[9][10]Historical Development
The origins of stochastic programming trace back to the mid-1950s, when researchers began addressing the inherent uncertainties in real-world optimization problems. George B. Dantzig, often regarded as the father of linear programming, highlighted the stochastic nature of practical applications in his seminal 1955 paper, "Linear Programming under Uncertainty," where he proposed initial approaches to incorporate probabilistic elements into linear programs.[11] Independently, E. M. L. Beale contributed foundational work in the same year through his paper "On Minimizing a Convex Function Subject to Linear Inequalities," which explored methods for handling stochastic linear programs by approximating expected values and recourse actions. These efforts marked the field's emergence as a distinct extension of deterministic optimization, focusing on decision-making under uncertainty. Key milestones in the late 1950s and 1960s further solidified the theoretical framework. Dantzig and Albert Madansky formalized the two-stage recourse problem in their 1961 paper, "On the Solution of Two-Stage Linear Programs under Uncertainty," presented at the Fourth Berkeley Symposium on Mathematical Statistics and Probability, introducing supporting hyperplanes for the recourse function to enable practical computation. Chance-constrained programming, a subclass emphasizing probabilistic feasibility, was introduced by Abraham Charnes and William W. Cooper in 1959, allowing constraints to hold with a specified probability rather than deterministically. During the 1960s and 1970s, decomposition methods gained prominence for tackling larger-scale problems; notably, the L-shaped method, an adaptation of Benders decomposition for stochastic programs, was developed by Richard Van Slyke and Roger J.-B. Wets in 1969, facilitating iterative solution of two-stage models by generating optimality and feasibility cuts.[12] The 1980s and 1990s saw significant growth in computational techniques and modeling sophistication, driven by advances in hardware and algorithms. Scenario trees emerged as a critical tool for representing multistage uncertainty, with early developments in the 1980s enabling non-anticipative decisions in dynamic settings, as explored in works like those by John R. Birge and François Louveaux in their 1997 book, which built on prior scenario-based approximations from the decade. Mixed-integer stochastic programming also advanced, with theoretical and computational progress starting in the late 1980s, allowing integration of discrete decisions under uncertainty.[13] The formation of the Stochastic Programming Society in 2012, evolving from the earlier Committee on Stochastic Programming (established in 1982) and the triennial International Conference on Stochastic Programming (initiated in 1986), fostered collaboration and dissemination of these innovations.[14] In recent years, up to 2025, stochastic programming has integrated with machine learning for enhanced scenario generation, such as using generative models to create realistic uncertainty representations from data, as reviewed in studies on machine learning applications to stochastic control.[15] Distributionally robust extensions have also proliferated, addressing ambiguity in probability distributions to improve solution robustness, with key formulations appearing in works like those on two-stage distributionally robust stochastic programs since 2020.[16] These trends are particularly evident in applications to renewable energy planning, where multistage models optimize capacity expansion under variable wind and solar outputs, as demonstrated in recent capacity planning frameworks combining stochastic operations with expansion decisions.[17]Problem Formulations
Two-Stage Stochastic Programs
Two-stage stochastic programs represent a core paradigm in stochastic programming, modeling decision-making under uncertainty where first-stage decisions must be made before the realization of random variables, followed by second-stage corrective actions. Introduced by George Dantzig in his seminal 1955 paper, this framework captures "here-and-now" choices in the first stage and "wait-and-see" adjustments in the second stage once uncertainty is revealed.[18] Such models are widely applied in areas like production planning and resource allocation, where initial commitments cannot be easily revised without incurring additional costs. The standard mathematical formulation of a two-stage stochastic linear program with recourse is given by subject to where denotes the first-stage decision vector, the second-stage decision vector, the random vector representing uncertainty, the first-stage cost coefficients, and is the recourse function capturing the minimum expected cost of second-stage adjustments for a given first-stage decision and uncertainty realization. The expectation integrates over the distribution of , reflecting the probabilistic nature of the recourse costs. This structure ensures that first-stage decisions hedge against potential future scenarios while minimizing total expected costs.[18] Recourse in two-stage models refers to the feasibility and cost of second-stage actions to address deviations caused by uncertainty. Complete recourse assumes that for every feasible first-stage and every realization , there exists a second-stage satisfying the constraints, ensuring is finite and well-defined everywhere. Relatively complete recourse relaxes this by requiring feasibility only for first-stage decisions in the original feasible set. Simple recourse, a special case, models second-stage decisions as non-negative surplus and shortage variables to balance supply-demand imbalances, often with linear costs. Economically, recourse costs interpret as penalties for corrective measures, such as overtime production or lost sales, incentivizing first-stage decisions that minimize expected adjustments. The random vector is typically assumed to have a known probability distribution, often with finite discrete support for tractability—representing scenarios with probabilities , , so the expectation becomes . For continuous distributions, the expectation is approximated by generating a finite set of scenarios via sampling methods like Monte Carlo, enabling reformulation as a large-scale deterministic equivalent. This scenario-based approximation preserves the two-stage structure while facilitating computational solution. A representative example is stochastic inventory planning under random demand. In the first stage, a retailer decides an order quantity at cost , subject to a budget constraint . Demand follows a discrete distribution with scenarios (e.g., low, medium, high demand) and probabilities . In the second stage, if , a shortage incurs penalty ; if , excess inventory costs . The recourse function is , and the objective minimizes . For instance, with , , , , and scenarios (), (), due to the specific parameters the expected total cost is constant at 128 for any in [80, 120]; with the budget constraint, the optimal yields an expected total cost of 128, balancing overstock and shortage risks.Multistage Stochastic Programs
Multistage stochastic programs extend the framework of stochastic optimization to sequential decision-making over multiple time periods, where uncertainty unfolds gradually and decisions are made adaptively based on partial information revelation. In this setting, decisions at each stage are taken before the full realization of future uncertainties, leading to a dynamic structure that captures the value of information and recourse actions over time. This contrasts with simpler models by allowing for a richer representation of real-world planning problems, such as resource allocation under evolving market conditions or environmental factors.[19] The general formulation of a multistage stochastic program involves minimizing a nested sequence of expectations over decision variables at each stage , conditional on information available up to that point. Specifically, the objective is to solve where the expectation is taken with respect to the filtration representing the information structure, subject to constraints like for realizations of the random process . Non-anticipativity constraints ensure that is -measurable, meaning decisions at stage depend only on past observations and not on future outcomes, preventing the use of unattainable foresight. This recursive structure defines the value function at each stage via dynamic programming, where the cost-to-go from stage onward is the conditional expectation of the remaining costs given the history up to . For instance, the two-stage model emerges as a special case when , reducing to a single here-and-now decision followed by wait-and-see recourse.[20][19] To operationalize this formulation, uncertainties are typically discretized into scenario trees, which provide a discrete approximation of the underlying stochastic process. A scenario tree is constructed as a lattice with nodes representing partial histories of the random outcomes, where branches from a node denote possible evolutions at the next stage, incorporating both fan-out (divergence into multiple futures) and fan-in (convergence of paths to shared nodes) structures. Decisions are node-based, with the same action prescribed for all scenarios passing through a given node to enforce non-anticipativity; for example, the root node corresponds to the initial decision , while leaf nodes terminate at stage with associated probabilities summing to one along each full path (scenario). Construction methods, such as backward reduction or forward clustering of initial scenarios, aim to balance approximation accuracy with computational feasibility, often using distance metrics like the -norm to bound errors in the tree's representation of the original distribution.[21][22] A key simplifying assumption in many multistage models is stagewise independence, where the random increments at stage are conditionally independent of the past history given the information up to . This Markovian property decouples the conditional expectations in the dynamic program, allowing the cost-to-go function to depend only on the current state rather than the entire path, which facilitates recursive computation and reduces the dimensionality of scenario dependencies. Without this assumption, the full history must be tracked, complicating tree structures and increasing storage requirements.[23] Despite these advancements, multistage stochastic programs face significant computational challenges, primarily the curse of dimensionality arising from the exponential growth in the number of nodes and scenarios as stages and branching factors increase. For scenarios per stage, the tree size scales as , rendering exact solutions intractable for large horizons; approximation techniques must thus be employed to prune or aggregate nodes while preserving solution quality. A representative application is long-term hydropower planning, where operators must allocate water releases over multiple periods (e.g., weeks or months) amid uncertain inflows and electricity prices, balancing immediate generation against future reservoir levels—problems where even modest stages can yield tens of thousands of nodes due to hydrological variability.[19][24]Chance-Constrained Programs
Chance-constrained programs address optimization problems under uncertainty by requiring that constraints hold with a specified probability, rather than deterministically, to model reliability in the presence of random parameters. The standard formulation minimizes a linear objective subject to probabilistic constraints on linear inequalities involving uncertain parameters, expressed as subject to , where is the decision vector, is a random vector with known distribution, is an affine function in and , is a deterministic vector, and is the risk tolerance level.[25] Chance constraints can be classified as individual or joint based on how multiple constraints interact probabilistically. Individual chance constraints apply separately to each constraint, requiring for each row , which simplifies computation but may overestimate feasibility since violations can occur simultaneously across constraints.[26] In contrast, joint chance constraints ensure simultaneous satisfaction of all constraints with the desired probability, , providing a more conservative and realistic reliability guarantee but increasing computational complexity.[26][27] Programs are further categorized as static or dynamic depending on the decision structure and uncertainty resolution. Static chance-constrained programs involve here-and-now decisions made before observing , with drawn from a fixed known distribution, leading to single-stage optimization.[28] Dynamic variants extend this to sequential decisions over time, where uncertainty unfolds gradually, often incorporating feedback or recourse actions, though the core probabilistic constraint framework remains similar.[28] Solving general chance-constrained programs is challenging due to non-convexity arising from the probabilistic nature of the constraints, which can result in non-convex feasible regions even for linear deterministic counterparts. For arbitrary distributions, these problems are NP-hard, particularly with discrete or non-elliptical continuous distributions, complicating exact solutions.[29] However, exact convex reformulations exist when follows a normal distribution, transforming individual chance constraints into deterministic second-order cone constraints via the inverse cumulative distribution function of the standard normal.[30][31] To address non-convexity, conservative approximations replace the chance constraint with a convex surrogate, such as one based on conditional value-at-risk (CVaR), which bounds the expected shortfall beyond the -quantile and yields a tractable semidefinite program for certain distributions.[32] This CVaR approach provides a feasible but potentially suboptimal solution, with tightness improving as decreases.[32] A representative application appears in reservoir operation, where the goal is to determine release policies that minimize costs while ensuring the probability of reservoir overflow (spill) remains below a threshold, such as , accounting for uncertain inflows.[33]Solution Methods
Scenario-Based Methods
Scenario-based methods in stochastic programming approximate the continuous probability distribution of uncertain parameters, denoted as , by a finite discrete set of scenarios , where each scenario is assigned a probability such that . This discretization process transforms the original stochastic program into a deterministic equivalent problem that can be solved using standard optimization techniques, enabling practical computation for problems where the uncertainty space is infinite or continuous. The choice of scenarios is guided by the need to capture the essential features of the distribution, such as moments or support points, often derived from historical data or analytical approximations. For multistage stochastic programs, scenario-based methods employ non-anticipative scenario trees to model the evolution of uncertainty over time, ensuring that decisions at each stage depend only on information available up to that point. In a scenario tree, nodes represent decision points, and branches from a common ancestor node share the same history, enforcing non-anticipativity through constraints that identical paths lead to identical decisions. For instance, a three-period tree might branch into multiple paths at each stage, with probabilities propagating along the branches to reflect conditional distributions of . This structure preserves the sequential nature of decisions under partial information revelation. The resulting deterministic equivalent for a two-stage stochastic program has a size that grows linearly with the number of scenarios , featuring variables and constraints, where and denote first- and second-stage dimensions, respectively. For a two-stage formulation , the equivalent is subject to and for each , with non-negativity. In multistage settings, the extensive form expands similarly across tree nodes, leading to exponential growth in for deep trees, which poses computational challenges. To mitigate this, scenario reduction techniques such as fast-forward selection iteratively select a subset of scenarios by maximizing probabilistic similarity, using metrics like the Kantorovich distance to preserve distribution properties while reducing (e.g., from thousands to dozens), thereby trading minor approximation error for significant decreases in solve time.[34] A representative example is production planning under demand uncertainty, where scenarios are generated to model varying customer demands over planning periods. In a two-stage model, first-stage decisions set production capacities, while second-stage recourse adjusts inventory or backorders for each demand scenario with probability ; for instance, discretizing a normal demand distribution into five equiprobable scenarios allows solving the deterministic equivalent to balance expected costs. Scenarios can be generated via sampling methods to approximate the underlying distribution.Decomposition Techniques
Decomposition techniques in stochastic programming exploit the structure of the problem to divide large-scale formulations into smaller, more manageable subproblems, facilitating efficient computation while preserving optimality guarantees. These methods are particularly valuable for two-stage and multistage programs where the expected value function introduces nonlinearity that can be approximated through iterative cut generation or dual updates. By solving subproblems corresponding to scenarios—which represent possible realizations of the uncertainty—these algorithms generate supporting information to refine the first-stage decisions progressively.[35] A foundational approach is Benders decomposition adapted to two-stage stochastic programs, known as the L-shaped method, which separates the here-and-now decisions from the wait-and-see recourse decisions . The two-stage problem is formulated as minimizing , where is the recourse function for random variable . The algorithm iteratively solves a master problem approximating the expected recourse via linear cuts and subproblems for each scenario to generate dual information. Optimality cuts are derived from extreme points of the dual feasible set , taking the form , added to bound the recourse from below. Feasibility cuts, generated when subproblems are infeasible, use extreme rays of the dual to enforce . The process converges to the optimal solution under finite scenarios, with the master providing lower bounds and subproblem evaluations yielding upper bounds.[36] Stochastic decomposition extends this framework by incorporating sampling to handle large or continuous uncertainty sets, generating sample-based cuts that approximate the expected recourse statistically. In the two-stage setting, the algorithm alternates between solving a master problem with cuts from a growing sample of scenarios and updating the sample to reduce variance in the approximation, ensuring almost sure convergence to the true optimum as the sample size increases.[35] Variants for multistage programs build on this by sequentially sampling across stages, using forward and backward passes to propagate cuts and value functions, which bridges stochastic programming with approximate dynamic programming techniques. These multistage extensions incorporate variance reduction strategies, such as importance sampling or control variates, to accelerate convergence in high-dimensional settings with endogenous uncertainties.[37] For instance, the method generates stagewise cuts based on empirical distributions, allowing parallel subproblem solves while maintaining statistical consistency.[38] Progressive hedging provides an alternative dual decomposition strategy suited for scenario-based multistage programs, enforcing the non-anticipativity constraints—requiring decisions to be scenario-independent up to the information revelation—through penalty terms and aggregation. The algorithm solves scenario subproblems independently in each iteration, then updates Lagrange multipliers to penalize deviations from the average (hedged) policy, converging to a feasible non-anticipative solution under convexity assumptions.[39] This approach is particularly effective for parallel computation, as subproblems can be distributed across processors, and it handles integer variables via relaxations or bundling. Recent enhancements include adaptive penalty updates to balance feasibility and optimality progress. As an illustrative example, consider a two-stage newsvendor (inventory) model where the first-stage decision is the order quantity, and the second-stage recourse accounts for overage and underage costs under uncertain demand . The objective is to minimize (assuming unit costs for excess and shortage), with and scenarios each with probability . The L-shaped method proceeds iteratively, solving the master problem and subproblems to generate optimality and feasibility cuts that tighten the approximation of the recourse function. The process adds cuts based on dual information from scenario subproblems, with upper bounds from subproblem costs and lower bounds from the master, converging after several iterations to the optimal solution at , where .Approximation and Sampling Methods
In stochastic programming, approximation methods rely on sampling techniques to estimate expectations involving random variables, enabling the solution of otherwise intractable problems. Monte Carlo sampling serves as a foundational approach, where a set of independent and identically distributed (i.i.d.) samples , , drawn from the underlying probability distribution, approximates the expected value function by the empirical mean . This method is particularly useful for high-dimensional or complex distributions, as it requires minimal assumptions on the probability measure beyond the ability to generate samples.[40] The sample average approximation (SAA) method builds directly on Monte Carlo sampling by formulating and solving a deterministic optimization problem using the sample-based estimate as a proxy for the original stochastic program. In SAA, the true problem is replaced by , which can be solved using standard optimization solvers, with the resulting solution serving as an approximation to the optimal stochastic decision. To mitigate the high variance inherent in crude Monte Carlo estimates, importance sampling reweights the sampling distribution to focus on regions of high contribution to the expectation, reducing the variance of the estimator without introducing bias when properly adjusted. For instance, samples are drawn from a proposal distribution and reweighted by the likelihood ratio , where is the target distribution, leading to more efficient approximations in problems with rare events or skewed uncertainties.[41][42][43] Beyond basic Monte Carlo, specialized scenario construction methods enhance approximation quality by generating structured samples that better capture distributional properties. Quasi-Monte Carlo (QMC) methods employ low-discrepancy sequences, such as Sobol or Halton points, to produce samples that are more uniformly distributed than pseudorandom ones, yielding faster convergence rates—often in dimension —for smooth integrands typical in recourse functions. Latin hypercube sampling (LHS) divides the probability space into strata and samples one point from each, ensuring marginal coverage and reducing clustering, which is effective for scenario generation in multidimensional settings. Moment-matching techniques construct discrete scenarios by optimizing weights and support points to replicate specified statistical moments (e.g., mean, variance, skewness, and correlations) of the original distribution, providing a calibrated approximation suitable for multistage programs. These methods can be used as inputs to decomposition algorithms like Benders decomposition to improve subproblem evaluations.[44][45][46][47] A representative application of SAA arises in portfolio selection under random asset returns, where the objective is to maximize expected return subject to risk constraints. Samples of return scenarios are generated via Monte Carlo or LHS, and the SAA problem is solved to approximate the efficient frontier; however, smaller sample sizes introduce bias toward overly optimistic portfolios, while larger sizes reduce variance but increase computational cost, necessitating a trade-off analysis to balance estimation error and solvability.[48]Theoretical Foundations
Deterministic Equivalents
In stochastic programming, a deterministic equivalent reformulates the original problem into a large-scale deterministic optimization problem that preserves the optimality conditions of the stochastic formulation, allowing it to be solved using standard optimization solvers. This approach is particularly useful for scenario-based models where uncertainty is discretized into a finite set of scenarios, each with an associated probability. The resulting equivalent is often a linear or mixed-integer program, depending on the original problem structure.[5] For a two-stage stochastic linear program with recourse, the deterministic equivalent takes the form of minimizing the expected total cost over scenarios. Specifically, consider a problem where first-stage decisions are made before uncertainty is revealed, followed by second-stage recourse decisions for each scenario . The equivalent is given by subject to where is the probability of scenario , and the variables are scenario-indexed to reflect recourse adapted to the realized uncertainty. This formulation expands the problem size linearly with the number of scenarios , making it tractable for moderate uncertainty but challenging for large sets.[2] In the multistage case, the deterministic equivalent adopts an extensive form that represents the decision tree of evolving uncertainty over stages. Here, decisions at stage are replicated across all scenario paths up to that point, with non-anticipativity enforced either through shared variables for decisions made under the same information or via explicit linking constraints that ensure identical decisions for indistinguishable histories.[20] The resulting problem size grows exponentially as , where is the number of scenarios per stage, leading to a combinatorial explosion that renders direct solution impractical for more than a few stages without reduction techniques. To mitigate this, scenario aggregation methods bundle similar scenarios into representative nodes, iteratively refining the approximation while preserving key distributional properties, as developed in progressive aggregation algorithms.[49] A concrete example illustrates the two-stage deterministic equivalent for a simple linear program with three equally probable scenarios. Consider a farmer deciding on planting acres (wheat), (corn), and (sugar beets) on 500 acres to minimize costs while meeting uncertain yield-based feed requirements in the second stage. The first-stage objective includes planting costs: . For each scenario—good (), fair (), and bad () yields—the second-stage recourse minimizes the expected costs of purchases (y, to cover feed requirements if production is insufficient) and sales (w, of excess production), such as per scenario (where negative coefficients reflect revenues from sales and positive reflect purchase costs), subject to yield-dependent constraints like (good), (fair), and (bad) for wheat, with analogous forms for corn (requiring 240 tons) and beets (sales constraints without purchases), plus and non-negativity. The full equivalent integrates these into a single linear program with expected second-stage costs weighted by , yielding an optimal solution of 108,390 total cost with , , .[50]Convergence and Statistical Inference
In stochastic programming, the sample average approximation (SAA) method replaces the expected value in the objective function with an empirical mean based on a sample of size from the underlying probability distribution. Under suitable regularity conditions, such as the feasible set being compact and the objective function being continuous with finite moments, the SAA optimal value converges almost surely to the true optimal value as . Similarly, the SAA optimal solution converges almost surely to the true optimal solution set, provided the latter is nonempty and the sample average function converges uniformly on the feasible set. The asymptotic distribution of the SAA optimal value is characterized by a central limit theorem: converges in distribution to a normal random variable with mean zero and variance equal to the variance of the objective function evaluated at the optimal solution, , assuming a unique minimizer and Lipschitz continuity of the objective with respect to the decision variables. For more general cases without uniqueness, the limiting distribution involves the infimum of a Gaussian process over the optimal solution set. Variance estimation can be achieved using the sample variance of the objective function values at the SAA solution or, more precisely, through influence functions that account for the optimization effect on the estimator.[48] Statistical inference in SAA leverages these asymptotic properties to construct confidence intervals for the optimal value, typically by standardizing the centered and scaled estimator with its estimated variance and applying normal quantiles; for instance, an approximate -level confidence interval is , where is the standard normal quantile and is a consistent estimator of the asymptotic variance. Hypothesis testing can assess model stability, such as comparing optimal values across competing distributions via Wald-type tests on the difference of SAA estimators, ensuring the selected model is robust to distributional assumptions. These tools provide quantifiable uncertainty measures essential for decision-making in applications with limited data.[48] A representative example is the two-stage newsvendor problem, where the first-stage decision is the order quantity before demand realization, and the second-stage recourse adjusts for shortages or overstock. Applying SAA, the asymptotic normality of holds under standard assumptions like continuous demand distribution, with the limiting variance capturing the variability in profit due to demand uncertainty; numerical studies confirm that confidence intervals tighten rapidly with increasing , often achieving reasonable precision at .[48]Applications
Financial and Portfolio Optimization
Stochastic programming plays a pivotal role in financial and portfolio optimization by modeling uncertainty in asset returns, market conditions, and economic factors through probabilistic scenarios or distributions, enabling robust decision-making under risk.[51] In portfolio contexts, it extends classical mean-variance frameworks to account for dynamic environments where future returns are random, allowing for sequential decisions that adapt to unfolding information.[52] This approach is particularly valuable for institutional investors managing large-scale assets, as it incorporates real-world frictions like liquidity constraints and regulatory limits.[53] Multistage stochastic programs facilitate dynamic asset allocation by representing investment horizons as a sequence of stages, where decisions such as buying or selling assets are made at each stage based on evolving random returns, while incorporating transaction costs and rebalancing to maintain target exposures.[51] For instance, in asset-liability management, these models optimize pension fund portfolios over multiple periods by hedging against interest rate fluctuations and equity volatility using scenario trees to approximate uncertainty distributions.[54] Rebalancing in such frameworks minimizes deviation from strategic allocations, often solved via decomposition methods to handle the curse of dimensionality in large scenario sets.[53] Risk-averse extensions of stochastic portfolio models integrate coherent risk measures like conditional value-at-risk (CVaR) into the objective function to penalize tail risks beyond simple variance, promoting portfolios that limit severe losses under adverse scenarios. CVaR, defined as the expected loss exceeding the value-at-risk threshold, can be optimized linearly within stochastic programs, allowing investors to balance expected returns against downside exposure while respecting budget and diversification constraints.[10] These measures ensure coherence properties such as subadditivity, making them suitable for multi-asset portfolios where correlations amplify risks. A representative example is the two-stage mean-variance portfolio model, where the first-stage decision allocates initial weights to assets under uncertainty, and the second-stage recourse adjusts holdings based on realized scenario returns to minimize variance while targeting a return threshold.[55] Scenario-based returns are generated from historical or simulated data, such as daily S&P 500 constituent prices. Post-2020 developments have integrated environmental, social, and governance (ESG) factors into multistage stochastic frameworks, treating ESG scores as constraints or objectives to align portfolios with sustainability goals amid volatile markets.[56] For high-volatility assets like cryptocurrencies, chance-constrained stochastic programs optimize allocations by enforcing probabilistic bounds on losses, as seen in models for Ethereum and other altcoins that incorporate CDaR to manage extreme drawdowns, yielding risk-adjusted returns superior to naive diversification.[57] These advancements reflect growing demand for ethical investing under uncertainty.Supply Chain and Process Systems
Stochastic programming plays a pivotal role in inventory and production planning within supply chains, particularly through two-stage models that address random demand uncertainties. In these models, first-stage decisions involve determining initial production quantities or order levels without full knowledge of demand realization, while second-stage recourse actions adjust for shortages or excess inventory based on observed demand scenarios. The objective is typically to minimize the expected total cost, encompassing holding costs for surplus inventory and shortage penalties for unmet demand. For instance, in perishable goods supply chains like blood products, two-stage stochastic programs optimize periodic review policies by generating scenarios for demand variability.[58] Global supply chain design leverages two-stage stochastic programming to enhance resilience against disruptions such as supplier failures or transportation delays. These models employ scenario trees to represent evolving uncertainties over multiple planning periods, enabling decisions on facility locations, capacities, and flows that balance expected costs with risk mitigation. By incorporating probabilistic scenarios for disruption events, firms can design networks that maintain service levels during adverse conditions, as demonstrated in four-echelon supply chains where stochastic formulations reduced vulnerability by up to approximately 4% relative to static designs. Decomposition techniques, such as Benders decomposition, are occasionally applied to solve these large-scale problems efficiently.[59] A representative application in process systems is the optimization of chemical production networks under feedstock price volatility, where stochastic programming integrates capacity expansion decisions with operational planning. In such models, uncertain prices are captured via scenario-based formulations, allowing for robust investment strategies that hedge against fluctuations while minimizing long-term costs. For example, stochastic pooling problems in refinery operations use two-stage approaches to optimize blending and distribution under price and demand variability. Recent advances in stochastic programming for supply chains emphasize sustainability, particularly incorporating carbon emission uncertainties in network design. Multistage models now account for volatile carbon pricing and regulatory scenarios, optimizing for low-carbon pathways in global logistics while balancing economic and environmental objectives. These frameworks have been applied to petrochemical supply chains, where scenario trees model uncertainties in energy and carbon prices alongside emissions, achieving reductions of over 3 ktons CO2-eq without sacrificing profitability.[60]Energy and Other Engineering Applications
Stochastic programming plays a crucial role in power generation planning, particularly in multistage hydro-thermal scheduling, where uncertainties in water inflows and electricity demand necessitate robust optimization to minimize costs and ensure reliable supply. In these models, random inflows to reservoirs and fluctuating loads are represented through scenario trees or Monte Carlo sampling, allowing for the coordination of hydroelectric and thermal generation over medium-term horizons, such as monthly planning. For instance, a multistage stochastic programming formulation using nested Benders decomposition has been applied to optimize water usage in hydro-thermal systems, reducing reliance on expensive thermal plants during peak demand periods by efficiently handling up to 350,000 scenarios in simulations spanning 12 months.[61] This approach solves large-scale problems with millions of variables in under 20 minutes on standard hardware, demonstrating significant computational efficiency for real-world utility operations.[61] The integration of renewable energy sources like wind and solar into power systems further leverages stochastic programming through chance-constrained unit commitment formulations, which account for the variability in renewable output while maintaining reliability constraints. These models incorporate probabilistic guarantees, such as ensuring that supply meets demand with a specified probability (e.g., 75% tolerance for wind deviations modeled via Weibull distributions), to schedule thermal units and energy storage alongside intermittent renewables. A mixed-integer linear programming-based stochastic unit commitment problem for wind-battery-thermal systems has shown that incorporating wind power can reduce daily generation costs by approximately 3.5% (from $548,436 to $527,070 in a base case), while energy storage enables meeting up to 15% higher demand levels that would otherwise be infeasible with renewables alone.[62] Such chance constraints provide a brief mechanism to enforce reliability in energy systems under variability, balancing operational risks without overly conservative deterministic approximations.[62] Beyond energy, stochastic programming addresses uncertainties in other engineering domains, such as biological processes and telecommunications infrastructure. In vaccine production, dynamic stochastic models optimize the composition of influenza vaccines under random yield uncertainties, where production success rates for new strains can vary widely, leading to potential shortages if early decisions favor unproven formulations. The optimal policy derived from these models uses threshold-based rules to decide between retaining established compositions (with lower yield risk but possible mismatch to evolving strains) or updating them, improving overall social welfare by adapting to both yield variability and strain effectiveness risks in historical applications.[63] Similarly, in telecommunications network design, stochastic programs model traffic demand uncertainty across multi-commodity flows, enabling capacity planning that minimizes costs while satisfying probabilistic service levels for links and nodes. These formulations distinguish design, dimensioning, and routing decisions under stochastic loads, providing robust topologies that handle variability from user behavior to network failures.[64] A representative example of stochastic programming in energy applications is the two-stage formulation for electricity market bidding, where first-stage decisions commit bids in day-ahead markets under price uncertainty, and second-stage recourse adjusts for realized scenarios. In a stochastic bi-level model for virtual energy storage merchants, price and renewable output scenarios (e.g., 7 scenarios including extreme ramps) are used to maximize profits while ensuring feasibility across thousands of sampled outcomes; case studies from Gansu Province, China, in the early 2020s demonstrate that strategic bidding increases merchant profits to over 219,000 yuan while reducing wind curtailment from 6.9% to 4.5%.[65] This approach highlights the practical impact of stochastic methods in enhancing market efficiency and renewable utilization in modern power systems. Recent advances as of 2025 include multi-timescale stochastic programming frameworks for power systems decision-making under uncertainty.[66]Software Tools
Modeling Languages
Algebraic modeling languages (AMLs) such as GAMS and AMPL provide robust support for formulating stochastic programs by extending deterministic modeling paradigms to handle uncertainty through scenarios and probabilistic elements. In GAMS, the Extended Mathematical Programming (EMP) framework enables stochastic modeling via annotations that define random variables with discrete or continuous distributions, such as normal or uniform, allowing for automatic scenario generation and evaluation.[67] This includes support for scenario loops over multiple realizations of uncertainty, where the solver processes each scenario independently before aggregating results.[68] Expectation operators, like theExpectedValue keyword, facilitate the computation of objective functions as weighted averages over scenarios, directly incorporating recourse decisions in multi-stage formulations.[67]
AMPL similarly supports stochastic programming through its algebraic syntax, emphasizing sample average approximation (SAA) for handling uncertainty by defining scenario-specific parameters, such as demand realizations drawn from a distribution.[69] Users can loop over scenarios using indexing sets and compute expectations via summation, e.g., averaging profits or costs across sampled outcomes to approximate the stochastic objective.[69] For recourse functions, AMPL allows declarative specification of second-stage variables contingent on first-stage decisions and scenario outcomes, enabling models like two-stage inventory problems with overage and underage costs.[70] Both GAMS and AMPL integrate with external scenario generators for sampling from empirical or parametric distributions, streamlining the transition from deterministic prototypes to stochastic variants without altering core model structure.[67][69]
Python-based tools like Pyomo offer flexible extensions for stochastic programming, particularly through the now-deprecated PySP (Python Stochastic Programming) or its active successor mpi-sppy (MPI-based Stochastic Programming in Python), which builds on Pyomo's object-oriented algebraic modeling to define multi-stage problems using scenario trees.[71][72] These extensions allow users to specify stages explicitly, with first-stage decisions independent of uncertainty and subsequent stages adapting via recourse variables indexed by scenarios.[72] Distributions are modeled via scenario probabilities in a tree structure, supporting discrete approximations of continuous uncertainties, while recourse functions are declared declaratively within the base model, extended per scenario.[73] Integration with scenario generators is achieved through data files or Python scripts that populate the tree, enabling compatibility with sampling methods like Latin hypercube for efficient uncertainty representation.[73]
A key advantage of these languages is their declarative syntax, which separates model logic from data and uncertainty, facilitating recourse modeling without explicit enumeration of all scenarios in the formulation. For instance, in Pyomo, a two-stage newsvendor model—where the first stage decides order quantity under uncertain demand, and the second stage handles sales and salvage—can be expressed as follows, using an extensive form approximation with discrete demand scenarios:
from pyomo.environ import *
model = ConcreteModel()
# First-stage decision: order quantity
model.Q = Var(bounds=(0, None))
# Scenarios for demand (e.g., low=80, medium=100, high=120 with probs 0.3, 0.4, 0.3)
model.S = Set(initialize=['low', 'medium', 'high'])
model.demand = [Param](/page/PARAM)(model.S, initialize={'low':80, 'medium':100, 'high':120})
model.prob = [Param](/page/PARAM)(model.S, initialize={'low':0.3, 'medium':0.4, 'high':0.3})
model.p = [Param](/page/PARAM)(initialize=5) # selling price
model.c = [Param](/page/PARAM)(initialize=3) # [cost](/page/Cost)
model.s = [Param](/page/PARAM)(initialize=1) # salvage value
# Second-stage: sales and leftover
model.sales = Var(model.S, bounds=(0, None))
model.left = Var(model.S, bounds=(0, None))
# Constraints
def sales_rule(m, s):
return m.sales[s] <= m.demand[s]
model.sales_con = Constraint(model.S, rule=sales_rule)
def left_rule(m, s):
return m.left[s] == m.Q - m.sales[s]
model.left_con = Constraint(model.S, rule=left_rule)
# Objective: expected profit
def obj_rule(m):
return sum(m.prob[s] * (m.p * m.sales[s] - m.c * m.Q + m.s * m.left[s]) for s in m.S)
model.obj = Objective(rule=obj_rule, sense=maximize)
# Solve with a solver like GLPK
solver = SolverFactory('glpk')
results = solver.solve(model)
from pyomo.environ import *
model = ConcreteModel()
# First-stage decision: order quantity
model.Q = Var(bounds=(0, None))
# Scenarios for demand (e.g., low=80, medium=100, high=120 with probs 0.3, 0.4, 0.3)
model.S = Set(initialize=['low', 'medium', 'high'])
model.demand = [Param](/page/PARAM)(model.S, initialize={'low':80, 'medium':100, 'high':120})
model.prob = [Param](/page/PARAM)(model.S, initialize={'low':0.3, 'medium':0.4, 'high':0.3})
model.p = [Param](/page/PARAM)(initialize=5) # selling price
model.c = [Param](/page/PARAM)(initialize=3) # [cost](/page/Cost)
model.s = [Param](/page/PARAM)(initialize=1) # salvage value
# Second-stage: sales and leftover
model.sales = Var(model.S, bounds=(0, None))
model.left = Var(model.S, bounds=(0, None))
# Constraints
def sales_rule(m, s):
return m.sales[s] <= m.demand[s]
model.sales_con = Constraint(model.S, rule=sales_rule)
def left_rule(m, s):
return m.left[s] == m.Q - m.sales[s]
model.left_con = Constraint(model.S, rule=left_rule)
# Objective: expected profit
def obj_rule(m):
return sum(m.prob[s] * (m.p * m.sales[s] - m.c * m.Q + m.s * m.left[s]) for s in m.S)
model.obj = Objective(rule=obj_rule, sense=maximize)
# Solve with a solver like GLPK
solver = SolverFactory('glpk')
results = solver.solve(model)
