LP Lab Forged Tools

LP, as one procedure Formulation · Graphical · Simplex · Big-M — Winston Row-0 form. Read the boxes as a walk-through.

FORMULATECHOOSE SOLVER →   GRAPHICAL   or   standard form → [Big-M setup if any ≥ or =] → SIMPLEX LOOP   → READ ANSWER

STEP 1 · FORMULATE the model

// setup depends on the problem type
1. VARIABLES  define what you choose, precisely:
              xₕ = number of ___ per (unit & period)
2. OBJECTIVE  Max z (profit)  or  Min z / w (cost)
              z = c₁x₁ + c₂x₂ + ... + cₙxₙ
3. CONSTRAINTS  one per limit; sense by wording:
       "at most / available / capacity"  → ≤
       "at least / minimum / required"    → ≥
       "exactly / must equal"             → =
4. SIGNS      xₕ ≥ 0   (no negative amounts)
Step 1 always makes 3 things — variables, objective, constraints. Fill them in by problem type:
Type① Variables② Objective③ Constraints (the shape)
Product-mix
(MAX)
xᵢ = units of product i to make Max Σ (profit per unit)·xᵢ one ≤ per shared resource: Σ(amount used per unit)·xᵢ ≤ amount available. Optional demand cap xᵢ ≤ Dᵢ.
Diet / blend
(MIN)
xᵢ = amount of ingredient i used Min Σ (cost per unit)·xᵢ one ≥ per requirement: Σ(nutrient per unit)·xᵢ ≥ minimum needed.
Scheduling
(MIN)
xᵢ = number of workers who start on day i Min Σ xᵢ (total workers) one ≥ per day: (day i's starter + the 4 previous days' starters) ≥ staff needed that day. Week is cyclic — "previous days" wrap around (Monday's 4 previous days are Thu, Fri, Sat, Sun).
Multi-period
(MIN)
per period t: xₜ made, yₜ overtime, iₜ inventory (dₜ = demand) Min Σ (make + overtime + holding cost) one = balance per period: iₜ = iₜ₋₁ + xₜ + yₜ − dₜ (end = start + made − shipped); iₜ ≥ 0; give i₀. Also cap regular production each period: xₜ ≤ capacity (overtime yₜ usually uncapped).
Every type also: add the sign restrictions xᵢ ≥ 0. Then go to Step 2 to pick the solver.

STEP 2 · CHOOSE the solver

// pure decision — read the finished model
IF the model has exactly 2 decision variables:
     → GRAPHICAL  (Step 3)
ELSE:
     put every constraint into standard form:
         ≤   add slack     (+s)
         ≥   subtract surplus (−e)  AND add artificial (+a)
         =   add artificial (+a)
     IF any constraint was ≥ or =  (you added an artificial):
          → BIG-M   (Step 4 setup, then Step 5)
     ELSE (every constraint was ≤):
          → SIMPLEX (straight to Step 5)

STEP 3 · GRAPHICAL solve (2 variables only)

1. each constraint → a line (plot its two intercepts)
2. shade its feasible side: test the point (0,0)
      TRUE  → keep the origin side
      FALSE → keep the far side
   feasible region = overlap of all shaded sides (+ x ≥ 0)
3. list every corner:
      axis corners  +  line∩line (solve the 2×2 by elimination)
      keep only corners that satisfy ALL constraints
4. compute z at every corner
      max → largest z      min → smallest z

STOP → answer = that corner's (x₁,x₂) and its z
   IF two corners tie for best   → ALTERNATIVE OPTIMA (whole edge)
   IF the region is empty       → INFEASIBLE (no solution)
   IF region open the improving way → UNBOUNDED (max only)

STEP 4 · BIG-M setup (only if Step 2 sent you here)

// a prefix that gives the loop a starting basis
1. any RHS < 0 ?  multiply that row by −1 (flips its inequality)
2. (standard form already added  s / −e / a  in Step 2)
3. penalize the artificials in the objective:
       MIN:  z = (original) + M·a₁ + M·a₂ + ...
       MAX:  Z = (original) − M·a₁ − M·a₂ − ...
4. clear artificials out of Row 0 (they start basic):
       New Row 0 = Row 0 + M·(each artificial's row)   [− for max]
   Row 0 now carries symbolic M coefficients
→ go to Step 5

STEP 5 · THE SIMPLEX LOOP (Simplex & Big-M share this)

// Row 0:  z − c₁x₁ − c₂x₂ − ... = 0
// start: decision vars = 0, slacks = RHS, z = 0

REPEAT:
   ── optimality test ──
   MAX: every Row-0 coeff ≥ 0 ?   ┐ yes → STOP (optimal)
   MIN: every Row-0 coeff ≤ 0 ?   ┘ no  → keep going

   ── entering variable (nonbasic → basic) ──
   MAX: the MOST NEGATIVE Row-0 coefficient
   MIN: the MOST POSITIVE Row-0 coefficient
   IF that column has no positive entry → STOP: UNBOUNDED

   ── leaving variable (basic → nonbasic): ratio test ──
   each row with a positive entry: ratio = RHS ÷ entry
   smallest ratio → that row leaves
   pivot element = entering column ∩ leaving row

   ── pivot ──
   divide the pivot row by the pivot element (→ 1)
   clear that column in EVERY other row, including Row 0:
       new row = old row − (its entry in that column)×(new pivot row)

GO BACK TO REPEAT

STOP → READ THE ANSWER:
   basic variable = its RHS   ·   nonbasic variable = 0   ·   z = Row 0's RHS
   slack sᵢ = 0 → constraint binding   ·   sᵢ > 0 → that much unused
   IF Big-M and any artificial > 0 → INFEASIBLE (LP has no solution)
The loop, mapped onto a tableau (generic layout — no data)
BVzx₁x₂s₁s₂RHSRatio
z1d₁d₂00z
s₁010b₁b₁ ÷ •
s₂001b₂b₂ ÷ •
dⱼ = Row-0 coefficient of a variable · • = any number ·  pink  = the entering column ·  yellow  = the ratio test.
Optimality — scan Row 0's variable coeffs dⱼ. Max: all ≥ 0 → STOP · Min: all ≤ 0 → STOP.
Enter — the column whose dⱼ is most negative (max) / most positive (min) → the pink column.
Ratio test — down that column: RHS ÷ each positive entry; the smallest ratio picks the leaving row.
Pivot — the cell where the pink column meets the leaving row: make it 1, then clear the rest of that column, including Row 0.
Read — each basic variable (left column) = its RHS; z = Row 0's RHS.
Big-M tableau — same loop, extra columns + symbolic M (generic layout)
BVzx₁x₂s₁e₂a₂a₃RHSRatio
z1g₁g₂0−M00cM
s₁01000b₁
a₂00−110b₂
a₃00001b₃
gⱼ = a Row-0 coeff that carries an M-term (form pM−q) · cM = an M-multiple ·  purple  = artificial columns/rows (must end at 0). What differs from ordinary simplex:
Starting basis = s₁, a₂, a₃ — the ≥ and = rows start on their artificials (a ≤ row starts on its slack).
Row 0 already cleared in Step 4: artificial columns show 0; the x-coeffs and RHS carry M.
Same loop — but since M dominates, the entering rule attacks the artificial-heavy columns first, driving a₂, a₃ out.
Extra final check — at STOP: all artificials = 0 → feasible optimum; any artificial > 0 → LP infeasible.

Definitions & quick reference

bfs (basic feasible solution) = pick (#constraints) variables to be basic, set the rest to 0, and all come out ≥ 0. A bfs is a corner of the feasible region; simplex hops corner-to-corner.
basic = in the solution (value read off the RHS) · nonbasic = set to 0.
standard form = all constraints are equations, all variables ≥ 0.
slack (+s) = unused room on a ≤ · surplus (−e) = amount above a ≥ minimum · artificial (+a) = fake variable to start; penalty M forces it to 0.
binding = constraint holds with equality at the optimum (used up) · non-binding = slack remains · redundant = line never bounds the region.
convert: ≤ → +s · ≥ → −e + a · = → +a  |  enter: max most-neg / min most-pos Row 0  |  Big-M penalty: min +Ma / max −Ma.
Diagnostics at a glance: UNBOUNDED = entering column has no positive entry · INFEASIBLE = an artificial stays basic at > 0 · ALTERNATIVE OPTIMA = a nonbasic Row-0 coeff = 0 at the optimum · DEGENERATE = a basic variable = 0 (ratio-test tie).