⛰️Numerical Optimisation
Constrained Optimisation and Linear Programming
Lagrange multipliers and KKT conditions, penalty and SQP methods, linear programming, minimum-mass truss layout
The Pentagon, 1947
George Dantzig is a mathematical adviser to the US Air Force Comptroller. His task, under a project code-named SCOOP, is to mechanise planning: how to allocate aircraft, crews, fuel and training across thousands of activities, subject to hundreds of limits, to meet the Air Force's objectives at least cost. Until now such plans have been assembled by hand, by experience and negotiation.
Dantzig formulates the problem with every relationship linear — so much fuel per sortie, so many crews per aircraft — and invents an algorithm to solve it: the simplex method, which walks from corner to corner of the region of feasible plans, improving the objective at each step, until no neighbouring corner is better. Unknown to him, Leonid Kantorovich in Leningrad had formulated similar problems in 1939 for a plywood trust, but his work was little known outside the Soviet Union.
Linear programming spread from military logistics to oil refineries, airlines, steel mills and electricity grids. Kantorovich shared the 1975 Nobel Prize in economics for it with Tjalling Koopmans. Today's solvers handle millions of variables, and an engineer meets them in structural design, scheduling and power dispatch.
A constrained problem minimises subject to equality constraints and inequality constraints . The solution often lies on the boundary of the feasible set, where some inequality constraints are active (hold with equality). Setting the gradient to zero no longer works: the objective may still be decreasing in a direction that leaves the feasible set.
💡Lagrange multipliers and the KKT conditions
At a constrained minimum, must be a combination of the gradients of the active constraints — otherwise some feasible direction would still decrease :
These are the Karush–Kuhn–Tucker (KKT) conditions (Karush 1939, Kuhn and Tucker 1951). The multipliers have a practical meaning: or is the rate at which the optimal objective would improve if that constraint were relaxed by one unit — a shadow price. A zero multiplier means the constraint is not limiting the design.
Derivation
The multiplier condition, from geometry and on an example
One equality constraint. On the surface , a feasible move must keep unchanged to first order: , so feasible directions are perpendicular to . At a constrained minimum, no feasible direction may decrease , so for all of them too. A vector perpendicular to everything that is perpendicular to must be parallel to it:
The closest point on the unit circle to . Minimise with . The condition reads and , so
The point lies on the line through the origin and , as geometry demands. The constraint gives , so and .
What the multiplier measures. Change the constraint to . The best distance squared becomes , and at
The multiplier is the rate at which the optimum changes as the constraint is relaxed — the shadow price. (The quadratic penalty of the lab satisfies at its minimum instead; comparing with shows its constraint violation is , the the lab prints at .)
Inequalities. For the feasible side is where increases. If the constraint is active and with , then stepping into the feasible region (along ) would lower — not a minimum. So . And if the constraint is not active, it cannot hold the design back, so : in every case .
📐The lightest pressure tank
A steel tank must hold 2 m³ at 3 MPa with allowable stress 200 MPa; cylinder with hemispherical heads; shell thickness from hoop stress, heads half as thick. In formulas: the shell needs and the heads , so the steel volume is and the contents m³. Without other limits the lightest tank is a sphere of radius 0.782 m, 353 kg. But it must fit on a road vehicle: diameter at most 1.2 m.
scipy.optimize.minimize(method='SLSQP') gives radius 0.6000 m (the limit), cylinder length 0.968 m, mass 417.7 kg. Checking KKT numerically: kg/m³ for the volume constraint and kg/m for the diameter limit — positive, so the limit is active, and every extra metre of allowable diameter would save about 133 kg at the margin.How constrained solvers work. A penalty method adds (and similar terms for violated inequalities) to and minimises without constraints, increasing . It is simple but imperfect: the constraint is satisfied only as , and the problem's Hessian condition number grows like — at the error is still with . Augmented Lagrangian methods add multiplier estimates and avoid infinite . Sequential quadratic programming (SQP, e.g.
SLSQP) solves at each step a quadratic model of the Lagrangian with linearised constraints — Newton's method applied to the KKT conditions — and reaches directly. Interior-point methods keep iterates strictly feasible with a logarithmic barrier and dominate large problems.💡Linear programming
When the objective and every constraint are linear — minimise subject to , , — the feasible set is a convex polyhedron and an optimum, if one exists, lies at a vertex. The simplex method moves between adjacent vertices; interior-point methods (Karmarkar, 1984) cut through the middle. Both are inside
scipy.optimize.linprog, which calls the HiGHS solver. Linear programmes are convex, so a solution found is the global optimum, and duality theory provides shadow prices for every constraint.Linear programming is viewed as a revolutionary development giving man the ability to state general objectives and to find, by means of the simplex method, optimal policy decisions for a broad class of practical decision problems of great complexity.
📐The lightest truss that can carry a load
Place six nodes on a grid, connect every pair by a candidate bar (15 bars), pin two nodes and hang 100 kN from another. Split each bar force into tension and compression ; equilibrium at the free nodes is linear in ; the steel volume is linear too.
linprog finds the minimum: a volume of 7,200 cm³ (56.5 kg of steel) using only 2 of the 15 bars — one diagonal tie in tension (223.6 kN) and one horizontal strut in compression (200 kN). The optimiser discovered the structure, not just its sizes. This 'ground structure' formulation (Dorn, Gomory and Greenberg, 1964) descends from Anthony Michell's 1904 theory of optimal frames and is the seed of modern topology optimisation.💡Where you will use this
Optimal Guidance: powered-descent guidance for reusable rockets is solved on board as a convex optimisation problem every fraction of a second; sequential convex programming handles the nonconvex parts. Structures: sizing, shape and topology optimisation under stress and displacement constraints. Power Systems: economic dispatch and optimal power flow are LPs and SQPs. Geotechnics: limit analysis of slopes and foundations can be written as linear programmes.
📚Further reading
- Jorge Nocedal and Stephen Wright, Numerical Optimization (2nd ed., Springer, 2006), chapters 12, 13 and 18 — the KKT conditions, the simplex method and sequential quadratic programming.
- Stephen Boyd and Lieven Vandenberghe, Convex Optimization (Cambridge University Press, 2004), chapter 5, 'Duality' — Lagrange multipliers and shadow prices; free online.
- George Dantzig, Linear Programming and Extensions (Princeton University Press, 1963) — by the inventor of the simplex method.
- W. S. Dorn, R. E. Gomory and H. J. Greenberg, 'Automatic design of optimal structures', Journal de Mécanique 3, 25–52 (1964) — the ground-structure method of the truss example.
↓But there is a problem
Every number in this course so far — loads, material properties, initial conditions, measurements — has been treated as exactly known. Even least squares (Unit 5) treated noise only through the residuals it left behind.
Reality is uncertain. Loads vary, materials vary, sensors drift, and a navigation system must decide where it is from measurements it knows are wrong. The last unit is about computing with uncertainty: generating randomness on a deterministic machine, propagating it through models, and combining uncertain predictions with uncertain measurements to know more than either alone.
It starts with a warning from the 1960s: one of the most widely used random-number generators in the world produced numbers that were not random at all.