# Two-stage stochastic programme with recourse
#
# Chooses a capacity before demand is known, then meets whatever demand
# arrives by buying the shortfall at a penalty. The first-stage variable is
# shared across every scenario while the recourse variables are indexed by
# scenario — that split is the whole formulation, and it is what makes the
# model larger than the deterministic version by a factor of the scenario
# count.
#
# Technique: One here-and-now decision, then a separate wait-and-see
# decision per scenario, with the objective weighting recourse
# cost by scenario probability.
#
# On this instance the optimum is 83 (minimisation), confirmed
# independently by exhaustive enumeration before publication.
#
# Reference: Dantzig, G. B. (1955). Linear programming under uncertainty.
# Management Science 1(3–4), 197–206.
model m
set S = {1, 2, 3, 4}
const d = {3, 2, 4, 7}, forall s in S
const c = 4
const p = 7
const n = 4
# first stage: chosen before the scenario is known, shared by all of them
int 0 <= lim <= 7
# second stage: one shortfall variable per scenario
int 0 <= short <= 7, forall s in S
# n * (build cost) + sum of scenario penalties, i.e. n times the expected total
min n * c * lim + p * sum_{s in S}{short_{s}}
# whatever capacity does not cover must be bought at the penalty rate
constr lim + short_{s} >= d_{s}, forall s in S
end
import elytica
Read this through MCP: read with path: "formulations/two-stage-recourse", or resource hlpl://formulations/two-stage-recourse.