Prescriptive Analytics, Optimization, and SimulationIntroductionDescriptive analytics explains what has happened, diagnostic analytics investigates why it happened, and predictive analytics estimates what is likely to happen. Prescriptive analytics addresses the next managerial question: What should the organization do? It combines forecasts, business rules, mathematical optimization, simulation, and human judgment to recommend actions under constraints and uncertainty. Typical prescriptive decisions include: - how much inventory to order;
- which products to produce;
- how to allocate a marketing budget;
- which employees or vehicles to schedule;
- how to price a service;
- how much capacity to reserve; and
- which portfolio of projects to fund.
Python is particularly useful because it connects data preparation, predictive models, optimization libraries, simulation, visualization, and sensitivity analysis in one reproducible workflow. However, optimization does not replace managerial judgment. A mathematically optimal solution is only useful when the objective, data, constraints, and implementation assumptions are credible. Learning ObjectivesBy the end of this chapter, you should be able to: - formulate business objectives, decision variables, parameters, and constraints;
- distinguish linear, integer, nonlinear, and stochastic optimization problems;
- solve selected optimization problems in Python and interpret solver output;
- construct and interpret Monte Carlo simulations;
- evaluate trade-offs, risk, sensitivity, and robustness;
- recognize governance, ethical, and operational limitations of prescriptive models.
1. From Prediction to PrescriptionA predictive model may estimate demand for each product, but it does not determine the production plan. Prescription requires a decision model. The central elements are shown below. | Element | Meaning | Example |
|---|
| Decision variable | Quantity controlled by the decision-maker | Units of product A to produce | | Parameter | Known or estimated input | Unit profit, machine hours | | Objective function | Criterion to maximize or minimize | Total profit | | Constraint | Feasible restriction | Labour-hour availability | | Feasible solution | Decision satisfying every constraint | A valid production mix | | Optimal solution | Best feasible solution according to the objective | Maximum-profit mix | | Scenario | A specified set of assumptions or uncertain outcomes | High-demand case |
A general deterministic optimization problem can be written as: maximize or minimize f(x; θ) subject to gi(x; θ) ≤ 0, i = 1, …, m hj(x; θ) = 0, j = 1, …, r x ∈ X Here, x is the vector of decisions, θ is the vector of parameters, f is the objective, and gi and hj represent inequality and equality constraints. The set X specifies domains such as non-negativity, integer values, or binary values. The formulation applies when the objective and constraints accurately represent the decision context and all relevant units are consistent. Objective, constraints, and trade-offsAn objective may be profit, revenue, cost, service level, risk, emissions, or a weighted combination. For example, a firm may maximize profit while requiring a minimum service level. A multi-objective formulation can use a weighted objective: maximize Z = w₁P − w₂R − w₃E where P is profit, R is risk, E is emissions, and w₁, w₂, and w₃ are non-negative managerial weights. The weights must be justified because changing them changes the recommended decision. In many applications, it is preferable to present a Pareto frontier: solutions for which improving one objective would worsen at least one other objective. 2. Classes of Optimization ModelsLinear programmingA linear program (LP) has a linear objective and linear constraints: maximize cᵀx subject to Ax ≤ b, x ≥ 0 The vector x contains decisions, c contains objective coefficients, A contains resource-use coefficients, and b contains resource capacities. LP is appropriate when marginal returns and resource requirements are constant over the relevant range. It is computationally efficient and often provides useful shadow-price information. Integer and mixed-integer programmingSome decisions cannot be fractional. A store is either opened or not opened, and a delivery vehicle is usually assigned as a whole unit. Integer programming requires some or all variables to be integers. A binary variable satisfies y ∈ {0,1}. Mixed-integer linear programming (MILP) combines continuous and integer variables. A fixed-cost activation relationship can be represented by: x ≤ My where x is the activity level, y is a binary activation variable, and M is a valid upper bound on x. If y = 0, activity must be zero; if y = 1, activity may be positive up to M. Choosing an excessively large M can weaken computational performance, so it should be based on business limits. Nonlinear optimizationNonlinear models arise when costs, demand, or benefits change nonlinearly. Examples include quantity discounts, congestion, and price-response models. Nonlinear solvers may find local rather than global optima, especially when the objective is non-convex. Convexity, differentiability, starting values, and bounds therefore matter. Stochastic optimization and simulationOptimization is deterministic when parameters are treated as known. In reality, demand, processing time, failure, and prices are uncertain. Stochastic optimization incorporates probability distributions or scenarios directly into the model. Simulation instead evaluates the performance of a specified policy across many possible outcomes. The two approaches are complementary: optimization chooses a policy, while simulation can test its risk and robustness. 3. A Linear Programming ExampleConsider an illustrative furniture manufacturer producing desks and bookcases. Each desk earns £50 contribution and each bookcase earns £40. A desk requires 4 hours of carpentry and 2 hours of finishing. A bookcase requires 3 hours of carpentry and 1 hour of finishing. Weekly capacity is 240 carpentry hours and 100 finishing hours. Let x₁ be desks and x₂ be bookcases. The model is: maximize P = 50x₁ + 40x₂ subject to 4x₁ + 3x₂ ≤ 240 carpentry hours 2x₁ + x₂ ≤ 100 finishing hours x₁, x₂ ≥ 0 The intersection of the two resource boundaries is found by solving: 4x₁ + 3x₂ = 240 2x₁ + x₂ = 100 From the second equation, x₂ = 100 − 2x₁. Substitution gives 4x₁ + 3(100 − 2x₁) = 240, so x₁ = 30 and x₂ = 40. Profit is therefore 50(30) + 40(40) = £3,100. The axis intercepts also need checking. Producing only desks permits 50 desks and yields £2,500. Producing only bookcases permits 80 bookcases and yields £3,200. The feasible corner points are therefore approximately (0, 0), (50, 0), (30, 40), and (0, 80). Since £3,200 is greatest, the LP solution is 0 desks and 80 bookcases, assuming divisibility, constant contributions, and no additional business requirements. The intersection is feasible but not optimal. This example illustrates an important principle: an apparent bottleneck is not automatically the only determinant of the optimum. Every relevant corner point, or an equivalent solver result, must be evaluated. Python implementation with SciPyimport numpy as np
from scipy.optimize import linprog
# linprog minimizes, so negate contribution margins
c = np.array([-50, -40])
A_ub = np.array([[4, 3], [2, 1]])
b_ub = np.array([240, 100])
result = linprog(c, A_ub=A_ub, b_ub=b_ub,
bounds=[(0, None), (0, None)],
method="highs")
if result.success:
desks, bookcases = result.x
profit = -result.fun
print(desks, bookcases, profit)
else:
print(result.message)Because linprog minimizes, the objective coefficients are negated. A professional implementation should validate units, inspect result.success, record the solver and version, and independently check constraints. Numerical output should not be rounded before feasibility is assessed. Shadow prices and reduced costsAn LP solver may report a shadow price, also called a dual value, for a resource. It estimates the marginal improvement in the objective associated with one additional unit of a binding resource, within a valid sensitivity range. It is not automatically the price the firm should pay for unlimited extra capacity. Its interpretation depends on the current basis, ranges of validity, and whether the model omits strategic or operational considerations. A resource constraint is binding when it is used fully at the solution. Slack is calculated as capacity minus usage. A non-binding resource has positive slack and usually a zero marginal value in the basic LP interpretation. 4. Integer Optimization in PythonSuppose a retailer must decide which stores to open. Store i produces expected annual benefit bi, requires investment ci, and has binary decision yi. With a budget B, the model is: maximize ∑ᵢ bᵢyᵢ subject to ∑ᵢ cᵢyᵢ ≤ B yᵢ ∈ {0, 1} A compact implementation can use a MILP solver such as SciPy's milp: import numpy as np
from scipy.optimize import milp, LinearConstraint, Bounds
benefit = np.array([90, 70, 65, 50])
cost = np.array([60, 45, 40, 30])
budget = 100
# Minimize negative benefit
result = milp(
c=-benefit,
integrality=np.ones(4),
bounds=Bounds(0, 1),
constraints=LinearConstraint(cost.reshape(1, -1), -np.inf, budget)
)
if result.success:
selected = np.rint(result.x).astype(int)
print(selected, -result.fun)The selected stores are 1 and 3: cost £100 and benefit £155. Store combinations must be compared as discrete alternatives; a fractional solution such as 1.4 stores has no operational meaning. In larger models, integrality can make computation substantially harder than LP. 5. Monte Carlo SimulationOptimization chooses decisions; simulation represents uncertainty. In Monte Carlo simulation, uncertain inputs are sampled repeatedly from specified probability distributions, the model is evaluated for each draw, and the resulting distribution of outcomes is summarized. For a profit model: Π = (p − c)D − F where Π is profit, p is selling price per unit, c is variable cost per unit, D is random demand, and F is fixed cost. This formula assumes all demand can be served and that unsold inventory has no separate value or cost. If inventory is limited to Q, sales become min(D,Q), so the model must change. A simple Python simulation is: import numpy as np
rng = np.random.default_rng(42)
N = 100_000
price = 30
unit_cost = 18
fixed_cost = 20_000
demand = rng.normal(loc=4000, scale=800, size=N)
demand = np.maximum(demand, 0) # demand cannot be negative
profit = (price - unit_cost) * demand - fixed_cost
mean_profit = profit.mean()
probability_of_loss = np.mean(profit < 0)
p05, p50, p95 = np.quantile(profit, [0.05, 0.50, 0.95]) The expected profit is estimated by: Ê[Π] = (1/N)∑ₖ₌₁ᴺ Πₖ where N is the number of simulated trials and Πk is profit in trial k. The estimate becomes more stable as N increases, but more trials cannot correct a poor distributional assumption. If demand is normally distributed with mean 4,000 and standard deviation 800, the unconstrained example has mean profit: E[Π] = (30 − 18)(4,000) − 20,000 = £28,000 The break-even demand is: D₀ = F ÷ (p − c) = 20,000 ÷ 12 ≈ 1,666.7 units The probability of a loss is approximately P(D < 1,666.7), which is extremely small under these assumptions. This result should not be presented as a forecast of actual loss risk without checking whether the assumed demand distribution and cost structure are credible. Choosing distributionsDistribution selection should reflect the data-generating process: - normal distributions may be reasonable for measurement error or aggregated variation, but permit negative values;
- lognormal distributions are suitable for positive, right-skewed quantities such as some prices or sales volumes;
- Poisson or negative binomial models may represent counts, with the latter allowing overdispersion;
- triangular distributions are sometimes useful when only minimum, most likely, and maximum estimates are available;
- empirical resampling preserves observed patterns without imposing a parametric distribution, but requires representative historical data.
Inputs may be correlated. For example, high demand may coincide with higher expedited shipping costs. Independently sampling both variables can understate or distort risk. Correlation should be estimated carefully, and causal relationships should not be inferred from correlation alone. 6. Simulation-Based Decision AnalysisSuppose a firm is comparing order quantities. For each candidate quantity Q, simulation can estimate expected profit, stockout probability, expected leftover inventory, and downside percentiles. A policy should not be selected solely because it has the highest mean profit. Useful measures include: Stockout probability = P(D > Q) Expected shortfall at level α = −E[Π | Π ≤ q_α] where q_α is the α-quantile of profit. The second measure describes the average loss or low outcome in the worst α proportion of cases; the sign convention should be stated clearly. A practical comparison table might contain: | Policy | Mean profit | 5th-percentile profit | Stockout probability | Decision implication |
|---|
| Low order quantity | £… | £… | High | Lower commitment, weaker service | | Medium order quantity | £… | £… | Medium | Balanced trade-off | | High order quantity | £… | £… | Low | Better service, more overstock risk |
The final choice depends on risk tolerance, service commitments, cash constraints, and strategic priorities. 7. Sensitivity, Scenario, and Robustness AnalysisA model should be challenged rather than accepted as a single answer. One-way sensitivity analysisChange one input at a time—for example, unit cost, capacity, or demand mean—and observe the effect on the recommendation. This identifies influential assumptions but ignores interactions among variables. Two-way and tornado analysisTwo-way analysis varies two parameters jointly. A tornado chart ranks variables by their effect on the objective. These methods communicate model sensitivity to non-technical stakeholders, although ranking depends on selected ranges. Scenario analysisScenarios combine coherent assumptions, such as recession, base case, and rapid growth. Scenarios are not necessarily probabilities. If probabilities are assigned, expected values can be computed, but decision-makers should also inspect each scenario separately. Break-even analysisFor two alternatives with fixed costs F₁ and F₂ and variable costs v₁ and v₂, the volume at which costs are equal is: Q* = (F₂ − F₁) ÷ (v₁ − v₂) This formula applies when v₁ ≠ v₂ and both cost functions are linear over the relevant volume range. It is useful for identifying decision thresholds, not for proving that either alternative is operationally feasible. RobustnessA decision is robust when it performs acceptably across a broad range of plausible conditions. Robust solutions may sacrifice a small amount of expected profit to reduce severe downside outcomes. Robustness can be assessed by stress testing, distributional shifts, alternative model specifications, and out-of-sample evaluation. 8. Applied Case: FreshBite Meal KitsThis is an illustrative case. FreshBite sells weekly meal kits and must select a production quantity before demand is known. Background and problemEach kit sells for £42 and costs £24 to prepare. Unsold kits can be donated, creating a tax and social benefit equivalent to £5 per kit, while the remaining disposal cost is £2. Demand is uncertain because weather, promotions, and competitor actions vary. Management must balance expected profit, waste, and a 95% service target. FormulationLet Q be the production quantity and D random demand. Revenue is earned on kits sold, min(Q,D). The per-period contribution can be represented as: Π(Q,D) = 42 min(Q,D) + 3 max(Q − D, 0) − 24Q The £3 recovery value equals the £5 social/tax benefit minus £2 disposal cost. This model assumes no lost-sales goodwill value and no capacity-dependent preparation cost. Management estimates demand using historical data and proposes three candidate policies: 1,000, 1,200, and 1,400 kits. Analysts simulate 100,000 draws for each policy, using an empirically fitted distribution and preserving the observed relationship between promotion intensity and demand. Analysis and solution approachFor each draw and each quantity, analysts calculate profit, stockouts, and waste. They report means, medians, the 5th percentile, and the probability that service falls below 95%. They then repeat the analysis under a 20% demand decline, a 15% ingredient-cost increase, and a promotion-response assumption that is weaker than historical experience. The recommended policy should be the quantity that meets the service requirement while maintaining acceptable downside risk. If 1,400 kits has the highest expected profit but produces unacceptable waste under the downside scenario, 1,200 kits may be preferable. The result is not simply “the quantity with the largest simulated mean”; it is a decision based on objectives and constraints. Outcome and learning pointsThe case demonstrates five practices: - model the actual sales and salvage mechanics rather than using an unconstrained profit formula;
- distinguish a service constraint from a financial objective;
- preserve dependence among uncertain inputs where evidence supports it;
- evaluate distributions of outcomes, not only averages; and
- document assumptions so managers can challenge and improve them.
9. Implementation, Governance, and Ethical IssuesPrescriptive systems can affect employees, customers, suppliers, and communities. Important controls include: - Data quality: check missingness, outliers, time alignment, units, and leakage from future information.
- Model validation: test constraints against actual operating rules and compare recommendations with historical decisions.
- Transparency: explain objective terms, important constraints, and sensitivity to stakeholders.
- Fairness: examine whether optimization disadvantages protected groups or concentrates opportunities unfairly. A mathematically efficient allocation can still be ethically unacceptable.
- Human oversight: define approval thresholds, override procedures, and escalation for unusual situations.
- Auditability: preserve input data, code, solver settings, random seeds, model versions, and decision logs.
- Security and privacy: protect commercially sensitive and personal data, and restrict access according to legitimate need.
- Monitoring: detect drift in demand, costs, correlations, and operational performance after deployment.
AI systems may assist with forecasting, scenario generation, or natural-language interfaces, but generated assumptions and code require validation. An optimization system should not be allowed to invent constraints, silently change objectives, or make high-impact decisions without accountable review. 10. Best Practices and Common Failure ModesA reliable workflow is: - define the decision and decision horizon;
- identify stakeholders and competing objectives;
- specify variables, parameters, units, and constraints;
- validate data and assumptions;
- build the simplest adequate model;
- solve it with an appropriate algorithm;
- independently verify feasibility and objective calculations;
- simulate uncertainty and stress-test assumptions;
- communicate trade-offs and limitations; and
- monitor actual outcomes and update the model.
Common failures include optimizing an incorrect objective, omitting a binding constraint, treating forecasts as certainties, using independent random draws when inputs are correlated, relying on a single simulation run, interpreting shadow prices outside their valid range, and rounding decisions in ways that violate constraints. Solver status must always be checked: infeasibility, unboundedness, time limits, and numerical difficulties have different meanings and require different responses. Chapter SummaryPrescriptive analytics converts business goals into decisions by combining objectives, decision variables, parameters, and constraints. Linear programming is appropriate for linear relationships, while integer and mixed-integer models represent indivisible choices. Simulation evaluates policies under uncertainty and produces distributions of outcomes rather than a single forecast. Monte Carlo estimates expected results and risk through repeated random sampling, but its conclusions depend on credible distributions, dependence assumptions, and sufficient validation. Sensitivity, scenario, break-even, and robustness analysis reveal how recommendations change when assumptions vary. Effective practice requires unit consistency, feasibility checks, documented assumptions, ethical oversight, reproducible code, and human accountability. Key TermsPrescriptive analytics: Analytics that recommends actions under objectives and constraints. Decision variable: A quantity controlled by the decision-maker. Parameter: A known or estimated model input. Objective function: Mathematical expression to maximize or minimize. Constraint: A restriction defining allowable decisions. Feasible solution: A decision satisfying all constraints. Optimal solution: The best feasible solution under the stated objective. Linear programming: Optimization with linear objective and constraints. Integer programming: Optimization requiring some decisions to be integers. Binary variable: A variable restricted to 0 or 1. Mixed-integer linear programming: A linear model containing continuous and integer variables. Shadow price: Marginal objective value of relaxing a resource constraint within a valid range. Slack: Unused amount of a constrained resource. Monte Carlo simulation: Repeated random sampling used to estimate outcome distributions. Scenario analysis: Evaluation under coherent alternative assumptions. Sensitivity analysis: Study of how outputs change when inputs vary. Robustness: Ability of a decision to perform acceptably across plausible conditions. Expected shortfall: Average outcome in a specified worst-tail region. Model governance: Controls for validation, accountability, monitoring, and auditability. Review QuestionsShort Answer Questions- Distinguish a decision variable from a parameter and give one example of each.
- What makes a solution feasible but not necessarily optimal?
- Why are binary variables useful in business models?
- What does a Monte Carlo simulation estimate?
- Why should optimization results be subjected to sensitivity analysis?
Long Answer Questions- Explain how a business problem is translated into an optimization model, including objectives, variables, parameters, and constraints.
- Compare linear programming, integer programming, nonlinear optimization, and simulation.
- Explain the interpretation and limitations of shadow prices.
- Describe a rigorous workflow for building and validating a simulation model.
- Discuss ethical and governance requirements for a prescriptive analytics system affecting employees or customers.
Analytical / Application Questions- Formulate a production LP for two products using specified profits, labour capacities, and material requirements. Identify which constraints are binding and explain the result.
- Design a Monte Carlo experiment for a retailer choosing an order quantity under uncertain demand. Specify inputs, distributions, outputs, and risk measures.
- A manager prefers the policy with the highest expected profit, while a board requires a minimum 95% service level and limits downside loss. Explain how you would formulate and compare policies under these competing requirements.
Multiple Choice Questions with AnswersQuestion 1Which item is a decision variable in a production optimization model? A. Available machine hours B. Unit contribution margin C. Units of product to manufacture D. Forecast demand distribution Correct Answer: C. Units of product to manufacture Question 2In the furniture example, which production plan gives the greatest profit among the feasible corner points? A. 50 desks and 0 bookcases B. 30 desks and 40 bookcases C. 0 desks and 80 bookcases D. 0 desks and 0 bookcases Correct Answer: C. 0 desks and 80 bookcases Question 3Why are objective coefficients negated when using scipy.optimize.linprog in the example? A. The data are measured in negative units B. linprog solves minimization problems, while the business objective is maximization C. Negation forces all variables to be integers D. Negation removes resource constraints Correct Answer: B. linprog solves minimization problems, while the business objective is maximization Question 4A binary variable is restricted to which values? A. Any non-negative real number B. −1 and 1 C. 0 and 1 D. Any integer greater than 1 Correct Answer: C. 0 and 1 Question 5What does Monte Carlo simulation primarily provide? A. A guaranteed optimal decision B. A distribution of possible outcomes under specified assumptions C. A proof that input forecasts are correct D. A replacement for business constraints Correct Answer: B. A distribution of possible outcomes under specified assumptions Question 6Using Π = (p − c)D − F, what is profit when price is £30, variable cost is £18, demand is 4,000, and fixed cost is £20,000? A. £12,000 B. £20,000 C. £28,000 D. £48,000 Correct Answer: C. £28,000 Question 7What is a major risk of independently simulating two inputs that are positively correlated in reality? A. It always makes the simulation infeasible B. It may misrepresent or understate outcome risk C. It guarantees a higher expected profit D. It converts continuous variables into binary variables Correct Answer: B. It may misrepresent or understate outcome risk Question 8A constraint is binding when: A. It has positive unused capacity B. It is violated slightly after rounding C. Its available capacity is fully used at the solution D. It contains an integer variable Correct Answer: C. Its available capacity is fully used at the solution Question 9Which measure focuses on the average outcome in the worst specified tail of a distribution? A. Mean B. Median C. Expected shortfall D. Shadow price Correct Answer: C. Expected shortfall Question 10Which practice best supports reproducibility in simulation? A. Changing the random seed for every report without recording it B. Recording code, assumptions, random seed, inputs, and model version C. Reporting only the most favourable trial D. Rounding all simulated outcomes before analysis Correct Answer: B. Recording code, assumptions, random seed, inputs, and model version
|