Auditing an LP Formulation for Correctness

Systematic checks for catching modeling errors in a linear program before solving: unit consistency, inequality direction, coefficient-vs-variable-definition alignment, and completeness of the constraint set.

Step 1 of 157%

Tutorial

Auditing Units in the Objective and Constraints

Before solving an LP, audit it. The first and most mechanical check is dimensional consistency.

Every term inside a single sum must share the same units. Every comparison (LHS vs. RHS, or each term of the objective) must produce the same units. If the objective is in dollars, every term cjxjc_j x_j must work out to dollars. If a constraint's RHS is in labor-hours, every term aijxja_{ij} x_j on the LHS must be in labor-hours.

The coefficient aija_{ij} on xjx_j must carry the units of (RHS units) per (units of xjx_j).

For instance, suppose a bakery makes x1x_1 loaves of bread and x2x_2 cakes, where bread uses 0.50.5 kg of flour per loaf, cake uses 0.30.3 kg per cake, and 5050 kg of flour is available. The flour constraint is

0.5x1+0.3x250.0.5\, x_1 + 0.3\, x_2 \le 50.

Units check: (kg/loaf)(loaves)+(kg/cake)(cakes)=kg(\text{kg}/\text{loaf})(\text{loaves}) + (\text{kg}/\text{cake})(\text{cakes}) = \text{kg}, and the RHS is in kg. ✓

Now consider a flawed version that someone wrote in a hurry:

0.5x1+3x250,0.5\, x_1 + 3\, x_2 \le 50,

where the 33 was copied from a different data row meaning "minutes of oven time per cake." The LHS mixes kg and minutes — the audit catches this immediately.

navigate · Enter open · Esc close · ⌘K/Ctrl K toggle