IE 3315 Worked Examples
Teaching · IE 3315 Operations Research I · Worked examples
Each section has one idea, a short explanation, and something to try. The worked example is folded underneath for when you want every step, and the full math after that.
- Simplex: corner to corner
- Shadow prices and KKT
- A transportation network
- Branch and bound
- Convexity: Hessians and Sylvester
- Nonconvex problems and global solvers
1. Simplex: corner to corner
- Turn a word problem into variables, an objective and constraints
- Find the corner points of the feasible region
- Explain how simplex moves from corner to corner, and report z and x
Problem. A shop makes chairs ($40 profit each) and tables ($50). A chair takes 1 hour of labor and 4 units of wood; a table takes 2 hours and 3 units. There are 40 hours and 120 units a week.
The best answer is always at a corner. Simplex starts at one corner (make nothing), checks whether a neighbouring corner is better (a negative number in the z row says yes), moves there, and repeats. Each basis in the table is one corner on the graph.
Try it. Click a negative number in the z row to pick the entering variable, then press Pivot. Watch the table and the graph move together.
Worked example: the graphical method
- Draw each constraint from its intercepts. Labor: and . Wood: and .
- Shade the feasible side (the origin passes both).
- Find the corners. Where the lines cross, solve them together: , .
- Check z at every corner: A 0; B 1,200; C 1,000; D 1,360.
- Answer:
Worked example: the pivots by hand
- Corner A. Slacks (spare labor) and (spare wood) are the basis: . The z row is .
- Entering variable: the most negative z-row number, : enters.
- Ratio test: labor , wood . Labor runs out first, so leaves: corner C , .
- Again: z row , so enters; ratios and , so wood leaves: corner D.
- Stop: z row , nothing negative. The 16 and 6 are the shadow prices.
2. Shadow prices and KKT
- Write the dual of an LP and read its shadow prices
- Explain a reduced cost
- Use the KKT conditions to confirm a primal and a dual solution are optimal
Every LP has a dual that prices its resources: one price per constraint. A shadow price is how much z improves per extra unit of a resource. KKT checks a plan and a set of prices with three tests: the plan is feasible, the prices are feasible, and complementary slackness holds (slack means a zero price). As four lines:
Try it. Change the resources and watch the best corner, the profit and the prices move. Then try your own prices in the KKT check.
Check KKT with any prices
Worked example: the dual, shadow prices and the KKT check
The primal and dual come in pairs: each primal constraint goes with a dual variable; the primal's is the dual's costs and its the dual's right-hand side; max becomes min; primal slacks are dual reduced costs.
- Weak duality: any feasible pair has . Strong duality: at the optimum , so when they match you can stop.
- Both products are made, so both dual constraints are tight: .
- Shadow prices: labor is worth $16 an hour and wood $6 a unit, while labor stays between 30 and 80 hours and wood between 60 and 160.
- Reduced cost: a bench earning $30, using 1 hour and 3 units, uses resources worth . Reduced cost : it stays out unless its profit passes $34.
| KKT line | Plug in x = (24, 8), y = (16, 6) | Holds? |
|---|---|---|
| labor ; wood | yes | |
| chair ; table | yes | |
| yes | ||
| yes |
All four hold: , both optimal. KKT is always necessary; it is also sufficient for convex problems (every LP), and only necessary for nonconvex ones.
The full KKT conditions, for nonlinear problems
For subject to , dual feasibility becomes stationarity:
For the shop, : the objective's direction is a positive mix of the binding constraints' directions.
Nonlinear example: subject to gives , ; the objective is convex, so it is the global minimum.
3. A transportation network
- Write the standard transportation formulation
- Draw it as a network of supply and demand nodes
- Solve it and check it is optimal
Ship from each supplier to each customer at cost : every supply is shipped and every demand is met. Each plant and store is a node, each route an arc, and whole-number supplies give a whole-number answer.
Try it. Change any shipping cost. The cheapest plan re-solves, and the network shows which arcs it uses.
| Cost per unit | Store A (needs 70) | Store B (needs 80) |
|---|---|---|
| Plant 1 (has 50) | $ | $ |
| Plant 2 (has 60) | $ | $ |
| Plant 3 (has 40) | $ | $ |
Worked example: three plants, two stores
- Cheapest arcs first. Plant 2 to B costs $3: send 60. Plant 3 to A costs $3: send 40.
- Fill what is left. A needs 30 more and B 20 more, from Plant 1.
- Cost:
- Check. Prices with on used arcs (): . Unused arcs' reduced costs are 4 and 2, both positive: optimal.
4. Branch and bound
- Solve the LP relaxation of an integer program
- Branch on a fractional variable
- Prune branches, and know when you are done
Problem. Maximize subject to and , whole numbers only.
Relax (drop "whole numbers" and solve the LP: its z is a bound), branch on a fractional variable ( or ), prune a branch that is infeasible, already whole, or no better than the best so far, and stop when nothing is left to branch.
Try it. Press Next to solve one LP at a time. Watch the region get cut and the tree grow.
Worked example: why rounding fails, and the whole tree
The LP answer is , z = 41.25. Rounding to breaks the second constraint (46 > 45); rounding down to earns only 34.
5. Convexity: Hessians and Sylvester
- Build the Hessian of a function
- Find the leading principal minors and apply Sylvester's criterion
- Decide whether the objective and every constraint are convex
A convex problem has one valley, so any local minimum is the global one. To check a function: build the Hessian (second derivatives), take the leading principal minors , , and apply Sylvester: all positive means convex (a bowl); alternating, starting negative, means concave (a dome); a negative means a saddle.
Try it. Move the sliders, or pick a shape. The checks update as you go.
Worked examples: a bowl and a saddle
- A: , : convex. Eigenvalues 6 and 2.
- B: , : a saddle. Eigenvalues 6 and −2.
- If a leading minor is 0, check every principal minor: all at least 0 still means convex (semidefinite).
6. Nonconvex problems and global solvers
- Spot a nonconvex objective or constraint
- Lift a polynomial into a quadratic by adding variables
- Approximate other nonlinear terms with a Taylor series or pieces
With more than one valley, a local method stops in whichever one it starts in. Lift polynomials into quadratics (for , let , so ) and approximate other functions with a Taylor series or straight-line pieces; then a global solver such as Gurobi, SCIP or BARON finds the best valley and proves it.
Try it. Pick a starting point. A local method slides downhill and stops in whichever valley it starts in.
Worked example: x⁴ − 3x² + x
- Convex? is negative near 0. No.
- Two valleys: () and ().
- Lift: subject to , .
- Solve globally (Gurobi,
NonConvex=2):
How the global solvers do it
Spatial branch and bound: the tree from section 4, but branching on ranges of continuous variables. Each product such as is bounded by a convex relaxation (McCormick envelopes), which gives the bounds that prune branches. Tight variable bounds make it much faster. Gurobi has solved nonconvex quadratic problems this way since version 9, and recent versions take functions such as directly.