Back to the on-screen lesson ·

The constraint matrix

Writing a model as $A$, $b$ and $c$; what a row says, what a column says, and why units must agree.

Paper packet. Every task here also exists on screen, where it is checked automatically; answers written on paper are not assessed by Nydus. When you are back at a device, enter your answers there.

1. What you will learn

By the end of this lesson you will be able to write a described model as a constraint matrix with one row per constraint and one column per variable, read a row as a limit and a column as an activity, compute what a plan uses and what it leaves, and check that both sides of every row are measured in the same unit.

2. What you already have

You can multiply a matrix by a vector and you have just written a model as a list of inequalities. This lesson does nothing but put that list into a rectangle, which is how every solver and every later unit of this course will read it.

3. Reading the rectangle

$A$ is the constraint matrix, $b$ the right-hand side, $c$ the cost or profit vector and $x$ the vector of decisions. A row of $A$ is one constraint; a column is one variable. The slack of a row is what its limit has left.

4. The model as a rectangle of numbers

Every linear program is four objects: $A$ with one row per constraint and one column per variable, $b$ with one entry per constraint, $c$ with one entry per variable, and $x$ the unknown. The whole model is $\max c^{T}x$ subject to $Ax \le b$, $x \ge 0$.

The entry $a_{ij}$ answers exactly one question: how much of resource $i$ does one unit of activity $j$ consume? Fix $i$ and you read a row — one limit, seen across every activity. Fix $j$ and you read a column — one activity, seen as its whole appetite. Both readings are useful and they are not interchangeable, and most early modelling errors are one read as the other.

One discipline makes the rectangle trustworthy: every row's two sides must be in the same unit. A row comparing grams with kilograms is arithmetic nothing will object to and everything downstream will believe.

Another way: steps

  1. Fix an order for the variables and never change it.
  2. One row per constraint, filled across in that order.
  3. Put the limits in $b$ and the objective coefficients in $c$.
  4. Check each row's units.

Another way: example

Chairs and tables, wood then labour: $A = \begin{pmatrix} 2 & 5 \\ 3 & 2 \end{pmatrix}$, $b = (100, 60)$, $c = (30, 50)$. The first column, $(2, 3)$, is everything one chair takes.

5. Where this usually goes wrong

Two entries get written into $A$ that do not belong there: the profit of a product, which is an entry of $c$, and the quantity to be made, which is an entry of $x$. The other recurring error is filling the second row in a different product order from the first, which silently swaps two columns and produces a model about a different factory.

6. Reading a row and a column of the same matrix

  1. $A = \begin{pmatrix} 2 & 5 \\ 3 & 2 \end{pmatrix}$ with rows wood and labour. Row one says $2x_1 + 5x_2 \le 100$: the wood limit.

    A row is one constraint.

  2. Column one is $(2, 3)$: a chair takes $2$ wood and $3$ hours. Nothing about how many chairs, and nothing about what a chair earns.

    A column is one activity.

  3. $Ax$ for the plan $x = (10, 10)$ is $(70, 50)$: wood used, hours used. Both are under their limits, so the plan is feasible.

    $Ax$ is the resources consumed.

7. Your turn: a bakery uses $3$ and $4$ units of flour and $1$ and $2$ eggs per loaf and per cake, with $60$ flour and $20$ eggs

  1. $A = \begin{pmatrix} 3 & 4 \\ 1 & 2 \end{pmatrix}$ with rows flour then eggs, and $b = (60, 20)$.

    Rows are resources.

  2. Your turn: work this step out. Its working is at the end of the packet.

    The first column $(3, 1)$ is a loaf's whole appetite: $3$ flour and $1$ egg.

8. Guided practice

A plant makes three products. One unit of them takes $2$, $6$ and $6$ units of wood, and $4$, $5$ and $2$ hours of labour. Write the constraint matrix $A$, wood first.

This task has no paper form; do it on a device.

9. Guided practice

Only chairs are made, so $y = 0$. A chair takes $2$ units of wood and there are $8$ units. Which values of $x$ satisfy the wood constraint and non-negativity?

This task has no paper form; do it on a device.

10. Guided practice

The plan makes $6$ chairs and $6$ tables. A chair takes $3$ wood and $3$ hours; a table takes $3$ wood and $3$ hours. Fill in what the plan uses and what it leaves.

UsedAvailableLeft over
Wood37
Labour45

11. Practice

A model has $7$ products and $4$ resources, so $A$ has $4$ rows and $7$ columns. What does one column of $A$ describe?

12. Practice

A model has $5$ decision variables and $2$ constraints besides non-negativity. Complete the description of $A$.

$A$ has r rows and c columns, so it holds e entries.

13. Somewhere new

A blending row was written with the coefficients in grams — $24$ grams of additive per litre — and its limit in kilograms: $9$ kilograms. Rewrite the limit in grams.

Answer:

14. Lesson test

Lesson test: one question per skill, one attempt each, no hints. Your answers are checked when you submit.

15. Test question

A plant makes three products. One unit of them takes $4$, $2$ and $5$ units of wood, and $2$, $5$ and $5$ hours of labour. Write the constraint matrix $A$, wood first.

This task has no paper form; do it on a device.

16. What you can do now

You can put a model into the matrix form the rest of the course uses, and read a row and a column apart. Say in your own words why a row whose two sides are in different units produces no error message.

Working for the steps left to you

7. Your turn: a bakery uses $3$ and $4$ units of flour and $1$ and $2$ eggs per loaf and per cake, with $60$ flour and $20$ eggs, step 2