Session 10
Agenda
Stochastic Programming
Recourse Decisions
Chance Constraints in Optimization
Course Wrap-up
Process Flexibility
We simulated the performance (expected capacity utilization) of the
long chain design, for given capacity of each plant.
What is the optimal capacity of each plant? (Assume we know the cost
of capacity per unit, the price of each product, etc.)
Product 1
Product 2
Price/unit
$35,000 $31,000
Demand (Normal distribution)
Mean
100 units
100 units
Stdev
40 units
40 units
Plant 1
Plant 2
Plant 3
Plant 4
Plant 5
Product 3 Product 4 Product 5
$30,000 $25,000 $20,000
100 units 100 units 100 units
40 units 40 units 40 units
Capacity
Cost/Unit
$5,000
$4,800
$4,500
$4,000
$4,800
Process Flexibility
Decisions to be made:
• Capacity of each plant
• Allocation of the capacities to different products
When do you have to make these decisions?
• “Here and now” decision –before knowing the actual demand
–
Capacity of each plant
• “Wait and see” (recourse, adaptive) decision –after knowing the
actual demand
–
Allocation of the capacities to different products
Two-stage problem with recourse decisions.
Gas Company Example
A gas company buys gas and then sells it to its consumers.
This year:
• Demand is 100 units (known with certainty).
• The price of gas is $5 per unit this year
• Storage cost $1 per unit
Next year:
• Demand is uncertain, depending on the weather (normal, cold, or
very cold).
• The price of gas is also uncertain, depending on customer demand.
• What’s the optimal plan to minimize the expected total cost?
Decisions to Make
Decisions to make:
• How much gas to purchase this year?
• How much gas to store this year?
• How much gas to purchase next year?
When do you have to make these decisions?
“Here and now” decision –before knowing next year’s demand
•How much gas to purchase this year?
•How much gas to store this year?
“Wait and see” decision –after knowing next year’s demand
• How much gas to purchase next year?
If the company must commit to all of its gas purchases now, before
next year’s demand is known, then it’s a two-stage problem with static
decisions.
Uncertainty: State of Nature
The state of nature (scenario) in the gas company’s decision making
•
Normal weather next year
•
Cold weather next year
•
Very cold weather next year
We use ω to denote the state of nature
• ω = 1: Normal
• ω = 2: Cold
• ω = 3: Very cold
The set of states of nature (scenarios) is denoted by Ω = {1, 2, 3}
Uncertainty: Price/Demand
The demand and price next year are determined by the state of nature
• D(ω) is the demand next year in scenario ω
• p(ω) is the price next year in scenario ω
Probability that scenario ω will occur:
Denoted by Pr(ω) = 0.333 for ω=1,2,3.
A
5
6
7
8
B
Scenario
1 Normal
2 Cold
3 Very Cold
C
D
Probability Gas Cost ($)
0.3333
$
5.00
0.3333
$
6.00
0.3333
$
7.50
E
Demand (Units)
100
150
180
Decision Variables
“Here and now” variables -- first stage (normal) variables
– x: # of units of gas to purchase this year
– y: # of units of gas to store this year
“Wait and see” variables -- recourse variables
– Decision made after observing “state of nature” ω
– Decisions can be different in different states
– z(ω): # of units to purchase next year in state ω
Objective Function
Minimize the total expected cost
This year’s purchasing and inventory holding cost
$5x + $1y
Next year’s purchasing cost: $p(ω)z(ω)
Total expected total cost
3
5x y Pr( )p( )z( )
1
5x y 0.333[ 5 z(1)] 0.333[6 z( 2 )] 0.333[7.5 z( 3)]
5x y 1.667[ z(1)] 2.000[ z( 2 )] 2.500[ z( 3)]
Constraints
x – y = 100
Satisfy demand this year
y + z(1) = 100
y + z(2) = 150
Satisfy demand next year
y + z(3) = 180
y >= 0
z(1), z(2), z(3) >= 0
Nonnegativity
LP Formulation
Min 5x + y + 1.667z(1) + 2.0z(2) + 2.5z(3)
s.t.
x – y = 100
y + z(1) = 100
y + z(2) = 150
y + z(3) = 180
y >= 0
z(1), z(2), z(3) >= 0
A
1 Total Cost
2 Cost Year 1
3 Cost Year 2
4
5
6
1
7
2
8
3
9
10
11 Units to Buy
12 Units to Store
13
14
15
16
17 Constraints
18
19
20
21
B
$ 1,400.00
$ 1,100.00
$ 300.00
Scenario
Normal
Cold
Very Cold
Year 1
200
100
Year 1
100
C
D
E
F
G
H
=B3+B2
=SUMPRODUCT(B11:B12,C11:C12)
=SUMPRODUCT(C6:C8,D6:D8,F11:F13)
Probability Gas Cost ($)
0.3333
$
5.00
0.3333
$
6.00
0.3333
$
7.50
5
1
Demand (Units)
100
150
180
Normal
Cold
Very Cold
Year 2
0
50
80
Normal
Cold
Very Cold
Year 2
Demand
=$B$12+F11
100 >=
100
150 >=
150
180 >=
180
=B11-B12 Demand
>=
100
I
Optimal Plan
A
10
11 Units to Buy
12 Units to Store
13
B
Year 1
200
100
C
5
1
D
E
Normal
Cold
Very Cold
F
Year 2
0
50
80
• This year: Purchase 200 units and store 100 units.
• Next year: if the weather is normal, purchase 0 units; if the
weather is cold, purchase 50 units; if the weather is very cold,
purchase 80 units.
Stochastic Programming (SP)
Usual procedure:
• Set up spreadsheet with parameters and formulas
• Identify Decision Variables, Objective, and Constraints
New steps:
• Distinguish recourse from normal Decision Variables
• Re-define Objective Function (now a statistic)
• Test Model
Usual procedure:
• Run Model
• Interpret results
Stochastic Programming (SP) Formulation
Min
s.t.
5x + y + E[p(ω)z(ω)]
x – y = 100
y + z(ω) = D(ω) for ω = 1, 2, 3
y >= 0
z(ω) >= 0
x, y: first stage variables (normal variables)
z: recourse variables
A
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Total Cost
Cost Year 1
Cost Year 2
B
$ 1,400.00
$ 1,100.00
$ 300.00
Scenario
1 Normal
2 Cold
3 Very Cold
Units to Buy
Units to Store
Random
Year 1
200
100
2
C
Expected
#N/A
D
E
F
G
H
I
=PsiMean(B2)
Probability Gas Cost ($)
0.3333
$
5.00
0.3333
$
6.00
0.3333
$
7.50
Demand (Units)
100
150
180
5
1
=PsiIntUniform(1,3,PsiBaseCase(1))
Cold
$
6.00
150
50
Purchased Year 2
=VLOOKUP(B15,$A$7:$E$9,2,0)
Constraints
Year 1
100
>=
Demand
100
Cold
Year 2
Demand
150 =
150
=E15
• In B15, use PsiIntUniform(1,3) to simulate the state of nature next
year. (Random integers 1, 2, 3)
• In C15:E15, use Excel LOOKUP or IF function to generate weather,
demand, and price of gas next year.
A
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Total Cost
Cost Year 1
Cost Year 2
B
$ 1,400.00
$ 1,100.00
$ 300.00
Scenario
1 Normal
2 Cold
3 Very Cold
Units to Buy
Units to Store
Random
Year 1
200
100
2
C
Expected
#N/A
D
E
F
G
H
I
=PsiMean(B2)
Probability Gas Cost ($)
0.3333
$
5.00
0.3333
$
6.00
0.3333
$
7.50
Demand (Units)
100
150
180
5
1
=PsiIntUniform(1,3,PsiBaseCase(1))
Cold
$
6.00
150
50
Purchased Year 2
=VLOOKUP(B15,$A$7:$E$9,2,0)
Constraints
Year 1
100
>=
Demand
100
Cold
Year 2
Demand
150 =
150
=E15
SP Formulation: Decision Variables
A
11
12 Units to Buy
13 Units to Store
14
15 Random
B
Year 1
200
100
3
C
D
E
F
180
50
G
H
I
5
1
Very Cold
$
7.50
Purchased Year 2
• B12:B13 are normal decision variables
• F15 is a recourse decision variable: select F15, Decision Recourse
SP Formulation: Constraints
A
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Total Cost
Cost Year 1
Cost Year 2
B
$ 1,400.00
$ 1,100.00
$ 300.00
Scenario
1 Normal
2 Cold
3 Very Cold
Units to Buy
Units to Store
Random
Year 1
200
100
2
C
Expected
#N/A
D
E
Probability Gas Cost ($)
0.3333
$
5.00
0.3333
$
6.00
0.3333
$
7.50
F
G
H
I
Demand (Units)
100
150
180
5
1
Cold
$
6.00
150
50
Purchased Year 2
Constraints
Year 1
100
=
Demand
100
Cold
=B12-B13
Constraints:
B19 = D19 (first stage demand)
F19 = H19 (second stage random demand)
Both are normal constraints.
Year 2
Demand
150 =
150
=C15
=$B$13+F15
=E15
SP Formulation
Risk Solver Platform analyzes the structure of the problem
and recognizes this is an LP/Convex problem.
If the number of variables/constraints (of the transformed
problem) are less than 8000, it transforms the problem to a
deterministic equivalent problem by sampling
(simulation).
Otherwise, transformed to “robust counterpart” (an
approximation of the original problem).
A Simple Linear Constraint
McCormick Manufacturing Company problem.
The linear programming formulation has four resource constraints, one
for each department.
A
B
C
D
1
2
3
Product 1 Product 2
4
5743.59 1794.872
5
6 Profit
$ 10.00 $ 9.00
7
8
Dept 1
0.65
0.95
9
Dept 2
0.45
0.85
10
Dept 3
1.00
0.70
11
Dept 4
0.15
0.30
E
F
G
H
$ 73,589.74
5438.46
4110.26
7000.00
1400.00
<=
<=
<=
<=
6500
6000
7000
1400
A Simple Linear Constraint
Recall the McCormick Manufacturing Company example.
The linear programming formulation has four resource constraints, one
for each department.
The constraint for department 1 is
0.65 x1 + 0.95 x2 <= 6500
where
–(x1, x2) are the production quantities of the two products, respectively
–(0.65, 0.95) are the labor requirement per unit of the two products,
respectively
–Right-hand side 6500 is the # of hours available
Constraint Uncertainty
The number of hours available in Department 1 may be uncertain
–Machine breakdown
–Sick leave
What if it is a normal distribution? Say, ~N (6500, 100)
Now the resource constraint should be:
0.65 x1 + 0.95 x2 <= Normal(6500, 100)
However, this constraint may not hold (at least theoretically) even if
(x1, x2) are very small, say (100, 100).
Recall that the normal distribution is unbounded. It can take
(theoretically) very small and very large values.
Feasible Solutions
In the deterministic case, (x1, x2) = (100, 100) is feasible
because the constraint
0.65 x1 + 0.95 x2 <= 6500
holds for this particular solution.
0.65 x1 + 0.95 x2
= 0.65 * 100 + 0.95 * 100
= 170 <= 6500
Feasible Solutions
What is a feasible solution when there is constraint
uncertainty?
Is (x1, x2)=(100, 100) feasible for the constraint below?
0.65 x1 + 0.95 x2 <= N(6500, 100)
Equivalently, does the following inequality hold?
160 <= Normal(6500, 100)
This inequality is very likely to hold.
So (x1, x2)=(100, 100) is very likely a feasible solution.
Feasible Solution
Is (x1, x2)=(1000, 1000) feasible for the constraint below?
0.65 x1 + 0.95 x2 <= Normal(6500, 100)
Equivalently, does the following inequality hold?
1600 <= Normal(6500, 100)
This inequality is very likely to hold.
So (x1, x2)=(1000, 1000) is very likely a feasible solution.
Is (x1, x2)=(4000, 4000) feasible for the constraint below?
0.65 x1 + 0.95 x2 <= Normal(6500, 100)
Equivalently, does the following inequality hold?
6400 <= Normal(6500, 100)
How likely this inequality will hold?
How likely the following inequality will hold?
6400 <= Normal(6500, 100)
The solution (x1, x2)=(4000, 4000) is feasible with probability 84.13%.
Chance Constraint
For any fixed value of (x1, x2), the uncertain constraint
0.65 x1 + 0.95 x2 <= Normal(6500, 100)
may or may not hold.
It holds with certain probability.
•For solution (x1,x2)=(100,100), the probability is very high
•For solution (x1, x2)=(4000,4000), the probability is only 84.13%
Chance constraint:
Pr{0.65 x1 + 0.95 x2 ≤ Normal(6500, 100)} ≥ α
We require the resource constraint to hold with probability at least 1α. Here α could be 0.1%, 1%, 5%, 10%, etc.
Chance Constraint
If we want the original constraint to be true with 95% probability:
𝑃 0.65𝑥1 + 0.95𝑥2 ≤ 𝑁𝑜𝑟𝑚𝑎𝑙 6500, 100 ≥ 0.95
Excel: NORM.INV(5%, 6500, 100) =6335.5
Higher Confidence Level
If we want the original constraint to be true with 99% probability:
𝑃 0.65𝑥1 + 0.95𝑥2 ≤ 𝑁𝑜𝑟𝑚𝑎𝑙 6500, 100 ≥ 0.99
Excel: NORM.INV(1%, 6500, 100) =6267.5
An LP with Chance Constraints
The following LP with chance constraint
max
𝑠. 𝑡.
10 𝑥1 + 9 𝑥2
Pr 0.65 𝑥1 + 0.95 𝑥2 ≤
Course Wrap-up
张家伟
Prof. Jiawei Zhang
Solution Approaches?
Traditional demand prediction approach does not apply
– For any given item, there is not enough historical data available
Modern machine learning approaches
– Center of big data
– Use large amount of sales data of items that have similar features
(color, style, size, etc.)
– Clustering, classification trees, random forest, etc.
– Still not accurate. Order quantity based on predicted demand did
not work well
Decision modeling approach
– Regard the output of the demand prediction models as “random
demand”
– Minimize lost sales and surplus inventory by explicitly
incorporating demand uncertainty
– Substantial cost saving based on real data testing
What is Decision Modeling?
Decision Modeling Process
Formulation
Real world
System
Decision
Model
Deduction
Implementation
Real World
Conclusions
Interpretation
Model
Conclusions
What is Analytics?
… besides bad English?
Data
Data Visualization
Statistics
Econometrics
Machine Learning
Inferences
Optimization
Decision Analysis
Simulation
Stochastic Modeling
Decisions
Business
This course is about decision modeling under uncertainty
Example: Investment Wheel
Static
Decision
$3
$2
$6
Adaptive
Decision
Single Stage
Multi-Stage
Bet on three
sections maximize
expected return
after one spin
fixed-proportion strategy
to maximize the expected
growth rate over 100
spins.
proportion depends on
•cash position
•Number of spins left
to maximize long term
growth rate.
Example: Laptop-Bag Pricing
Single Stage
Static
Decision
Adaptive
Decision
Set a single price to
maximize the
expected revenue of
the season.
Multi-Stage
Set prices for next 9 weeks now
(prices may different from week to
week) to maximize…
Future price (of a given week)
depends on
•Remaining inventory
•Price of previous week
to maximize expected revenue over
9 weeks.
Example: Personalized Discount
Static
Decision
Adaptive
Decision
Single Stage
Multi-Stage
Choose “major,
minor, no” discount
to maximize profit of
a period.
Choose the discount offers for next
5 quarters (offers may different
from quarter to quarter) to
maximize expected life time value
of the customer
Future offer (of a given quarter)
depends on
•Purchase history of the customer
(active, inactive, etc.)
•Number of quarters remaining
to maximize expected life time
value of the customer
Example: Inventory Management
Single Stage
Static
Decision
Adaptive
Decision
Choose an order
quantity to maximize
expected profit of a
single period.
Multi-Stage
Choose the order quantities for
next 10 months (order quantities
may different from month to
month) to maximize expected
profit over 10 months
Future order quantity (of a given
month) depends on
•Current inventory
•Number of months remaining
to maximize expected profit
Methods/Tools
Single Stage
Static
Decision
Adaptive
Decision
Multi-Stage
Relative easy to formulate and solve (e.g., OptQuest in
Crystal Ball)
Dynamic programming, applicable
if
•Small number of decision
variables
•State space not too large
Approximation of DP
•Reduce to static decision via
simple policy
•Deterministic approx. (linear
program) and re-optimization
Two-Stage Problem
Single Stage
Static
Decision
Adaptive
Decision
Two-Stage
Relative easy to formulate and solve (e.g., OptQuest in
Crystal Ball)
Reformulating as deterministic
linear program.
Adaptive decisions, a.k.a. recourse
decisions.
Summary
Decision criteria
–EMV maximization, Utility function
–Risk measures: VaR
Single-stage optimization
–Static decision (Optquest in Crystal Ball)
Two-stage optimization with recourse
–Differentiate “here-and-now” decisions and “recourse” decisions
–Can be reformulated as a “larger” deterministic linear program
–Embed Solver in Crystal Ball
Multi-stage optimization: adaptive decision
Dynamic programming: state variables,
–Re-optimization (regular solver)
–Simple policy: reduces to static decision (Optquest)
© Copyright 2026 Paperzz