The Matrix Form of a Linear Program

What you will be able to do

Given a linear program written in scalars, the learner can assemble A , b and c with correct shapes and write the program as min c T x subject to A x ≤ b , x ≥ 0 ; and given a program in matrix form, can recover a named constraint by its row and state what a named column contributes.

Orientation

A program with forty constraints and sixty variables fills a page in scalars and one line in matrix notation. The compression is useful on its own, and it is not the reason the notation is used.

The reason is that A x can be read two ways, and the later methods are stated in one or the other. Read by rows, the product recovers each constraint and answers whether a point is allowed. Read by columns, it exhibits the left-hand side as a combination of the columns of A , weighted by the variables, which is the reading a basis, a pivot and a reduced cost are all defined in.

A solver's interface asks for the same three objects: a coefficient array, a right-hand-side vector, a cost vector. Assembling them by hand once is what makes that interface legible.

Intuition

Two questions, one product

Rows answer whether a point is allowed. Row i holds the coefficients of constraint i , so the i th entry of A x is a i T x : the amount of resource i that the plan x consumes. Comparing it with b i decides that constraint. Checking feasibility is running down the rows.

Columns answer what a plan is made of. Column j holds everything variable j contributes, one entry per constraint. Running activity j at level x j consumes x j A j , and the total consumption is the sum:

A x = x 1 A 1 + ⋯ + x n A n .

So A x is a combination of the columns, with the decision variables as the weights.

The readings describe the same numbers and suit different questions. "The feasible region is an intersection of half-spaces" is a row statement. "A basis is a set of m independent columns" is a column statement. Chapters that seem to describe unrelated objects are often the two readings of one product, which is why moving between them is the competence rather than either one alone.

The shapes are not a convention to memorise; they are forced. A must have one column per variable for A x to be defined, and one row per constraint for the result to be comparable with b . A transposed A usually produces a product that is undefined, and when the dimensions happen to agree it computes something that answers no question in the problem.

Definition

The objects and their shapes

Beyond the statement itself, three details decide whether an assembled A , b and c are right.

Where each number goes. The coefficient of variable j in constraint i is a i j : the row index is the constraint, the column index is the variable. A variable absent from a constraint contributes 0 , and that zero must be written. A shorter row is a different program.

ObjectShapeIndexed by
A m × n constraint, then variable
b m constraint
c n variable
x n variable

Mixed directions. A x ≤ b requires every row to be a ≤ relation. A constraint written a T x ≥ β becomes − a T x ≤ − β , negating both the row and its right-hand side. An equality needs two rows, a T x ≤ β and − a T x ≤ − β , or a separate equality block A eq x = b eq . Dropping the direction rather than converting it is the error this produces.

Maximisation. max c T x and min ( − c ) T x have the same optimal x and objective values differing by sign. The matrix form as written above is a minimisation, so a maximisation is negated on the way in and the reported value negated on the way out.

What the form does not do. It records the program, unchanged. No constraint is removed, no feasible point is added, and the optimum is the same point it was in scalars.

Principle

Which reading each later result uses

The two readings of A x are not competing accounts. Each later result is stated in one of them, and knowing which removes most of the difficulty in following it.

ResultReadingStatement
Feasibility of a pointrowevery a i T x ≤ b i holds
Active constraints at a pointrowthe rows holding with equality
Feasible region as a polyhedronrowintersection of the half-spaces a i T x ≤ b i
Basic solutioncolumnchoose m independent columns, solve A B x B = b
Direction of a simplex stepcolumn u = A B − 1 A j , built from the entering column
Reduced costcolumn c ¯ j = c j − c B T A B − 1 A j
Unboundedness detected in a pivotcolumnno positive entry in the direction u

A pattern is visible in the table. Questions about a point are row questions: they take an x and test it. Questions about which plans are available are column questions: they select columns and solve for the weights.

The simplex method is a column method throughout, which is why it is stated for programs in the equality form A x = b rather than for A x ≤ b . Converting to that form is what makes the columns the objects being selected.

Worked example

Assembling a program, then reading it back

The program. A workshop makes three products. Each unit of product 1 uses 2 machine hours, 1 labour hour and 4 kg of material; product 2 uses 1, 2 and 3; product 3 uses 3, 2 and 5. Available: 120 machine hours, 90 labour hours, 250 kg. Unit profits are 30, 20 and 45. Maximise profit.

Step 1: fix the index order. Variables x 1 , x 2 , x 3 are units of each product. Constraints are ordered machine, labour, material. Both orders are arbitrary and both must then be used consistently.

Step 2: assemble. One row per constraint, one column per variable:

A = ( 2 1 3 1 2 2 4 3 5 ) , b = ( 120 90 250 ) , c = ( 30 20 45 ) .

A is 3 × 3 here because the counts coincide; that is not general.

Step 3: write the program.

max c T x subject to A x ≤ b , x ≥ 0 .

As a minimisation, min ( − c ) T x over the same set, with the reported value negated.

---

Step 4: read a row back. Row 2 is ( 1 , 2 , 2 ) with b 2 = 90 , so constraint 2 is

x 1 + 2 x 2 + 2 x 3 ≤ 90 ,

the labour hours. This is the check that the assembly is right: every row must translate back to a constraint of the original description.

