Knowledge / Mathematics / Linear programming

Linear programming

Mathematics (B.Sc) · More core mathematics · free study notes for exams, placements and interviews

In short

Linear programming (LP) is the branch of optimisation that maximises or minimises a linear objective function of decision variables subject to linear equalities and inequalities. It is the workhorse of operations research: production planning, blending, logistics, portfolio and manpower scheduling all reduce to LP models. In Indian B.Sc/B.Tech syllabi (UGC CBCS "Linear Programming and Optimisation", AICTE "Operations Research") it carries formulation, graphical and simplex solutions, duality, transportation and assignment problems. It is examined in GATE (MA, and the OR section of ME/PI/CE), ISI/CMI and IIT JAM style questions, UGC-NET, Indian Statistical Service and actuarial exams, and appears in analytics placement rounds at Mu Sigma, ZS Associates, Flipkart, Delhivery, TCS Analytics and supply-chain roles.

Explained

Formulation and standard forms

Geometry: convexity and the basic feasible solution

Simplex method

  1. Convert to standard form; obtain a starting BFS (slacks as the initial basis).
  2. Build the simplex table: basis column, cB, the constraint coefficients, and the b column; compute Zⱼ = ΣcB·aᵢⱼ and the net evaluation row cⱼ − Zⱼ.
  3. Optimality test (max problem): optimal when all cⱼ − Zⱼ ≤ 0. Otherwise the most positive cⱼ − Zⱼ fixes the entering variable (key column). (For a min problem, enter on the most negative; equivalently use the Zⱼ − cⱼ convention consistently.)
  4. Minimum-ratio test: compute b_i/a_ik for a_ik > 0 only; the least ratio fixes the leaving variable (key row). If no a_ik > 0, the solution is unbounded.
  5. Pivot: divide the key row by the pivot element, then row-reduce the other rows so the key column becomes a unit vector. Repeat from step 3.
  6. Ties: tie in the entering column — choose arbitrarily; tie in the ratio (degeneracy) — Bland's rule or lowest-subscript rule avoids cycling.
  7. Artificial variables are needed when ≥ or = constraints leave no feasible slack basis:
    • Big-M (penalty) method: add artificials with cost −M (max) or +M (min), M arbitrarily large; if any artificial remains basic at a positive level in the optimum, the original problem is infeasible.
    • Two-phase method: Phase I minimises the sum of artificials; if the Phase I minimum > 0 the problem is infeasible, else drop the artificials and run Phase II on the real objective. Numerically safer than Big-M.
  8. Reading the table: cⱼ − Zⱼ = 0 for a non-basic variable at optimality signals alternative optima; the cⱼ − Zⱼ values of the slack columns give the dual variables (shadow prices) up to sign.

Duality

Sensitivity (post-optimality) analysis

Transportation and assignment problems

Extensions, computation and limitations

Key points

Formulas and examples

General LP: max (or min) Z = Σⱼ cⱼxⱼ subject to Σⱼ aᵢⱼxⱼ {≤, =, ≥} bᵢ, i = 1…m; xⱼ ≥ 0.
cⱼ = profit/cost per unit of activity j (₹/unit); aᵢⱼ = units of resource i per unit of activity j; bᵢ = resource availability (same units as aᵢⱼxⱼ); Z in ₹.
Standard form: Ax = b, b ≥ 0, x ≥ 0, with slack sᵢ ≥ 0 added to ≤ rows and surplus sᵢ ≥ 0 subtracted from ≥ rows.
Basic solution: xB = B⁻¹b (B = m×m basis matrix); simplex multipliers yᵗ = cBᵗ B⁻¹; reduced cost c̄ⱼ = cⱼ − yᵗAⱼ.
Optimality (max): c̄ⱼ ≤ 0 for all j. Entering: max c̄ⱼ. Leaving: min{ bᵢ/aᵢₖ : aᵢₖ > 0 }.
Dual pair: max cᵗx, Ax ≤ b, x ≥ 0 ↔ min bᵗy, Aᵗy ≥ c, y ≥ 0; at optimum cᵗx* = bᵗy*.
Complementary slackness: yᵢ*(bᵢ − Σⱼaᵢⱼxⱼ*) = 0 and xⱼ*(Σᵢaᵢⱼyᵢ* − cⱼ) = 0.
RHS sensitivity: ΔZ = yᵢ* × Δbᵢ, valid while the basis stays feasible.
Transportation: basic cells = m+n−1; MODI: uᵢ + vⱼ = cᵢⱼ (basic cells), dᵢⱼ = cᵢⱼ − uᵢ − vⱼ (non-basic); optimal when all dᵢⱼ ≥ 0.