Step 5: read a column back. Column 3 is ( 3 , 2 , 5 ) T : one unit of product 3 uses 3 machine hours, 2 labour hours and 5 kg. A column is an activity's resource profile, not a constraint.

Step 6: evaluate a plan both ways. Take x = ( 10 , 15 , 20 ) T .

By rows:

A x = ( 2 ( 10 ) + 1 ( 15 ) + 3 ( 20 ) 1 ( 10 ) + 2 ( 15 ) + 2 ( 20 ) 4 ( 10 ) + 3 ( 15 ) + 5 ( 20 ) ) = ( 95 80 185 ) .

Every entry is at most the corresponding entry of b = ( 120 , 90 , 250 ) T , so the plan is feasible. Profit is c T x = 30 ( 10 ) + 20 ( 15 ) + 45 ( 20 ) = 1500 .

By columns:

10 ( 2 1 4 ) + 15 ( 1 2 3 ) + 20 ( 3 2 5 ) = ( 20 10 40 ) + ( 15 30 45 ) + ( 60 40 100 ) = ( 95 80 185 ) .

The same vector. The readings are two groupings of one calculation, and agreeing on every entry is what makes them readings of one object rather than two procedures.

Step 7: a constraint in the wrong direction. Suppose the description also required total output of at least 12 units: x 1 + x 2 + x 3 ≥ 12 . To join A x ≤ b it is negated on both sides,

− x 1 − x 2 − x 3 ≤ − 12 ,

adding the row ( − 1 , − 1 , − 1 ) with right-hand side − 12 , and making A a 4 × 3 matrix. At x = ( 10 , 15 , 20 ) T the new row gives − 45 ≤ − 12 , which holds. Dropping the direction instead of negating it is the error this step exists to prevent.

Non-example

Four assemblies that are not the program

Comparing the vectors as wholes. A reader takes A x ≤ b to mean that A x is shorter than b , or that its entries sum to less. With A x = ( 95 , 80 , 185 ) T and b = ( 120 , 90 , 250 ) T both readings happen to agree with the entrywise one, which is why the mistake survives. Take A x = ( 135 , 90 , 225 ) T instead: the total is smaller than the total of b , and the plan is infeasible, because row 1 gives 135 > 120 . The inequality is m separate statements and one failure is enough.

A transposed coefficient matrix. Writing A with one row per variable and one column per constraint makes A x undefined unless the counts coincide. When they do coincide, a square A , as in the worked example, the product is defined and computes nothing the problem asked about: entry i becomes a sum over constraints of the coefficients of variable i , which is not a resource total. This is the failure that a units check catches and a shape check does not.

A dropped direction. A constraint x 1 + x 2 ≥ 12 entered as the row ( 1 , 1 , 0 ) with right-hand side 12 asserts x 1 + x 2 ≤ 12 : the feasible set is now bounded where the description bounded it below. The row is correct and the program is a different one.

Omitted zeros. Variable 3 absent from constraint 1 is recorded as a 13 = 0 . A row written with two entries because "the third does not appear" either fails to parse or silently shifts every later coefficient one place left, which renames the variables.

What unites the four is that each produces a well-formed object. Nothing about A , b or the arithmetic reports the fault; only translating a row back into the sentence it came from does.

Contrast

The same matrix, read two ways

Take

A = ( 2 1 3 1 2 2 4 3 5 ) , b = ( 120 90 250 ) ,

for three products and three resources.

Row readingColumn reading
What one line isa constraintan activity
Row 2 / column 2 saysproduct mix uses x 1 + 2 x 2 + 2 x 3 labour hours, at most 90 one unit of product 2 uses 1 machine hour, 2 labour hours, 3 kg
The question it answersis this plan allowed?what does this product cost in resources?
A x isa list of resource totals, one per constraint x 1 A 1 + x 2 A 2 + x 3 A 3
Used byfeasibility, active sets, the polyhedronbases, pivots, reduced costs

Both descriptions are of the same nine numbers. Row 2 and column 2 share only the entry a 22 = 2 , and they mean different things by it: in the row it is the labour used per unit of product 2, in the column it is the same quantity seen as part of product 2's resource profile. That the two readings agree on every entry is what makes the matrix one object rather than two tables.

The practical use of the distinction is diagnostic. A reader stuck on "what is A B − 1 A j " is usually reading rows in a column statement. Naming the reading in force is often the whole of the difficulty.

Next step

Practice The Matrix Form of a Linear Program

Practice this

Results update as you type. Use the up and down arrow keys to move between results, Enter to open one, and Escape to close.

Type to search.

Settings

Appearance

Interface density

Your record

Your progress is stored in this browser and nowhere else: an identifier, the answers you have given, the mastery states and review schedule derived from them, and the lesson you last opened. Clearing it makes you a new learner on this device. It cannot be undone, and it will not affect your appearance or density settings.

Focus timer

Focus--minutes remaining

Phase

Kept in this browser only, and used to label the session in your own history.

Today

Nothing recorded yet. Finish a focus session and it will appear here.

Settings

Focus sessions between long breaks.

Sessions you are aiming for in a day.

Notifications

Your history

Sessions are stored in this browser and nowhere else. They are not evidence and never reach your mastery record.