Example 1 — Graphical method (product mix). A Pune workshop makes chairs (₹300 profit) and tables (₹500 profit). A chair needs 2 carpentry-hours and 1 finishing-hour; a table needs 4 carpentry-hours and 1 finishing-hour. Available: 240 carpentry-hours, 80 finishing-hours.

Model: max Z = 300x + 500y s.t. 2x + 4y ≤ 240, x + y ≤ 80, x, y ≥ 0.

Example 2 — Simplex, same problem. Standard form: 2x + 4y + s₁ = 240; x + y + s₂ = 80.

BasiscBxys₁s₂bRatio
s₁0241024060
s₂011018080
cⱼ−Zⱼ30050000Z=0

y enters (500 largest), s₁ leaves (ratio 60). Divide row 1 by 4 → (0.5, 1, 0.25, 0, 60); new row 2 = old row 2 − row 1 → (0.5, 0, −0.25, 1, 20).

BasiscBxys₁s₂bRatio
y5000.510.25060120
s₂00.50−0.2512040
cⱼ−Zⱼ500−1250Z=30,000

x enters, s₂ leaves. Row 2 ÷ 0.5 → (1, 0, −0.5, 2, 40); row 1 − 0.5×new row 2 → (0, 1, 0.5, −1, 40).

BasiscBxys₁s₂b
y500010.5−140
x30010−0.5240
cⱼ−Zⱼ00−100−100Z=32,000

All cⱼ−Zⱼ ≤ 0 → optimal: x = 40, y = 40, Z = ₹32,000, matching the graphical answer. Shadow prices from the slack columns: ₹100 per carpentry-hour and ₹100 per finishing-hour. Check: 100(240) + 100(80) = 24,000 + 8,000 = ₹32,000 = Z, as strong duality requires.

Example 3 — Dual and its verification. Dual of Example 1: min W = 240y₁ + 80y₂ s.t. 2y₁ + y₂ ≥ 300 (chair), 4y₁ + y₂ ≥ 500 (table), y₁, y₂ ≥ 0.

Example 4 — Transportation by VAM, then MODI check. Three plants (supplies 20, 30, 25 tonnes) ship to three depots (demands 25, 25, 25). Costs in ₹ hundred per tonne:

D1D2D3Supply
P146820
P253730
P365425
Demand25252575/75

Row penalties: P1 = 6−4 = 2, P2 = 5−3 = 2, P3 = 5−4 = 1. Column penalties: D1 = 5−4 = 1, D2 = 5−3 = 2, D3 = 7−4 = 3. Largest penalty = D3 → least cost in D3 is P3 (4) → allot min(25, 25) = 25 to P3D3. P3 and D3 are exhausted.

Example 5 — Assignment by the Hungarian method. Four engineers, four sites; travel cost in ₹ thousand:

S1S2S3S4
E110121911
E251078
E312141311
E4815119

Row reduction (subtract row minima 10, 5, 11, 8):

S1S2S3S4
E10291
E20523
E31320
E40731

Column reduction (column minima 0, 2, 2, 0):

S1S2S3S4
E10071
E20303
E31100
E40511

The minimum number of lines needed to cover all zeros is 4 — for example {column S1, row E1, column S3, row E3} — which equals n, so no further adjustment is required and a complete assignment on zeros exists. Assignment on zeros: E1→S2 (its only remaining zero), E2→S3, E3→S4, E4→S1.

MethodUseKey testComplexity note
Graphical2 variablesCorner-point / iso-profit lineInstant, illustrative only
SimplexGeneral LPcⱼ − Zⱼ ≤ 0Fast in practice, exponential worst case
Big-M / Two-phase≥ and = constraintsArtificial out of basisTwo-phase is numerically safer
Dual simplexAdded constraints, reoptimisationFeasibility restoredCore of branch and bound
MODI (transportation)m×n cost minimisationdᵢⱼ ≥ 0Integer solution guaranteed
Hungariann×n assignmentn covering linesO(n³)
Branch and bound / cutting planesInteger variablesBound pruning / Gomory cutsNP-hard in general

Where it is used

Interview questions

Common mistakes

Related topics

Graph theory basics · Numerical methods · Matrix algebra and systems of linear equations · Convex optimisation and nonlinear programming · Game theory and decision analysis · Queuing theory and inventory models

Open in the Knowledge reader →Find jobs →