Logistics and Freight Modelling
IISc SL 225 · “Tour Guide”

How deliveries, depots and routes are planned with mathematics

This is a companion to SL 225 Logistics and Freight Modeling. The course assumes linear programming, integer programming and algorithms. Here those are built up first, and then the course itself: facility location, branch and bound, the travelling salesman problem, vehicle routing, cutting planes, column generation and branch and price.

Based on SL 225 Logistics and Freight Modeling at IISc, taught by Prof. Tarun Rambha.

The course is self-contained. Foundation parts A to D cover the maths, modelling, graph and code tools the lectures use; if you already have them, start at Part 0. Parts 0 to 12 follow this year's lectures, from linear programming to branch and price, and end with the Walmart case study; the last part has exam-level practice.

The route

    The lectures use a compact language: sums, subsets, vectors, matrices and systems of equations. This part sets out that language with small delivery examples. It supports Lectures 1 to 6, where every formula is written in it.

    You need: solving one equation and plotting a line.

    Symbols and sums: reading the language of the slides

    A model is a short sentence written in symbols: a sum to add things up, a "for all" to repeat a rule, and a set to say which things we mean.

    Every lecture slide is built from these few symbols. Once you can read them, a page of formulas becomes a page of plain statements.

    It is like a shopping list in shorthand: "2 kg of each of these 5 items" is one line instead of five.

    A running example: choosing parcels

    A courier can carry parcels $1,2,3,4,5$ in one trip. Parcel $j$ earns value $c_j$ and weighs $a_j$ kg. For each parcel we make a yes/no decision: $x_j=1$ if we take it, $x_j=0$ if we leave it. A variable that can only be $0$ or $1$ is called a binary variable.

    The total value of what we take is $c_1x_1+c_2x_2+c_3x_3+c_4x_4+c_5x_5$. Writing five terms is fine, but for 500 parcels we need a shorthand.

    $$\sum_{j=1}^{n} c_j x_j \;=\; c_1x_1 + c_2x_2 + \dots + c_nx_n$$

    The letter under the $\Sigma$ is a counter. It starts at the bottom value, goes up by one each time, and stops at the top value. Each step adds one term.

    Symbols you will meet
    $\sum$
    add up a list of terms
    $\forall$
    "for all": the rule after it holds once for every value listed
    $j \in S$
    $j$ is a member of the set $S$
    $S\subseteq T$
    every member of $S$ is also in $T$ ($S$ is a subset of $T$)
    $|S|$
    the number of members of $S$
    $\{0,1\}$
    the set containing just $0$ and $1$; "$x\in\{0,1\}$" means binary
    $\mathbb{Z}_+$
    the whole numbers $0,1,2,\dots$
    $\le,\ \ge$
    at most, at least

    A constraint is a rule the decision must obey. Suppose the courier's bag holds at most $10$ kg. The constraint is $\sum_{j=1}^{5} a_jx_j \le 10$. Notice that the sum only adds the weight of parcels with $x_j=1$, because a parcel with $x_j=0$ contributes $a_j\cdot 0 = 0$.

    The symbol $\forall$ repeats a rule. If there are three customers $i=1,2,3$ and each must be served by exactly one of two vans $j=1,2$, with $x_{ij}=1$ meaning van $j$ serves customer $i$, we write $$\sum_{j=1}^{2} x_{ij} = 1 \qquad \forall\, i\in\{1,2,3\}.$$ This one line stands for three separate constraints: $x_{11}+x_{12}=1$, $x_{21}+x_{22}=1$ and $x_{31}+x_{32}=1$.

    A sum can also run over two counters at once. $\sum_{i=1}^{2}\sum_{j=1}^{3} i\,j$ means: for each $i$, add $i\cdot 1+i\cdot 2+i\cdot 3$, then add the results for $i=1$ and $i=2$.

    Careful: in $x_{ij}$ the two small numbers are two separate indices, not "$i$ times $j$". Read $x_{23}$ as "x, customer 2, van 3". A double sum $\sum_i\sum_j$ adds every pair $(i,j)$ once.
    Try it

    Press the buttons to take or leave each parcel. Watch the sums on the readout and find the most valuable choice that still fits in 10 kg. Notice how a parcel you leave contributes $0$ to both sums.

    Courier data: values $c=(4,7,2,9,5)$, weights $a=(3,5,1,6,2)$, bag limit 10 kg. Is the choice $x=(1,0,1,0,1)$ allowed, and what is its value?

    1. Write the weight sum with the data: $3\cdot1+5\cdot0+1\cdot1+6\cdot0+2\cdot1$.

      Each term is weight times decision. Zeros switch the term off.

    2. Add: $3+0+1+0+2=6$. Since $6\le 10$ the choice is allowed.

      The constraint is $\sum a_jx_j\le 10$, so we compare the total with 10.

    3. Value: $4\cdot1+7\cdot0+2\cdot1+9\cdot0+5\cdot1=4+2+5=11$.

      Same pattern with $c$ instead of $a$.

    4. Answer: allowed, value $11$. (A better choice exists: parcels 1, 2 and 5 weigh $3+5+2=10$ and are worth $4+7+5=16$.)

      This yes/no "which items to take" problem is the knapsack problem of Lecture 3.

    Go deeper: why write $\forall$ at all?

    A model with 50 customers and 20 vans has 50 assignment rules. Writing them as one line with $\forall i$ makes the pattern visible, and it is exactly how modelling code is written: a loop over $i$ that adds one constraint each time.

    Compute $\sum_{j=1}^{4} j^2$.

    Write out the four terms $1^2+2^2+3^2+4^2$.

    $1+4+9+16=30$.

    Values are $c=(4,7,2,9)$ and the decisions are $x=(1,0,1,1)$. What is $\sum_{j=1}^{4} c_jx_j$?

    Multiply term by term first. The second term is $7\cdot 0$.

    $4+0+2+9=15$.

    Compute the double sum $\sum_{i=1}^{2}\sum_{j=1}^{3} i\,j$.

    For $i=1$ the inner sum is $1+2+3$. For $i=2$ it is $2+4+6$.

    $(1+2+3)+(2+4+6)=6+12=18$. This equals $(1+2)(1+2+3)=3\cdot 6$.

    How many subsets of $\{1,2,3\}$ have at least 2 members?

    List the subsets of size 2 first, then size 3.

    Size 2: $\{1,2\},\{1,3\},\{2,3\}$. Size 3: $\{1,2,3\}$. Total $3+1=4$.

    The rule $\sum_{j=1}^{4} x_{ij}=1\ \ \forall\, i\in\{1,\dots,6\}$ is how many separate constraints?

    $\forall$ repeats the rule once per listed value of $i$.

    One for each $i=1,\dots,6$, so 6 constraints, each with 4 terms.

    • Expand a sum by hand for a small $n$ before trusting it.
    • Say a constraint aloud in words: "for every customer, the vans serving them add up to one".
    • Mixing up the index you sum over with the index after $\forall$.
    • Reading $x_{ij}$ as a product of $i$ and $j$.
    1. $\sum$ adds a list of terms; the counter under it says which terms.
    2. $\forall$ repeats one rule for every listed index, so one line can mean many constraints.
    3. A binary variable $x_j\in\{0,1\}$ switches a term on or off, which is how yes/no decisions enter a model.

    With $x=(1,1,0,1)$ and $a=(2,5,4,3)$, what is $\sum_{j=1}^{4} a_jx_j$?

    14
    That adds every weight. Parcels with $x_j=0$ should contribute nothing.
    10
    $2+5+0+3=10$: the parcel with $x_3=0$ is switched off.
    7
    Check which entries of $x$ are 1 before adding.

    What does $\sum_{i=1}^{3}x_{ij}\le 1\ \ \forall j\in\{1,2\}$ express?

    Customer $j$ is served at most once by each of three vans.
    Look at which index is summed and which is repeated by $\forall$.
    For each of two positions $j$, the three variables $x_{1j},x_{2j},x_{3j}$ add up to at most one: two constraints.
    The sum runs over $i$; $\forall j$ makes one constraint for each of $j=1,2$.
    There is a single constraint adding all six variables.
    $\forall$ creates one constraint per value of $j$, not one overall.

    $S=\{2,5\}$ and $T=\{1,2,3,5\}$. Which statement is true?

    $T\subseteq S$
    The subset symbol points at the smaller set.
    $|S|=|T|$
    Count the members of each set.
    $S\subseteq T$ and $|T|=4$
    Every member of $S$ is in $T$, and $T$ has four members.

    Vectors and matrices: many numbers, handled as one

    A vector is an ordered list of numbers, and a matrix is a table of numbers. Together they let one short line describe dozens of constraints.

    The lectures write every linear programme as $\min\ c^\top x$ subject to $Ax\ge b$. If you cannot read that line, nothing after it will make sense.

    It is like a spreadsheet: the column of quantities you control, a column of unit prices, and a table of recipes that turns one into the other.

    Vectors

    A vector is a list of numbers in a fixed order, such as $x=(x_1,x_2)$. You can see it as a point on a plane, or as an arrow from the origin to that point. A vector with $n$ entries lives in $\mathbb{R}^n$. In these notes lowercase bold or plain letters ($\x$, $\b$, $c$) are vectors and capital letters ($A$, $B$) are matrices.

    Two operations are used constantly. Adding two vectors adds matching entries: $(1,2)+(3,-1)=(4,1)$. Scaling multiplies every entry by a number: $3\cdot(1,2)=(3,6)$.

    For two vectors of the same length, $$c^\top x=c_1x_1+c_2x_2+\dots+c_nx_n=\sum_{j=1}^{n}c_jx_j.$$ The small $\top$ ("transpose") only says "write $c$ as a row so it can multiply the column $x$".

    This is the sum from the last chapter in its compact form. If $c_j$ is the cost per unit of product $j$ and $x_j$ is how many units you buy, then $c^\top x$ is your total cost. That is why LPs are written $\min c^\top x$: the objective is a dot product.

    Try it

    Drag the orange point $x$. The dashed line joins every point with the same value of $c^\top x$. Switch between the three vectors $c$ and notice that the dashed line always meets the purple arrow $c$ at a right angle, and that moving along the direction of $c$ raises the value fastest.

    Matrices and Ax

    A matrix is a rectangular table. A matrix $A$ with $m$ rows and $n$ columns is called $m\times n$, and $A_{ij}$ is the entry in row $i$, column $j$. The product $Ax$ takes the dot product of every row of $A$ with $x$, giving a list of $m$ numbers.

    For $A=\begin{pmatrix}1&2\\3&-1\end{pmatrix}$ and $x=(2,3)$: row 1 gives $1\cdot2+2\cdot3=8$ and row 2 gives $3\cdot 2+(-1)\cdot3=3$, so $Ax=(8,3)$.

    Now the key idea. Suppose a bakery has two recipes, and row $i$ of $A$ says how much of ingredient $i$ each unit of each recipe uses. Then $Ax$ is the list of total ingredients used, and the inequality $Ax\ge b$ or $Ax\le b$ compares each total with a requirement or a stock level. One matrix inequality is $m$ ordinary constraints, one per row.

    $$\min\ c^\top x\quad\text{s.t.}\quad Ax\ge b,\ \ x\ge 0$$ means: choose the quantities $x$ (non-negative) so that, row by row, the totals $Ax$ meet the requirements $b$, and the total cost $c^\top x$ is as small as possible. "s.t." is short for "subject to".

    Two customers need deliveries and there are three routes. Row $i$ of $A$ marks which routes pass customer $i$: $A=\begin{pmatrix}1&1&0\\0&1&1\end{pmatrix}$. Customer 1 needs at least 2 visits and customer 2 at least 1, so $b=(2,1)$. If we run routes $x=(1,1,0)$ (route 3 unused), is $Ax\ge b$?

    1. Take row 1 times $x$: $1\cdot1+1\cdot1+0\cdot0=2$.

      Each row is one constraint, so each row gets its own dot product.

    2. Take row 2 times $x$: $0\cdot1+1\cdot1+1\cdot0=1$.

      Same step for the second row.

    3. So $Ax=(2,1)$. Compare with $b=(2,1)$: $2\ge2$ and $1\ge1$, so both rows hold.

      A vector inequality holds only if every entry satisfies it.

    Go deeper: the transpose and the shape rule

    $A$ is $m\times n$ and $x$ has $n$ entries, so $Ax$ has $m$ entries. The inner sizes must match. The transpose $A^\top$ swaps rows and columns, so it is $n\times m$; you will meet $A^\top y\le c$ when we study duality in Lecture 2.

    Compute $(2,-1,3)\cdot(4,5,1)$.

    Multiply matching entries, then add: $2\cdot4$, $(-1)\cdot5$, $3\cdot1$.

    $8-5+3=6$.

    Unit costs are $c=(5,3)$ and you buy $x=(10,4)$ units. What is the total cost $c^\top x$?

    $5\cdot10+3\cdot4$.

    $50+12=62$.

    For $A=\begin{pmatrix}1&2\\3&-1\end{pmatrix}$ and $x=(2,3)$, find the two entries of $Ax$.

    Each entry is the dot product of one row of $A$ with $x$.

    Row 1: $1\cdot2+2\cdot3=8$. Row 2: $3\cdot2+(-1)\cdot3=3$. So $Ax=(8,3)$.

    The line $Ax\le b$ with $A$ a $2\times 5$ matrix stands for how many separate constraints, each with how many variables? Enter the number of constraints.

    One constraint per row of $A$.

    $A$ has 2 rows, so there are 2 constraints, each involving up to 5 variables (one per column).

    For $A=\begin{pmatrix}2&1\\1&3\end{pmatrix}$, $b=(5,5)$ and $x=(2,1)$, is $Ax\ge b$ true?

    Compute $Ax$ first, then compare entry by entry.

    $Ax=(2\cdot2+1\cdot1,\ 1\cdot2+3\cdot1)=(5,5)$. Both entries are $\ge5$, so yes (with equality).

    • Check sizes before multiplying: columns of $A$ must equal entries of $x$.
    • Read $Ax\ge b$ as a stack of ordinary inequalities, one per row.
    • Multiplying $A$ by $x$ entry by entry instead of row by row.
    • Assuming the inequality holds when it holds in only some rows.
    1. The dot product $c^\top x=\sum c_jx_j$ is a total, such as a total cost; it is the objective of an LP.
    2. $Ax$ is the list of the dot products of each row of $A$ with $x$.
    3. $Ax\ge b$ means every row satisfies its own inequality: a whole model in one line.

    $A$ is a $3\times 4$ matrix. What is the size of $x$ in $Ax$, and of $Ax$?

    $x$ has 3 entries and $Ax$ has 4.
    Columns of $A$ must match the entries of $x$.
    $x$ has 4 entries and $Ax$ has 3.
    Four columns need four entries, and each of the three rows produces one entry.
    Both have 3 entries.
    $x$ has one entry per column.

    Moving the point $x$ along the dashed line in the widget keeps $c^\top x$ the same. Why?

    The line is parallel to $c$.
    Try it: moving in the direction of $c$ changes the value fastest.
    The line is perpendicular to $c$, so moving along it does not move you "in the direction of $c$".
    The dot product measures how far $x$ goes along $c$, and that stays constant along a perpendicular line.
    The value always stays zero.
    The value equals $c^\top x$ and is generally non-zero.

    If $c=(2,1)$ and $x=(3,4)$, what is $c^\top x$?

    $(6,4)$
    The dot product is a single number, not a vector.
    10
    $2\cdot3+1\cdot4=10$.
    7
    That adds the entries of $c$ and $x$ instead of multiplying matching pairs.

    Solving linear systems: independence, rank and the inverse

    A system of linear equations $Ax=b$ can have one solution, none, or infinitely many. Linear independence and rank tell you which, and row operations find the answer.

    The simplex method of Lecture 1 is nothing but repeatedly solving $Bx_B=b$ for a chosen set of columns $B$. You must be able to do this by hand.

    It is like a recipe puzzle: with two independent recipes you can hit any target mix, but with two copies of the same recipe you can only hit targets on one line.

    Two views of the same system

    Take $x+y=4$ and $x-y=2$. In the row view each equation is a line, and a solution is a point on both lines, here $(3,1)$. There are three possible pictures: the lines cross at one point, the lines are parallel and never meet, or the two equations describe the same line.

    Try it

    Use the three preset buttons, then move the sliders. Notice that the number $a_1b_2-b_1a_2$ (called the determinant) is zero exactly when the lines are parallel or identical.

    In the column view we read the same system differently. Write $A=\begin{pmatrix}2&1\\1&3\end{pmatrix}$ with columns $A_{\cdot1}=(2,1)$ and $A_{\cdot2}=(1,3)$. Then $Ax=b$ asks: how much of each column must we add together to reach $b$? $$x_1\begin{pmatrix}2\\1\end{pmatrix}+x_2\begin{pmatrix}1\\3\end{pmatrix}=\begin{pmatrix}5\\5\end{pmatrix}.$$ Simplex uses the column view, so it is worth practising.

    Try it

    Set $x_1$ and $x_2$ so that the tip of the combination lands on the green ring $b$. Then switch to $A_2=(4,2)$, which points the same way as $A_1$, and try to reach $b$ again. Notice that you cannot.

    Vectors are linearly independent if the only way to combine them to get the zero vector is to scale every one of them by zero. If one of them can be built from the others, they are dependent. For two vectors in the plane: independent means they do not lie on a common line through the origin.

    The rank of a matrix is the largest number of linearly independent columns (equivalently, rows) it has. A square $n\times n$ matrix with rank $n$ is called invertible: its columns are independent, its determinant is not zero, and $Ax=b$ has exactly one solution for every $b$.

    For an invertible matrix $B$ there is a matrix $B^{-1}$, the inverse, with $B^{-1}B=I$ where $I$ is the identity matrix (ones on the diagonal, zeros elsewhere). Multiplying $Bx=b$ by $B^{-1}$ gives $x=B^{-1}b$. This exact formula, $x_B=B^{-1}b$, is on the slides for basic solutions in Lecture 1.

    For a $2\times2$ matrix $\begin{pmatrix}p&q\\r&s\end{pmatrix}$ with determinant $D=ps-qr\ne0$ the inverse is $\dfrac1D\begin{pmatrix}s&-q\\-r&p\end{pmatrix}$.

    Row operations (Gauss–Jordan)

    For bigger systems we use three allowed moves that never change the solution: swap two rows, multiply a row by a non-zero number, add a multiple of one row to another. The goal is to turn $A$ into the identity; the right-hand column then becomes the solution. Simplex tableaux in Lecture 2 are exactly this table of numbers.

    Solve $x+y+z=6$, $\ 2x-y+z=3$, $\ x+2y-z=2$ by row operations.

    1. Write the augmented table (coefficients, then right-hand side): rows $(1,1,1\,|\,6)$, $(2,-1,1\,|\,3)$, $(1,2,-1\,|\,2)$.

      The table carries all the information of the three equations.

    2. Clear the first column: $R_2\leftarrow R_2-2R_1$ gives $(0,-3,-1\,|\,-9)$; $R_3\leftarrow R_3-R_1$ gives $(0,1,-2\,|\,-4)$.

      We want zeros below the first pivot so the remaining rows only involve $y$ and $z$.

    3. Swap rows 2 and 3, then $R_3\leftarrow R_3+3R_2$: row 3 becomes $(0,0,-7\,|\,-21)$, so $z=3$.

      Using the row with the coefficient 1 as pivot avoids fractions.

    4. Back-substitute: row 2 reads $y-2z=-4$, so $y=-4+6=2$. Row 1 reads $x+y+z=6$, so $x=6-2-3=1$.

      Clearing entries above the pivots is the Jordan part of Gauss–Jordan.

    5. Check in the original equations: $1+2+3=6$, $\ 2-2+3=3$, $\ 1+4-3=2$. The solution is $(1,2,3)$.

      Always verify: it catches arithmetic slips.

    Careful: a square matrix with a zero determinant is not invertible. Then $Ax=b$ has either no solution or infinitely many. Never divide by a determinant before checking it is not zero.
    Go deeper: basis, and why simplex cares

    A basis of the plane is any two independent vectors: every point is then a unique combination of them. In an LP with $m$ equality constraints, a basic solution picks $m$ independent columns $B$, sets all other variables to zero, and solves $Bx_B=b$. Lecture 1 shows that corner points of the feasible region are exactly the basic solutions that are also non-negative.

    Solve $2x+y=7$ and $x-y=2$.

    Add the two equations to eliminate $y$.

    Adding: $3x=9$, so $x=3$. Then $y=x-2=1$. Check: $6+1=7$.

    How many solutions do $2x+4y=6$ and $x+2y=3$ have?

    Divide the first equation by 2 and compare.

    Dividing the first by 2 gives $x+2y=3$: the same line, so infinitely many solutions. (The determinant $2\cdot2-4\cdot1=0$.)

    What is the rank of $\begin{pmatrix}1&2&3\\2&4&6\\1&0&1\end{pmatrix}$?

    Row 2 is a multiple of row 1. How many independent rows remain?

    Row 2 equals $2\times$ row 1, so it adds nothing. Row 3 is not a multiple of row 1. Two independent rows, so rank 2.

    Let $B=\begin{pmatrix}2&1\\5&3\end{pmatrix}$, whose inverse is $B^{-1}=\begin{pmatrix}3&-1\\-5&2\end{pmatrix}$. Solve $Bx=(4,9)$ using $x=B^{-1}b$.

    Multiply each row of $B^{-1}$ by $b=(4,9)$.

    $x_1=3\cdot4-1\cdot9=3$ and $x_2=-5\cdot4+2\cdot9=-2$. Check: $2\cdot3+(-2)=4$ and $5\cdot3+3\cdot(-2)=9$.

    Find the combination $x_1(2,1)+x_2(1,3)=(5,5)$.

    Write it as two equations: $2x_1+x_2=5$ and $x_1+3x_2=5$.

    From the first, $x_2=5-2x_1$. Substituting: $x_1+15-6x_1=5$, so $x_1=2$ and $x_2=1$. Check: $(4,2)+(1,3)=(5,5)$.

    • Check a solution in every original equation.
    • Look at the determinant (or the rank) first: it tells you which of the three cases you are in.
    • Calling two vectors independent when one is a multiple of the other.
    • Applying a row operation to only part of a row.
    1. A system has one solution, none or infinitely many; for a square matrix this depends on whether the columns are independent (non-zero determinant).
    2. If $B$ is invertible, $Bx=b$ is solved by $x=B^{-1}b$, or by row operations on the augmented table.
    3. The column view asks for the right amounts of each column to reach $b$: this is how the simplex method thinks.

    Why can $A_1=(2,1)$ and $A_2=(4,2)$ not reach $b=(5,5)$?

    The numbers are too small.
    Scaling can make them as large as you like; the issue is direction.
    $A_2=2A_1$, so every combination lies on the line through $A_1$, and $(5,5)$ is not on it.
    Dependent columns span only a line, not the plane.
    $b$ must have integer entries.
    Nothing requires integers in the column view.

    A square system $Ax=b$ has determinant 0. Which statement is certainly true?

    There is exactly one solution.
    That requires the determinant to be non-zero.
    $A^{-1}$ exists.
    An inverse exists only when the determinant is not zero.
    There is not exactly one solution: either none or infinitely many.
    Dependent columns remove the uniqueness.

    Which is not an allowed row operation in Gauss–Jordan?

    Swap two rows.
    This is allowed.
    Multiply one row by 0.
    Multiplying by zero destroys information and can change the solution set.
    Add 3 times row 1 to row 2.
    This is allowed.

    Parcel values are $c=(3,6,4)$ and the decisions are $x=(0,1,1)$. What is $\sum c_jx_j$?

    13
    That adds every value; parcel 1 has $x_1=0$.
    10
    $0+6+4=10$.
    9
    Re-add the two active parcels.

    A model has $A$ with 4 rows and 6 columns. How many constraints and variables does $Ax\le b$ involve?

    6 constraints, 4 variables
    Rows are constraints, columns are variables.
    4 constraints, 6 variables
    One constraint per row, one variable per column.
    24 constraints, 6 variables
    The rows are not multiplied by the columns.

    If $Bx=b$ and $B$ is invertible, what is $x$?

    $bB^{-1}$ in any order
    The order of matrix multiplication matters.
    $B^{-1}b$
    Multiply both sides on the left by $B^{-1}$.
    $b/B$
    Matrices have no division symbol; use the inverse.

    Two lines are parallel but not identical. What does the system of their equations have?

    One solution
    One solution needs the lines to cross.
    No solution
    Parallel and distinct lines never meet.
    Infinitely many solutions
    That happens only when the lines coincide.

    Before any algorithm, someone has to turn a messy request ("get the parcels out, cheaply, with the vans we have") into a precise model. This part shows how, and then draws the simplest linear programmes on paper so you can see what the lectures later prove. It supports Lecture 0 (requirements as constraints), Lecture 1 (the feasible region) and the integer problems of Lectures 3 and 4.

    You need: plotting a line and solving two equations. The sums of Part A help but are not required.

    From words to a model: variables, objective, constraints

    A model has three parts: the decisions you control, the single number you want to make small or large, and the rules that limit you.

    Every problem in this course, from vehicle routing to facility location, is first a paragraph of words. If you cannot write the three parts down, no solver can help you.

    It is like writing an order for a caterer: how many of each dish (decisions), what you are trying to save or earn (goal), and the budget, the oven and the guest count (limits).

    A running example: van trips at a depot

    A depot must deliver at least $400$ parcels today. It can run two kinds of trip. A small van trip carries $30$ parcels and costs ₹500. A large van trip carries $80$ parcels and costs ₹1000. There are only $10$ drivers, and each trip uses one driver. Only $4$ large vans exist, and each makes one trip today.

    How many trips of each kind should the depot run to keep the cost as low as possible? Ask three questions in this order.

    1. What do I decide? The number of small trips and the number of large trips.
    2. What do I want? The lowest total cost.
    3. What stops me? The parcel target, the drivers and the large vans.

    A decision variable is a quantity you are free to choose, written as a letter. The objective is the formula for the one number you want to minimise or maximise. A constraint is a rule that the decision must satisfy. Fixed numbers from the problem (costs, capacities, demands) are the data or parameters. A choice of values that obeys every constraint is feasible; the feasible choice with the best objective is optimal.

    Writing the depot model

    Let $x_1$ be the number of small van trips and $x_2$ the number of large van trips. Each term below is "per-trip number times number of trips", so the units agree.

    The cost is $500x_1+1000x_2$ rupees. The parcels delivered are $30x_1+80x_2$. The three rules become inequalities, and trips cannot be negative: $$\begin{aligned}\min\quad & 500x_1+1000x_2 \\ \text{s.t.}\quad & 30x_1+80x_2\ge 400 \quad\text{(at least 400 parcels)}\\ & x_1+x_2\le 10 \quad\text{(at most 10 drivers)}\\ & x_2\le 4 \quad\text{(at most 4 large vans)}\\ & x_1,\ x_2\ge 0.\end{aligned}$$ Here "s.t." means "subject to". The last line is easy to forget, and it is a real rule: you cannot run $-2$ trips.

    Try it

    Choose $x_1$ and $x_2$ with the sliders (or click a point of the grid). The readout checks each rule and shows the cost. Find several feasible plans, and try to find the cheapest. Notice how the green feasible points sit together in one region of the grid.

    At least, at most, exactly

    The wording of a rule decides the inequality. "At least" is a floor ($\ge$), "at most" is a ceiling ($\le$), and "exactly" is an equation ($=$). The number mentioned always counts as allowed.

    Try it

    Switch between the three rules and slide $x$ over $4$. Notice that the boundary value $4$ is allowed in all three, and that "exactly" allows only that one value.

    Yes/no decisions

    Some decisions are not quantities but choices: take this parcel or leave it, open this depot or not. For these we use a binary variable: $x_j=1$ means yes and $x_j=0$ means no. A sum such as $\sum_j w_jx_j$ then adds up only the weights of the items you took (as in Part A). Binary variables turn many "either/or" rules into short inequalities. For example, "at most one of consignments $A$ and $C$" is $x_A+x_C\le 1$, because $1+1=2$ is excluded while $1+0$, $0+1$ and $0+0$ are allowed.

    A truck can carry $100$ boxes. Consignment $A$ has $40$ boxes and pays ₹900, $B$ has $35$ boxes and pays ₹700, $C$ has $50$ boxes and pays ₹1000, $D$ has $30$ boxes and pays ₹500. Each is taken whole or not at all. $A$ and $C$ go to the same dock, and the dock accepts only one of them. Write the model and find the best choice.

    1. Decisions: $x_A,x_B,x_C,x_D\in\{0,1\}$, with $x_j=1$ if consignment $j$ is loaded.

      Each consignment is a yes/no choice, so each gets a binary variable.

    2. Objective: maximise $900x_A+700x_B+1000x_C+500x_D$.

      Revenue only counts for consignments with $x_j=1$.

    3. Capacity: $40x_A+35x_B+50x_C+30x_D\le 100$. Dock: $x_A+x_C\le 1$.

      The first is an "at most" rule on boxes. The second forbids loading both $A$ and $C$.

    4. List the choices that fit in 100 boxes and obey the dock rule: $\{A,B\}$ (75 boxes, ₹1600), $\{A,D\}$ (70 boxes, ₹1400), $\{B,C\}$ (85 boxes, ₹1700), $\{B,D\}$ (65 boxes, ₹1200), $\{C,D\}$ (80 boxes, ₹1500), and single consignments. $\{A,C\}$ is excluded by the dock rule, and no three consignments fit under both rules (for example $\{A,B,D\}$ needs 105 boxes).

      With four binary variables there are only $2^4=16$ choices, so we can check them all.

    5. The best choice is $\{B,C\}$, worth ₹1700. Without the dock rule $\{A,C\}$ would give ₹1900 with 90 boxes.

      A constraint can only make the best value worse or leave it unchanged. Here it costs ₹200.

    Careful: make the variable match the unit in the data. If the costs are "per trip" then $x$ must count trips, not parcels and not vans. If $x_1$ counted parcels carried, "$500x_1$" would charge ₹500 per parcel. Also check that every term of one constraint has the same unit: parcels with parcels, hours with hours.
    Go deeper: hidden constraints

    Real problems hide rules in the words. "Each trip uses one driver" produced the driver constraint. "Four large vans exist" capped $x_2$. Whole trips only ($x_1,x_2$ integers) is another hidden rule, which Chapter B.3 shows can change the answer. A good habit is to read the paragraph once more after writing the model and ask of every sentence: "which line of my model says this?"

    In the depot model, what is the cost of running $x_1=3$ small trips and $x_2=4$ large trips?

    Multiply each cost per trip by the number of trips and add.

    $500\cdot 3+1000\cdot 4=1500+4000=5500$ rupees.

    For the plan $x_1=3$, $x_2=4$, how many parcels are delivered and how many trips (drivers) are used? Is the plan feasible?

    Parcels are $30x_1+80x_2$; trips are $x_1+x_2$.

    Parcels: $90+320=410\ge 400$. Trips: $3+4=7\le 10$. Large vans: $4\le 4$. All rules hold, so the plan is feasible.

    Which line says "the depot must deliver at least 400 parcels"?

    "At least" is a floor. Also check that the left side counts parcels, not trips.

    The left side $30x_1+80x_2$ is the number of parcels, and "at least 400" means $\ge 400$. The second choice is a ceiling; the third adds trips and compares them with a parcel count.

    In the truck example, consignments $B$ and $D$ are loaded ($x=(0,1,0,1)$ for $A,B,C,D$). How many boxes are carried, and what is the revenue? (Boxes $40,35,50,30$; revenues ₹900, ₹700, ₹1000, ₹500.)

    Only the entries with $x_j=1$ contribute.

    Boxes: $35+30=65\le 100$. Revenue: $700+500=1200$ rupees. The dock rule $x_A+x_C=0\le 1$ also holds.

    Suppose the depot runs exactly 6 trips in total, of which exactly 2 are large. How many parcels are delivered?

    "Exactly" fixes both numbers: $x_2=2$ and $x_1=6-2$.

    $x_2=2$, $x_1=4$. Parcels: $30\cdot4+80\cdot2=120+160=280$. (This misses the target of 400, so such a plan is not feasible.)

    • Name each variable with its unit: "$x_1$ = number of small van trips today".
    • Re-read the paragraph and tie every sentence to a line of the model.
    • Include non-negativity, and say "at least", "at most" or "exactly" aloud before choosing $\ge$, $\le$ or $=$.
    • Letting $x$ count one thing while the cost data is per another.
    • Mixing units inside one constraint (hours with minutes, kilograms with tonnes).
    • Forgetting a rule that was only implied, such as the number of large vans.
    1. A model is decision variables, one objective and a set of constraints; the data are the fixed numbers.
    2. "At least" is $\ge$, "at most" is $\le$, "exactly" is $=$, and the boundary value is allowed.
    3. A yes/no decision is a binary variable, and rules such as "at most one of these two" become short inequalities like $x_A+x_C\le 1$.

    In the depot problem, which of these is a decision variable (as opposed to data)?

    The number of small van trips run today
    The depot chooses it, so it is a variable.
    The cost of ₹500 per small van trip
    That number is given in the problem; the depot cannot choose it.
    The target of 400 parcels
    This is a requirement from the customers, which is data.

    There are 10 drivers and every trip needs exactly one driver, but not every driver has to work. Which constraint is right?

    $x_1+x_2=10$
    This forces all 10 drivers to work.
    $x_1+x_2\ge 10$
    This would demand at least 10 trips, which is a floor, not a ceiling.
    $x_1+x_2\le 10$
    Trips cannot exceed the number of drivers, and fewer is allowed.

    Which constraint says "consignments $A$ and $C$ cannot both be loaded" for binary variables?

    $x_A+x_C=1$
    This also forces one of them to be loaded, which the sentence does not say.
    $x_A+x_C\ge 1$
    This would force at least one to be loaded.
    $x_A+x_C\le 1$
    The sum is 2 only when both are loaded, and that is excluded.

    Drawing a two-variable LP: region, objective line and corner

    With two variables a linear programme is a picture: each constraint cuts the plane along a line and keeps one side, and the best point is found by sliding the objective line.

    Lecture 1 describes the feasible region of an LP in exactly this way before moving to many variables. Seeing the two-variable picture makes the later algebra meaningful.

    It is like fencing a field with straight fences: each constraint is one fence, the allowed land is what is left inside, and you walk to the best corner of the field.

    A new example: standard and express shipments

    A packing crew handles two kinds of shipment. A standard shipment (count $x_1$) needs $1$ packing hour and $3$ forklift hours. An express shipment (count $x_2$) needs $2$ packing hours and $1$ forklift hour. The crew has $16$ packing hours and $18$ forklift hours. Profit is $3$ per standard and $4$ per express shipment, in units of ₹100. Maximise profit: $$\max\ 3x_1+4x_2\quad\text{s.t.}\quad x_1+2x_2\le 16,\ \ 3x_1+x_2\le 18,\ \ x_1,x_2\ge0.$$

    One constraint is a line with a shaded side

    The equation $x_1+2x_2=16$ is a straight line. Find two points on it, for example the intercepts $(16,0)$ and $(0,8)$, and join them. The inequality $x_1+2x_2\le16$ allows that line and one of its two sides. To find which, test one point not on the line, such as the origin: $0+0\le 16$ is true, so the side containing the origin is allowed.

    Try it

    Pick a constraint and drag the test point. The shaded side is the allowed side. Notice how the readout flips from "ok" to "above" exactly as the point crosses the line. Then choose "all four" to see where all rules hold together.

    The feasible region is the set of all points that satisfy every constraint at once. Geometrically it is the overlap of all the allowed sides. A corner (vertex) is a point of the region where two of the boundary lines cross.

    Sliding the objective line

    The profit $3x_1+4x_2$ equals a given number $k$ along a straight line (called a level line). Different $k$ give parallel lines. Bigger $k$ moves the line up and to the right, in the direction of the arrow $(3,4)$. Start with a line far below the region, and slide it in the direction of increasing profit. The last point of the region it touches is the best plan.

    That last touching point is a corner of the region (or a whole edge, when the level line is parallel to that edge). This is why, in a two-variable LP, it is enough to compare the corners.

    Try it

    Slide the line level $k$ upward and watch the line turn from red (misses the region) to green (touches it) and back. Then change the profits $c_1,c_2$ and the two limits and see which corner wins. Try $c_1=1$, $c_2=2$ (the objective line becomes parallel to the packing edge, so a whole edge ties). Finally, try the other two buttons for an infeasible and an unbounded model.

    When there is no best plan

    Two things can go wrong. The model is infeasible if no point satisfies all the constraints, for instance $x_1+x_2\le 2$ together with $x_1+x_2\ge5$: the allowed sides do not overlap. The model is unbounded if the region extends forever in a direction that improves the objective, for example maximising profit with only a minimum order and no limits. Infeasibility signals contradictory rules; unboundedness usually signals a forgotten constraint.

    Solve $\max\ 3x_1+4x_2$ s.t. $x_1+2x_2\le16$, $3x_1+x_2\le18$, $x_1,x_2\ge0$ by the corner method.

    1. Draw the lines. Packing: through $(16,0)$ and $(0,8)$. Forklift: through $(6,0)$ and $(0,18)$. Together with the two axes these bound the region.

      The origin satisfies both inequalities, so the allowed side of each line is the one containing the origin.

    2. Find the corners. On the axes: $(0,0)$, $(6,0)$ (where the forklift line meets $x_2=0$) and $(0,8)$ (where the packing line meets $x_1=0$). The two lines meet where $x_1+2x_2=16$ and $3x_1+x_2=18$. From the second, $x_2=18-3x_1$; substituting gives $x_1+36-6x_1=16$, so $x_1=4$ and $x_2=6$.

      Each corner is the intersection of two boundary lines, so it is the solution of two equations. The points $(16,0)$ and $(0,18)$ are not corners, because they break the other constraint.

    3. Check the corner $(4,6)$: $4+12=16\le16$ and $12+6=18\le 18$. It is feasible and sits on both lines.

      A corner found by solving equations must still be tested against every constraint.

    4. Evaluate the profit at each corner: $(0,0)\to0$, $(6,0)\to18$, $(4,6)\to12+24=36$, $(0,8)\to32$.

      The best point of a two-variable LP is at a corner, so the best corner value is the answer.

    5. The best plan is $x_1=4$ standard and $x_2=6$ express shipments, profit $36$ (that is ₹3600). Both resources are fully used.

      Confirm with the widget: with the default settings the plum ring sits at $(4,6)$ with best value $36$.

    Go deeper: why the best point is at a corner

    Inside the region the objective $c_1x_1+c_2x_2$ changes at the same constant rate in every direction. So from any interior point you can always move in the direction of increasing profit and improve, until a boundary stops you. Sliding along that boundary, the rate is again constant, so you continue to the end of the edge: a corner. Lecture 1 proves the statement for any number of variables, and the simplex method of Part 1 is a way of walking from corner to corner.

    Where does the line $x_1+2x_2=16$ meet the $x_1$-axis and the $x_2$-axis? Give the two intercept values.

    On the $x_1$-axis set $x_2=0$. On the $x_2$-axis set $x_1=0$.

    With $x_2=0$: $x_1=16$. With $x_1=0$: $2x_2=16$, so $x_2=8$. The points are $(16,0)$ and $(0,8)$.

    Is the point $(5,5)$ allowed by the constraint $3x_1+x_2\le18$?

    Substitute the point and compare the result with 18.

    $3\cdot5+5=20>18$, so the point is on the forbidden side.

    Find the corner where the lines $x_1+2x_2=16$ and $3x_1+x_2=18$ cross.

    Solve the second equation for $x_2$ and substitute into the first.

    $x_2=18-3x_1$, so $x_1+36-6x_1=16$ and $x_1=4$, $x_2=6$. Check: $4+12=16$ and $12+6=18$.

    Now change the profits to $5$ per standard and $1$ per express shipment. For the same region (corners $(0,0)$, $(6,0)$, $(4,6)$, $(0,8)$), which $x_1$ gives the best corner, and what is the best value of $5x_1+x_2$?

    Evaluate $5x_1+x_2$ at all four corners.

    $(0,0)\to0$, $(6,0)\to30$, $(4,6)\to26$, $(0,8)\to8$. The best corner is $(6,0)$ with value $30$. Cheap standard shipments now dominate.

    Maximise $x_1+x_2$ subject to $x_1+x_2\ge3$ and $x_1,x_2\ge0$. What happens?

    Is there any rule stopping $x_1$ from growing?

    The point $(3,0)$ is feasible, and so is $(100,0)$, with value 100, and so on. Nothing limits the objective from above, so the problem is unbounded.

    • Test the origin (or another easy point) to decide which side of a line is allowed.
    • Compute corners by solving two equations, then check them against all the other constraints.
    • Evaluate the objective at every feasible corner and compare.
    • Treating every line crossing as a corner: it must also be feasible.
    • Shading the wrong side because the inequality sign was misread.
    • Forgetting $x_1,x_2\ge0$, which makes the axes boundaries too.
    1. Each constraint is a line with one allowed side; the feasible region is the overlap of all allowed sides.
    2. Sliding the objective line in the improving direction until it last touches the region shows that the best point is at a corner (or along a whole edge).
    3. No overlap means infeasible; a region that runs off in an improving direction means unbounded.

    For the constraint $2x_1+3x_2\ge 6$, you test the origin. Which side of the line is allowed?

    The side containing the origin.
    Substitute $(0,0)$: is $0\ge 6$ true?
    The side not containing the origin.
    $0\ge6$ is false, so the origin is forbidden and the other side is allowed.
    Both sides.
    A line separates allowed points from forbidden ones.

    A model has the constraints $x_1+x_2\le2$ and $x_1+x_2\ge5$ (and $x\ge0$). What do you conclude?

    It is unbounded.
    Unbounded needs feasible points; look for any.
    It is infeasible.
    A sum cannot be at most 2 and at least 5 at once, so the region is empty.
    The optimum is at $(2,5)$.
    Test that point in both constraints.

    You slide the level line of a maximise-profit objective in the direction of increasing profit. Where is the best plan?

    At the last corner (or edge) the line touches before leaving the region.
    After that point nothing feasible is better.
    At the centre of the region.
    The line keeps improving until it leaves the region, so it ends at the boundary.
    At the origin.
    The origin has the lowest profit, not the highest.

    What makes a model linear, and why whole numbers change things

    A model is linear when every variable appears on its own, multiplied by a constant. A variable is continuous if it may take any value, and integer if only whole numbers make sense.

    The lectures solve linear programmes quickly with simplex, but vans and parcels come in whole numbers. Lecture 4 starts from the fact that simply rounding the LP answer can fail.

    It is like a recipe scaled to 2.5 cakes: fine for flour, but you cannot bake half of a van.

    Linear or not?

    In a linear programme the objective and every constraint use only terms of the form (number) $\times$ (one variable), added together, and compared with a number. Two ideas hide in that: doubling a variable doubles its effect (proportionality), and effects of different variables just add up (additivity).

    • Linear: $4x_1-7x_2\le12$, or $500x_1+1000x_2$. A constant added to the whole objective, such as ₹2000 for hiring the depot once, is also fine.
    • Not linear: $x_1x_2\ge4$ (a product of variables), $x_1^2+x_2\le9$ (a square), $\sqrt{x_1}$ or $1/x_1$.

    A quick test for one variable: the cost of one more trip should be the same whatever the number of trips so far. That is the same as saying the graph of cost against trips is a straight line.

    Try it

    For each cost formula, move $x$ and read the cost of the next trip and of the trip after. Notice which formulas give the same extra cost every time (the three red points on a straight line) and which do not. Notice that "$2000+300x$" passes the test even though its line does not start at zero.

    Careful: a fixed charge, such as "₹2000 if the depot is used at all, whatever the volume", looks like a jump, not a line. It can still be modelled linearly with a yes/no variable $y\in\{0,1\}$ and the cost term $2000y$. That is the idea behind the facility-location models of Lecture 3 (a binary variable per depot).

    Continuous or integer?

    A continuous variable can take any real value in its range (litres of fuel, hours worked). An integer variable must be a whole number (vans, trips, parcels), and a binary variable is an integer variable limited to $0$ and $1$. A model with integer variables is an integer programme (IP); if every variable is continuous it is an LP. The LP obtained by dropping the integer requirement from an IP is its LP relaxation.

    Because the relaxation allows more points, its best value is never worse than the IP's. For a maximisation problem, $\text{LP value}\ge\text{IP value}$; for minimisation, $\text{LP value}\le\text{IP value}$. In the depot model of Chapter B.1 the LP relaxation says run $2\tfrac23$ small trips and $4$ large trips, at cost $5333.33$. Whole trips need $3$ small trips and cost ₹5500.

    Why not just round?

    It is tempting to solve the LP and round the answer. Two things go wrong, and both appear in Lecture 4: the rounded point can break a constraint (infeasible), or it can be feasible but far from the best integer plan. Look at an example. A depot chooses how many refrigerated vans ($x_1$) and open vans ($x_2$) to dispatch. Dock hours and driver hours are each limited to $25$, and the profit is $7$ and $5$ units per van: $$\max\ 7x_1+5x_2\quad\text{s.t.}\quad 4x_1+6x_2\le25,\ \ 6x_1+4x_2\le25,\ \ x_1,x_2\ge0\ \text{integer}.$$

    Try it

    The gold dot is the LP optimum. The red circle is that point rounded to the nearest whole numbers, and the gold circle is it rounded down. The green circle is the true best integer plan. Click grid points to test them, and switch to "Vans B" for a second example. Notice that the best integer plan is not next to the LP optimum.

    Max versus min, and units once more

    Maximising and minimising are two sides of one coin: maximising $z$ gives the same plan as minimising $-z$, with the value's sign flipped, so $\max z=-\min(-z)$. When a problem says "profit" you maximise; when it says "cost" or "distance" you minimise. Always check the direction against the question: a bin packing model minimises the number of bins, never maximises it.

    Finally, every constraint should balance in units. If a coefficient is in minutes per job and the limit is in hours, convert one of them first, or the model will quietly allow plans that are $60$ times too long or too short.

    For the vans model above, show that rounding the LP optimum fails, and find the best integer plan.

    1. The LP optimum: by symmetry of the two constraints, try $x_1=x_2=t$. Then $10t=25$, so $t=2.5$ and the point $(2.5,2.5)$ lies on both lines. Its value is $7\cdot2.5+5\cdot2.5=30$. The other corners $(0,0)$, $(25/6,0)$ and $(0,25/6)$ give $0$, about $29.17$ and about $20.83$, so $(2.5,2.5)$ is the best corner with LP value $30$.

      This uses the corner method of the previous chapter. $2.5$ vans is not a possible plan.

    2. Round up to $(3,3)$: $4\cdot3+6\cdot3=30>25$, so this plan is infeasible. The nearer options $(3,2)$ and $(2,3)$ also fail: $6\cdot3+4\cdot2=26>25$ and $4\cdot2+6\cdot3=26>25$.

      Each rounded plan must be tested in every constraint.

    3. Round down to $(2,2)$: $20\le25$ in both constraints, and the value is $14+10=24$.

      Rounding down is safe here, but it gives up $30-24=6$ units.

    4. Check all whole-number plans. The feasible ones include $(4,0)$ with value $28$, $(3,1)$ with value $26$, $(2,2)$ with value $24$ and $(1,3)$ with value $22$. Checking $(4,0)$: $16\le25$ and $24\le25$. No feasible plan beats $28$.

      The integer region is small, so we can list it. Real problems need smarter methods, which is the subject of Lecture 4.

    5. The best integer plan is $(4,0)$, worth $28$, which is $2$ below the LP value $30$ and quite unlike the LP point $(2.5,2.5)$.

      As expected for a maximisation, the integer value does not exceed the LP value.

    Go deeper: when does rounding work?

    If the numbers are large (hundreds of trucks), rounding the LP answer changes the value by a tiny fraction, and it is often good enough in practice. For small counts, as here, or when yes/no decisions are involved, it is unreliable. Some special models (assignment and shortest-path problems) have the lucky property that the LP optimum is already integer. Lecture 3 and Part 6 show which ones.

    Which of these constraints is allowed in a linear programme?

    Look for a product of two variables or a power of a variable.

    $4x_1-7x_2\le12$ has only constants times single variables. $x_1x_2$ is a product of variables and $x_1^2$ is a square, so both are non-linear.

    A constraint reads $30x_1+45x_2\le 8$, where $30$ and $45$ are minutes per job and $8$ is the working day in hours. Rewrite the right-hand side in minutes.

    One hour is 60 minutes.

    $8\cdot60=480$, so the consistent constraint is $30x_1+45x_2\le480$.

    In the vans model the LP value is $30$ and the best integer plan has value $28$. By how much does the LP value overestimate what whole vans can achieve?

    Subtract.

    $30-28=2$ units. For a maximisation, the LP value is always an upper limit for the integer value.

    Over some region, the largest value of $2x_1-5x_2$ is $12$. What is the smallest value of $-2x_1+5x_2$ over the same region?

    Use $\min(-z)=-\max z$.

    $-2x_1+5x_2=-(2x_1-5x_2)$, so its minimum is $-12$, at the same point.

    How many whole-number plans $(x_1,x_2)$ with $x_1,x_2\ge0$ satisfy both $4x_1+6x_2\le25$ and $6x_1+4x_2\le25$?

    Count the feasible values of $x_2$ for each $x_1=0,1,2,3,4$.

    $x_1=0$: $x_2\le4$ (5 plans). $x_1=1$: $6x_2\le21$ and $4x_2\le19$, so $x_2\le3$ (4 plans). $x_1=2$: $x_2\le2$ (3 plans). $x_1=3$: $4x_2\le7$, so $x_2\le1$ (2 plans). $x_1=4$: $4x_2\le1$, so $x_2=0$ (1 plan). Total $5+4+3+2+1=15$.

    • Compare the LP value with the integer value: it is a bound (upper for maximise, lower for minimise).
    • After rounding, re-test every constraint.
    • Check that each constraint has one unit throughout.
    • Rounding the LP answer and calling it optimal.
    • Multiplying two decision variables and expecting an LP.
    • Maximising a cost or minimising a profit by mistake.
    1. A linear model has only constants times single variables, added and compared with numbers; products, squares and roots break linearity.
    2. Dropping integrality gives the LP relaxation, whose value can never be worse than the integer value.
    3. Rounding the LP optimum can be infeasible or far from the best integer plan, which is why integer programming needs its own methods.

    An LP relaxation of a cost-minimising integer problem has optimal value 100. What can you say about the integer optimum?

    It is at most 100.
    The relaxation has more feasible points, so it can only be cheaper.
    It is exactly 100.
    Equality happens only when the LP optimum happens to be integer.
    It is at least 100.
    Minimising over fewer points cannot give a lower value.

    Why can we not simply round the LP optimum $(2.5,2.5)$ to $(3,3)$ in the vans example?

    Rounding is never allowed in any model.
    It is allowed, but the result must be checked.
    $(3,3)$ breaks the constraints, since $4\cdot3+6\cdot3=30>25$.
    A rounded point must be tested, and this one is infeasible.
    $(3,3)$ has a lower profit than the LP optimum.
    Its profit would be higher, which is exactly why it is tempting; the issue is feasibility.

    Which statement about the cost "₹2000 to hire the depot plus ₹300 per trip" is true?

    It is non-linear because the line does not pass through zero.
    A constant added to a linear function is still allowed.
    It is non-linear because it contains a constant.
    Linear objectives may contain a constant; only products and powers of variables are excluded.
    It is linear: every extra trip costs ₹300.
    The extra cost is constant, which is the test for linearity.

    A team defines $x$ as "parcels delivered by vans", but the cost data is ₹500 per trip. What is wrong with writing the cost as $500x$?

    The variable counts parcels but the cost is per trip, so the units do not match.
    The variable must count trips for $500x$ to be a cost.
    Nothing, since cost is always proportional to parcels.
    Check what the 500 multiplies.
    The cost should be subtracted.
    The sign is not the issue; the unit is.

    Is $(4,4)$ feasible for $x_1+x_2\le8$ and $2x_1+x_2\le12$ with $x\ge0$?

    No, since $x_1+x_2=8$ is not strictly below 8.
    The boundary value is allowed in an "at most" constraint.
    Yes, since $4+4=8\le8$ and $8+4=12\le12$.
    Both constraints hold with equality, so it lies on both lines: a corner.
    No, since $2x_1+x_2=12$ exceeds 8.
    That is a different constraint with its own limit of 12.

    For a maximisation problem, how do the LP relaxation value and the integer optimum compare?

    The integer optimum is at least the LP value.
    The relaxation has more points to choose from.
    They are always equal after rounding.
    Rounding can break feasibility.
    The LP value is at least the integer optimum.
    Dropping a restriction cannot lower the best achievable profit.

    A model has 3 constraints (besides $x\ge0$) in 2 variables, written $Ax\le b$. What is the shape of $A$?

    $3\times2$
    One row for each of the 3 constraints, one column for each of the 2 variables.
    $2\times3$
    Rows are constraints, columns are variables.
    $3\times3$
    The number of columns equals the number of variables.

    Lectures 3, 5 and 6 speak about graphs, cuts, matchings, tours and "NP-hard" problems as if everyone already knew them. This part covers that background: what a graph is and how to read the cut notation $\delta(S)$ and $E(S)$, how two classic algorithms (shortest paths and cheapest spanning trees) work and why they are fast, and why a problem like the travelling salesman problem is a different kind of beast.

    You need: Part A (sums and sets, in particular $\sum$, $\in$ and $\subseteq$). No programming and no earlier optimisation theory.

    Graphs and networks: the picture behind every routing model

    A graph is a set of points (nodes) joined by lines (edges), and it is the standard way to describe a road network, a delivery area or a set of possible assignments.

    Lecture 5 writes $\delta(S)$ and $E(S)$ on almost every slide, and Lecture 3 asks for matchings and node covers. These are simply names for parts of a picture, and once you can see the picture the formulas become easy to read.

    It is like a metro map: it ignores the real geography and keeps only what matters, which stations exist, which are joined, and how long each hop takes.

    The running story: one depot, five customers

    A van starts at a depot and must serve five customers. The roads between them form the map below. We give the places the numbers $0,1,\dots,5$, with $0$ the depot, and write on every road its length in kilometres. Everything in this part uses this same map.

    A graph $G=(V,E)$ has a set $V$ of nodes (also called vertices) and a set $E$ of edges. An edge joins two nodes and is written $\{u,v\}$ or simply $uv$. Each edge $e$ can carry a number $c_e$, its weight (a cost, a length or a time). Our map has $|V|=6$ nodes and $|E|=8$ edges, where $|\cdot|$ counts members of a set.

    When roads are two-way the graph is undirected. When a road is one-way we use a directed graph $G=(N,A)$ whose members are nodes $N$ and arcs $A$; an arc $(i,j)$ may be used from $i$ to $j$ but not back. Both kinds appear in the lectures, which write $G=(V,E)$ for undirected graphs and $G=(N,A)$ for directed ones.

    Words for the picture
    degree of $v$
    the number of edges that touch node $v$
    path
    a walk from one node to another that never visits a node twice
    cycle
    a path that comes back to where it started (three or more nodes, no node repeated except the start)
    connected
    there is a path between every two nodes
    tree
    a connected graph with no cycle; a tree on $n$ nodes always has exactly $n-1$ edges
    spanning tree
    a tree that uses all the nodes of $G$ and some of its edges
    complete graph $K_n$
    $n$ nodes with an edge between every pair; it has $n(n-1)/2$ edges

    In any undirected graph, $$\sum_{v\in V}\deg(v)=2\,|E|.$$ Every edge has two ends, so it is counted exactly twice when we add the degrees of all nodes. In particular the sum of the degrees is even, so the number of nodes with odd degree is always even.

    Storing a graph

    A computer keeps a graph in one of two ways. The adjacency list stores, for each node, the list of its neighbours with the edge weights. The adjacency matrix is a table with a row and a column for every node; entry $(u,v)$ holds the weight of edge $uv$ (a dash means "no edge"). For our map:

    nodeneighbours (weight)012345
    01 (4), 2 (5)–45–––
    10 (4), 2 (2), 3 (3)4–23––
    20 (5), 1 (2), 4 (4)52––4–
    31 (3), 4 (6), 5 (4)–3––64
    42 (4), 3 (6), 5 (3)––46–3
    53 (4), 4 (3)–––43–

    A real road network has millions of junctions but each junction touches only a handful of roads. The list stores only the roads that exist, while the matrix would need a million million entries. That is why road software uses lists, and why the matrix is mostly a notation for small examples and for complete graphs such as the distance tables of a TSP.

    Subsets of nodes, cuts and inner edges

    Lecture 5 constantly asks "which edges lie inside this group of nodes, and which leave it?". Take any subset of nodes $S\subseteq V$ and write $S^c=V\setminus S$ for the nodes outside it.

    $E(S)$ is the set of edges with both ends in $S$. The cut $\delta(S)$ is the set of edges with exactly one end in $S$ (the other end is in $S^c$). For a single node, $\delta(v)=\delta(\{v\})$ is the set of edges touching $v$, so $|\delta(v)|=\deg(v)$.

    If every edge has a value $x_e$, write $x(F)=\sum_{e\in F}x_e$ for the total over a set $F$ of edges. So $x(\delta(S))$ adds $x_e$ over all edges leaving $S$.

    Two facts are worth keeping in mind. First, $\delta(S)=\delta(S^c)$: an edge that leaves $S$ is an edge that enters $S^c$, so the cut looks the same from either side. Second, every edge of the graph is in exactly one of three places: inside $S$, inside $S^c$, or in the cut $\delta(S)$.

    Why does Lecture 5 care? A tour of all customers is one loop. If you split the customers into any group $S$ and the rest, the loop must leave $S$ and come back, so it uses at least two edges of $\delta(S)$. That single sentence, written as $x(\delta(S))\ge 2$, is the heart of the TSP model. Here we only learn to read it.

    Careful: $E(S)$ and $\delta(S)$ are sets of edges, not of nodes. Only edges that actually exist in the graph count. Also $E(S)$ means "inside $S$", while $E$ alone means all edges.
    Try it

    Drag the nodes anywhere (the lengths stay fixed). Tap a node, or use the number buttons, to put it in or take it out of $S$. Watch the green edges, which form $E(S)$, and the orange dashed edges, which form $\delta(S)$, and read the cut cost. Then switch to the second mode and delete edges to see how the degrees and the Euler-circuit test react. Notice that the degrees always add up to twice the number of edges, and that $\delta(S)$ never changes if you swap $S$ for the other nodes.

    On the road map, let $S=\{1,2,3\}$. List $E(S)$ and $\delta(S)$, and find the total length of the edges leaving $S$.

    1. Go through all eight edges and ask where each end lies. The edges are $01,02,12,13,24,34,35,45$ and $S^c=\{0,4,5\}$.

      Every edge must be classified, so we do not forget any.

    2. Both ends in $S$: edge $12$ and edge $13$. So $E(S)=\{12,13\}$.

      Nodes 1, 2, 3 are all in $S$ for these two edges. Edge $23$ does not exist, so it is not listed.

    3. Exactly one end in $S$: $01$ (0 outside), $02$, $24$ (4 outside), $34$, $35$. So $\delta(S)=\{01,02,24,34,35\}$.

      These are the edges a van would use to enter or leave the group $\{1,2,3\}$.

    4. Lengths: $4+5+4+6+4=23$.

      The cut cost is just the sum of the weights over $\delta(S)$.

    5. Check: edge $45$ has both ends in $S^c$, so it is in neither set. That accounts for $2+5+1=8$ edges.

      Inside $S$, in the cut and inside $S^c$ must add to all of $E$.

    Two famous kinds of tour

    A Hamiltonian cycle visits every node exactly once and returns to the start. Finding the cheapest one is the travelling salesman problem (Lecture 5). On our map $0\to1\to3\to5\to4\to2\to0$ is a Hamiltonian cycle: every edge exists and every node appears once. Its length is $4+3+4+3+4+5=23$.

    An Euler circuit uses every edge exactly once and returns to the start. Nodes may be visited many times. This is the street-sweeper or postman problem: cover every street, never repeat one. The idea comes from the Königsberg bridge puzzle, where a town had four land areas joined by seven bridges and people asked whether one could walk over each bridge exactly once and come home. The four areas had degrees $5,3,3,3$.

    A connected graph has an Euler circuit if and only if every node has even degree.

    Here is why even degrees are necessary. Each time the walk passes through a node it enters along one edge and leaves along another, using up edges two at a time. The start node is left once at the beginning and entered once at the end. So every node uses an even number of its edges, and an odd degree makes the circuit impossible. The harder direction (even degrees are enough) is sketched in the box below. Königsberg had four odd degrees, so no such walk exists. Our road map has odd nodes $1,2,3,4$, so a sweeper cannot cover every road exactly once; some roads must be driven twice.

    Go deeper: why even degrees are enough

    Start anywhere and keep walking along unused edges. With all degrees even, you can never get stuck anywhere except at the start node, so you return to the start having used a closed loop. If edges remain, they form smaller graphs with all degrees still even; connectedness lets you pick a node on your loop that touches an unused edge, run a new loop from there, and splice it in. Repeat until no edge is left.

    Matching and node cover

    A matching is a set of edges no two of which share a node, such as pairing drivers with customers so that nobody is used twice. A node cover is a set of nodes that touches every edge, such as putting guards at junctions so that every road is watched. Lecture 3 writes both as 0–1 programmes: a matching is a packing (each node used at most once) and a node cover is a covering (each edge touched at least once).

    On our map, $\{01,\,24,\,35\}$ is a matching of three edges. No matching can have more, because six nodes allow at most three disjoint pairs. A smallest node cover is $\{1,2,3,4\}$ with four nodes. It cannot have three: the triangle $0,1,2$ needs two of its nodes and the triangle $3,4,5$ needs two more, and the triangles share no node. Notice $3\le4$. This is no accident: every node in a cover can touch at most one edge of a matching, so a matching never has more edges than a cover has nodes.

    A graph has 7 nodes and 10 edges. What is the sum of the degrees of all its nodes?

    Every edge has two ends.

    Each edge adds 1 to the degree of each of its two ends, so the degrees add up to $2\times10=20$.

    A complete graph has 8 nodes, with one edge between every pair. How many edges does it have?

    Each node has an edge to every other node. Count the edge ends, then remember each edge has two ends.

    Each of the 8 nodes has degree 7, so the degrees add to $56$, and by the handshake rule there are $56/2=28$ edges. Equivalently $8\cdot7/2=28$.

    On the road map take $S=\{2,4\}$. What is the total length of the edges in $\delta(S)$?

    List the edges touching node 2 or node 4, and drop the one that joins them (it is inside $S$).

    Edges touching 2: $02$ (5), $12$ (2), $24$ (4). Edges touching 4: $24$, $34$ (6), $45$ (3). Edge $24$ has both ends in $S$, so it is in $E(S)$ and not in the cut. The cut is $\{02,12,34,45\}$ with length $5+2+6+3=16$.

    A connected graph on six nodes has degrees $2,4,4,2,6,2$. Does it have an Euler circuit?

    Euler's theorem asks only two things: connected, and every degree even.

    The graph is connected and every degree ($2,4,4,2,6,2$) is even, so an Euler circuit exists. (Check of the handshake rule: the degrees add to $20=2\cdot10$, so it has 10 edges.)

    A tree connects 12 depots. How many edges does it have?

    Start with one node and no edges. Each new node must be attached by exactly one edge.

    The first node needs no edge and each of the other $11$ nodes is attached by exactly one new edge. More edges would create a cycle, fewer would leave the graph disconnected. So $12-1=11$.

    • Classify every edge as inside $S$, inside $S^c$ or in $\delta(S)$ before adding anything up.
    • Use the handshake rule as a check: degrees must add to twice the number of edges.
    • Test Euler circuits by degrees, and Hamiltonian cycles by actually searching.
    • Calling $\delta(S)$ a set of nodes. It is a set of edges.
    • Mixing up Euler (every edge once) with Hamilton (every node once).
    • Forgetting that an edge with both ends outside $S$ is in neither $E(S)$ nor $\delta(S)$.
    1. A graph is nodes plus edges with weights; the degree of a node is how many edges touch it, and the degrees always add up to twice the number of edges.
    2. $E(S)$ are the edges inside a node set $S$, and the cut $\delta(S)$ are the edges leaving it; $x(\delta(S))\ge2$ says a tour must leave every group.
    3. A connected graph has an Euler circuit exactly when all degrees are even, a Hamiltonian cycle visits each node once (the TSP), and a matching never has more edges than a node cover has nodes.

    For $S=\{0,1,2\}$ on the road map, which edges form $\delta(S)$?

    $01,02,12$
    Those three have both ends in $S$. They form $E(S)$, not the cut.
    $13$ and $24$
    These are the only edges with exactly one end in $S=\{0,1,2\}$.
    $13,24,34,35,45$
    Edges $34,35,45$ lie entirely outside $S$.

    In Königsberg every one of the four land areas touched an odd number of bridges. What follows?

    A walk crossing every bridge once exists, but must start on the island.
    Euler's rule allows only even degrees for a closed walk.
    Each bridge can be crossed twice.
    The puzzle asks for each bridge exactly once, which odd degrees forbid.
    No closed walk crossing every bridge exactly once exists.
    A closed walk uses the edges at each node in pairs (in and out), so every degree would have to be even.

    In a graph, a matching has 5 edges. What can we say about any node cover?

    It has at most 5 nodes.
    The inequality goes the other way.
    It has at least 5 nodes.
    The 5 matching edges share no node, so each needs its own covering node.
    It has exactly 5 nodes.
    That is true only in special graphs (for example bipartite ones), not always.

    Shortest paths and cheapest spanning trees: two problems with fast answers

    Two questions on a weighted graph have simple greedy algorithms that always give the true optimum: the shortest route between two places (Dijkstra) and the cheapest way to link every place (a minimum spanning tree).

    Navigation software, cable laying and the distance tables that feed routing models all use them, and they show what an "easy" optimisation problem looks like before Chapter C.3 turns to the hard ones.

    It is like asking a local for directions: keep the best-known time to each junction, always finalise the nearest one, and update its neighbours.

    Shortest paths

    The van at depot $0$ wants the quickest road route to customer $5$. The length of a path is the sum of its edge weights. Looking at the map, $0\to1\to3\to5$ has length $4+3+4=11$ and $0\to2\to4\to5$ has length $5+4+3=12$. With six nodes we can try routes by eye, but a real network has millions, so we need a method.

    Dijkstra's algorithm keeps a label $d(v)$ on every node: the shortest distance to $v$ found so far. Labels start at $\infty$ (unreached) except the start node, which gets $0$. The algorithm then repeats one simple move: take the unsettled node with the smallest label, declare that label final, and use it to improve the labels of its neighbours.

    1. Set $d(s)=0$ for the start node $s$ and $d(v)=\infty$ for all others. No node is settled.
    2. Pick the unsettled node $u$ with the smallest label $d(u)$. Mark it settled: this label is now final.
    3. For every unsettled neighbour $v$ of $u$, compute $d(u)+c_{uv}$. If this is smaller than $d(v)$, replace $d(v)$ with it and remember $u$ as the node before $v$.
    4. Repeat steps 2 and 3 until every node is settled (or until the target is settled).

    Why can the settled label be trusted? When $u$ has the smallest label among unsettled nodes, any other route to $u$ would have to leave the settled region through some unsettled node, whose label is already at least $d(u)$. Adding more edges can only add more length, because weights are not negative, so no other route beats $d(u)$.

    The remembered "node before" links form the shortest-path tree: follow them backwards from any node to read off its shortest route. Directed graphs work the same way, using only arcs that leave $u$.

    Careful: Dijkstra needs every weight to be at least $0$. A negative weight can make a settled label wrong, because a later detour could shorten it. Travel times and distances are never negative, so this rarely matters in logistics.
    Try it

    Press Next step and watch one node at a time become settled (filled). Read what happens to the labels of its neighbours: which ones improve and which are kept. Then choose a different start node and run it to the end. Notice that a label is never changed after its node is settled, and that the thick green edges always form a tree.

    Run Dijkstra by hand on the road map from depot $0$, and find the shortest route to node $5$.

    1. Start: $d=(0,\infty,\infty,\infty,\infty,\infty)$ for nodes $0,\dots,5$. Settle node $0$ (label $0$). Neighbours: $d(1)=0+4=4$ and $d(2)=0+5=5$.

      Only the start has a finite label, so it is the smallest.

    2. Smallest unsettled label is node $1$ with $4$. Settle it. Neighbour $2$: $4+2=6$, which is not below $5$, so keep $5$. Neighbour $3$: $4+3=7$, set $d(3)=7$.

      Going $0\to1\to2$ costs 6, worse than the direct road $0\to2$.

    3. Settle node $2$ (label $5$). Neighbour $4$: $5+4=9$, set $d(4)=9$. (Neighbour $1$ is already settled.)

      Settled nodes are never updated again.

    4. Settle node $3$ (label $7$). Neighbour $4$: $7+6=13\ge9$, keep $9$. Neighbour $5$: $7+4=11$, set $d(5)=11$.

      The new route to $4$ through $3$ is longer than the one already known.

    5. Settle node $4$ (label $9$). Neighbour $5$: $9+3=12\ge11$, keep $11$. Settle node $5$ with label $11$.

      All nodes are settled, so we stop.

    6. Follow the "node before" links backwards from $5$: $5\leftarrow3\leftarrow1\leftarrow0$. The shortest route is $0\to1\to3\to5$ with length $11$.

      The route $0\to2\to4\to5$ of length $12$ is one km longer. The tree of all shortest routes uses edges $01,02,13,24,35$.

    Spanning trees: link everyone as cheaply as possible

    Now a different question. A utility must lay cable so that every one of the six places is connected, directly or through others, and wants the cheapest total length. Closing a loop never helps, because removing any edge of a cycle keeps everything connected. So the cheapest solution is a spanning tree, with $n-1=5$ edges. The cheapest one is the minimum spanning tree (MST).

    The classic method is Kruskal's algorithm. Sort the edges from cheapest to dearest. Go through them in that order and accept an edge if it joins two nodes that are not yet connected, and reject it if it would close a cycle. Stop when $n-1$ edges are accepted. A convenient way to track this is to keep "groups": at the start every node is its own group, accepting an edge merges two groups, and an edge is rejected when both ends are already in the same group.

    Why is this greedy rule right? Take any split of the nodes into $S$ and $S^c$. The cheapest edge in the cut $\delta(S)$ can always be used in some minimum spanning tree, since any tree that avoids it has to cross the cut with a dearer edge, and swapping that edge for the cheap one does not cost more. Kruskal always picks such a cheapest crossing edge. A second method, Prim's algorithm, grows a single tree from one node and repeatedly adds the cheapest edge of $\delta(S)$, where $S$ is the set of nodes already in the tree.

    Try it

    Press Examine next edge repeatedly. Node colours show the groups, so you can see why an edge is rejected: both ends share a colour. Then press Reset, switch to "Dearest edge first" and run it again. Notice that the order decides the answer: sorting the wrong way gives the most expensive tree.

    Find a minimum spanning tree of the road map by Kruskal's algorithm.

    1. Sort by weight (ties in the order listed): $12\,(2)$, $13\,(3)$, $45\,(3)$, $01\,(4)$, $24\,(4)$, $35\,(4)$, $02\,(5)$, $34\,(6)$.

      Cheapest edges are tried first.

    2. $12$ (2): nodes 1 and 2 are in different groups: accept. Total $2$. $13$ (3): 3 is alone: accept. Total $5$; group $\{1,2,3\}$.

      Each acceptance merges two groups.

    3. $45$ (3): accept, total $8$; groups $\{1,2,3\}$, $\{4,5\}$, $\{0\}$. $01$ (4): accept, total $12$; group $\{0,1,2,3\}$.

      Node 0 joins the large group through its cheapest road.

    4. $24$ (4): 2 is in $\{0,1,2,3\}$ and 4 is in $\{4,5\}$: accept, total $16$. That is $5=n-1$ edges, so we stop.

      The remaining edges $35$, $02$, $34$ would all close cycles anyway.

    5. The tree is $\{12,13,45,01,24\}$ with total length $16$.

      Using $35$ in place of $24$ also gives 16: ties can give a different tree but never a different cost.

    Careful: the shortest-path tree from the depot and the minimum spanning tree answer different questions. Here the shortest-path tree ($01,02,13,24,35$) has total length $20$ while the MST has $16$. The first minimises each journey from the depot, the second minimises the total cable.
    Go deeper: a link to the TSP, and to flows

    If you delete one edge from a tour you get a spanning tree (a path through all nodes), whose length is at least the MST length. So a minimum spanning tree gives a quick lower bound on the tour length: on our map the tour of length $23$ obeys $23\ge16$. This kind of bound is exactly what Lectures 4 and 5 use to prune a search.

    Flow problems, and why they count as easy

    Lecture 0 lists four families of logistics problems: routing, matching and assignment, location, and flow. A flow problem asks how much of a good to send along each road of a network, with capacities on the roads, to move goods from sources to sinks (maximum flow) or to do it at least cost (minimum-cost flow). Lecture 0 states that these can be solved by polynomial-time algorithms, meaning algorithms whose running time grows only like a modest power of the network size, as the next chapter explains. A shortest path is itself the simplest minimum-cost flow: send one unit from the start to the target at the least cost. When capacities and supplies are whole numbers, the optimal flow can be taken to be whole numbers too, so no integer programming is needed. This is why routing a single vehicle between two points is easy while deciding the order of visits for a whole round (the TSP) is not.

    Maximum flow and minimum cut

    Picture a small network of one-way roads with a capacity on each road (how many vans per hour it can carry), a source $s$ where vans start and a sink $t$ where they must arrive. The maximum flow is the largest number of vans per hour you can push from $s$ to $t$ without exceeding any road's capacity. Each road can carry a flow between $0$ and its capacity, and at every other node what comes in must equal what goes out.

    A cut is a way of splitting the nodes into two groups, one containing $s$ and the other containing $t$. Its capacity is the total capacity of the roads that start in the $s$ group and end in the $t$ group. Every van going from $s$ to $t$ has to cross the split at least once, so no flow can exceed the capacity of any cut. In particular it cannot exceed the smallest cut.

    In every network with capacities, the value of a maximum flow from $s$ to $t$ equals the capacity of a minimum cut separating $s$ from $t$.

    Roads (capacity): $s\to a$ ($5$), $s\to b$ ($4$), $a\to b$ ($1$), $a\to t$ ($3$), $b\to t$ ($4$). Find the maximum flow from $s$ to $t$ and a cut that proves it.

    1. List every cut. The group with $s$ can be $\{s\}$, $\{s,a\}$, $\{s,b\}$ or $\{s,a,b\}$.

      With two middle nodes there are only four ways to choose which of them sit on the $s$ side.

    2. Add up the capacities of the roads leaving the $s$ group: $\{s\}$ gives $5+4=9$; $\{s,a\}$ gives $4+1+3=8$; $\{s,b\}$ gives $5+4=9$; $\{s,a,b\}$ gives $3+4=7$.

      Roads that go back into the $s$ group do not count; only roads leaving it carry vans across.

    3. The smallest cut is $\{s,a,b\}$ with capacity $7$, so no flow can exceed $7$.

      This is an upper bound on the flow. It is the two roads that enter $t$.

    4. Send $3$ vans along $s\to a\to t$ and $4$ vans along $s\to b\to t$. Every road stays within its capacity and the total reaching $t$ is $7$.

      This is a flow that reaches the bound, so the maximum flow is $7$ and the minimum cut is $7$: the two agree, as the theorem says.

    Why it matters later: Part 5 uses this in reverse. To test whether a fractional TSP solution breaks a subtour constraint, a solver computes a maximum flow between two cities. By the theorem that same computation also returns the smallest cut, which is exactly the set of cities the solver needs to add a constraint for.

    On the road map, what is the shortest distance from node $4$ to node $1$?

    Node 4 touches $24$ (4), $34$ (6) and $45$ (3). Compare the route through 2 with the route through 3.

    $4\to2\to1$ costs $4+2=6$. $4\to3\to1$ costs $6+3=9$. Any route through 5 must come back through 3 and costs at least $3+4+3=10$. The shortest is $6$.

    The road $35$ is closed. What is now the shortest distance from the depot $0$ to node $5$?

    Node 5 is now reached only through $45$ (3). Find the shortest distance from 0 to node 4 first.

    The shortest distance to node 4 is $9$ (route $0\to2\to4$, as in the worked example). Adding the edge $45$ of length $3$ gives $9+3=12$ along $0\to2\to4\to5$. The alternatives $0\to1\to2\to4\to5$ (13) and $0\to1\to3\to4\to5$ (16) are longer.

    Delete the road $12$ (length 2) from the map. What is the length of the minimum spanning tree of what remains?

    Run Kruskal again on the seven remaining edges: $13\,(3)$, $45\,(3)$, $01\,(4)$, $24\,(4)$, $35\,(4)$, $02\,(5)$, $34\,(6)$.

    Accept $13$ (3), $45$ (3), $01$ (4): groups $\{0,1,3\}$ and $\{4,5\}$, node 2 alone. Accept $24$ (4): group $\{2,4,5\}$. Edge $35$ (4) joins $\{0,1,3\}$ to $\{2,4,5\}$: accept. That is 5 edges: $3+3+4+4+4=18$.

    How many edges does every spanning tree of a connected graph with 25 nodes contain?

    A tree on $n$ nodes has $n-1$ edges.

    $25-1=24$. Kruskal's algorithm stops exactly when it has accepted this many edges.

    In Dijkstra's algorithm node 3 has just been settled with label 7, and all weights are non-negative. Can a later step lower the label of node 3?

    Any other route to node 3 must pass through a node that is not yet settled. What do we know about the labels of such nodes?

    No. All unsettled nodes have labels at least 7, since node 3 had the smallest one, and weights are not negative, so any route to node 3 through them has length at least 7. The label is final.

    • Write the label table after each step when running Dijkstra by hand.
    • Track groups in Kruskal: reject an edge whenever both ends are already in one group.
    • Check the edge count: an MST of $n$ nodes has $n-1$ edges.
    • Using Dijkstra with negative weights.
    • Confusing a shortest-path tree with a minimum spanning tree.
    • Accepting an edge only because it is cheap, without checking that it does not close a cycle.
    1. Dijkstra repeatedly settles the unsettled node with the smallest label and relaxes its neighbours; with non-negative weights each settled label is final.
    2. A minimum spanning tree links all nodes with $n-1$ edges at the least total length, and Kruskal builds it by accepting the cheapest edges that close no cycle.
    3. Shortest paths, spanning trees and flow problems all have fast exact algorithms, which is why Lecture 0 calls flow problems the easier family.

    Kruskal's algorithm looks at edge $uv$ and finds that $u$ and $v$ are already in the same group. What does it do?

    Accepts it, because it is cheap.
    An edge inside a group would close a cycle, and a tree has none.
    Rejects it, since it would close a cycle.
    Both ends are already connected through accepted edges.
    Accepts it and removes the dearest accepted edge.
    Kruskal never removes an accepted edge.

    Which statement about the road map is correct?

    The shortest-path tree from the depot is always also a minimum spanning tree.
    Compare totals: 20 for the shortest-path tree and 16 for the MST.
    The shortest-path tree from node 0 has length 20 while the MST has length 16.
    They solve different problems, so their totals can differ.
    The MST gives each customer their shortest route to the depot.
    The MST minimises total length, not individual journeys.

    A shortest-path problem is a special case of which family in Lecture 0?

    Location problems.
    Location decides where to place facilities.
    Routing problems of the TSP type.
    The TSP asks for an order of many visits and is much harder.
    Flow problems (send one unit at minimum cost).
    That is a minimum-cost flow, which polynomial algorithms solve.

    How fast, and how hard? Counting work, and why most routing problems resist

    We judge an algorithm by how the number of steps it needs grows as the problem grows, and some problems seem to demand a number of steps that explodes.

    Lecture 0 says that most logistics problems are NP-hard, so elementary methods do not scale. This chapter tells you exactly what that sentence means, what it does not mean, and why the rest of the course is about clever exact methods and good heuristics.

    It is like seating guests: placing 10 people in a row has 3.6 million arrangements, and 25 people have about $1.6\times10^{25}$, far more than the estimated number of grains of sand on all of Earth's beaches, so checking every arrangement is hopeless.

    Count steps, not seconds

    The time a program takes depends on the computer, so we count operations instead (one comparison, one addition, one lookup). Some examples with $n$ items:

    • Finding the smallest of $n$ labels takes $n-1$ comparisons, about $n$ operations.
    • Comparing every pair of $n$ customers takes $n(n-1)/2$ comparisons.
    • The plain version of Dijkstra repeats "find the smallest label" $n$ times, so it needs about $n^2$ operations.

    The Big-O notation keeps only the part that dominates when $n$ is large, ignoring constants and smaller terms. If an algorithm needs $3n^2+50n+20$ operations we write $O(n^2)$ and say "of order $n^2$". At $n=1000$ the term $3n^2=3{,}000{,}000$ already swamps $50n=50{,}000$. The practical meaning: doubling $n$ multiplies an $O(n)$ algorithm's work by 2, an $O(n^2)$ one's by 4, and an $O(n^3)$ one's by 8.

    Careful: Big-O describes growth, not speed at one size. An algorithm needing $1000n$ steps is slower than one needing $n^2$ steps for every $n$ below 1000, and only wins beyond that. We ignore constants to compare how algorithms behave as problems get large.

    Polynomial against exponential

    An algorithm is polynomial time if its operation count is at most some fixed power of the input size, like $n^2$ or $n^5$. It is exponential if $n$ appears in an exponent, like $2^n$, or if it grows even faster, like $n!=1\cdot2\cdot3\cdots n$. The difference is dramatic. At one billion operations per second:

    $n$$n^2$ stepstime$2^n$ stepstime$n!$ stepstime
    101000.1 µs1,0241.0 µs3,628,8003.6 ms
    204000.4 µs1,048,5761.0 ms2.43 × 101877 years
    309000.9 µs1.07 × 1091.1 s2.65 × 10328.4 × 1015 years
    502,5002.5 µs1.13 × 101513 days3.04 × 10649.6 × 1047 years

    A faster computer hardly helps. A machine 1000 times faster solves only about $10$ more cities with a $2^n$ method, since $2^{10}\approx1000$. Its gain on an $n!$ method is even smaller: a few more cities at best.

    How many tours does a TSP have?

    The TSP is the clearest place where the explosion bites. Fix the depot as the starting city. The other $n-1$ cities can be visited in any order, which gives $(n-1)!$ orders. When distances are symmetric, a tour and the same tour run backwards have equal length, so each tour has been counted twice. The number of different tours is therefore $$\frac{(n-1)!}{2}.$$ For $n=5$ cities this is $12$; for $n=10$ it is $181{,}440$; for $n=15$ about $4.4\times10^{10}$; for $n=20$ about $6.1\times10^{16}$.

    A program checks one tour per nanosecond (a billion per second). Roughly how long does it take to check every tour of 20 cities?

    A few seconds
    That would be only a few billion tours; there are about $6\times10^{16}$.
    About 2 years
    $6.1\times10^{16}$ tours divided by $10^9$ per second is $6.1\times10^7$ seconds, about 1.9 years.
    About 77 years
    That is the time for $20!$ orders, not for $19!/2$ tours.

    And one more city: for 21 cities the number of tours grows by a factor of 20, so the same program would need about 39 years. Use the widget below and move the slider.

    Try it

    Drag $n$ upward and read the operation counts and times, then switch to the computer that is 1000 times faster. On the plot the vertical axis is logarithmic (each gridline is ten times higher), and the dashed horizontal lines are one second, one day, one year and the age of the universe. Find the largest $n$ at which $2^n$ and $n!$ still fit under "one day". Notice that $n^2$ and $n^3$ barely leave the bottom of the picture while $n!$ shoots through the age of the universe before $n$ reaches 30.

    P, NP-complete and NP-hard in plain words

    Computer scientists sort problems by how hard they seem. We state the ideas informally for a yes/no version such as "is there a tour of length at most $K$?".

    • P: problems with a polynomial-time algorithm. Shortest paths, spanning trees, maximum flow and maximum matching are in P.
    • NP: problems where, if someone hands you a proposed answer, you can check it in polynomial time. Given a tour you can add up its $n$ edges and compare with $K$ in a moment, even though finding such a tour is hard.
    • NP-complete: the hardest problems in NP. If any one of them had a polynomial-time algorithm, every problem in NP would have one. The decision version of the TSP is NP-complete.
    • NP-hard: at least as hard as the NP-complete problems; this includes optimisation versions ("find the cheapest tour"), which are not even yes/no questions.

    Whether P equals NP is a famous open question. Nearly everyone believes the answer is no, which would mean that no polynomial-time method exists for NP-hard problems. Among the problems of this course the TSP, the vehicle routing problem, bin packing, set covering and facility location are NP-hard. Notice that the same integer-programming style also models problems in P: maximum matching is in P, while finding the smallest node cover of a general graph is NP-hard, even though both were Lecture 3 examples.

    It means: for these problems nobody knows an algorithm whose worst-case running time stays polynomial as the instance grows, and most experts believe none exists. So "elementary methods" such as checking all possibilities (or all subsets) blow up, and off-the-shelf solvers handle only instances up to a certain size. It does not mean that every instance is hard or that clever methods are useless.

    Careful: "NP-hard" is a statement about the worst case as the problem grows, not about every instance. Lecture 5 reports TSP instances of tens of thousands of cities solved to optimality, because such instances have structure that branch-and-cut methods exploit. The skill this course teaches is spotting and exploiting structure.

    Exact methods and heuristics

    An exact method guarantees an optimal answer, but may run for a very long time on large instances. Brute-force enumeration is exact but explosive; branch and bound and branch and cut (Lectures 4 and 5) are exact methods that cleverly skip most of the possibilities. A heuristic is a rule of thumb that returns a good answer quickly but gives no guarantee of optimality. Two simple families:

    • Greedy methods build a solution one step at a time, always making the locally best choice, and never reconsider. The nearest-neighbour tour starts at the depot and always drives to the closest unvisited city.
    • Local search starts from some solution and keeps making small changes that improve it until none does. For tours, a 2-opt move deletes two edges and reconnects the pieces the other way, which reverses a stretch of the tour.
    Try it

    Press the first button repeatedly to build the nearest-neighbour tour on five cities (the table shows distances in km), then press the second button to let a 2-opt move improve it. Watch the last leg back to the depot: the greedy rule leaves a long one for the end.

    Distances (km) among the depot $0$ and four customers $1$–$4$ are $d_{01}=16,\ d_{02}=3,\ d_{03}=12,\ d_{04}=7,\ d_{12}=13,\ d_{13}=10,\ d_{14}=13,\ d_{23}=13,\ d_{24}=8,\ d_{34}=5$. Build the nearest-neighbour tour from the depot, then try a 2-opt move, and compare with the best of all tours.

    1. From $0$ the nearest city is $2$ (3 km). From $2$ the unvisited cities are $1$ (13), $3$ (13) and $4$ (8): go to $4$. From $4$: $1$ (13) and $3$ (5): go to $3$. From $3$ only city $1$ is left (10). Return $1\to0$: 16.

      At each step the rule looks only at the distances from the current city.

    2. The nearest-neighbour tour is $0\to2\to4\to3\to1\to0$ with length $3+8+5+10+16=42$ km.

      Add the five legs, including the return leg.

    3. 2-opt: delete edges $2\!-\!4$ (8) and $1\!-\!0$ (16), and reconnect with $2\!-\!1$ (13) and $4\!-\!0$ (7). The stretch $4,3,1$ is reversed and the tour becomes $0\to2\to1\to3\to4\to0$.

      The change in length is $13+7-8-16=-4$, so the tour is shorter.

    4. New length: $3+13+10+5+7=38$ km, which is $42-4$.

      Adding all five legs confirms the saving.

    5. There are $(5-1)!/2=12$ tours in all. Listing them gives lengths $38,42,46,46,46,50,50,54,54,54,58,62$, so $38$ is optimal. Nearest neighbour gave $42$, which is about $10.5\%$ above the best.

      With 5 cities we can enumerate; with 50 cities there are about $3\times10^{62}$ tours, which is why heuristics and clever exact methods are needed.

    How many pairs of customers must be compared if we check every pair among 100 customers?

    Use $n(n-1)/2$.

    $100\cdot99/2=4950$. Each customer is paired with 99 others, which counts every pair twice, so we halve $9900$.

    A depot and 7 customers make 8 cities in all. How many different tours (symmetric distances) are there?

    Use $(n-1)!/2$ with $n=8$.

    $(8-1)!/2=7!/2=5040/2=2520$.

    A method needs $2^{40}$ operations (about $1.0995\times10^{12}$) and the computer does $10^9$ operations per second. How many seconds does it take, to one decimal place?

    Divide the number of operations by the speed.

    $2^{40}=1{,}099{,}511{,}627{,}776$, and dividing by $10^9$ gives about $1099.5$ seconds, roughly 18 minutes.

    Distances: $d_{01}=5,\ d_{02}=2,\ d_{03}=6,\ d_{12}=3,\ d_{13}=4,\ d_{23}=7$. Starting from depot $0$, what is the length of the nearest-neighbour tour (including the return to the depot)?

    From the current city always go to the closest unvisited one, then return to $0$ at the end.

    From $0$: city 2 (2). From $2$: cities 1 (3) and 3 (7), go to 1. From $1$: only city 3 is left (4). Return $3\to0$: 6. Total $2+3+4+6=15$.

    Starting from $n=2$, what is the smallest $n$ for which $2^n$ is larger than $n^3$?

    Compare $2^n$ and $n^3$ one by one: $n=9$ gives $512$ and $729$.

    For $n=2,\dots,9$, $2^n\le n^3$ (for example $n=9$: $512\lt729$). At $n=10$, $2^{10}=1024\gt1000=10^3$. From then on $2^n$ stays larger and the gap keeps growing.

    • Compare algorithms by how their operation counts grow with $n$.
    • Ask whether a proposed answer can be checked quickly: that is the NP idea.
    • Use heuristics for speed, and compare with a bound or an exact answer when possible.
    • Reading "NP-hard" as "impossible", or as "every instance is hard".
    • Concluding that a heuristic's answer is optimal because it looks reasonable.
    • Forgetting that doubling $n$ multiplies $n^2$ work by 4 but $2^n$ work by $2^n$.
    1. Big-O records how the number of operations grows with the problem size; polynomial growth ($n^2$, $n^3$) stays manageable while exponential or factorial growth ($2^n$, $n!$) quickly becomes impossible, and a TSP on $n$ cities has $(n-1)!/2$ tours.
    2. NP-complete problems can be checked fast but have no known fast solution method, and NP-hard problems are at least as hard; the TSP, vehicle routing, bin packing and set covering are NP-hard, which is what Lecture 0 means.
    3. Exact methods guarantee optimality but may be slow, heuristics such as nearest neighbour and 2-opt are fast without guarantees, and good solvers combine bounds, structure and search.

    An algorithm uses $3n^2+50n+20$ operations. How is its growth written?

    $O(n)$
    The term in $n^2$ dominates the term in $n$ when $n$ is large.
    $O(n^2)$
    Constants and smaller terms are dropped, leaving the dominant $n^2$.
    $O(3n^2+50n+20)$
    Big-O keeps only the dominating term and drops its constant.

    What does "the vehicle routing problem is NP-hard" tell a practitioner?

    No instance can ever be solved to optimality.
    Many large instances are solved exactly by methods that exploit structure.
    No algorithm with guaranteed polynomial running time is known, so exact solutions may need exploding effort as instances grow and heuristics are often used.
    It is a worst-case statement that explains why exact solvers slow down and why heuristics are valuable.
    Heuristics cannot be used because the problem is too hard.
    Heuristics are the practical tool when exact solving is too slow.

    On the five-city example, nearest neighbour gave 42 km and the optimum is 38 km. What does this show?

    Nearest neighbour always overshoots the optimum by about 10%.
    One example says nothing about a fixed percentage.
    A 2-opt move can make any tour optimal in one step.
    It happened here, but in general 2-opt may stop at a local optimum.
    A greedy heuristic gives no guarantee of optimality.
    The greedy choice left a long final leg, and a better tour existed.

    A tour on the road map uses edges $01,13,35,54,42,20$, so $x_e=1$ for those edges and $x_e=0$ for all others. For $S=\{0,1,2\}$, what is $x(\delta(S))=\sum_{e\in\delta(S)}x_e$?

    3
    Only edges with exactly one end in $S$ count, and $01,02,12$ are inside $S$.
    2
    $\delta(S)=\{13,24\}$, and both are in the tour: $1+1=2$, as every tour must leave a group and return.
    6
    That counts all tour edges; the sum runs only over the cut.

    You need cable linking all six places at the least total length, and also the quickest route from the depot to each place. Which statement is right?

    Dijkstra solves both jobs.
    Dijkstra's tree is shortest per journey and totals 20, not the cheapest total of 16.
    Kruskal answers the cable question and Dijkstra the routes question.
    The questions differ, and the trees have different total lengths (16 and 20).
    Both jobs are NP-hard.
    Both problems have fast polynomial algorithms.

    How many different tours (symmetric distances) visit a depot and 9 customers, ten cities in all?

    $10!/2$
    One city is fixed as the start, so there are $9!$ orders.
    $9!/2=181{,}440$
    $(n-1)!/2$ with $n=10$.
    $9!=362{,}880$
    Each tour is counted twice (once per direction), so halve.

    Which is true of NP-hardness?

    An NP-hard problem has a polynomial algorithm for small instances only.
    The definition concerns how hard the problem is relative to others, not instance size.
    If someone found a polynomial-time algorithm for one NP-complete problem, all problems in NP could be solved in polynomial time.
    That is the meaning of NP-complete: they are the hardest in NP.
    Any problem solved by a heuristic is NP-hard.
    Heuristics are used on easy problems too.

    Lecture 3 turns routing and location questions into integer programmes. That needs three small skills: describing choices with sets and 0/1 tables, expressing "if", "or" and "at most" with binary variables, and reading the Python and Gurobi files used in the labs. This part teaches those three skills with tiny examples you can check by hand. It prepares Lecture 3 and the Gurobi labs.

    You need: Part A (sums, subsets, binary variables, matrices and $Ax$). The idea of an LP relaxation is explained here, and the code needs no prior Python.

    Sets, subsets and incidence matrices: covering a list of customers

    A cover, a packing and a partition are three ways of choosing some subsets of a ground set, and one 0/1 table (the incidence matrix) turns all three into linear constraints.

    Lecture 3 uses this table for route selection, matchings and node covers. If you can read it, those formulations become routine.

    It is like choosing which bus routes to run so that every neighbourhood has service: "at least one route", "no overlap" and "exactly one" are three different promises.

    Running example

    A distributor has five customers $1,2,3,4,5$ and six candidate van routes $R_1,\dots,R_6$. Each route visits some customers and has a cost $w_j$ per day.

    Route$R_1$$R_2$$R_3$$R_4$$R_5$$R_6$
    Customers visited$\{1,2\}$$\{2,3\}$$\{3,4,5\}$$\{1,4\}$$\{1,2,3\}$$\{4,5\}$
    Cost $w_j$446583

    Sets in one minute

    A set is a collection of distinct items. The ground set here is $S=\{1,2,3,4,5\}$, the customers. Each route is a subset of $S$. Two operations matter:

    • The union $A\cup B$ contains everything that is in $A$ or in $B$ (or both). Example: $R_1\cup R_4=\{1,2\}\cup\{1,4\}=\{1,2,4\}$.
    • The intersection $A\cap B$ contains what is in both. Example: $R_2\cap R_5=\{2,3\}\cap\{1,2,3\}=\{2,3\}$. If $A\cap B=\emptyset$ (the empty set) the two sets are disjoint.

    Let $\mathcal{X}$ be a chosen collection of subsets of $S$.

    $\mathcal{X}$ is a cover if the union of its members is all of $S$: every element is in at least one chosen subset.

    $\mathcal{X}$ is a packing if its members are pairwise disjoint: no element is in two chosen subsets.

    $\mathcal{X}$ is a partition if it is both a cover and a packing: every element is in exactly one chosen subset.

    With the routes above, $\{R_1,R_3\}$ is a partition (customers 1,2 from $R_1$; 3,4,5 from $R_3$). $\{R_2,R_4,R_6\}$ is a cover but not a packing, because customer 4 is visited by both $R_4$ and $R_6$. $\{R_2,R_4\}$ is a packing but not a cover, because customer 5 is left out.

    The incidence matrix

    To feed these ideas to a solver we record membership in a table. Rows are elements (customers), columns are subsets (routes), and the entry is $a_{ij}=1$ if element $i$ belongs to subset $j$, and $0$ otherwise. For our six routes: $$A=\begin{pmatrix}1&0&0&1&1&0\\ 1&1&0&0&1&0\\ 0&1&1&0&1&0\\ 0&0&1&1&0&1\\ 0&0&1&0&0&1\end{pmatrix}.$$ Column 3 reads $0,0,1,1,1$: route $R_3$ visits customers 3, 4 and 5. Row 1 reads $1,0,0,1,1,0$: customer 1 is on routes $R_1$, $R_4$ and $R_5$.

    Now introduce a binary variable $x_j$: $x_j=1$ if we run route $R_j$ and $x_j=0$ otherwise. The number of chosen routes that visit customer $i$ is $\sum_{j}a_{ij}x_j$, the $i$-th entry of $Ax$. Everything follows from that one sentence.

    Let $w_j$ be the weight (cost) of subset $j$.

    Minimum-weight cover: $\displaystyle\min\sum_{j=1}^{n}w_jx_j$ s.t. $\displaystyle\sum_{j=1}^{n}a_{ij}x_j\ge1\ \ \forall i=1,\dots,m$, $x_j\in\{0,1\}$.

    Maximum-weight packing: $\max\sum_j w_jx_j$ s.t. $\sum_j a_{ij}x_j\le1\ \ \forall i$, $x_j\in\{0,1\}$.

    Partition: the same constraints with "$=1$" for every row (minimise or maximise, as needed).

    Why does the packing model maximise? With "$\le1$" constraints, choosing nothing ($x=0$) is feasible and costs $0$, so minimising would always return the empty choice. A cover has the opposite problem: choosing everything is feasible, so we minimise cost. Whether an objective makes sense depends on which direction the constraints push.

    Try it

    Click routes to switch them on and off. Look at the right-hand column: it shows $\sum_j a_{ij}x_j$ for each customer, coloured missed, once, or twice or more. Find the cheapest cover, then the heaviest packing, and notice that both of them happen to be partitions here. Can you find a cover that is not a packing?

    Graphs: node cover and matching

    The same machinery handles graphs. A graph $G=(V,E)$ has nodes (vertices) $V$ and edges $E$. A matching is a set of edges no two of which share a node. A node cover is a set of nodes such that every edge has at least one end in the set. Take the graph below with six nodes and six edges.

    e1e2e3e4e5e6 123456

    Both problems are set problems in disguise, with the roles swapped:

    • Node cover. The ground set is the edges. Node $v$ is the subset of edges touching it. A collection of nodes whose subsets together contain every edge is exactly a node cover. Model: $\min\sum_{v}x_v$ s.t. $x_u+x_v\ge1$ for every edge $\{u,v\}$.
    • Matching. The ground set is the nodes. Edge $e=\{u,v\}$ is the subset $\{u,v\}$. Edges with disjoint node sets form a packing, which is a matching. Model: $\max\sum_{e}x_e$ s.t. $\sum_{e\ni v}x_e\le1$ for every node $v$ (where $e\ni v$ means "edge $e$ touches $v$").
    Try it

    Switch to the two graph views. In "Node cover" you pick nodes; in "Matching" you pick edges. Find a node cover with 3 nodes and a matching with 3 edges, and try to beat each by one.

    Using the routes table, check whether $x=(1,1,0,0,0,1)$ (routes $R_1$, $R_2$, $R_6$) is a cover, a packing or a partition, and find its cost.

    1. Compute $Ax$ row by row. Row 1: $1\cdot1+0+0+0+0+0=1$. Row 2: $1\cdot1+1\cdot1+0+0+0+0=2$. Row 3: $0+1\cdot1+0+0+0+0=1$. Row 4: only $a_{46}=1$ counts, giving $1$. Row 5: only $a_{56}=1$ counts, giving $1$. So $Ax=(1,2,1,1,1)$.

      Each entry counts how many chosen routes visit that customer.

    2. Every entry is at least $1$, so it is a cover. Entry 2 equals $2$, so it is not a packing, and therefore not a partition.

      Cover: all rows $\ge1$. Packing: all rows $\le1$. Partition: all rows exactly $1$.

    3. Cost: $w_1+w_2+w_6=4+4+3=11$. The cheapest cover costs $10$, namely $\{R_1,R_3\}$.

      Customer 2 is paid for twice: routes $R_1$ and $R_2$ both visit it. Dropping $R_2$ and using $R_3$ for customers 3, 4, 5 avoids that.

    Go deeper: a perfect match between two problems

    On this graph the largest matching has 3 edges and the smallest node cover has 3 nodes. That is no accident: for graphs that can be drawn with two groups of nodes and all edges going between the groups (bipartite graphs, such as this one), the two sizes are always equal (König's theorem). On a triangle they differ: the largest matching has 1 edge but a node cover needs 2 nodes.

    In the incidence matrix $A$ of the six routes, how many entries equal $1$? (Count the customers on each route and add.)

    Each column has as many ones as the route has customers: $2,2,3,2,3,2$.

    $2+2+3+2+3+2=14$. You can also count along rows: $3+3+3+3+2=14$.

    With costs $w=(4,4,6,5,8,3)$ what is the weight of a cheapest cover of customers $1,\dots,5$?

    Customer 5 is only on $R_3$ and $R_6$. Try each, then see what is left to cover.

    Using $R_3$ (cost 6) leaves customers 1 and 2; $R_1$ (cost 4) covers both: total 10. Using $R_6$ (cost 3) leaves 1, 2, 3; $R_5$ covers them for 8 (total 11), or $R_1+R_2$ for 8 (total 11). The cheapest is $\{R_1,R_3\}$ with weight $10$.

    With the same weights, what is the largest total weight of a packing (routes sharing no customer)?

    A packing may leave customers out. Try $R_5$ (the heaviest) first and see which routes remain compatible.

    $R_5=\{1,2,3\}$ is compatible only with $R_6=\{4,5\}$ (all others touch 1, 2 or 3), giving $8+3=11$. Other packings: $\{R_1,R_3\}$ with 10, $\{R_2,R_4\}$ with 9. The maximum is $11$.

    The routes $R_2,R_4,R_6$ are chosen. Which description is correct?

    Compute the row sums of $Ax$ for $x=(0,1,0,1,0,1)$: does any customer appear zero times? Twice?

    $R_2=\{2,3\}$, $R_4=\{1,4\}$, $R_6=\{4,5\}$ cover all five customers, so it is a cover. Customer 4 appears twice, so it is not a packing and hence not a partition. Cost $4+5+3=12$.

    The minimum-cost cover model for the five customers and six routes has how many covering constraints and how many binary variables?

    One constraint per row of $A$; one variable per column.

    One constraint $\sum_j a_{ij}x_j\ge1$ for each of the 5 customers, and one variable $x_j$ for each of the 6 routes.

    • Write the incidence matrix first; then check any proposed choice with $Ax$ row by row.
    • Decide the direction of the objective from the constraints: cover pushes cost up, so minimise; packing pushes value down, so maximise.
    • Say which objects are the elements and which are the subsets before writing a model.
    • Treating a packing as if it had to serve everybody: it may leave elements out.
    • Confusing "at least once" ($\ge1$) with "exactly once" ($=1$); partitions need equality.
    • Mixing up rows and columns of $A$: rows are elements, columns are subsets.
    1. A cover has every element in at least one chosen subset, a packing has every element in at most one, and a partition has every element in exactly one.
    2. The incidence matrix $a_{ij}$ (rows elements, columns subsets) makes these three conditions the linear constraints $Ax\ge1$, $Ax\le1$, $Ax=1$ on binary $x$.
    3. Node cover and matching are set cover and set packing on a graph, with edges and nodes taking turns as elements and subsets.

    Which constraint family describes "no customer is visited by more than one chosen route"?

    $\sum_j a_{ij}x_j\le1$ for all $i$
    The count of chosen routes at each customer is at most one: that is a packing.
    $\sum_j a_{ij}x_j\ge1$ for all $i$
    That demands every customer is visited at least once.
    $\sum_j a_{ij}x_j=0$ for all $i$
    That would forbid choosing any route that visits anyone.

    Why is "minimise $\sum w_jx_j$" a poor objective for the packing constraints $Ax\le1$?

    $x=0$ is feasible and costs nothing, so the answer would always be to choose nothing.
    With non-negative weights and only "at most" constraints, the empty choice is optimal, so one maximises instead.
    Packing constraints can never be satisfied.
    They are satisfied by the empty choice and by any disjoint routes.
    Because the $w_j$ must be negative.
    Signs are not the issue; think about which choices are feasible.

    In the node cover model $\min\sum_v x_v$ s.t. $x_u+x_v\ge1$ for each edge $\{u,v\}$, what do the elements and subsets stand for?

    Elements are nodes; subsets are edges.
    That roles pair is the one for matchings.
    Elements and subsets are both edges.
    Each constraint has one row per edge, but the columns are chosen objects.
    Elements are edges; subsets are nodes, each node containing the edges that touch it.
    Choosing nodes whose subsets together contain all edges is a cover of the edges.

    Logic with binary variables: yes/no decisions, forcing and big-M

    A binary variable is a yes/no switch. Sums and inequalities on these switches say AND, OR, NOT, "at most $k$" and "if this then that".

    Every integer programme in Lecture 3 (opening depots, choosing routes, scheduling jobs) is built from exactly these patterns, and the big-M trick decides whether the solver is fast or hopeless.

    It is like a control panel of light switches: a constraint is a rule such as "never both of these on", and big-M is a master breaker that switches a whole rule off.

    Yes/no variables and basic rules

    Let $y_j=1$ mean "depot $j$ is open" and $y_j=0$ "closed". With binary variables a sum counts how many are "yes". The following translations are used constantly (here $x,y,z\in\{0,1\}$):

    In wordsConstraint
    $x$ or $y$ (or both)$x+y\ge1$
    $x$ and $y$ both$x=1,\ y=1$ (or $x+y\ge2$)
    not $x$$x=0$; the quantity "not $x$" is $1-x$
    at most one of $x,y,z$$x+y+z\le1$
    at most $k$ of $y_1,\dots,y_n$$\sum_j y_j\le k$
    exactly one of $x,y$$x+y=1$
    if $x$ then $y$$x\le y$
    if $x$ or $y$ then $z$$x\le z$ and $y\le z$

    "If $x$ then $y$" deserves a second look. The pair $(x,y)=(1,0)$ is the only one that breaks the promise, and $x\le y$ is violated exactly there: $1\le0$ is false. For the other three pairs the inequality holds, including $(0,1)$ and $(0,0)$: when $x=0$ the rule says nothing about $y$.

    Try it

    Toggle $x$, $y$, $z$ and read down the "Holds?" column. Click a row to see all eight triples for that statement. Check that the linear form always agrees with the plain-English statement, and compare the last column: "at most one of three" is satisfied by 4 of the 8 triples, "at least two of three" by 4 as well.

    Forcing constraints: linking a yes/no to an amount

    Often a quantity may be positive only if a switch is on. Let $y_j$ say whether a depot is open and $x_{ij}\in[0,1]$ the fraction of customer $i$'s demand served from depot $j$. The rule "no service from a closed depot" is the forcing constraint $$x_{ij}\le y_j.$$ If $y_j=0$ it forces $x_{ij}=0$; if $y_j=1$ it allows any $x_{ij}\le1$. When the quantity is not already between 0 and 1, we write $x\le My$ where $M$ is a constant called big-M: any number at least as large as the largest value $x$ can take. If the depot is closed, $x\le0$; if open, $x\le M$, which should mean no restriction at all.

    A depot with a minimum useful load $L$ adds the other side: $Ly\le x\le My$. Open means load between $L$ and $M$; closed means load exactly $0$.

    Why a tight $M$ matters

    Solvers do not enumerate integer choices blindly. They first solve the LP relaxation: replace "$y\in\{0,1\}$" by "$0\le y\le1$", which gives a linear programme that is quick to solve and whose optimal value is a bound on the true answer (a lower bound when minimising). The closer the relaxation is to the integer problem, the less searching remains.

    Suppose a depot must carry a load $x=40$ units, and its fixed opening cost is $90$. The relaxed constraint $x\le My$ becomes $y\ge x/M=40/M$. With $M=40$ the relaxation must pay for $y=1$: the full 90. With $M=400$ it can choose $y=40/400=0.1$ and pays only $9$. Nothing in the real problem has changed; only the modelling constant. A loose $M$ lets the LP "buy a tenth of a depot", so its bound is weak and the solver must do far more branching.

    Try it

    Slide $M$ from 40 up to 400. The horizontal axis is the load $x$, the vertical axis is $y$. The feasible region of the relaxation is the shaded area above the line $y=x/M$ (up to $y=1$). The only integer points are $(0,0)$ and the top segment $y=1$. Watch the orange region grow and the fixed cost the LP pays shrink. Notice which value of $M$ makes the green triangle exactly the smallest region containing the integer points.

    The same lesson explains a choice in facility location (Lecture 3, strong formulations). For $m$ customers one can write the individual constraints $x_{ij}\le y_j$ for every pair, or the single aggregated constraint $\sum_i x_{ij}\le m\,y_j$ for each depot. Both are correct for integer $y_j$. But the aggregate has $M=m$, while each $x_{ij}$ can only reach $1$. In the relaxation a depot could serve one whole customer ($x_{ij}=1$) while "opening" only $y_j=1/m$ of itself. If $m=6$ and the fixed cost is $60$, that costs only $10$ instead of $60$. The individual form insists on $y_j\ge1$ and is called stronger: its relaxation is closer to the integer problem, even though it has more constraints.

    Product of two binaries

    Sometimes we need $z=xy$ for binary $x,y$, for example "$z=1$ only if both the depot and the road are used". The product is not linear, but these three constraints reproduce it exactly for binary variables: $$z\le x,\qquad z\le y,\qquad z\ge x+y-1.$$ The first two say $z$ cannot be 1 unless both are 1. The third says that when $x=y=1$ then $z\ge1$. Try each of the four pairs $(x,y)$ in the logic widget with the row "$z=x$ AND $y$".

    Either-or: at least one of two constraints holds

    To say "constraint 1 or constraint 2 (or both)", add a binary $\delta$ and a big-M on each constraint: $$a_1^\top x\le b_1+M_1(1-\delta),\qquad a_2^\top x\le b_2+M_2\,\delta.$$ If $\delta=1$ the first constraint is enforced and the second is relaxed by $M_2$; if $\delta=0$ it is the other way round. Each $M_k$ must be at least the largest amount by which the constraint can be violated, and should be no bigger, for the strength reason above.

    Four depots, binary $y_1,\dots,y_4$ ($1$ = open). Write constraints for: (i) at most two open; (ii) if depot 1 opens then depot 2 must open; (iii) depot 3 or depot 4 (or both) opens; (iv) depots 2 and 3 cannot both open. How many of the 16 open/closed patterns satisfy all four?

    1. (i) $y_1+y_2+y_3+y_4\le2$. (ii) $y_1\le y_2$. (iii) $y_3+y_4\ge1$. (iv) $y_2+y_3\le1$.

      Use the table of translations: "at most $k$" is a sum, "if then" is $\le$, "or" is a sum $\ge1$, "not both" is a sum $\le1$.

    2. Start from (iii): at least one of depots 3, 4 is open. If both are open, (i) forces $y_1=y_2=0$, giving $(0,0,1,1)$. It passes (ii) and (iv).

      Case split on the most restrictive rule keeps the search short.

    3. If depot 3 is open and depot 4 is closed: (iv) gives $y_2=0$, then (ii) gives $y_1=0$, so $(0,0,1,0)$.

      Opening depot 3 closes depot 2, and closing 2 stops depot 1 from opening.

    4. If depot 4 is open and depot 3 is closed: with $y_2=0$ rule (ii) forces $y_1=0$, giving $(0,0,0,1)$. With $y_2=1$ the choice $y_1=1$ would open three depots and break (i), so $y_1=0$, giving $(0,1,0,1)$.

      Check the total of open depots against rule (i) each time.

    5. The feasible patterns are $(0,0,0,1)$, $(0,0,1,0)$, $(0,0,1,1)$ and $(0,1,0,1)$: 4 of 16.

      Each of the four rules removed a share of the patterns; all together leave 4.

    Two jobs share one machine. Job A takes 4 hours and job B takes 3 hours. Start times $s_A,s_B$ lie between 0 and 20. The jobs must not overlap: either A finishes before B starts, or B finishes before A starts. Write this with one binary variable and find the smallest valid big-M constants.

    1. The two cases are $s_A+4\le s_B$ and $s_B+3\le s_A$.

      A finishes at $s_A+4$; B finishes at $s_B+3$.

    2. Introduce $\delta=1$ for "A first". Write $s_A+4\le s_B+M_1(1-\delta)$ and $s_B+3\le s_A+M_2\,\delta$.

      When $\delta=1$ the first is enforced (the term $M_1(1-\delta)=0$) and the second is relaxed by $M_2$.

    3. Smallest $M_1$: the largest value of $s_A+4-s_B$ is $20+4-0=24$, so $M_1=24$. Smallest $M_2$: the largest value of $s_B+3-s_A$ is $20+3-0=23$, so $M_2=23$.

      A relaxed constraint must be satisfied for every allowed pair of start times, so $M$ must cover the worst violation.

    4. Check: $s_A=2$, $s_B=6$, $\delta=1$. First: $6\le6$. Second: $9\le2+23=25$. Both hold, so the schedule is allowed.

      The second constraint is relaxed, not satisfied "for real": that is exactly what big-M is for.

    Go deeper: choosing the best M from the data

    The tightest $M$ for $x\le My$ is the largest value $x$ can take given the other constraints, for example total demand, capacity, or an upper bound on a time variable. In vehicle routing and scheduling, a huge round number such as $10^6$ is tempting and almost always a mistake: it hurts the LP bound and can cause numerical trouble in the solver.

    How many of the 8 triples $(x,y,z)\in\{0,1\}^3$ satisfy "if $x$ then $y$", that is $x\le y$?

    $z$ is free. Count the pairs $(x,y)$ that satisfy the rule, then multiply by the 2 choices of $z$.

    The pairs $(0,0),(0,1),(1,1)$ satisfy $x\le y$; only $(1,0)$ does not. That is 3 pairs, times 2 values of $z$: $6$.

    A depot's load cannot exceed 35. It must carry load $x=35$. Its fixed cost is 80, and the model uses $x\le 70\,y$. What fixed cost does the LP relaxation pay (the value of $80y$ with $y$ as small as possible)?

    The smallest $y$ with $35\le70y$ is $35/70$.

    $y\ge35/70=0.5$, so the LP pays $80\cdot0.5=40$, half the true fixed cost. With the tight $M=35$ it would pay $80$.

    How many triples $(x,y,z)\in\{0,1\}^3$ satisfy all three of $z\le x$, $z\le y$, $z\ge x+y-1$?

    For each pair $(x,y)$ see how many values of $z$ survive.

    $(0,0)$: $z\le0$ and $z\ge-1$ give $z=0$. $(0,1)$: $z\le0$, so $z=0$. $(1,0)$: $z=0$. $(1,1)$: $z\ge1$, so $z=1$. Exactly one $z$ for each of the 4 pairs: $4$ triples. They are the four rows of the AND table.

    Five depots with binary $y_1,\dots,y_5$ must satisfy $\sum_j y_j\le2$. How many open/closed patterns are allowed?

    Count patterns with 0, 1 and 2 open depots separately.

    $\binom50+\binom51+\binom52=1+5+10=16$.

    The constraint $2x_1+x_2\le8$ is to be switched off by a big-M: it is written $2x_1+x_2\le8+M$ when it is relaxed. With $0\le x_1,x_2\le5$, what is the smallest $M$ that makes $2x_1+x_2\le 8+M$ true for every allowed $(x_1,x_2)$?

    Find the maximum of $2x_1+x_2$ over the box, then subtract 8.

    The maximum of $2x_1+x_2$ is $2\cdot5+5=15$, so $M\ge15-8=7$. The smallest valid $M$ is $7$.

    • Translate each sentence into one constraint at a time and test it on the four (or eight) binary patterns.
    • Choose $M$ from the data: the largest value the left-hand side can reach.
    • Prefer individual forcing constraints $x_{ij}\le y_j$ over aggregated ones when the solver is slow.
    • Using $M=10^6$ "to be safe": the LP relaxation becomes almost useless.
    • Writing "if $x$ then $y$" as $y\le x$ (the reverse rule).
    • Multiplying two binary variables directly instead of introducing $z$ with three linear constraints.
    1. Sums and inequalities on binary variables express AND, OR, NOT, "at most $k$" and "if then" ($x\le y$) exactly.
    2. A forcing constraint $x\le My$ links an amount to a yes/no decision, and $M$ must be as small as the data allows because the LP relaxation sets $y=x/M$.
    3. Products of binaries use $z\le x$, $z\le y$, $z\ge x+y-1$, and "at least one of two constraints" uses a binary $\delta$ with a big-M on each.

    Which constraint says "depot 2 may open only if depot 5 is open"?

    $y_2\le y_5$
    If $y_2=1$ this forces $y_5=1$; if $y_2=0$ nothing is demanded of $y_5$.
    $y_5\le y_2$
    Test the pattern $y_2=1,y_5=0$: should it be allowed?
    $y_2+y_5\ge1$
    That is the rule "at least one of the two is open".

    A depot can carry at most 50 units. Which statement about $x\le My$ is correct?

    $M=1000$ is better because it can never be violated.
    It is valid, but think about the LP relaxation: which $y$ does it allow for $x=50$?
    $M=50$ gives the strongest relaxation, since it forces $y\ge x/50$, the smallest valid choice.
    Any larger $M$ is also correct for integer $y$ but lets the LP use a smaller fractional $y$.
    $M=10$ is the best because the LP bound is highest.
    Too small an $M$ cuts off feasible integer solutions: a load of 50 would be impossible.

    For binary $x,y$ and $z$ defined by $z\le x$, $z\le y$, $z\ge x+y-1$, what is $z$ when $x=1,\ y=0$?

    $z=1$
    $z\le y=0$ forbids it.
    $z=0$
    $z\le y=0$ forces it, and $z\ge x+y-1=0$ is then satisfied.
    $z$ can be 0 or 1
    Check the constraint $z\le y$.

    Just enough Python, Gurobi and NetworkX: reading a model file

    A Gurobi script is a model written down in order: read the numbers, create variables, state the objective, add constraints, solve, read the answer. Each line maps to a piece of the mathematics.

    The labs hand you such files. You need to read them, spot the objective and constraints, and change them confidently; you do not need to be a programmer.

    It is like a recipe card: ingredients (data), tools (variables), method (constraints), and the step "cook" (optimize).

    Python in five lines

    Python lists are written in square brackets and counted from 0: if value = [12, 10, 7] then value[0] is $12$ (this is $c_1$ in maths). The expression range(3) means $0,1,2$. A loop-in-brackets such as [2*j for j in range(3)] builds the list [0, 2, 4]. Dictionaries map keys (often pairs like (i, j)) to values, and text.split() chops a string into words. That is nearly all the Python these files use.

    The anatomy of a Gurobi model

    Install once with pip install gurobipy networkx. The pip install includes a size-limited licence that covers small models like the ones in this part (check Gurobi's current licence terms); for the larger lab instances use the academic licence described in the course's Gurobi setup notes. A model file follows the same steps every time:

    1. m = gp.Model("name"): an empty model.
    2. x = m.addVars(n, vtype=GRB.BINARY): $n$ variables x[0] … x[n-1]. With two counts, m.addVars(a, b) gives variables x[i, j]. Use GRB.CONTINUOUS (the default) or GRB.INTEGER for the other kinds, and lb=, ub= for bounds.
    3. m.setObjective(expr, GRB.MINIMIZE) (or GRB.MAXIMIZE).
    4. m.addConstr(lhs <= rhs) for one constraint, or m.addConstrs(( … for i in … )) for a family, which is the "for all $i$" of the maths.
    5. m.optimize(), then read m.Status, m.ObjVal and x[j].X.

    gp.quicksum(a[j] * x[j] for j in range(n)) is the sum $\sum_j a_jx_j$. It is the same as Python's own sum but faster for models.

    import gurobipy as gp
    from gurobipy import GRB
    
    value  = [12, 10, 7]
    weight = [5, 4, 3]
    cap    = 8
    
    m = gp.Model("knapsack")
    m.setParam("OutputFlag", 0)          # silence the solver log
    x = m.addVars(3, vtype=GRB.BINARY, name="x")
    m.setObjective(gp.quicksum(value[j] * x[j] for j in range(3)), GRB.MAXIMIZE)
    m.addConstr(gp.quicksum(weight[j] * x[j] for j in range(3)) <= cap, name="bag")
    m.optimize()
    
    print("status:", m.Status, "(optimal)" if m.Status == GRB.OPTIMAL else "")
    print("objective:", m.ObjVal)
    print("x =", [int(x[j].X) for j in range(3)])

    Output when run:

    status: 2 (optimal)
    objective: 19.0
    x = [1, 0, 1]

    This is the knapsack model $\max\ 12x_1+10x_2+7x_3$ s.t. $5x_1+4x_2+3x_3\le8$, $x\in\{0,1\}^3$. Items 1 and 3 weigh $5+3=8$ and are worth $19$; items 2 and 3 are worth only $17$. Status is a number: 2 is GRB.OPTIMAL. Always check it before reading .X (an infeasible model has no solution to read).

    Try it

    Click any part of the code (or the matching part of the maths) to highlight both together, or press Next piece to walk through them in order. Notice that the single line m.addConstr(...) contains the left-hand sum and the comparison with cap as separate pieces.

    Reading instance files

    Data usually comes in a text file of numbers whose layout is fixed by convention. The reading code turns the file into one long list and then walks a position counter through it. The facility-location files of Lab 1 (uflp_code.py and q1.py) use this layout:

    • the first two numbers are the number of candidate facilities and the number of customers;
    • next, one opening (fixed) cost per facility;
    • then, for each customer, a demand followed by the cost of serving that customer from each facility, in order.

    The lab's reader keeps only the tokens that look like numbers (a helper is_number discards words such as capacity that sit in the files), converts them, and slices them out in the order above. The model it builds is the one from Lecture 3: a binary $y_j$ per facility, a continuous $x_{ij}\ge0$ (fraction of customer $i$ served by facility $j$), the objective $\min\sum_j f_jy_j+\sum_{ij}c_{ij}x_{ij}$, the constraint $\sum_j x_{ij}=1$ for each customer, and the linking constraint. In uflp_code.py the link is the individual form $x_{ij}\le y_j$; in q1.py it is replaced by the aggregated $\sum_i x_{ij}\le n\,y_j$, so that the two formulations can be compared. Below is a miniature version with 3 depots and 4 customers that does both.

    import gurobipy as gp
    from gurobipy import GRB
    
    text = """
    3 4
     30
     45
     25
     10   4  9  7
     10   6  3  8
     10   8  7  2
     10   5  6  5
    """
    tokens = [float(t) for t in text.split()]
    nf, nc = int(tokens[0]), int(tokens[1])      # depots, customers
    fixed = tokens[2:2 + nf]                     # opening costs f_j
    pos = 2 + nf
    cost = []                                    # cost[i][j]: customer i from depot j
    for i in range(nc):
        pos += 1                                 # skip the demand number
        cost.append(tokens[pos:pos + nf])
        pos += nf
    
    def build(strong):
        m = gp.Model()
        m.setParam("OutputFlag", 0)
        y = m.addVars(nf, vtype=GRB.BINARY, name="y")
        x = m.addVars(nf, nc, lb=0, name="x")
        m.setObjective(gp.quicksum(fixed[j] * y[j] for j in range(nf))
                       + gp.quicksum(cost[i][j] * x[j, i] for i in range(nc) for j in range(nf)),
                       GRB.MINIMIZE)
        m.addConstrs((gp.quicksum(x[j, i] for j in range(nf)) == 1 for i in range(nc)), name="serve")
        if strong:
            m.addConstrs((x[j, i] <= y[j] for j in range(nf) for i in range(nc)), name="link")
        else:
            m.addConstrs((gp.quicksum(x[j, i] for i in range(nc)) <= nc * y[j] for j in range(nf)), name="link")
        return m, y
    
    for strong in (True, False):
        m, y = build(strong)
        m.optimize()
        lp = m.relax(); lp.optimize()            # drop integrality: the LP relaxation
        print("x<=y" if strong else "sum<=n*y", "| LP bound", round(lp.ObjVal, 2),
              "| integer optimum", m.ObjVal, "| open", [j for j in range(nf) if y[j].X > 0.5])

    Output when run:

    x<=y | LP bound 47.0 | integer optimum 47.0 | open [2]
    sum<=n*y | LP bound 44.5 | integer optimum 47.0 | open [2]

    Both versions agree on the integer optimum: open only depot index 2 (the third one) for a total of $25+7+8+2+5=47$. But the aggregated form has a relaxation bound of $44.5$, strictly below $47$: the weaker bound of the previous chapter, observed in a solver. In the big labs this gap decides how many branch-and-bound nodes Gurobi needs.

    Careful: Gurobi collects your commands and builds the model lazily. Call m.optimize() (or m.update()) before m.relax(); otherwise the copy is empty and reports an objective of $0$. Remember also that indices start at 0: depot "index 2" is the third depot.

    The GAP lab file

    In Lab 2 (GAP_Gurobi.py) the generalised assignment problem is solved the same way. The file lists $m$ agents and $n$ jobs, then the $m\times n$ cost matrix, then the $m\times n$ resource-use matrix, then the $m$ capacities. The reader flattens all numbers and slices them: the first $mn$ are costs, the next $mn$ resource use, the rest capacities. The model has a binary $x_{ij}$ (agent $i$ does job $j$); the objective is $\min\sum_{ij}c_{ij}x_{ij}$; each job is done exactly once, $\sum_i x_{ij}=1$; and each agent respects its capacity, $\sum_j r_{ij}x_{ij}\le q_i$. The lab then switches off presolve and cuts (Presolve=0, Cuts=0), so that branch and bound runs on the model as written, sets a time limit, solves, calls relax() to get the LP bound, and reports ObjVal, ObjBound, NodeCount and MIPGap. A miniature with 2 agents and 4 jobs:

    import gurobipy as gp
    from gurobipy import GRB
    
    text = """2 4
     6 9 4 7
     5 3 8 6
     3 4 2 4
     4 3 5 3
     7 8"""
    nums = [int(t) for t in text.split()]
    m_, n_ = nums[0], nums[1]
    body = nums[2:]
    cost = [body[i * n_:(i + 1) * n_] for i in range(m_)]
    use  = [body[m_ * n_ + i * n_: m_ * n_ + (i + 1) * n_] for i in range(m_)]
    cap  = body[2 * m_ * n_:]
    
    m = gp.Model("gap")
    m.setParam("OutputFlag", 0)
    x = m.addVars(m_, n_, vtype=GRB.BINARY, name="x")
    m.setObjective(gp.quicksum(cost[i][j] * x[i, j] for i in range(m_) for j in range(n_)), GRB.MINIMIZE)
    m.addConstrs((x.sum("*", j) == 1 for j in range(n_)), name="job")
    m.addConstrs((gp.quicksum(use[i][j] * x[i, j] for j in range(n_)) <= cap[i] for i in range(m_)), name="cap")
    m.optimize()
    print(m.Status, m.ObjVal)
    lp = m.relax(); lp.optimize(); print("LP bound", lp.ObjVal)

    Output when run:

    2 19.0
    LP bound 18.5

    Here x.sum("*", j) adds x[i, j] over all $i$, a shorthand for the quicksum over agents. The LP bound $18.5$ is below the integer optimum $19$: the integer restriction costs half a unit.

    NetworkX: graphs in a few lines

    Some labs and the routing project need a graph: nodes, edges with lengths, shortest paths. NetworkX stores that. G.add_edge("A","B", weight=4) creates both nodes and the edge with a length; nx.shortest_path(G, "A", "D", weight="weight") returns the list of nodes of a shortest route, and nx.shortest_path_length its length.

    import networkx as nx
    
    G = nx.Graph()
    G.add_edge("A", "B", weight=4)
    G.add_edge("A", "C", weight=1)
    G.add_edge("C", "B", weight=2)
    G.add_edge("B", "D", weight=5)
    G.add_edge("C", "D", weight=8)
    
    path = nx.shortest_path(G, "A", "D", weight="weight")
    length = nx.shortest_path_length(G, "A", "D", weight="weight")
    print(path, length)
    print(list(G.neighbors("C")), G.number_of_nodes(), G.number_of_edges())

    Output when run:

    ['A', 'C', 'B', 'D'] 8
    ['A', 'B', 'D'] 4 5

    The shortest route $A\to C\to B\to D$ has length $1+2+5=8$, which beats $A\to B\to D=9$ and $A\to C\to D=9$. The neighbors("C") list of ['A', 'B', 'D'] shows the nodes adjacent to $C$.

    You meet these three lines in a file. Write the mathematical model they build. y = m.addVars(3, vtype=GRB.BINARY)
    m.setObjective(gp.quicksum(f[j] * y[j] for j in range(3)), GRB.MINIMIZE)
    m.addConstrs((gp.quicksum(A[i][j] * y[j] for j in range(3)) >= 1 for i in range(4)))

    1. Line 1: three binary variables, $y_j\in\{0,1\}$ for $j=1,2,3$.

      The number inside addVars is the count, and GRB.BINARY gives the $\{0,1\}$ restriction.

    2. Line 2: $\min\sum_{j=1}^{3}f_jy_j$.

      quicksum over j is a sum, and GRB.MINIMIZE is the direction.

    3. Line 3: $\sum_{j=1}^{3}a_{ij}y_j\ge1$ for $i=1,\dots,4$, four constraints.

      addConstrs with a generator for i in range(4) is the "$\forall i$"; the comparison inside is the rule that is repeated.

    4. Together this is the minimum-weight set cover of Chapter D.1 with 4 elements and 3 subsets, with $f_j$ in the role of the weights $w_j$ and $A$ the incidence matrix.

      Recognising the pattern ($\ge1$ rows, a cost vector, binary variables) is what lets you read a long file quickly.

    Go deeper: what the solver does with optimize()

    For a model with binary variables Gurobi runs branch and bound (Lecture 4): it solves the LP relaxation, picks a fractional variable, splits into two sub-problems, and uses the LP bounds to discard sub-problems that cannot beat the best integer solution found. The tighter the relaxation (Chapter D.2), the fewer sub-problems. Parameters such as TimeLimit or MIPGap stop the search early and m.NodeCount reports how many sub-problems were explored.

    How many variables does m.addVars(3, 4, vtype=GRB.BINARY) create?

    With two counts there is one variable for each pair $(i,j)$.

    $3\times4=12$ variables, x[0,0] up to x[2,3].

    How many constraints are added by m.addConstrs((x[i, j] <= y[i] for i in range(5) for j in range(3)))?

    One constraint for every pair $(i,j)$ produced by the two loops.

    $5\times3=15$, one for each pair.

    After a successful solve to optimality, what number does m.Status hold in the examples above (the value of GRB.OPTIMAL)?

    Look at the first line of the knapsack output.

    The knapsack output printed status: 2, and the code compared it with GRB.OPTIMAL: the value is $2$.

    A facility-location file in the layout of this chapter has 3 facilities and 4 customers: two header numbers, 3 opening costs, and for each customer a demand plus 3 costs. How many numbers does the file contain?

    Add the header, the facility part, and four customer rows of length $1+3$.

    $2+3+4\cdot(1+3)=2+3+16=21$.

    Edges (with weights): A–B 4, A–C 1, C–B 2, B–D 5, C–D 8. What does nx.shortest_path_length(G, "A", "D", weight="weight") return?

    List the routes from A to D and add up the weights on each.

    A–C–B–D $=1+2+5=8$, A–B–D $=4+5=9$, A–C–D $=1+8=9$. The shortest is $8$.

    • Read a model file in the order: data, variables, objective, constraints, solve, output; write the maths next to each part.
    • Check m.Status before reading .X or .ObjVal.
    • Test code on a tiny instance whose answer you can verify by hand.
    • Forgetting that Python counts from 0 (item 1 in the maths is index 0 in the code).
    • Calling m.relax() before the model has been updated: the copy comes out empty.
    • Copying a constraint line without understanding which loop gives the "for all".
    1. A Gurobi script has a fixed anatomy: Model, addVars, setObjective, addConstr(s), optimize, then Status, ObjVal and .X; each line is one piece of the mathematics.
    2. Instance files are read by flattening the numbers and slicing them in the documented order; quicksum over a loop is a $\sum$ and addConstrs with a loop is a $\forall$.
    3. NetworkX stores weighted graphs and answers shortest-path questions with add_edge, shortest_path and shortest_path_length.

    In gp.quicksum(a[j] * x[j] for j in range(4)), which maths object is written?

    $\prod_{j=1}^{4}a_jx_j$
    The function name says "sum".
    $a_4x_4$ only
    The generator runs over all of range(4).
    $\sum_{j=1}^{4}a_jx_j$
    The generator lists the terms and quicksum adds them (indices shifted by one from Python's $0,\dots,3$).

    A script prints 0.0 as the LP bound after lp = m.relax(); lp.optimize() although the true bound is clearly positive. The most likely cause?

    The model was not updated (no optimize() or update() call) before relax(), so the copy was empty.
    Gurobi applies changes lazily; relaxing an unbuilt model copies nothing.
    Gurobi cannot solve LP relaxations of binary models.
    It can, as the examples above show.
    The objective must be reversed to maximise.
    The sense affects the sign of the bound, not whether the model is empty.

    What does m.addConstrs((gp.quicksum(x[i, j] for j in range(3)) == 1 for i in range(6))) add?

    One constraint adding all 18 variables to 1.
    The outer generator over i repeats the rule.
    Three constraints, one per $j$.
    Which index is summed inside and which is looped outside?
    Six constraints, one per $i$, each saying the three variables $x_{i1},x_{i2},x_{i3}$ add to 1.
    The loop over i is the "for all $i$", and the sum runs over $j$.

    Four elements and routes $R_1=\{1,2\}$, $R_2=\{2,3\}$, $R_3=\{3,4\}$. Which choice is a partition of $\{1,2,3,4\}$?

    $\{R_1,R_2,R_3\}$
    Element 2 appears in two chosen sets.
    $\{R_1,R_3\}$
    $\{1,2\}\cup\{3,4\}$ covers everything exactly once.
    $\{R_2\}$
    Elements 1 and 4 are missed, so it is not even a cover.

    Which pair of constraints models "if $x$ or $y$ is chosen, then $z$ must be chosen"?

    $z\le x$ and $z\le y$
    That says $z$ can be chosen only if both are, which is a different rule.
    $x+y\le z$
    With $x=y=1$, $z$ would need to be 2.
    $x\le z$ and $y\le z$
    If either is 1, then $z$ is forced to 1.

    Which line of a Gurobi file builds the objective $\min\sum_{j}c_jx_j$ over 5 items?

    m.addConstr(gp.quicksum(c[j] * x[j] for j in range(5)), GRB.MINIMIZE)
    Constraints are not given a direction like that.
    m.optimize(gp.quicksum(c[j] * x[j] for j in range(5)))
    optimize takes no objective; it just solves what is stored.
    m.setObjective(gp.quicksum(c[j] * x[j] for j in range(5)), GRB.MINIMIZE)
    setObjective stores the expression and the direction.

    With $A=\begin{pmatrix}1&0&1\\1&1&0\end{pmatrix}$ and $x=(1,1,0)$, $Ax=(1,2)$. What does this say about the chosen subsets?

    It is a packing, because the first entry is 1.
    A packing needs every entry at most 1.
    It is a cover but not a packing: element 2 is in two chosen subsets.
    Both entries are at least 1, and the entry 2 means a double cover.
    It is a partition.
    A partition needs every entry equal to 1.

    Lecture 0 introduces the course: what logistics and freight modelling is, the four families of problems it studies (routing, assignment, location and flow), why we model them as optimisation problems instead of simply calling a solver, and how linear programming, integer programming and branch and bound fit together. It ends with a roadmap of the other six parts, so you know where each idea is used later. Along the way we follow one small, fictional firm, Kaveri Courier of Bengaluru, whose owner makes the decisions the later parts learn to solve.

    You need: nothing beyond curiosity. Part A (sums and $Ax\ge b$) helps you read the few formulas here, and Part B (modelling) is the longer version of the modelling step; both are optional for this part.

    What logistics and freight modelling covers: four families of problems

    Logistics modelling turns a question such as "which van goes where, and in what order?" into a mathematical problem that a computer can solve, and most such problems fall into four families: routing, assignment, location and flow.

    Knowing the family tells you which tools to reach for. It also tells you whether to expect an easy problem or a very hard one.

    It is like sorting post by type before delivery: parcels, letters and bulk freight each follow a different path, even though they share the same vans.

    The supply side of moving goods

    Freight is goods in motion, by truck, rail or ship; logistics is the planning of that movement. A courier company, a cement producer and a city bus agency all face the same kind of question: with limited vehicles, depots and time, how do we serve the demand at the least cost?

    This course studies the supply side of that question. The demand is given: we are told where customers are and what they need. We then decide how to serve them. The course mostly looks at last-mile logistics, the final leg from a depot to the customer, in the offline, deterministic setting: all data (locations, quantities, travel costs) are known in advance and do not change while the plan is executed. Think of the morning plan of an online grocer, made after all orders for the day are in.

    Meet Kaveri Courier

    Kaveri Courier is a small, fictional courier firm in Bengaluru: one owner, a few depot sites, a few vans and customers spread across the city. Every morning the owner must decide which depot sites to use, which parcels go on which van, and in what order each van visits its customers. These are exactly the four families below, and the later parts of this site return to this firm whenever a model needs a concrete setting.

    Real operations have many extra rules, such as time windows or driver breaks. The skill this course trains is to turn a requirement into a variable or a constraint. After that, an extra rule is one more line in the model, not a new theory.

    The four families

    A complete logistics system usually mixes several of these. It helps to separate them by asking one question: what is the unknown?

    • Routing: the unknown is an order of visits. Which stops does a vehicle serve, and in which sequence? The classic problems are the travelling salesman problem (TSP: one vehicle, visit every customer once, return home) and the vehicle routing problem (VRP: several vehicles with limited capacity). Most of the course lives here.
    • Assignment (matching, scheduling): the unknown is a pairing. Which driver takes which order, which bus runs which trip, which crew works which shift?
    • Location: the unknown is where to put things: warehouses, depots, charging points, data centres. These are strategic decisions that last for years. Network design, choosing which road links to build, is a close relative.
    • Flow: the unknown is an amount on each link of a network, such as tonnes of grain per rail line. The amounts can be fractions, which makes these the easiest of the four.
    Try it

    Classify each scenario by its unknown. Press a family; after each answer read the reason. Notice that a scenario can touch two families (the truck fleet also decides who serves whom), and the family to name is the main unknown.

    FamilyUnknownEveryday exampleTypical difficulty
    Routingsequence of visitsa courier's daily tourhard (TSP, VRP are NP-hard)
    Assignmentwho is paired with whatdrivers to pickup requestseasy for one-to-one pairing; hard with capacities
    Locationwhich sites to openwarehouse networkhard
    Flowamount on each linktonnes of cement per rail lineeasy (polynomial time)
    Careful: "NP-hard" means that no method is known whose running time stays manageable as the instance grows; for such problems the best-known exact methods can take exponentially longer when the number of customers doubles. It does not mean a small instance is hard. A depot with 8 customers is solved in a blink; a depot with 800 is a research problem.

    Why the decisions matter: a picture

    Suppose a depot at the origin has two customers, $A$ at $3$ km east and $4$ km north, and $B$ twice as far in the same direction, at $(6,8)$. A van could serve each customer in a separate round trip, or go out through $A$ to $B$ and come back in one tour. The costs differ a great deal, and that difference is what logistics modelling captures.

    The depot is at $(0,0)$, customer $A$ at $(3,4)$ and customer $B$ at $(6,8)$, coordinates in km. Compare two plans: (i) two separate round trips; (ii) one tour depot → $A$ → $B$ → depot.

    1. Distance depot to $A$: $\sqrt{3^2+4^2}=5$. Distance depot to $B$: $\sqrt{6^2+8^2}=10$. Distance $A$ to $B$: $\sqrt{3^2+4^2}=5$.

      Straight-line (Euclidean) distance is the simplest travel cost; in practice it would come from a road network.

    2. Plan (i): the round trip to $A$ is $5+5=10$ km and to $B$ is $10+10=20$ km, so $30$ km in total.

      Each separate trip must come back to the depot.

    3. Plan (ii): $5$ (depot to $A$) $+\,5$ ($A$ to $B$) $+\,10$ ($B$ back to depot) $=20$ km.

      One loop reuses the outward leg that plan (i) drives twice.

    4. The tour saves $30-20=10$ km. The two customers happen to lie on one line from the depot, so serving both costs the same as serving only $B$.

      When customers are not on one line the saving is smaller, and choosing the order becomes a real problem. That is the TSP of Part 5.

    The map below (revealed on your answer) has two depots and six customers, and each customer must be served from exactly one depot. Each depot sends one vehicle on one closed tour. Which plan has the smaller total distance: all six customers from the left depot alone, or the customers split between the two depots?

    All six from one depot: fewer vehicles, so less driving.
    One vehicle must cross the whole map and back, which costs a lot of distance.
    Split between the two depots.
    Each vehicle then makes a short local loop. With these positions the split plan is shorter than a single loop through all six.
    Try it

    Drag the two depots (squares) and tap customers to switch which depot serves them. The line shows the shortest tour for each depot, found by checking every visiting order. Compare "Nearest depot" with "Cheapest split", then drag a depot to the far east and see which customers change hands. Notice that moving a depot changes the cost even if no customer changes depot.

    The same ideas in symbols: a location model

    The map mixes three decisions: where depots stand (location), which depot serves whom (assignment) and in what order (routing). To see how a model is written, take just the first two. We have candidate sites $j$, each with a yearly opening cost $f_j$, and customers $i$, where serving customer $i$ from site $j$ costs $c_{ij}$. We introduce a binary variable $y_j$ for "open site $j$" and a binary variable $x_{ij}$ for "serve customer $i$ from site $j$".

    Notation for this chapter
    $i$
    a customer
    $j$
    a candidate site (depot or warehouse)
    $f_j$
    fixed cost of opening site $j$
    $c_{ij}$
    cost of serving customer $i$ from site $j$
    $y_j\in\{0,1\}$
    1 if site $j$ is opened
    $x_{ij}\in\{0,1\}$
    1 if customer $i$ is served from site $j$

    $$\min\ \sum_j f_j\,y_j+\sum_i\sum_j c_{ij}\,x_{ij}$$ $$\text{s.t.}\quad \sum_j x_{ij}=1\ \ \forall i,\qquad x_{ij}\le y_j\ \ \forall i,j,\qquad x_{ij},y_j\in\{0,1\}.$$

    In words: each customer is served from exactly one site, and a site can serve only if it is open. The objective adds the opening costs of the open sites and the serving costs of all customers.

    The other families have the same flavour. Assignment uses $x_{ij}=1$ for "driver $j$ takes order $i$" with $\sum_j x_{ij}=1$ for every order, and a capacity version adds a rule such as $\sum_i d_i x_{ij}\le q_j$, where $d_i$ is the demand of item $i$ and $q_j$ the capacity of agent $j$ (Part 3). Flow has a variable $x_a\ge0$ for the amount on each arc $a$, a balance rule at every node and a capacity $q_a$ on every arc. Routing uses variables on the edges of a graph $G=(V,E)$ that say which edges the tours use (Parts 5 and 6).

    Two candidate sites with opening costs $f_1=10$, $f_2=14$ and three customers. Serving costs $c_{ij}$ (cost units): site 1 serves customers 1, 2, 3 at $2,6,9$; site 2 serves them at $7,3,2$. Which sites should we open?

    1. List the options: open only site 1, only site 2, or both. Opening none cannot serve anyone.

      With only two sites, listing every combination is feasible; in Part 3 we see why this does not scale.

    2. Only site 1: $10+(2+6+9)=27$. Only site 2: $14+(7+3+2)=26$.

      If a single site is open, it must serve every customer.

    3. Both: $10+14=24$ in opening costs, and each customer goes to its cheaper site: $\min(2,7)+\min(6,3)+\min(9,2)=2+3+2=7$. The total is $24+7=31$.

      Opening a site can only reduce serving costs, but it adds the fixed cost. Here the fixed cost of the second site outweighs the saving.

    4. The cheapest option is to open only site 2, at cost $26$.

      The constraint $x_{ij}\le y_j$ is what stops us from serving at the low costs of a site without paying for it.

    Go deeper: why flow is easy but the others are hard

    In a flow problem the amounts can be fractions, so the model is a linear programme, which is solved efficiently (Parts 1 and 2). Pairing one driver with one order also has an extremely helpful structure, so the answer comes out whole without being forced. Location, routing and capacitated assignment need yes/no or whole-number answers (open or not, edge used or not), and that single change turns a tractable problem into one for which the best-known exact methods are exponential in the worst case.

    The depot is at $(0,0)$ and the customers are at $(3,4)$ and $(3,-4)$. Find the length of the tour depot → $(3,4)$ → $(3,-4)$ → depot, in km.

    There are three legs. The middle leg is vertical.

    Depot to $(3,4)$ is $5$; $(3,4)$ to $(3,-4)$ is $8$ (the $y$-coordinates differ by 8); $(3,-4)$ back to the depot is $5$. Total $5+8+5=18$ km. Two separate round trips would cost $10+10=20$ km.

    Two sites have opening costs $f_1=12$, $f_2=7$. Three customers have serving costs $c_{i1}=(1,2,3)$ from site 1 and $c_{i2}=(4,5,3)$ from site 2. What is the minimum total cost of a valid plan?

    Evaluate three plans: only site 1, only site 2, both sites.

    Only site 1: $12+1+2+3=18$. Only site 2: $7+4+5+3=19$. Both: $12+7+\min(1,4)+\min(2,5)+\min(3,3)=19+1+2+3=25$. The cheapest is $18$ (site 1 only).

    A van starts at the depot and must visit $5$ customers once each and return. A tour and the same tour driven backwards count as one tour. How many different tours are there? (The count is $k!/2$ for $k$ customers.)

    Compute $5!=120$ and halve it.

    There are $5!=120$ orders of visits. Each tour appears twice, once in each direction, so there are $120/2=60$ different tours.

    A facility location model has $4$ candidate sites and $10$ customers. How many binary variables $y_j$ and $x_{ij}$ does it have in total?

    One $y_j$ for each site, and one $x_{ij}$ for each pair of customer and site.

    $4$ variables $y_j$ plus $10\times4=40$ variables $x_{ij}$, so $44$. The linking rules $x_{ij}\le y_j$ add $40$ constraints and the assignment rules add $10$, so $50$ constraints.

    A mining company must choose which of 6 possible sites will host its new rail loading terminals. Which family is the main decision?

    Is the unknown an order, a pairing, a place or an amount on a link?

    Choosing among candidate sites is a location decision. The later movement of ore along links would be a separate flow problem.

    • Name the unknown first: a route, a pairing, a site or an amount.
    • Ask whether several families are combined, and which decision comes first in time (sites first, then routes).
    • Treating "visit all customers" as a shortest-path problem; a shortest path joins two points and does not choose an order of visits.
    • Assuming that opening more depots is always cheaper: fixed costs and extra vehicles can outweigh the shorter trips.
    1. Logistics problems fall into four families, routing, assignment, location and flow, and the family is decided by what the unknown is.
    2. The course studies supply-side, last-mile, offline problems with known data, and teaches how to write requirements as variables and constraints.
    3. Yes/no decisions (open a site, use an edge) make a problem hard, while continuous flows stay easy; a location model uses a binary $y_j$ and a link rule $x_{ij}\le y_j$.

    A company plans how many tonnes of steel go along each of 20 rail links, splittable in any way, at least cost with link capacities. Which statement is true?

    It is a routing problem and probably very hard.
    No order of visits is chosen here; look at what the unknown is.
    It is a flow problem, and such problems can be solved efficiently.
    The unknown is an amount on each link, and fractional amounts are allowed, so the model is a linear programme.
    It is a location problem because the rail links are fixed.
    Nothing is being sited here; the links already exist.

    In the location model, what does the constraint $x_{ij}\le y_j$ forbid?

    Serving any customer from more than one site.
    That is the job of $\sum_j x_{ij}=1$.
    Opening more than one site.
    Nothing limits the number of sites that may be opened.
    Serving a customer from a site that has not been opened.
    If $y_j=0$ the rule forces every $x_{ij}=0$; if $y_j=1$ it allows $x_{ij}$ to be 0 or 1.

    Which of these is outside the scope of the course as described in Lecture 0?

    An offline plan for a day's deliveries with known orders.
    This is exactly the offline, deterministic setting.
    Predicting next month's demand and deciding prices.
    The course covers supply optimisation only, with demand given.
    Choosing the order in which one van visits its customers.
    This is routing, the main topic.

    Why do solvers not make modelling skills unnecessary?

    Solvers only work on routing problems.
    Solvers handle many problem types; think about the size of the instance.
    Most problems here are NP-hard, so a clumsy formulation or a large instance can defeat a solver, and a good model or a special method may be needed.
    Formulation quality and solution methods decide whether a realistic instance is solved at all.
    Solvers cannot read constraints.
    Solvers read constraints perfectly; the question is how fast they can solve them.

    How linear programming, integer programming and branch and bound fit together

    Linear programming (LP) solves problems with continuous variables quickly. Integer programming (IP) adds whole-number requirements, and branch and bound solves an IP by solving many LPs.

    This is the engine behind every method in the course, including the solvers you will call from Python. Knowing it now gives a skeleton for each later part.

    It is like planning a delivery fleet: first you work out the ideal answer ignoring that trucks come in whole units, then you repair it step by step until you have a plan you can actually run.

    Why not just try every plan?

    For small cases, listing all plans works, as the two-site example showed. But the number of plans grows explosively. A van that must visit $k$ customers and return has $k!/2$ different tours (the order of visits, with a tour and its reverse counted once). The widget shows how quickly that count passes anything a computer can check.

    Try it

    Move the slider and read the time needed to check every tour at one billion tours per second. Find the largest $k$ that still takes under an hour, and the first $k$ that takes more than a year. Notice that going from 10 to 15 customers multiplies the time by about 360 thousand.

    So we need methods that discard most plans without looking at them. The central trick of the course is to bound the answer using an easier problem. First we need two definitions.

    Linear and integer programs

    A linear programme (LP) minimises a linear cost $c^\top x$ over the points $x$ with $Ax\ge b$ and $x\ge0$ (Part 1 covers these). The variables may be fractions. An integer programme (IP) has the same form with one more requirement: $x$ must be a vector of whole numbers. If every variable is restricted to $0$ or $1$ it is a binary program, the kind used for open/close decisions. If only some variables are whole numbers it is a mixed integer programme.

    The LP relaxation of an IP is the same problem with the whole-number requirement dropped. Every feasible plan of the IP is also feasible for the relaxation, so the relaxation has at least as many choices.

    For a minimisation, the optimal value of the LP relaxation is at most the optimal value of the IP. If the LP optimum happens to have only whole entries, it is also optimal for the IP.

    Why: the relaxation minimises over a larger set, and a minimum over a larger set cannot be bigger. Therefore the LP value is a lower bound: no plan can beat it. If we also hold a real plan, the gap between the two tells us how far from optimal that plan can be.

    A small example

    A depot must cover at least $8$ units of heavy parcels and at least $8$ units of stops per day. A truck of type 1 costs $5$ cost units per day, carries $4$ units of heavy parcels and makes $2$ units of stops. Type 2 costs $4$, carries $1$ unit of heavy parcels and makes $2$ units of stops. Let $x_1,x_2$ be the numbers of trucks hired. Then $$\min\ 5x_1+4x_2\quad\text{s.t.}\quad 4x_1+x_2\ge 8,\quad 2x_1+2x_2\ge 8,\quad x_1,x_2\in\mathbb{Z}_+.$$ Ignoring whole numbers, the cheapest LP plan hires $x_1=4/3$ and $x_2=8/3$ trucks at cost $52/3\approx17.33$. We cannot hire a third of a truck, so the relaxation is only a bound, not a plan.

    Careful: rounding the LP answer is not a solution method. Here, rounding to the nearest whole number gives $(1,3)$, which carries only $4+3=7$ heavy units and is infeasible. Rounding up gives $(2,3)$, feasible but costing $22$, while a plan costing $18$ exists. In large models rounding can be far worse or impossible.

    The LP optimum is $x_1=4/3$, $x_2=8/3$. The best whole-number plan must obey $x_1\le 1$ or $x_1\ge 2$, because no whole number lies strictly between $1$ and $2$. What do you expect to happen if we solve the LP again once with $x_1\le1$ added, and once with $x_1\ge2$ added?

    Each new LP will give the same fractional point as before.
    The old point violates both new rules ($4/3$ is neither at most 1 nor at least 2), so it is no longer allowed.
    Both new LPs have a different optimum, and both costs are at least $52/3$.
    Adding a constraint can only make the minimum larger or equal; the point $(4/3,8/3)$ has been cut off.
    Try it

    Press the three buttons: the full problem (the root), then the two sub-problems made by adding $x_1\le1$ and $x_1\ge2$. In each picture the green dots are the whole-number plans that remain and the red ring is the LP optimum. Tap integer points to test your own plan. Notice that both sub-problems have whole-number LP optima here.

    Branch and bound

    What you just did is the method itself. We solve the relaxation; if the answer is not whole, we split the problem into two smaller ones that exclude the current answer but keep every whole-number plan (branching); then we solve those relaxations, and so on. The LP values act as bounds (bounding), which allow us to throw whole branches away (pruning).

    1. Keep an incumbent: the best whole-number plan found so far, with its cost (at the start there is none, cost $+\infty$).
    2. Take an unsolved problem and solve its LP relaxation.
    3. If the LP is infeasible, discard the problem. If its LP value is at least the incumbent cost, discard it as well (prune by bound): no plan inside can be better.
    4. If the LP optimum is whole, it is a plan: record it as the new incumbent (prune by integrality).
    5. Otherwise choose a fractional variable $x_j=v$ and create two problems, one with $x_j\le\lfloor v\rfloor$ and one with $x_j\ge\lceil v\rceil$. Return to step 2 until no unsolved problems remain.

    Run branch and bound on $\min\ 5x_1+4x_2$ s.t. $4x_1+x_2\ge8$, $2x_1+2x_2\ge8$, $x\in\mathbb{Z}_+^2$.

    1. Root LP: the optimum is $x=(4/3,8/3)$ with cost $\tfrac{20}{3}+\tfrac{32}{3}=\tfrac{52}{3}\approx17.33$. It is fractional, so branch on $x_1=4/3$: children $x_1\le1$ and $x_1\ge2$.

      $\lfloor4/3\rfloor=1$ and $\lceil4/3\rceil=2$. We could also have branched on $x_2=8/3$, giving $x_2\le2$ and $x_2\ge3$.

    2. Child $x_1\le1$: with $x_1=1$ the rule $4x_1+x_2\ge8$ needs $x_2\ge4$, and then $2x_1+2x_2=10\ge8$ holds. The LP optimum is $(1,4)$ at cost $5+16=21$. It is whole, so the incumbent is $21$.

      With $x_1\le1$ the cheapest way to meet the heavy-parcel requirement is to keep $x_1=1$ and fill the rest with type 2 trucks.

    3. Child $x_1\ge2$: the optimum is $(2,2)$ at cost $10+8=18$, whole, and $18\lt21$. The incumbent becomes $18$.

      At $x_1=2$ the first rule gives $8+x_2\ge8$ and the second gives $4+2x_2\ge 8$, so $x_2=2$ is the smallest choice.

    4. No unsolved problems remain, so $(2,2)$ with cost $18$ is optimal. The root bound agrees: all costs here are whole numbers, so any plan costs at least $\lceil52/3\rceil=18$.

      The gap between the bound $17.33$ and the incumbent $18$ is less than 1, and no whole-number plan can have a cost strictly between them.

    Where this goes, and how the course runs

    Every serious method in the course sits on this loop: a stronger LP relaxation (a better formulation, or extra valid inequalities called cutting planes) gives tighter bounds and fewer branches. TSP and VRP will use exactly this, with relaxations that are cleverly written or generated as needed.

    The course is assessed (as Lecture 0 describes it) through five programming assignments in Python, graded in a competitive mode on accuracy and run time, and a final project in an implementation track (reproduce a published logistics paper) or a research track. Labs take place every two weeks. Check the current syllabus for exact weights and dates.

    PartLectureWhat you learn
    A to Dfoundationsmaths toolkit, modelling and LP basics, graphs and algorithms, sets, logic and code
    1Lecture 1geometry of LPs and the simplex method
    2Lecture 2simplex in detail and LP duality
    3Lecture 3integer programming and strong formulations
    4Lecture 4branch and bound, in full
    5Lecture 5the travelling salesman problem and its cutting planes
    6Lecture 12the vehicle routing problem and set covering/partitioning models
    7Lectures 6–7valid inequalities, covers and lifting, faces and facets
    8Lecture 8cutting-plane algorithms, Gomory cuts, branch and cut
    9Lectures 9–10cuts for the TSP: connectivity, blossoms, combs, time windows
    10Lecture 13column generation and Dantzig–Wolfe decomposition
    11Lecture 14branch and price for vehicle routing
    12last classcase study: Walmart's grocery network
    Go deeper: the course modules and what comes after Part 6

    Lecture 0 groups the course into five modules: background (LP, IP, branch and bound), classic logistics problems (TSP, VRP, matching, location, with a short look at computational complexity), TSP and cutting planes, VRP and column generation (branch and price), and a final module on heuristics for TSP and VRP, vehicle and crew scheduling, and collaborative logistics. This site covers the first four modules: the VRP formulations of Lecture 12 in Part 6, valid inequalities and cutting planes in Parts 7 to 9, column generation and branch and price in Parts 10 and 11, and the Walmart case study of the last class in Part 12. Inventory (Lecture 15) has its own companion course, Restock.

    For $\min\ 5x_1+4x_2$, what is the cost at the LP optimum $x=(4/3,\,8/3)$? Give the value to two decimals if you like.

    Compute $5\cdot\tfrac43+4\cdot\tfrac83$.

    $\tfrac{20}{3}+\tfrac{32}{3}=\tfrac{52}{3}\approx17.33$. This is a lower bound on the integer optimum.

    Is $x=(1,3)$ a feasible plan for the integer program $4x_1+x_2\ge8$, $2x_1+2x_2\ge8$, $x\in\mathbb{Z}_+^2$?

    Check the first inequality; the second holds comfortably.

    $4\cdot1+3=7\lt 8$, so the first inequality fails. Rounding the LP optimum to the nearest point is therefore not safe.

    The LP optimum has $x_2=8/3$. Branching on $x_2$ gives the children $x_2\le 2$ and $x_2\ge ?$. Fill in the missing whole number.

    It is the whole number just above $8/3\approx2.67$.

    $\lceil8/3\rceil=3$. The children are $x_2\le2$ and $x_2\ge3$. Whole-number values of $x_2$ lie in one of these two sets, and the fractional point $8/3$ lies in neither.

    The incumbent plan costs $18$. A sub-problem has a fractional LP optimum with cost $18.5$. In a minimisation, what should branch and bound do with this sub-problem?

    Every plan inside the sub-problem costs at least as much as its LP value.

    Every whole-number plan in the sub-problem costs at least $18.5$, which is more than $18$, so nothing in it can improve the incumbent. We prune it.

    The incumbent costs $18$. A sub-problem has a fractional LP optimum with cost $16.2$. What should happen?

    Is it possible that some whole-number plan inside costs less than $18$?

    The bound $16.2$ is below $18$, so a whole-number plan costing less than $18$ (for example $17$) could still hide inside. We cannot prune; we branch on a fractional variable.

    • Treat the LP relaxation as a bound (a lower bound for a minimisation), not as a plan.
    • Branch on a fractional variable, using $\le\lfloor v\rfloor$ and $\ge\lceil v\rceil$, so no whole-number plan is lost.
    • Rounding an LP answer and calling it optimal.
    • Pruning a sub-problem whose bound is below the incumbent: it may still hide a better plan.
    1. An IP is an LP plus whole-number requirements; dropping them gives the LP relaxation, whose optimal value is a bound (lower for a minimisation).
    2. Branch and bound solves a sequence of LPs, splitting on a fractional variable and pruning sub-problems that are infeasible, whole, or no better than the incumbent.
    3. Tighter relaxations (better formulations and cutting planes) mean fewer branches; this is the thread through Parts 1 to 6.

    Why is the LP relaxation's optimal value never above the IP optimum when minimising?

    Because LPs always have whole-number solutions.
    LP solutions are often fractional, as in the truck example.
    Because the relaxation minimises over a larger set that contains every IP plan.
    A minimum over a bigger set cannot be larger.
    Because the LP uses fewer variables.
    The relaxation keeps the same variables; it only drops the whole-number rule.

    The LP relaxation of a minimisation IP returns a solution with all variables whole. What follows?

    We must still branch on every variable.
    Branching is only needed on fractional variables.
    It is feasible but may not be optimal.
    It is optimal for the relaxation, whose value is a lower bound for the IP.
    It is optimal for the IP as well.
    It is a feasible plan whose cost equals the lower bound, so nothing can beat it.

    A node's LP relaxation turns out to be infeasible. What does branch and bound do?

    Discards the node: it contains no whole-number plans either.
    A plan of the node would be feasible for its relaxation, so an infeasible relaxation means no plans exist.
    Rounds some variables until it becomes feasible.
    Constraints cannot be repaired by rounding.
    Branches anyway on any variable.
    Branching on a problem with no feasible point only creates empty problems.

    Which choice correctly describes the children made from a fractional value $x_j=2.4$?

    $x_j\le 2.4$ and $x_j\ge 2.4$
    The children must exclude the fractional point; these keep it.
    $x_j\le2$ and $x_j\ge3$
    They remove the fractional band $2\lt x_j\lt3$ and keep every whole-number plan.
    $x_j=2$ and $x_j=3$
    That would lose plans with larger or smaller $x_j$, such as $x_j=5$.

    Which family is the TSP in, and what is its unknown?

    Location; where to put the depot.
    In the TSP the depot is already given.
    Routing; the order in which the customers are visited.
    The unknown is the sequence of the tour.
    Flow; the number of tonnes on each road.
    The TSP does not decide quantities on links.

    With $f=(5,9)$ and customers' serving costs $c_{i1}=(1,4)$, $c_{i2}=(3,1)$ for two customers, which plan is cheapest?

    Only site 2, cost 13.
    Site 2 costs $9+3+1=13$ in total; compare every plan, including the one with the cheaper opening cost.
    Only site 1, cost 10.
    $5+1+4=10$, against $9+3+1=13$ for site 2 alone and $5+9+1+1=16$ for both.
    Both sites, cost 16.
    Both pays $5+9=14$ in fixed costs, which outweighs the small saving on serving costs.

    With $a=(2,5,4)$, $x=(1,0,1)$, what is $\sum_j a_jx_j$?

    11
    That adds all three entries of $a$. Parcels with $x_j=0$ are left out.
    6
    $2+0+4=6$.
    8
    Re-check which entries of $x$ equal 1.

    Which statement about an LP relaxation of a minimisation IP is correct?

    Its optimal value is an upper bound on the IP optimum.
    The relaxation has more choices, so its minimum is not larger.
    Its optimal value is a lower bound on the IP optimum.
    It minimises over a set containing every feasible plan of the IP.
    Its optimum is always the optimum of the IP after rounding.
    Rounding can give an infeasible or poor plan.

    The incumbent cost is 40. A node has LP value 37.5 (fractional). What should branch and bound do?

    Prune the node.
    Pruning needs the LP value to be at least 40.
    Branch on a fractional variable of the node.
    A plan costing between 37.5 and 40 may be inside, so the node cannot be discarded.
    Accept the LP point as a new incumbent.
    It is fractional, so it is not a valid plan.

    Lecture 1 reviews linear programming: how an LP is written, what its feasible region looks like, what a corner point is in matrix language, and how the simplex method walks from corner to corner. Every later lecture (integer programs, branch and bound, even TSP) calls an LP solver as a building block, so this part is the engine room. For the fictional Kaveri Courier of Part 0, an LP is the kind of plan the owner can compute each day, and the running examples below (including the staff canteen) are small stand-ins for it.

    You need: Part A (sums, $Ax\ge b$, solving $Bx=b$, rank and independence) and Part B (turning a word problem into variables, objective and constraints, and drawing a two-variable LP).

    Writing an LP in canonical and standard form

    A linear programme (LP) minimises or maximises a linear objective subject to linear constraints, and it can always be rewritten in one fixed shape that algorithms like.

    Solvers and the simplex method of this part all expect that fixed shape, so you must convert any problem into it without errors.

    It is like filling in a form: the information is the same, but it only gets processed when it sits in the right boxes.

    A small diet problem

    Kaveri Courier also runs a small canteen for its drivers. The canteen buys two foods. Food 1 costs $3$ per portion and food 2 costs $2$. A portion of food 1 gives $2$ units of protein and $1$ unit of iron; a portion of food 2 gives $1$ unit of protein and $1$ of iron. Each day the meals must contain at least $8$ units of protein and at least $6$ units of iron. How many portions $x_1,x_2$ of each food minimise the cost?

    $$\min\ 3x_1+2x_2\quad\text{s.t.}\quad 2x_1+x_2\ge 8,\quad x_1+x_2\ge 6,\quad x_1,x_2\ge 0.$$

    This is already a linear programme: the objective and every constraint are sums of variables times constants.

    $$\min\ c^\top x\quad\text{s.t.}\quad Ax\ge b,\ \ x\ge 0.$$ All constraints are "$\ge$" and all variables are non-negative.

    $$\min\ c^\top x\quad\text{s.t.}\quad Ax=b,\ \ x\ge 0.$$ All constraints are equalities (with $b\ge0$ after multiplying rows by $-1$ if needed) and all variables are non-negative. Linear algebra works with equalities, so simplex needs this form.

    Converting to standard form

    Three rules do all the work.

    • A "$\ge$" constraint becomes an equality by subtracting a surplus variable $s\ge0$ that measures how far above the requirement you are: $2x_1+x_2\ge8$ becomes $2x_1+x_2-s_1=8$.
    • A "$\le$" constraint becomes an equality by adding a slack variable $s\ge0$ that measures unused room: $x_1+2x_2\le10$ becomes $x_1+2x_2+s=10$.
    • A maximisation is turned into a minimisation by flipping the sign of the objective: $\max f$ and $\min(-f)$ have the same optimal point, and the optimal values differ by a sign.

    The diet problem in standard form is $$\min\ 3x_1+2x_2\quad\text{s.t.}\quad 2x_1+x_2-s_1=8,\ \ x_1+x_2-s_2=6,\ \ x_1,x_2,s_1,s_2\ge0.$$ We now have 4 variables and 2 equations. The slack and surplus variables do not cost anything: they appear in the objective with coefficient $0$.

    Careful: surplus and slack have opposite signs: "$\ge$" gets $-s$, "$\le$" gets $+s$. Getting this backwards changes the problem. Check by asking: when the constraint is exactly tight, is $s=0$?
    Try it

    Pick each preset and slide the line value $k$. Find the best point of the running example $\max\,5x_1+3x_2$ ($x_1+x_2\le8$, $x_1+3x_2\le18$, $2x_1+x_2\le12$). Notice where the line last touches the shaded region.

    Solve the diet problem by checking its corner points.

    1. The constraint lines cross the axes and each other. Where $2x_1+x_2=8$ meets $x_1=0$: $(0,8)$. Where $x_1+x_2=6$ meets $x_2=0$: $(6,0)$.

      The feasible region is the area above both lines in the first quadrant: it is unbounded to the upper right, with three corners.

    2. The two lines meet where $2x_1+x_2=8$ and $x_1+x_2=6$: subtracting gives $x_1=2$, so $x_2=4$. Corner $(2,4)$.

      Each corner is where two boundary lines (or a line and an axis) meet.

    3. Costs: $(0,8)\to16$, $(2,4)\to6+8=14$, $(6,0)\to18$.

      A linear objective over a region with corners is best at a corner (Chapter 1.2).

    4. The minimum cost is $14$ at $x=(2,4)$: 2 portions of food 1 and 4 of food 2.

      Both constraints are tight there: $s_1=s_2=0$.

    Go deeper: free variables

    If a variable may be negative (a "free" variable), write it as the difference $x=x^+-x^-$ of two non-negative variables. The lectures later use this when a dual variable is unrestricted in sign.

    The LP $\min 4x_1+x_2$ s.t. $3x_1+x_2\ge9$, $x_1+2x_2\le10$, $x_1-x_2\le2$, $x\ge0$ is converted to standard form. How many variables does the standard form have?

    Each of the three inequalities needs its own slack or surplus variable.

    Two original variables plus one slack or surplus per inequality: $2+3=5$.

    In the LP above, what turns $x_1+2x_2\le10$ into an equality?

    At the tight point the extra variable must be 0, and it must never be negative.

    The left side is below 10 when not tight, so we add the missing amount: $x_1+2x_2+s=10$.

    Write $\max\,3x_1+2x_2$ as a minimisation. What is the coefficient of $x_1$ in the new objective?

    Multiply the whole objective by $-1$.

    $\max(3x_1+2x_2)$ is the same as $\min(-3x_1-2x_2)$, so the coefficient is $-3$.

    What is the minimum cost of the canteen diet problem in this chapter?

    Evaluate $3x_1+2x_2$ at the three corners $(0,8)$, $(2,4)$, $(6,0)$.

    Costs are $16$, $14$ and $18$. The minimum is $14$.

    Is the diet plan $x=(1,5)$ feasible?

    Check the protein constraint $2x_1+x_2\ge8$.

    Protein is $2\cdot1+5=7<8$, so it is infeasible even though iron is $1+5=6\ge6$.

    • Convert one constraint at a time and recheck that a tight constraint gives $s=0$.
    • Keep slack and surplus variables in the objective with coefficient 0.
    • Adding a surplus to a "$\le$" constraint (or a slack to a "$\ge$").
    • Forgetting to flip the sign of the objective when turning max into min.
    1. Any LP can be written as $\min c^\top x$ with $Ax=b$, $x\ge0$ by adding slacks, subtracting surpluses and flipping max to min.
    2. Slack and surplus variables measure unused room and excess; they are zero exactly when a constraint is tight.
    3. For two variables you can solve the LP by looking at corner points: the best value occurs at a corner.

    Which standard-form row comes from $5x_1+2x_2\ge20$?

    $5x_1+2x_2+s=20$
    Adding $s\ge0$ forces the left side to be at most 20, the wrong direction for a "$\ge$" constraint.
    $5x_1+2x_2-s=20$, $s\ge0$
    $s$ is the amount by which the left side exceeds 20.
    $5x_1+2x_2=20$
    That would forbid solutions that exceed the requirement.

    An LP in standard form has 3 equality constraints and 7 variables. How many of the variables does a basic solution set to zero?

    3
    Three variables are basic in the next chapters; count the rest.
    4
    $7-3=4$ non-basic variables are zero.
    7
    That would set every variable to zero.

    If $\max f(x)$ has optimal value $12$, what is the optimal value of the equivalent $\min(-f(x))$?

    12
    The sign of the objective was flipped.
    −12
    The optimal point is the same but the value is negated.
    0
    The values are linked, not cancelled.

    Polyhedra, corners and the four outcomes

    The feasible region of an LP is a polyhedron: the points satisfying a list of linear inequalities. Its corners are called extreme points, and an LP can end in exactly four ways.

    Knowing the shape explains why simplex only needs to look at corners and why a solver can report "infeasible" or "unbounded".

    It is like a cut gemstone: the sparkle (the best value) is always on a corner or a whole flat edge, never in the middle of a face.

    Each linear inequality $a^\top x\le\beta$ cuts space in half: the points on one side of a line (in the plane) or plane (in 3D) are allowed. The set of points obeying all the constraints at once is their overlap.

    A halfspace is a set $\{x: a^\top x\le\beta\}$. A polyhedron is an intersection of finitely many halfspaces: $P=\{x: Ax\le b\}$. A bounded polyhedron is a polytope.

    A convex combination of points $x^1,\dots,x^k$ is $\sum_i\lambda_ix^i$ with all $\lambda_i\ge0$ and $\sum_i\lambda_i=1$. The convex hull is the set of all such combinations: the shape you get by stretching a rubber band around the points. A set is convex if it contains the straight segment between any two of its points.

    A point of a convex set is an extreme point (a corner) if it is not a convex combination of two other points of the set, i.e. it does not lie in the interior of any segment inside the set.

    A linear programme either (1) is infeasible (empty region), (2) is unbounded (the objective improves forever), (3) has a unique optimal solution at a corner, or (4) has many optimal solutions, a whole edge of the region (the objective line is parallel to that edge). In (3) and (4) an optimum is always attained at a corner of the region, whenever the region has corners.

    Try it

    Cycle through the four presets. For each one, slide the objective line $k$ and decide: where does the line stop touching the region, and what does that mean? Notice that "Many optima" and "Unique optimum" use the same region but different objective directions.

    Unbounded regions and cones

    A region can run off to infinity. The directions in which it runs are described by a cone: a set closed under adding vectors and scaling by positive numbers. A direction $d\ne0$ is a direction of $P=\{Ax\le b\}$ if starting at any point of $P$ and moving along $d$ forever keeps you inside, which happens exactly when $Ad\le0$. The cone's tip sits at the origin, and its edges are the extreme directions, the directions that cannot be built from others.

    Every polyhedron with at least one corner is the sum of a polytope and a cone: every point is (a convex combination of extreme points) $+$ (a non-negative combination of extreme directions).

    Careful: "extreme point" and "corner point" mean the same thing here, but "extreme direction" is a different object: it describes how the region extends to infinity, not where it ends.

    The region of the running example has corners $(0,0),(6,0),(4,4),(3,5),(0,6)$. Is $(4,2)$ a convex combination of $(6,0)$ and $(0,6)$, and is it inside the region?

    1. Solve $\lambda(6,0)+(1-\lambda)(0,6)=(4,2)$. First coordinate: $6\lambda=4$, so $\lambda=\tfrac23$.

      The first coordinate fixes $\lambda$; the second coordinate must then agree.

    2. Second coordinate: $6(1-\lambda)=6\cdot\tfrac13=2$. It matches, and $0\le\lambda\le1$.

      Both coordinates agree, so $(4,2)$ lies on the segment.

    3. Inside the region: $4+2=6\le8$, $\ 4+6=10\le18$, $\ 8+2=10\le12$, and both coordinates are $\ge0$.

      Membership means every constraint holds.

    Go deeper: why the optimum is at a corner

    If an optimal point were strictly inside a segment of feasible points, then moving along the segment in the improving direction of the linear objective would improve it, a contradiction, unless the objective is flat along the segment. In that flat case the whole segment is optimal, including its endpoints. Repeating this argument moves you to a corner.

    How many corner points does the region $x_1+x_2\le8$, $x_1+3x_2\le18$, $2x_1+x_2\le12$, $x\ge0$ have?

    Walk around the boundary and list each turning point, starting at the origin.

    $(0,0)$, $(6,0)$, $(4,4)$, $(3,5)$ and $(0,6)$: five corners.

    $\max\ x_1+x_2$ subject to $x_1-x_2\le2$, $x_1+x_2\ge2$, $x\ge0$. What happens?

    Can you move to larger $x_1$ and $x_2$ while keeping $x_1-x_2\le2$?

    Take $x_1=x_2=t$: both constraints hold for every $t\ge1$, and the objective $2t$ grows without limit.

    Find $\lambda$ so that $\lambda(6,0)+(1-\lambda)(0,6)=(4,2)$.

    Look at the first coordinate only.

    $6\lambda=4$, so $\lambda=2/3$; check the second coordinate: $6\cdot\tfrac13=2$.

    Is $(3.5,4.5)$ an extreme point of the running region? It is the midpoint of $(4,4)$ and $(3,5)$.

    An extreme point cannot be the midpoint of two other points of the region.

    It is the midpoint of two feasible points, so it is not extreme: it lies in the middle of an edge.

    For the running region, what is the maximum of $2x_1+2x_2$?

    This objective is parallel to the constraint $x_1+x_2\le8$. Evaluate it at $(4,4)$ and $(3,5)$.

    $2(4+4)=16$ and $2(3+5)=16$: the whole edge between them is optimal, with value $16$.

    • Sketch the region and list its corners before running any algorithm.
    • Ask the four-outcome question first: is it empty, unbounded, unique or tied?
    • Assuming the optimum is always unique.
    • Calling a point on an edge a corner.
    1. The feasible region of an LP is a polyhedron, an intersection of halfspaces, and it is convex.
    2. An LP is infeasible, unbounded, uniquely solved at a corner, or solved along a whole edge; the optimum is attained at a corner whenever corners exist.
    3. Extreme points are the corners; extreme directions describe how an unbounded region runs off to infinity.

    The objective line of a maximisation is parallel to one edge of the region, and that edge is the last one touched. What can you conclude?

    The LP is infeasible.
    The line touches the region, so points exist.
    The LP is unbounded.
    The line stops touching the region, so the value is capped.
    Every point of that edge is optimal: there are many optimal solutions.
    The objective has the same value along the edge.

    Which set is NOT convex?

    A triangle with its inside.
    Any segment between two of its points stays inside.
    A halfplane $\{x_1+x_2\le 3\}$.
    A halfplane contains the segment between two of its points.
    The circle line $x_1^2+x_2^2=1$ (only the curve, not the disc).
    The midpoint of two points on the curve is inside it, not on it.

    A region is empty. A solver reports:

    Unbounded
    Unbounded needs feasible points to move along.
    Infeasible
    No point satisfies all constraints.
    Optimal with value 0
    There is no feasible point to attain any value.

    Basic feasible solutions: corners in matrix language

    In standard form $Ax=b$, a corner of the region corresponds to choosing $m$ independent columns of $A$ (a basis), setting every other variable to zero and solving for the rest.

    This turns the geometric idea "go to a corner" into a computation a computer can do: solve a small linear system.

    It is like picking which $m$ of many levers to hold: you set all others to zero and the chosen levers are forced to specific positions.

    Row view and column view

    Take the running example and write it in standard form with slack variables $s_1,s_2,s_3$ for the three constraints: $$x_1+x_2+s_1=8,\qquad x_1+3x_2+s_2=18,\qquad 2x_1+x_2+s_3=12.$$ The matrix has $m=3$ rows and $n=5$ columns, $A=\begin{pmatrix}1&1&1&0&0\\1&3&0&1&0\\2&1&0&0&1\end{pmatrix}$.

    The row view reads each equation as a halfspace boundary in the $(x_1,x_2)$ picture: that is the polygon of the last chapter. The column view reads $Ax=b$ as "mix the five columns of $A$ in amounts $x_j$ to produce the target $b$" (as in Part A). Simplex works in the column view.

    Pick $m$ linearly independent columns of $A$ and call them the matrix $B$ (the basis); the other columns form $N$. Set all non-basic variables to $0$ and solve $Bx_B=b$, i.e. $x_B=B^{-1}b$. The result is a basic solution. If also $x_B\ge0$ it is a basic feasible solution (BFS).

    A point is a basic feasible solution of $\{x: Ax=b,\ x\ge0\}$ if and only if it is an extreme point (corner) of that set.

    So the corners of the polygon are exactly the basic feasible solutions. There are at most $\binom{n}{m}$ bases, here $\binom53=10$. Some bases give negative values: those are points where the constraint lines meet outside the region.

    Try it

    Click through all 10 bases. For each, read the values of $x_1,x_2,s_1,s_2,s_3$ and see where the point lands. Notice which bases give a green dot on a corner and which give a red point outside the region, and which variable is negative there.

    Compute the basic solution for the basis $\{x_1,x_2,s_2\}$, and decide whether it is feasible.

    1. Non-basic variables $s_1=s_3=0$. The equations become $x_1+x_2=8$, $\ x_1+3x_2+s_2=18$, $\ 2x_1+x_2=12$.

      Setting the non-basic variables to zero deletes their columns.

    2. The first and third equations give $x_1=4$ (subtract: $x_1=12-8$), so $x_2=4$.

      Two equations in two unknowns, solved as in Part A.

    3. The second equation gives $s_2=18-4-12=2$.

      The remaining variable is determined by the remaining equation.

    4. All values $(4,4,0,2,0)$ are $\ge0$: it is a BFS, the corner $(4,4)$.

      Feasible means non-negative; basic means built from a basis.

    Careful: a basic solution need not be feasible. The basis $\{x_1,x_2,s_1\}$ gives $x=(3.6,4.8)$ and $s_1=-0.4$: the lines $x_1+3x_2=18$ and $2x_1+x_2=12$ meet at a point that violates $x_1+x_2\le8$.
    Go deeper: degeneracy

    If a basic feasible solution has a basic variable equal to zero, it is degenerate: more than $n-m$ of the variables are zero, so several different bases describe the same corner. Simplex can then take a step of length zero. Degeneracy does not change the theory but explains why a corner can be "visited" by several bases.

    An LP in standard form has 3 constraints and 5 variables. At most how many bases (choices of 3 columns) are there?

    Count the ways to choose 3 of 5: $\binom53$.

    $\binom53=\frac{5\cdot4}{2}=10$.

    In the running LP, for the basis $\{x_1,x_2,s_2\}$ what is the value of $s_2$?

    First find $x_1,x_2$ from the equations that do not contain $s_2$, then use $x_1+3x_2+s_2=18$.

    $x_1=x_2=4$, so $s_2=18-4-12=2$.

    Is the basic solution for $\{x_1,x_2,s_1\}$ feasible? (It has $x_1=3.6$, $x_2=4.8$.)

    Compute $s_1=8-x_1-x_2$.

    $s_1=8-3.6-4.8=-0.4<0$, so it is not feasible.

    For the basis $\{x_1,s_1,s_2\}$ (so $x_2=s_3=0$), what is $s_2$?

    The equation $2x_1=12$ gives $x_1$. Then use $x_1+3x_2+s_2=18$.

    $x_1=6$, so $s_2=18-6=12$. Also $s_1=8-6=2$: the corner $(6,0)$.

    Of the 10 bases of the running LP, how many are basic feasible solutions (corners)?

    The region has five corners, and each corner comes from at least one basis.

    Five: $(0,0),(6,0),(4,4),(3,5),(0,6)$. The other five bases give points outside the region.

    • Choose the basis, set the rest to zero, solve a square system, then check signs.
    • Link every BFS back to a corner in the picture.
    • Treating a basic solution as automatically feasible.
    • Choosing columns that are linearly dependent (then $B$ has no inverse).
    1. A basis is a set of $m$ independent columns; the basic solution sets the other variables to 0 and solves $Bx_B=b$.
    2. A basic solution that is also non-negative is a BFS, and BFS are exactly the corners of the feasible region.
    3. With $n$ variables and $m$ equations there are at most $\binom nm$ corners, which is why we need a smart way to search them.

    A standard-form LP has $m=4$ constraints and $n=9$ variables. How many variables are zero in a non-degenerate BFS?

    4
    Four variables are basic and may be non-zero.
    5
    $n-m=5$ non-basic variables are zero.
    9
    That would be the zero vector, which is not generally feasible.

    A basic solution has a negative value for one basic variable. What does it represent?

    A corner of the feasible region.
    Corners need all variables $\ge0$.
    The meeting point of boundary lines that lies outside the feasible region.
    It satisfies the equations but breaks a non-negativity requirement.
    An optimal solution.
    Optimal solutions must be feasible.

    Why is it enough to search over basic feasible solutions?

    They are the only feasible points.
    There are infinitely many feasible points.
    If an LP has an optimum, one is attained at a corner, and corners are the BFS.
    That is the "optimum at a corner" fact combined with BFS = extreme point.
    Non-basic variables are always optimal at zero.
    That is not true in general; they are only zero at the current corner.

    The simplex method: walking from corner to corner

    Simplex starts at a corner and repeatedly moves along an edge to a neighbouring corner that improves the objective, stopping when no neighbour is better.

    It avoids checking all $\binom nm$ corners, and it is the algorithm behind every LP solved inside branch and bound in this course.

    It is like climbing a rock face by always stepping to a higher hold along the edge you are on, until every neighbouring hold is lower.

    At a BFS with basis $B$ and non-basic columns $N$, the objective can be written purely in the non-basic variables. Since $x_B=B^{-1}b-B^{-1}Nx_N$, $$z=c_B^\top B^{-1}b+\big(c_N^\top-c_B^\top B^{-1}N\big)x_N.$$ The first term is the current objective value. The bracket is a list of numbers, one per non-basic variable.

    The reduced cost of a non-basic variable $x_j$ is $$\bar c_j=c_j-c_B^\top B^{-1}A_{\cdot j}.$$ It is the change in the objective per unit increase of $x_j$ when the basic variables adjust to keep $Ax=b$.

    If $x$ is a BFS (for a minimisation) and $\bar c_j\ge0$ for every non-basic $j$, then $x$ is optimal: raising any non-basic variable can only increase the objective.

    One simplex step

    If some non-basic $x_j$ has $\bar c_j<0$, raising it lowers the objective. Raise $x_j$ from $0$ to $\eta$ and let the basic variables adapt: the point moves by $\eta d$ with $d_N=e_j$ (a 1 in position $j$, zeros elsewhere) and $d_B=-B^{-1}A_{\cdot j}$. The objective changes by $\eta\bar c_j$.

    How far? Keep $x_B+\eta d_B\ge0$. Only entries with $(d_B)_k<0$ shrink, and entry $k$ reaches zero at $\eta=\frac{(x_B)_k}{-(d_B)_k}$. The step length is the smallest of these ratios, the minimum ratio test. The basic variable that hits zero leaves the basis and $x_j$ enters. If no entry of $d_B$ is negative, nothing stops the step: the LP is unbounded.

    1. Start from a basic feasible solution with basis $B$.
    2. Compute the reduced costs $\bar c_N^\top=c_N^\top-c_B^\top B^{-1}N$.
    3. If $\bar c_N\ge0$, stop: $x$ is optimal.
    4. Otherwise pick $j$ with $\bar c_j<0$ and let $d_B=-B^{-1}A_{\cdot j}$.
    5. If $d_B\ge0$, stop: the LP is unbounded.
    6. Otherwise $\eta=\min\{(x_B)_k/(-(d_B)_k): (d_B)_k<0\}$; the minimising $k$ leaves the basis.
    7. Replace the leaving column by $A_{\cdot j}$, recompute $x_B=B^{-1}b$ and go to step 2.
    Try it

    Press the "Enter" buttons to run simplex on the running LP. First take $x_1$, then $x_2$. Then Reset and take $x_2$ first. Notice that the two paths differ but end at the same optimal corner, and that every step improves the objective.

    Run simplex on $\min\ -5x_1-3x_2$ with $x_1+x_2+s_1=8$, $\ x_1+3x_2+s_2=18$, $\ 2x_1+x_2+s_3=12$, starting from the basis of slacks $\{s_1,s_2,s_3\}$.

    1. Start: $x=(0,0)$, $s=(8,18,12)$, objective $0$. The basis is slacks, so $c_B=0$ and the reduced costs are the original costs: $\bar c_{x_1}=-5$, $\bar c_{x_2}=-3$.

      With $c_B=0$ the formula gives $\bar c_j=c_j$.

    2. Enter $x_1$ (most negative). Then $d_B=-(1,1,2)$. Ratios: $8/1=8$, $18/1=18$, $12/2=6$. The smallest is $6$, so $s_3$ leaves.

      The third constraint $2x_1\le12$ is the first to become tight.

    3. New corner $(6,0)$: $s=(2,12,0)$, objective $-5\cdot6=-30$. New reduced costs: $\bar c_{x_2}=-\tfrac12$ and $\bar c_{s_3}=\tfrac52$.

      Raising $x_2$ still helps (its reduced cost is negative); raising $s_3$ would hurt.

    4. Enter $x_2$. The basis is $\{s_1,s_2,x_1\}$. The ratios are $s_1$: $4$, $s_2$: $4.8$, $x_1$: $12$. The smallest is $4$, so $s_1$ leaves.

      The constraint $x_1+x_2\le8$ becomes tight first.

    5. New corner $(4,4)$, objective $-32$. Reduced costs: $\bar c_{s_1}=1$, $\bar c_{s_3}=2$, both $\ge0$: optimal. The maximum profit is $32$.

      All reduced costs non-negative means no neighbouring corner is better.

    Careful: simplex moves along edges, so each step lands on a neighbouring corner, never across the interior. The reduced cost tells you the rate of change; the ratio test tells you how far you can go before a constraint blocks you.
    Go deeper: the tableau and what "reduced cost" is made of

    The table the lecture draws (reduced costs on top, then rows $x_B$) is just $c-c_B^\top B^{-1}A$ and $B^{-1}A$ written side by side, so it stores everything one step needs. The numbers $y^\top=c_B^\top B^{-1}$ turn out to be the dual variables. Here (taking the sign flip from max to min into account) $y=(1,0,2)$ and $y^\top b=8+24=32$, matching the optimal profit. That is the story of Lecture 2.

    At the corner $(6,0)$ of the running LP (basis $\{s_1,s_2,x_1\}$), what is the reduced cost of $x_2$?

    Raise $x_2$ by 1. Then $x_1$ must drop by $\tfrac12$ to keep $2x_1+x_2=12$.

    Objective $-5x_1-3x_2$ changes by $-5(-\tfrac12)-3(1)=2.5-3=-0.5$.

    Start at the origin and choose $x_2$ to enter. What is the step length from the ratio test? (Constraints: $x_1+x_2\le8$, $x_1+3x_2\le18$, $2x_1+x_2\le12$.)

    With $x_1=0$ the constraints read $x_2\le8$, $3x_2\le18$, $x_2\le12$.

    The limits are $8$, $6$ and $12$. The smallest is $6$, so $x_2$ rises to $6$ and $s_2$ leaves.

    From the origin, $x_1$ enters with step length $6$ and reduced cost $-5$. By how much does the objective $-5x_1-3x_2$ change?

    Change = step length times reduced cost.

    $6\cdot(-5)=-30$, taking the objective from $0$ to $-30$.

    A variable has a negative reduced cost, and every entry of $d_B=-B^{-1}A_{\cdot j}$ is $\ge0$. What does that tell you?

    If no basic variable ever decreases, what stops the step?

    Nothing hits zero, so $x_j$ can grow forever while the objective keeps falling: unbounded.

    Using "most negative reduced cost enters", how many simplex iterations take the running LP from the origin to its optimum?

    Follow the example: origin, then $(6,0)$, then...

    Origin $\to(6,0)\to(4,4)$: two iterations.

    • Check the sign of every reduced cost before stopping.
    • Run the ratio test only over entries where $d_B$ is negative.
    • Stopping when one reduced cost is non-negative but another is negative.
    • Dividing by a positive entry in the ratio test (that entry does not limit the step).
    1. Simplex moves between neighbouring BFS: pick a non-basic variable with negative reduced cost, move until a basic variable hits zero, swap them.
    2. All reduced costs $\ge0$ proves optimality for a minimisation; $d_B\ge0$ with a negative reduced cost proves unboundedness.
    3. Each step changes the objective by (step length) $\times$ (reduced cost), so with non-zero steps the objective strictly improves.

    At a BFS, all reduced costs of the non-basic variables are positive. What do you conclude?

    The LP is unbounded.
    Unboundedness needs a negative reduced cost.
    The BFS is optimal (and uniquely so, if all are strictly positive).
    Every direction away from it increases the objective.
    Simplex must take another step.
    A step is only possible with a negative reduced cost.

    In the ratio test, the basic variable values are $(4,6,3)$ and the direction entries $d_B$ are $(-2,1,-1)$. Which basic variable leaves and what is the step length?

    The second, step 6.
    Its direction entry is positive, so that variable grows and does not limit the step.
    The third, step 3.
    Compute the ratio for the first variable too, and take the smaller one.
    The first, step 2.
    Only the first and third entries are negative. Their ratios are $4/2=2$ and $3/1=3$, and the smaller one, 2, decides.

    At the origin of the running LP, why does $x_1$ entering stop at step length 6 and not 8?

    The objective stops improving at 6.
    The step is limited by feasibility, not by the objective.
    The constraint $2x_1+x_2\le12$ becomes tight at $x_1=6$, before $x_1+x_2\le8$ does at 8.
    The minimum ratio is the first constraint to be hit.
    The reduced cost is $-6$.
    The reduced cost of $x_1$ is $-5$; the 6 comes from the ratio test.

    Converting $2x_1+x_2\ge8$ to standard form gives:

    $2x_1+x_2+s=8$
    That is the form for "at most".
    $2x_1+x_2-s=8$ with $s\ge0$
    $s$ measures the excess over 8.
    $2x_1+x_2=8+s$ with $s\le0$
    Slack and surplus variables are non-negative by convention.

    A region is the overlap of finitely many halfspaces. What is it called?

    A cone
    A cone has its tip at the origin and is closed under positive scaling.
    A polyhedron
    An intersection of finitely many halfspaces.
    A basis
    A basis is a set of columns, not a region.

    $Bx_B=b$ with $B=\begin{pmatrix}2&1\\5&3\end{pmatrix}$ and $b=(4,9)$. What is $x_B$?

    $(3,2)$
    Check the sign of the second entry.
    $(3,-2)$
    $B^{-1}b$: the second entry is negative, so this basic solution would not be feasible.
    $(-3,2)$
    Substitute back into $2x_1+x_2=4$.

    Which statement about simplex is true for a minimisation?

    It stops when any reduced cost is non-negative.
    It must wait for all of them.
    It stops when all non-basic reduced costs are non-negative.
    Then no neighbouring corner improves the objective.
    It picks the variable with the largest positive reduced cost.
    A positive reduced cost makes the objective worse.

    Lecture 2 finishes the LP toolkit. It shows how simplex copes with upper and lower bounds on variables, how every LP has a mirror-image dual LP whose prices certify optimality, how the dual simplex method repairs a solution after the data change, and how to read from the final answer what happens when costs or right-hand sides move. Integer programming (Parts 3 and 4) re-solves LPs thousands of times, and these tools are why that is affordable.

    You need: Part 1 (standard form, basic feasible solutions, reduced costs, the simplex step and ratio test, and the running LP $\max 5x_1+3x_2$ whose optimum is $32$ at $(4,4)$), and Part A (solving small linear systems and reading $B^{-1}b$).

    Simplex with upper and lower bounds

    When variables carry bounds $\ell\le x\le u$, simplex keeps every non-basic variable parked at one of its two bounds (not always at zero) and needs only one extra rule in the ratio test: an entering variable may run into its own opposite bound before any basic variable is blocked.

    Bounds appear everywhere in logistics: a van can take at most so many parcels, an arc has a capacity, a binary variable lives in $[0,1]$. Branch and bound (Part 4) tightens bounds all the time, so the LP solver must treat them cheaply.

    It is like a lift with a floor and a ceiling: a passenger can wait at the bottom or the top, and when the lift moves, the trip may simply end at the other end of the shaft instead of at a floor in between.

    A dispatch problem with caps

    A depot sends parcels with two vans. Van 1 earns $3$ units of profit per parcel and can take at most $4$; van 2 earns $2$ per parcel and can take at most $3$. The loading bay can handle $5$ parcels per hour in total. With $x_1,x_2$ the numbers of parcels, $$\max\ 3x_1+2x_2\quad\text{s.t.}\quad x_1+x_2\le5,\quad 0\le x_1\le4,\quad 0\le x_2\le3.$$ Written as a minimisation with a slack $s\ge0$ for the bay, this is $\min\,-3x_1-2x_2$ with $x_1+x_2+s=5$ and bounds $0\le x_1\le4$, $0\le x_2\le3$, $0\le s$.

    The obvious route is to turn each bound into a row of its own. For $n$ variables with both bounds, that adds $2n$ rows and $2n$ slack variables, so $m+2n$ rows and $3n$ variables. Every simplex step then works with a much bigger basis, for a fact that is nearly free to handle directly.

    The bounded LP is $\min c^\top x$ s.t. $Ax=b$, $\ell\le x\le u$. A basis $B$ is again $m$ independent columns. Every non-basic variable is fixed at a bound: those at their lower bound form $N_\ell$, those at their upper bound form $N_u$. The basic variables follow from the equations: $$x_B=B^{-1}\big(b-N_\ell\,\ell_{N_\ell}-N_u\,u_{N_u}\big).$$ If also $\ell_B\le x_B\le u_B$ the point is a basic feasible solution, and these are exactly the corners of the bounded region.

    When is a corner optimal?

    The reduced cost $\bar c_j=c_j-c_B^\top B^{-1}A_{\cdot j}$ keeps its meaning: it is the change in the objective per unit increase of $x_j$ while the basic variables adjust. A variable at its lower bound can only increase; one at its upper bound can only decrease. So:

    A basic feasible solution is optimal if $\bar c_j\ge0$ for every non-basic $x_j$ at its lower bound and $\bar c_j\le0$ for every non-basic $x_j$ at its upper bound.

    Why: raising a variable with $\bar c_j\ge0$ from its lower bound cannot lower the cost, and lowering a variable with $\bar c_j\le0$ from its upper bound cannot lower it either.

    The step, with three possible limits

    Suppose $x_j$ sits at its lower bound with $\bar c_j\lt0$. Raise it by $\eta$; the basic variables move by $\eta d_B$ with $d_B=-B^{-1}A_{\cdot j}$ (if $x_j$ is at its upper bound and $\bar c_j\gt0$, lower it and use $d_B=+B^{-1}A_{\cdot j}$). The step length $\eta$ is the smallest of three kinds of limit:

    • a basic variable with $(d_B)_k\lt0$ falls to its lower bound: $\eta\le\dfrac{(x_B-\ell_B)_k}{-(d_B)_k}$;
    • a basic variable with $(d_B)_k\gt0$ rises to its upper bound: $\eta\le\dfrac{(u_B-x_B)_k}{(d_B)_k}$;
    • the entering variable reaches its own other bound: $\eta\le u_j-\ell_j$.

    If a basic variable is the winner it leaves the basis, at whichever bound it hit. If the third limit wins, the basis does not change at all: $x_j$ just jumps from one bound to the other, a bound flip. If no limit is finite, the LP is unbounded.

    Try it

    Run the dispatch problem. Raise $x_1$ first and read the step test: is the step stopped by the bay slack $s$ or by $x_1$'s own cap? Then continue until the readout says optimal. Reset and try the other entering order. Notice that one step is a bound flip with no change of basis, and that at the end $x_1$ stays at its upper bound.

    Solve $\min\,-3x_1-2x_2$ with $x_1+x_2+s=5$, $\ 0\le x_1\le4$, $0\le x_2\le3$, $s\ge0$, starting from the basis $\{s\}$ with $x_1,x_2$ at their lower bounds.

    1. Start: $x_1=x_2=0$, so $s=5$ and the objective is $0$. With $c_B=0$ the reduced costs are $\bar c_{x_1}=-3$, $\bar c_{x_2}=-2$. Both variables are at their lower bounds with negative reduced cost, so both can improve.

      At a lower bound, a negative reduced cost means that raising the variable lowers the cost.

    2. Enter $x_1$. Limits: $s=5-\eta\ge0$ gives $\eta\le5$; the cap on $x_1$ gives $\eta\le4-0=4$. The smaller is $4$, and it is the entering variable's own cap.

      The bay still has room when $x_1$ hits its cap, so no basic variable leaves.

    3. Bound flip: $x_1=4$ is now non-basic at its upper bound; $s=1$; objective $-12$. The basis is still $\{s\}$ with $y=c_s/1=0$, so $\bar c_{x_1}=-3\le0$ (fine at an upper bound) and $\bar c_{x_2}=-2\lt0$ at a lower bound: $x_2$ can still improve.

      At an upper bound the sign condition flips: we need $\bar c\le0$, and $-3$ passes.

    4. Enter $x_2$. Limits: $s=1-\eta\ge0$ gives $1$; its own cap gives $3$. The smaller is $1$, so $s$ leaves (at $0$) and $x_2$ enters at value $1$.

      Now the bay constraint is tight: $4+1=5$.

    5. Corner $(x_1,x_2)=(4,1)$, objective $-14$. New basis $\{x_2\}$: $y=c_{x_2}/1=-2$. Then $\bar c_s=0-(-2)(1)=2\ge0$ (at its lower bound, good) and $\bar c_{x_1}=-3-(-2)(1)=-1\le0$ (at its upper bound, good). Optimal: maximum profit $14$.

      Both sign conditions of the optimality theorem hold; a variable can be optimal sitting at either bound.

    Careful: the sign test depends on where the variable sits. A positive reduced cost at an upper bound is a chance to improve (lower the variable), not a sign of optimality. Check each non-basic variable against the condition for its own bound.
    Go deeper: nonzero lower bounds and free variables

    A lower bound $\ell_j\ne0$ is handled by the same formulas; only the starting point moves. A variable with no bounds at all can be left basic permanently once it enters, since it never blocks a step. Solvers such as Gurobi apply exactly this bounded simplex internally, which is why setting lb and ub on variables is better than adding rows.

    In the dispatch problem, $x_1$ sits at its upper bound $4$, $x_2$ at its lower bound $0$, and the slack $s$ is basic in $x_1+x_2+s=5$. What is $s$?

    Substitute the two parked values and solve for $s$.

    $s=5-4-0=1$.

    An LP has $m=4$ equality rows and $n=6$ variables, each with a lower and an upper bound. If every bound were written as an extra row, how many rows ($m+2n$) would the system have?

    Two extra rows per variable.

    $4+2\cdot6=16$ rows. Bounded simplex keeps the basis at size $m=4$.

    In a minimisation, a non-basic variable sits at its upper bound and has $\bar c_j=-1$. Does this variable satisfy the optimality condition (no improvement is available through it)?

    It can only decrease from its upper bound. What does lowering it by one unit do to the cost when $\bar c_j=-1$?

    Lowering by one unit changes the cost by $-\bar c_j=+1$: worse. The condition for a variable at an upper bound is $\bar c_j\le0$, which holds.

    State: $x_1=4$ at its upper bound, $s=1$ basic, $x_2$ at $0$ with cap $3$, row $x_1+x_2+s=5$. $x_2$ enters. What is the step length?

    Compare how far $x_2$ can rise before $s$ reaches $0$ with its own range $u_2-\ell_2$.

    $s$ allows $1$, the cap allows $3$. The step is $\min(1,3)=1$.

    Row $x_1+x_2+x_3=10$ with $x_1$ basic, $x_2$ non-basic at its upper bound $3$, $x_3$ non-basic at its lower bound $1$. Find $x_1$.

    $x_B=B^{-1}(b-\text{contribution of the non-basic columns at their bounds})$.

    $x_1=10-3-1=6$.

    • Record, for each non-basic variable, whether it is at its lower or upper bound before computing $x_B$ and the reduced costs.
    • Include "$u_j-\ell_j$" as a candidate in every ratio test.
    • Assuming non-basic variables are always zero.
    • Declaring optimality because a reduced cost is positive without checking whether the variable is at an upper bound.
    1. With bounds, non-basic variables rest at their lower or upper bound, and $x_B=B^{-1}(b-N_\ell\ell-N_uu)$ gives the basic variables.
    2. Optimality needs $\bar c_j\ge0$ at lower bounds and $\bar c_j\le0$ at upper bounds.
    3. The ratio test has three kinds of limit; when the entering variable's own range wins, it flips bound and the basis stays the same.

    In a minimisation, a non-basic variable at its upper bound has $\bar c_j=+2$. What is true?

    The current point is optimal for this variable.
    That sign is the optimal one for a variable at a lower bound, not an upper bound.
    Lowering it improves the objective, so it is a candidate to move.
    Lowering by one unit changes the cost by $-2$.
    The LP is unbounded.
    Unboundedness needs a direction with no limit; here the variable has a finite range.

    An entering variable has range $u_j-\ell_j=2$, and every basic variable allows a step of at least 3. What happens?

    A basic variable leaves the basis.
    No basic variable is the first to be blocked.
    The LP is unbounded.
    The step is limited by $2$, which is finite.
    The variable flips to its other bound and the basis does not change.
    The smallest limit is the variable's own range.

    Row $x_1+2x_2+x_3=12$, with $x_1$ basic, $x_2$ non-basic at its upper bound $4$ and $x_3$ non-basic at its lower bound $0$. What is $x_1$?

    12
    That ignores the contribution of $x_2$ at its upper bound.
    8
    Remember the coefficient $2$ in front of $x_2$.
    4
    $12-2\cdot4-0=4$.

    Duality: writing the dual and proving it is a bound

    Every LP (the primal) has a partner LP (the dual) built from the same numbers; any feasible solution of one bounds the optimal value of the other, and at the optimum the two values are equal.

    The dual gives a cheap certificate that a solution is optimal, it reveals the prices of resources (Chapter 2.4), and it is the basis of the dual simplex method and of the bounds used in branch and bound.

    It is like a canteen manager and a pill seller: the manager hunts for the cheapest meals that satisfy the nutrition rules, the seller hunts for the highest prices for nutrients that still beat the food, and at the optimum their bills agree to the last unit.

    A canteen and a pill seller

    Recall the canteen of Kaveri Courier from Part 1: portions $x_1,x_2$ of two foods at costs $3$ and $2$, with $$\min\ 3x_1+2x_2\quad\text{s.t.}\quad 2x_1+x_2\ge8\ \ (\text{protein}),\quad x_1+x_2\ge6\ \ (\text{iron}),\quad x\ge0.$$ Its best plan is $x=(2,4)$ at cost $14$.

    A pharmacist offers to sell pure protein units at price $y_1$ and pure iron units at price $y_2$, to replace food altogether. She wants the largest income from the canteen's needs: $8y_1+6y_2$. But the canteen will only buy pills if they are no dearer than the food they replace. A portion of food 1 provides $2$ protein and $1$ iron, so its pill equivalent costs $2y_1+y_2$, and that must not exceed the food's price $3$. Likewise for food 2. So she solves $$\max\ 8y_1+6y_2\quad\text{s.t.}\quad 2y_1+y_2\le3,\quad y_1+y_2\le2,\quad y\ge0.$$ The best prices are $y=(1,1)$: income $8+6=14$, exactly the canteen's best cost.

    $$\text{Primal:}\ \min\ c^\top x\ \ \text{s.t. }Ax\ge b,\ x\ge0\qquad\qquad\text{Dual:}\ \max\ b^\top y\ \ \text{s.t. }A^\top y\le c,\ y\ge0$$

    One dual variable $y_i$ per primal constraint; one dual constraint per primal variable (column $A_{\cdot j}$ against cost $c_j$). The dual of the dual is the primal. Dual variables are called shadow prices, or marginal prices: the value one extra unit of the right-hand side is worth.

    Careful: dual row $j$ always uses column $j$ of $A$ against the cost $c_j$ of that variable. For the canteen, row 1 is $2y_1+y_2\le3$: the first column $(2,1)$ against the first price $3$. When a diet has many foods and several nutrients, write each food's column across the dual constraint with its own price on the right, and keep the units of the nutrient table identical to those used in the primal. A slide that copies a different row, or mixes units between two tables of the same diet, gives a dual that is not the dual of that primal.

    Rules for any LP

    Non-canonical LPs follow a table. Read it row by row: the sense of a constraint decides the sign of its dual variable, and the sign of a variable decides the sense of its dual constraint.

    Minimisation problemMaximisation problem
    constraint $\ge$variable $\ge0$
    constraint $\le$variable $\le0$
    constraint $=$variable free
    variable $\ge0$constraint $\le$
    variable $\le0$constraint $\ge$
    variable freeconstraint $=$

    For a maximisation primal, read the table from right to left. For the running LP of Part 1, $\max5x_1+3x_2$ with three "$\le$" constraints and $x\ge0$, the dual is $$\min\ 8y_1+18y_2+12y_3\quad\text{s.t.}\quad y_1+y_2+2y_3\ge5,\quad y_1+3y_2+y_3\ge3,\quad y\ge0.$$ A standard-form primal $\min c^\top x$, $Ax=b$, $x\ge0$ has dual $\max b^\top y$, $A^\top y\le c$ with $y$ free.

    Write the dual of $\min\ 2x_1-x_2+3x_3$ s.t. $x_1+x_2+x_3\ge4$, $\ 2x_1-x_3\le5$, $\ x_1+2x_2=3$, with $x_1\ge0$, $x_2\le0$, $x_3$ free.

    1. One dual variable per constraint: $y_1$ for the "$\ge$" row, $y_2$ for the "$\le$" row, $y_3$ for the "$=$" row. Signs from the table (minimisation): $y_1\ge0$, $y_2\le0$, $y_3$ free.

      In a minimisation, a "$\ge$" row gets a non-negative variable, a "$\le$" row a non-positive one, an equality a free one.

    2. Objective: $\max\ 4y_1+5y_2+3y_3$ (right-hand sides times dual variables).

      A minimisation primal gives a maximisation dual with $b$ as the objective.

    3. One dual constraint per primal variable, using its column: $x_1\ge0$ gives $y_1+2y_2+y_3\le2$; $x_2\le0$ gives $y_1+0\cdot y_2+2y_3\ge-1$; $x_3$ free gives $y_1-y_2+0\cdot y_3=3$.

      Variable $\ge0$ gives "$\le$", variable $\le0$ gives "$\ge$", free variable gives "$=$"; the right-hand sides are the costs $2,-1,3$.

    4. Check: the primal optimum is $9$ at $x=(3,0,1)$, and the dual has value $4\cdot0+5\cdot(-3)+3\cdot8=9$ at $y=(0,-3,8)$.

      Equal optimal values are what the strong duality theorem below promises.

    Seeing the dual

    The dual of a two-constraint problem lives in the plane of $(y_1,y_2)$, so you can draw it. Its feasible region is where no food is overpriced, and the objective $b^\top y$ pushes the prices up as far as the region allows.

    Try it

    Drag the price point $y$ around the dual region of each diet. When it is feasible, compare its income to the cost of the best diet (14 or 12). Drag it to the corner that gives the highest income and use "Show optimum". Notice that no feasible price vector ever beats the primal cost, and that the best one exactly equals it.

    Weak duality: every dual value is a lower bound

    This is the first examinable proof of the part; it takes only the two sign facts of the pair.

    If $x$ is feasible for the primal $\min c^\top x$, $Ax\ge b$, $x\ge0$ and $y$ is feasible for the dual $\max b^\top y$, $A^\top y\le c$, $y\ge0$, then $b^\top y\le c^\top x$.

    Prove weak duality.

    1. Since $Ax\ge b$ and $y\ge0$, multiplying each row by a non-negative number keeps "$\ge$": $y^\top Ax\ge y^\top b$.

      Each row $A_{i\cdot}x\ge b_i$ is multiplied by $y_i\ge0$ and the rows are added up.

    2. Since $A^\top y\le c$ and $x\ge0$, each column inequality is multiplied by $x_j\ge0$ and added: $x^\top A^\top y\le x^\top c$, that is $y^\top Ax\le c^\top x$.

      The scalar $x^\top A^\top y$ equals $y^\top Ax$.

    3. Chain the two: $b^\top y\le y^\top Ax\le c^\top x$.

      The middle term $y^\top Ax$ bridges the dual objective and the primal objective.

    Two consequences matter. If $b^\top y=c^\top x$ for a feasible pair, both are optimal (neither can be improved without crossing the other). If the primal is unbounded below, no dual $y$ can exist, because every dual value would have to lie below $-\infty$.

    Strong duality: the bound is tight

    If the primal has an optimal solution $x^*$, then the dual has an optimal solution $y^*$ and $c^\top x^*=b^\top y^*$.

    Sketch of the proof (simplex route): why does an optimal basis hand us an optimal dual?

    1. Write the primal in standard form with surplus variables, and let $B$ be an optimal basis, so $x_B=B^{-1}b$ and all reduced costs $\bar c_j=c_j-c_B^\top B^{-1}A_{\cdot j}$ are $\ge0$.

      Simplex terminates at such a basis whenever the LP has an optimal solution (Part 1).

    2. Define $y^\top=c_B^\top B^{-1}$. Then $\bar c_j\ge0$ says $c_j-y^\top A_{\cdot j}\ge0$ for every original column: $A^\top y\le c$. For a surplus column $(-e_i)$ with cost $0$, $\bar c=y_i\ge0$: so $y\ge0$.

      Non-negative reduced costs are exactly dual feasibility.

    3. The dual objective is $y^\top b=c_B^\top B^{-1}b=c_B^\top x_B=c^\top x^*$.

      Equal values for a feasible pair imply optimality by weak duality.

    For the running LP, the optimal basis is $\{x_1,x_2,s_2\}$ and the numbers $y^\top=c_B^\top B^{-1}$ come out as $y=(1,0,2)$ (for the maximisation form, after undoing the sign flip of min versus max): dual feasible ($1+0+4=5\ge5$ and $1+0+2=3\ge3$) with value $8+0+24=32$, the same as the primal optimum.

    Which combinations can occur?

    Weak and strong duality together restrict the status of a primal-dual pair to the following table.

    Primal \ DualFinite optimumUnboundedInfeasible
    Finite optimumpossibleimpossibleimpossible
    Unboundedimpossibleimpossiblepossible
    Infeasibleimpossiblepossiblepossible
    Go deeper: both problems can be infeasible

    Take $\min\,-x_1-x_2$ s.t. $x_1-x_2\ge1$, $-x_1+x_2\ge1$, $x\ge0$. Adding the two constraints gives $0\ge2$, so the primal is infeasible. Its dual is $\max\,y_1+y_2$ s.t. $y_1-y_2\le-1$, $-y_1+y_2\le-1$, $y\ge0$, and adding those two gives $0\le-2$: also infeasible.

    For the canteen dual $\max8y_1+6y_2$ s.t. $2y_1+y_2\le3$, $y_1+y_2\le2$, $y\ge0$, what is the objective at the feasible prices $y=(1,1)$?

    Check feasibility first: $2+1\le3$ and $1+1\le2$.

    $8\cdot1+6\cdot1=14$, equal to the best diet cost.

    A primal LP has 3 constraints and 5 non-negative variables. How many constraints (apart from sign conditions) does its dual have?

    One dual constraint per primal variable.

    5, one per primal variable. The dual has 3 variables, one per primal constraint.

    For a primal minimisation, $x$ is feasible with cost $20$ and $y$ is dual feasible with dual objective $13$. Between which two numbers must the optimal value lie?

    Weak duality: dual values are lower bounds, feasible primal costs are upper bounds.

    At least $13$ and at most $20$.

    The dual of the running LP is $\min8y_1+18y_2+12y_3$ s.t. $y_1+y_2+2y_3\ge5$, $y_1+3y_2+y_3\ge3$, $y\ge0$. Evaluate the objective at $y=(1,0,2)$.

    Substitute each value; the middle term vanishes.

    $8\cdot1+18\cdot0+12\cdot2=32$.

    The primal minimisation is unbounded. What is the status of its dual?

    Any dual feasible $y$ would give a finite lower bound.

    A feasible dual point would bound the primal cost from below, which contradicts unboundedness. So the dual is infeasible.

    In a minimisation primal, a constraint is of type "$\le$". What sign condition does its dual variable get?

    Use the table: "$\ge$" gives $y\ge0$, "$=$" gives free.

    A "$\le$" constraint in a minimisation gives a non-positive dual variable.

    • Count first: one dual variable per primal row, one dual row per primal column.
    • Sanity-check a dual by evaluating one feasible primal $x$ and one feasible dual $y$: the primal value must not be below the dual value.
    • Copying the right-hand side $b$ into the dual constraints (it goes in the dual objective; the dual's right-hand sides are the costs $c$).
    • Forgetting that an equality row gives a free dual variable.
    1. The dual of $\min c^\top x$, $Ax\ge b$, $x\ge0$ is $\max b^\top y$, $A^\top y\le c$, $y\ge0$; the sign rules turn any LP into its dual.
    2. Weak duality: every dual feasible value is at most every primal feasible cost, so a dual solution is a certified lower bound.
    3. Strong duality: at an optimal basis, $y^\top=c_B^\top B^{-1}$ is dual optimal and the two optimal values are equal.

    The dual of $\min4x_1+5x_2$ s.t. $x_1+2x_2\ge3$, $2x_1+x_2\ge3$, $x\ge0$ is:

    $\max4y_1+5y_2$ s.t. $y_1+2y_2\le3$, $2y_1+y_2\le3$
    The costs go in the dual constraints, not the dual objective.
    $\max3y_1+3y_2$ s.t. $y_1+2y_2\le4$, $2y_1+y_2\le5$, $y\ge0$
    The right-hand sides become the objective; columns of $A$ against $c$ form the constraints.
    $\min3y_1+3y_2$ s.t. $y_1+2y_2\ge4$, $2y_1+y_2\ge5$
    A minimisation primal gives a maximisation dual.

    A feasible primal point costs $40$ and a feasible dual point is worth $35$. The primal optimal value is:

    exactly $35$.
    Weak duality gives a bracket, not equality.
    somewhere in $[35,40]$.
    The dual value is a lower bound and the primal cost an upper bound.
    above $40$.
    The optimum cannot exceed a feasible cost.

    The primal is infeasible. Which can the dual be?

    Have a finite optimal solution.
    Strong duality would give the primal an optimal solution too.
    Unbounded or infeasible.
    These are the only two cells of the status table left.
    Only infeasible.
    An infeasible primal can have an unbounded dual.

    In the canteen, what does $y_1=1$ mean?

    Each portion of food 1 costs 1.
    That is a primal cost, $3$.
    The pharmacist charges 1 unit per unit of protein: the canteen's price for protein at the optimum.
    It is the price attached to the protein row.
    The canteen needs 1 unit of protein.
    That is the right-hand side $8$.

    Complementary slackness and the dual simplex method

    At an optimal pair, a constraint with slack carries a zero price and a positive variable has a tight dual row; the dual simplex method exploits the mirror image of the primal simplex, keeping the reduced costs non-negative and chasing feasibility.

    Complementary slackness lets you recover the dual from the primal (or check a candidate answer) without solving anything, and the dual simplex is what a solver runs after you add a constraint or change a right-hand side, which happens at every node of branch and bound.

    It is like a market at equilibrium: a resource nobody uses up is free, and a product that is sold must break even on its ingredient prices.

    Feasible $x$ (primal) and $y$ (dual) are both optimal if and only if $$y_i\,(A_{i\cdot}x-b_i)=0\ \ \forall i\qquad\text{and}\qquad x_j\,(c_j-y^\top A_{\cdot j})=0\ \ \forall j.$$ In words: a constraint with slack has price $0$; a variable that is positive has a tight dual row.

    Prove complementary slackness.

    1. Recall the weak duality chain $b^\top y\le y^\top Ax\le c^\top x$, with $y^\top Ax-b^\top y=\sum_i y_i(A_{i\cdot}x-b_i)$ and $c^\top x-y^\top Ax=\sum_j (c_j-y^\top A_{\cdot j})x_j$.

      Each of the two gaps is a sum written row by row, respectively column by column.

    2. Every term of both sums is $\ge0$: $y_i\ge0$ times $A_{i\cdot}x-b_i\ge0$, and $x_j\ge0$ times $c_j-y^\top A_{\cdot j}\ge0$.

      These are the feasibility conditions of the two problems.

    3. The total gap is $c^\top x-b^\top y=\sum_iy_i(A_{i\cdot}x-b_i)+\sum_j(c_j-y^\top A_{\cdot j})x_j$.

      Adding the two gaps cancels the middle term.

    4. Both are optimal exactly when the gap is $0$ (strong duality), and a sum of non-negative terms is $0$ exactly when every term is $0$. That is the pair of conditions.

      Optimality, zero gap and termwise zero are all equivalent for a feasible pair.

    Using it on the running LP

    For the running LP $\max5x_1+3x_2$ with constraints $c_1,c_2,c_3$, the same statement reads (a "$\le$" constraint now has slack $b_i-A_{i\cdot}x$, and dual rows have excess $A^\top y-c\ge0$): $y_i\cdot\text{slack}_i=0$ and $x_j\cdot\text{excess}_j=0$.

    Try it

    Pick a corner of the running LP and a candidate price vector. The readout lists all five complementary slackness products. Find the one pair that is fully optimal. Then choose $(0,1,2)$ with the corner $(4,4)$: both are feasible and the values differ. Which products are non-zero, and how do they add up to the gap between the values?

    The primal optimum of the running LP is $x^*=(4,4)$. Find the optimal dual $y^*$ using complementary slackness alone.

    1. Slacks at $(4,4)$: $c_1$: $8-8=0$; $c_2$: $18-16=2$; $c_3$: $12-12=0$.

      The second constraint is not tight.

    2. The slack in $c_2$ forces $y_2=0$.

      A constraint with room to spare is worth nothing: $y_2\cdot2=0$.

    3. Both $x_1,x_2$ are positive, so both dual rows must be tight: $y_1+y_2+2y_3=5$ and $y_1+3y_2+y_3=3$. With $y_2=0$: $y_1+2y_3=5$ and $y_1+y_3=3$.

      A positive variable means $x_j\cdot\text{excess}_j=0$ forces the excess to be $0$.

    4. Subtract: $y_3=2$, then $y_1=1$. So $y^*=(1,0,2)$ with value $8+24=32$, which matches $5\cdot4+3\cdot4=32$.

      Equal values for a feasible pair prove optimality of both.

    Careful: complementary slackness does not say that "tight" means "positive price": a tight constraint may still have price $0$ (this happens at degenerate corners). And a pair satisfying all the products but violating dual feasibility proves nothing: try the corner $(6,0)$ with $y=(0,0,2.5)$ in the widget.

    The dual simplex method

    Primal simplex keeps $x$ feasible and works towards non-negative reduced costs (dual feasibility). The dual simplex does the reverse: it keeps all reduced costs $\ge0$ and works towards a non-negative right-hand side (primal feasibility). It is natural whenever the starting point is dual feasible but not primal feasible. Two cases matter:

    • a minimisation with costs $c\ge0$ and constraints $Ax\ge b$: the slack basis has $c_B=0$, so the reduced costs are $c\ge0$, while the basic values $-b$ are negative;
    • a solved LP after a change that damages feasibility but not optimality of the reduced costs: a new constraint, or a changed right-hand side (Chapter 2.4).

    We never write the dual: the tableau is the ordinary primal tableau.

    1. Start from a basis with all reduced costs $\bar c_j\ge0$ (dual feasible).
    2. If every basic value $\bar b_i\ge0$, stop: optimal.
    3. Leaving row: choose a row $r$ with $\bar b_r\lt0$ (usually the most negative).
    4. If no entry of row $r$ is negative, stop: the primal LP is infeasible.
    5. Entering column: among columns with $a_{rj}\lt0$ choose $j$ minimising $\bar c_j/|a_{rj}|$.
    6. Pivot on $(r,j)$ with the usual row operations and go to step 2.

    Why the ratio rule works. After pivoting, a column $k$ has new reduced cost $\bar c_k-\bar c_j\,a_{rk}/a_{rj}$. If $a_{rk}\ge0$ this does not decrease (the pivot $a_{rj}$ is negative). If $a_{rk}\lt0$ it stays $\ge0$ exactly when $\bar c_k/|a_{rk}|\ge\bar c_j/|a_{rj}|$, which is why $j$ must have the smallest ratio. So dual feasibility is never lost. Each pivot raises the objective (for a minimisation) and finally reaches primal feasibility.

    Try it

    Run the three presets. In each tableau, the highlighted row is the leaving row, the "ratio" line shows $\bar c_j/|a_{rj}|$ and the boxed column is the entering one. Press Pivot until the readout reports a result. Notice that the reduced costs (top row) never turn negative, while the right-hand sides turn from negative to non-negative. In the last preset, read why it stops.

    Solve the canteen diet $\min3x_1+2x_2$ s.t. $2x_1+x_2\ge8$, $x_1+x_2\ge6$ with the dual simplex method.

    1. Multiply the rows by $-1$ and add slacks: $-2x_1-x_2+s_1=-8$, $-x_1-x_2+s_2=-6$. With basis $\{s_1,s_2\}$ the reduced costs are $(3,2,0,0)$, all $\ge0$, but the basic values $(-8,-6)$ are negative.

      The slack basis is dual feasible because the costs are non-negative.

    2. Leaving row: $s_1$ (value $-8$, the most negative). Its negative entries are $-2$ in $x_1$ and $-1$ in $x_2$. Ratios: $3/2=1.5$ and $2/1=2$. The smaller is $x_1$, so $x_1$ enters.

      Dividing reduced cost by $|a_{rj}|$ finds the first dual constraint that would become violated.

    3. Pivot on the entry $-2$. New rows: $x_1+\tfrac12x_2-\tfrac12s_1=4$ and $-\tfrac12x_2-\tfrac12s_1+s_2=-2$; reduced costs $(0,\tfrac12,\tfrac32,0)$, objective $12$.

      Still dual feasible; row 2 is the only one still negative.

    4. Leaving row: $s_2$ (value $-2$). Negative entries: $-\tfrac12$ in $x_2$ and $-\tfrac12$ in $s_1$. Ratios: $\tfrac12/\tfrac12=1$ and $\tfrac32/\tfrac12=3$. So $x_2$ enters.

      The smaller ratio keeps all reduced costs non-negative.

    5. Pivot: $x_1=2$, $x_2=4$, reduced costs of $s_1,s_2$ both $1$, objective $14$. All values are $\ge0$: optimal.

      The reduced costs $(1,1)$ of the surplus columns are the dual prices $y=(1,1)$ of the pharmacist, and $8+6=14$ matches the primal cost.

    Go deeper: dual simplex is primal simplex on the dual

    Run primal simplex on the dual LP and translate each basis and pivot back to the primal tableau: you get precisely the rules above (the leaving row corresponds to the entering dual variable, the entering column to the dual ratio test). That is why the objective of a minimisation climbs monotonically during dual simplex: it is the dual objective, which primal simplex on the dual increases.

    At the optimum $(4,4)$ of the running LP the second constraint $x_1+3x_2\le18$ has value $16$. By complementary slackness, what is its optimal price $y_2$?

    Does this constraint have slack?

    The slack is $2\ne0$, so $y_2\cdot2=0$ forces $y_2=0$.

    With $y_2=0$ and both $x_1,x_2$ positive, the dual rows are $y_1+2y_3=5$ and $y_1+y_3=3$. Find $y_3$.

    Subtract the second equation from the first.

    $(y_1+2y_3)-(y_1+y_3)=y_3=5-3=2$ (and then $y_1=1$).

    Dual simplex on $\min2x_1+3x_2+4x_3$ s.t. $x_1+2x_2+x_3\ge3$, $2x_1-x_2+3x_3\ge4$. After adding slacks the tableau has reduced costs $(2,3,4,0,0)$, row $s_1$: $(-1,-2,-1,1,0\,|\,-3)$ and row $s_2$: $(-2,1,-3,0,1\,|\,-4)$. Row $s_2$ (most negative) leaves. What is the smallest ratio $\bar c_j/|a_{rj}|$?

    Row $s_2$ has negative entries in $x_1$ ($-2$) and $x_3$ ($-3$) only.

    $x_1$: $2/2=1$; $x_3$: $4/3\approx1.33$. The smallest is $1$ (so $x_1$ enters).

    After pivoting on the entry $-2$ of the previous tableau, what is the value of the basic variable $x_1$ (the new row is the old row $s_2$ divided by $-2$)?

    The row's right-hand side is $-4$.

    $-4/(-2)=2$.

    The reduced-cost row after that pivot has right-hand side $-4$ in the lecture convention (RHS of the RC row is $-z$). What is the objective $z$? Check it: $x_1=2$ costs $2\cdot2$.

    Change the sign.

    $z=4$, the cost of $x_1=2$ at price $2$. It is a lower bound for the final optimum $5.6$.

    In dual simplex, a row has a negative right-hand side and no negative entries in the other columns. What do you conclude?

    The row then reads "non-negative combination of non-negative variables equals a negative number".

    Such a row cannot be satisfied by any $x\ge0$: the primal is infeasible.

    • Check dual feasibility (all reduced costs $\ge0$) before starting dual simplex.
    • Take the ratio only over negative entries of the leaving row.
    • Dividing by positive entries or by zero entries.
    • Taking the minimum ratio over the wrong row: the ratio test of dual simplex runs along the leaving row, not down a column.
    1. Complementary slackness: at an optimal pair, price $\times$ slack $=0$ for each constraint and variable $\times$ dual-row excess $=0$ for each variable; it recovers $y$ from $x$.
    2. Dual simplex keeps reduced costs $\ge0$ and pivots to remove negative right-hand sides; it detects primal infeasibility when a negative row has no negative entry.
    3. Choose the leaving row first (a negative basic value), then the entering column by the smallest $\bar c_j/|a_{rj}|$.

    A constraint has a positive slack at the primal optimum. What does complementary slackness say about its optimal dual price?

    It is positive.
    A positive price on a constraint with unused room would make the products non-zero.
    It is $0$.
    Price times slack must vanish, and the slack is not zero.
    It cannot be determined.
    The condition decides it.

    A variable is positive at the primal optimum. What is true of its dual constraint?

    It has slack.
    That would make $x_j\cdot\text{excess}_j\gt0$.
    It is tight (the excess is $0$).
    Variable times excess must be $0$.
    It is violated.
    The optimal dual is feasible.

    Dual simplex has right-hand sides $(3,-5,-1)$ in the three rows. Which row leaves under the usual rule?

    The first.
    That value is already feasible.
    The second.
    The most negative value, $-5$.
    The third.
    It is negative but not the most negative.

    Why must the entering column minimise $\bar c_j/|a_{rj}|$ over negative entries of row $r$?

    It makes the objective largest.
    The aim is to keep reduced costs from going negative.
    It is the choice that keeps every reduced cost non-negative.
    A larger ratio would make some other reduced cost negative.
    It makes the right-hand side positive immediately.
    It may take several pivots to clear all negative values.

    Sensitivity analysis: reduced costs, shadow prices and ranging

    Once the optimal basis is known, you can read how the answer reacts to small changes in the costs, the right-hand sides, or the model itself without solving the LP again.

    Data are estimates (demand, capacity, costs). A planner wants to know which estimates matter, and branch and bound re-solves slightly changed LPs constantly, starting from the old basis.

    It is like a recipe tested in a kitchen: before changing the oven temperature, you want to know how much it can move before the dish is ruined, and how much each degree is worth.

    Throughout we use the running LP, whose optimal basis is $\{x_1,x_2,s_2\}$, with optimal point $(4,4)$ and slacks $s=(0,2,0)$. Its optimal tableau for $\min-5x_1-3x_2$ (right-hand side of the top row is $-z$) is $$\begin{array}{c|ccccc|c}&x_1&x_2&s_1&s_2&s_3&\text{RHS}\\\hline \text{RC}&0&0&1&0&2&32\\x_1&1&0&-1&0&1&4\\x_2&0&1&2&0&-1&4\\s_2&0&0&-5&1&2&2\end{array}$$ so $B^{-1}$ (the three slack columns) has columns $(-1,2,-5)$, $(0,0,1)$, $(1,-1,2)$, and $y=(1,0,2)$.

    What the reduced costs and prices say

    The reduced costs of the non-basic slacks, $1$ and $2$, equal the dual prices $y_1,y_3$: forcing the slack $s_1$ to be one unit (that is, using one fewer unit of the first resource) costs $1$ unit of profit. The slack $s_2$ is basic with value $2$: the second resource is not scarce and its price is $0$. In general, when the optimal basis is non-degenerate, the optimal dual variables are the marginal values of the right-hand sides: $\partial z^*/\partial b_i=y_i$.

    The shadow price of constraint $i$ is the change in the optimal value per unit increase of $b_i$: it equals $y_i^*$. It holds only while the optimal basis stays the same: the range of $b_i$.

    Changing a right-hand side

    Raise $b_i$ by $t$. The reduced costs $c_N^\top-c_B^\top B^{-1}N$ do not involve $b$, so optimality conditions are intact. Only feasibility can fail: $$x_B(t)=B^{-1}b+t\,B^{-1}e_i\ \ge0.$$ The basis stays optimal exactly while this holds, and the optimal value is $z^*+y_i\,t$ in this range. Outside the range, a basic variable would turn negative, the point is dual feasible but primal infeasible, and dual simplex (Chapter 2.3) repairs it.

    Try it

    Choose a constraint and slide its right-hand side. Left: the region and optimal corner; right: the optimal profit as a function of $b_i$. The dashed line is the tangent with slope equal to the shadow price. Find where the slope changes for each constraint, and note that constraint 2 has price $0$ over a long range.

    Find the range of $b_1$ over which the shadow price $y_1=1$ is valid, and the value of the running LP at $b_1=8.2$.

    1. The first column of $B^{-1}$ is $(-1,2,-5)$ and the current basic values are $(x_1,x_2,s_2)=(4,4,2)$. So $x_B(t)=(4-t,\ 4+2t,\ 2-5t)$.

      Increasing $b_1$ by $t$ shifts the basic variables along the column of $B^{-1}$ belonging to constraint 1.

    2. Require all non-negative: $4-t\ge0$ gives $t\le4$; $4+2t\ge0$ gives $t\ge-2$; $2-5t\ge0$ gives $t\le0.4$. So $-2\le t\le0.4$.

      The most restrictive bounds are the lower $-2$ and the upper $0.4$.

    3. The range is $b_1\in[6,8.4]$. Inside it, $z^*=32+1\cdot t$.

      The shadow price $1$ is the slope of the profit curve in this range.

    4. At $b_1=8.2$, $t=0.2$: $z^*=32.2$ at $x=(3.8,4.4)$ (check: $3.8+4.4=8.2$, $5\cdot3.8+3\cdot4.4=32.2$).

      The point is inside the range, so no re-solve is needed.

    The same recipe for the other two constraints: for $b_2$ the column is $(0,0,1)$, so $s_2=2+t\ge0$ gives $b_2\ge16$ with price $0$ (no upper limit); for $b_3$ the column is $(1,-1,2)$, giving $x_B(t)=(4+t,4-t,2+2t)$ and $-1\le t\le4$, so $b_3\in[11,16]$ with price $2$.

    Changing a cost

    A cost change does not move the point $x_B=B^{-1}b$, so feasibility is untouched; only the reduced costs change. For a non-basic variable, only its own reduced cost changes. For a basic variable, $c_B$ changes, so all reduced costs change. The current basis stays optimal while all reduced costs keep their signs.

    Try it

    Slide the profits $c_1,c_2$ of the running LP. The mint line through the optimal corner is the objective line. Find how far $c_1$ can move before the optimal corner changes, and watch for the tie when the objective line lies along an edge.

    Keeping $c_2=3$, find the range of $c_1$ for which $(4,4)$ stays optimal.

    1. With profits $(c_1,3,0)$ on the basis $\{x_1,x_2,s_2\}$, the dual prices are $y^\top=c_B^\top B^{-1}=(c_1,3,0)\,B^{-1}=(6-c_1,\ 0,\ c_1-3)$.

      Multiply $c_B$ by the columns of $B^{-1}$ listed above: $-c_1+6$, $0$, $c_1-3$.

    2. For a maximisation, optimality needs $y\ge0$ (the reduced costs of the slacks, $y_1$ and $y_3$, are non-negative): $6-c_1\ge0$ and $c_1-3\ge0$.

      The basic columns have zero reduced cost by definition; only the non-basic slacks can fail.

    3. So $3\le c_1\le6$. At $c_1=6$ the objective line is parallel to the constraint $2x_1+x_2\le12$ and the edge from $(6,0)$ to $(4,4)$ ties; at $c_1=3$ it is parallel to $x_1+x_2\le8$.

      At the end points the reduced cost of a non-basic variable becomes $0$: there are alternative optima.

    4. Same method with $c_1=5$ fixed: $y=(2c_2-5,\ 0,\ 5-c_2)$, so $2.5\le c_2\le5$.

      The ratio $c_1/c_2$ must stay between the slopes of the two tight constraints: between $1$ and $2$.

    A new variable and a new constraint

    New variable. Add a product $x_6$ with profit $4$ using $(1,1,1)$ units of the three resources. Treat it as non-basic at $0$: the current point is still feasible. Price it out: the resources it uses are worth $y^\top A_{\cdot6}=1\cdot1+0\cdot1+2\cdot1=3$ at the current prices, below its profit $4$. Its reduced cost (in the minimisation) is $-4+3=-1\lt0$, so it enters and simplex continues: the new optimum is $36$ at $x_1=4,x_6=4$. If its profit were $3$ or less, it would stay out.

    New constraint. Add $x_2\le3$. If the current optimum satisfies it, the optimum is unchanged. Here $(4,4)$ violates it, but the old reduced costs remain non-negative once the new slack joins the basis: the new tableau is dual feasible and primal infeasible, the exact situation for dual simplex.

    Re-optimise the running LP after adding $x_2\le3$, starting from the optimal tableau above.

    1. Write the new row with slack $s_4$: $x_2+s_4=3$. Substitute $x_2=4-2s_1+s_3$ from the $x_2$ row of the tableau: $-2s_1+s_3+s_4=-1$.

      The new row must be expressed in terms of the non-basic variables so $s_4$ can be basic.

    2. The basic value $s_4=-1$ is negative: dual simplex. The row has one negative entry, $-2$ in the column $s_1$. Ratio: $\bar c_{s_1}/2=1/2$. So $s_1$ enters and $s_4$ leaves.

      Only $s_1$ has a negative entry, so it is the only candidate.

    3. Pivot. New values: $s_1=\tfrac12$, $x_2=3$, $x_1=4+s_1=4.5$, $s_2=2+5s_1=4.5$; reduced costs of $s_3,s_4$ are $2.5$ and $0.5$.

      All values are non-negative and all reduced costs are positive, so the tableau is optimal.

    4. New optimum: $x=(4.5,3)$ with profit $5\cdot4.5+3\cdot3=31.5$, down from $32$.

      One pivot instead of a restart from the origin.

    Careful: shadow prices are one-at-a-time and local. Changing two right-hand sides together, or one by more than its range, needs a new check of $B^{-1}b\ge0$. And at a degenerate optimum (a basic variable equal to $0$) the left and right slopes of the profit curve can differ, so there is no single price.
    Go deeper: leaving the range

    If $b_2$ drops from $18$ to $15$ (below its range limit $16$), $s_2=2+(15-18)=-1$ becomes negative while the reduced costs are untouched: dual simplex. The row of $s_2$ has the negative entry $-5$ in the column $s_1$, ratio $1/5$, so $s_1$ enters: profit $32-0.2=31.8$ at $(4.2,3.6)$. The new slope of the profit curve below $16$ is therefore $0.2$ per unit, no longer $0$.

    The running LP has $y=(1,0,2)$ and a range $[11,16]$ for $b_3$. How much does the optimal profit rise when $b_3$ goes from $12$ to $13$?

    $13$ is inside the range, so the price applies.

    $y_3\cdot1=2$. Check: at $b_3=13$ the optimum is $(5,3)$ with profit $34$.

    With $x_B(t)=(4-t,\ 4+2t,\ 2-5t)$ for $(x_1,x_2,s_2)$, what is the largest $b_1$ keeping the basis feasible? (Current $b_1=8$.)

    The binding entry is the one that decreases fastest. Solve $2-5t\ge0$.

    $t\le0.4$, so $b_1\le8.4$.

    What is the optimal profit of the running LP when $b_1=8.2$?

    The value is $32+y_1t$ inside the range $[6,8.4]$.

    $32+1\cdot0.2=32.2$.

    With $c_1=5$ fixed, the dual prices on the optimal basis are $y_1=2c_2-5$ and $y_3=5-c_2$. What is the smallest $c_2$ for which $(4,4)$ stays optimal?

    Both prices must be $\ge0$.

    $2c_2-5\ge0$ gives $c_2\ge2.5$ (and $5-c_2\ge0$ gives $c_2\le5$).

    A new product with profit $2.5$ would use $(1,1,1)$ units of the three resources of the running LP. Should the current plan change? (Prices $y=(1,0,2)$.)

    Compare the profit with the worth $y^\top A_{\cdot j}$ of the resources it uses.

    The resources are worth $1+0+2=3\gt2.5$: producing it would lose $0.5$ per unit, so it stays out.

    If $b_2$ falls from $18$ to $15$ in the running LP, what is the new optimal profit? (Hint: $s_2=-1$ after the change; dual simplex pivots in $s_1$ with ratio $1/5$.)

    The objective drops by (ratio) $\times$ (size of the infeasibility), i.e. $\tfrac15\cdot1$.

    $32-0.2=31.8$. Direct check: $x_1+3x_2=15$ and $2x_1+x_2=12$ meet at $(4.2,3.6)$, profit $21+10.8=31.8$.

    • Always report a shadow price together with its range.
    • For a cost change on a basic variable, recompute all reduced costs, not just one.
    • Applying a shadow price beyond its range.
    • Reading "price $0$" as "constraint can be dropped": it only means a small change does not matter.
    1. The optimal dual variables $y_i$ are the shadow prices of the right-hand sides; they hold while $B^{-1}b+t\,B^{-1}e_i\ge0$.
    2. A cost change keeps the basis optimal as long as all reduced costs keep their signs; for the running LP, $3\le c_1\le6$ and $2.5\le c_2\le5$.
    3. New variables are priced out with $y^\top A_{\cdot j}$; a new violated constraint or a right-hand side outside its range is repaired by dual simplex, not by a restart.

    A resource has shadow price $4$ with range $[10,30]$ and its supply is now $20$. Supply rises to $26$. By how much does the optimal value change?

    $0$.
    A positive price means extra supply helps.
    By $4\cdot6=24$.
    $26$ is inside the range, so the price applies to all six units.
    It cannot be said.
    The range tells you the price is valid.

    After a change in $b$, the old basis has all reduced costs $\ge0$ but one basic value is negative. Which method restarts efficiently?

    Primal simplex.
    Primal simplex needs a primal feasible start.
    Dual simplex.
    The basis is dual feasible and primal infeasible.
    Solve the dual from scratch.
    That would discard the basis you already have.

    A new variable has reduced cost $-1$ (minimisation) at the current prices. What happens?

    Nothing; the current solution is still optimal.
    A negative reduced cost is an improving direction.
    It enters the basis and primal simplex continues.
    The current point is still feasible and the new column can improve it.
    The LP becomes infeasible.
    The point is unchanged and still feasible.

    Why is a cost change handled by checking reduced costs, while a right-hand side change is handled by checking $B^{-1}b$?

    Both change the reduced costs.
    A right-hand side change leaves them untouched.
    The costs enter the reduced costs only, and $b$ enters the basic values only.
    Optimality (dual feasibility) depends on $c$, feasibility on $b$.
    The two checks are equivalent.
    They test different things.

    Primal: $\min4x_1+3x_2$ s.t. $x_1+2x_2\ge6$, $3x_1+x_2\ge6$, $x\ge0$. The point $x=(2,2)$ is feasible with cost $14$. The dual is $\max6y_1+6y_2$ s.t. $y_1+3y_2\le4$, $2y_1+y_2\le3$, $y\ge0$, and $y=(1,1)$ is dual feasible. What is guaranteed?

    The optimal cost is exactly $14$.
    $14$ is the cost of one feasible plan, an upper bound only.
    The optimal cost is exactly $12$.
    $12$ is a lower bound from weak duality; equality needs more evidence.
    The optimal cost lies between $12$ and $14$.
    The dual value $6+6=12$ is a lower bound, the primal plan an upper bound.

    At the optimum of an LP, the first constraint has slack $3$ and the first variable is positive. Which statements must hold?

    $y_1=0$ and the first dual row is tight.
    Price times slack is $0$; variable times excess is $0$.
    $y_1\gt0$ and the first dual row has slack.
    Both conclusions are the opposite of what is required.
    $y_1=0$ and the first dual row has slack.
    A positive variable forces its dual row to be tight.

    The running LP has $y_1=1$ for the first constraint and range $b_1\in[6,8.4]$. The planner raises $b_1$ from $8$ to $10$. What is the correct statement?

    Profit rises by exactly $2$.
    $10$ is beyond the range, so the price may no longer apply.
    Profit rises by at most $0.4$ at price $1$ within the range; beyond $8.4$ the basis changes and the price must be recomputed.
    Up to $8.4$ the slope is $1$; after that, the slope drops (to $0$ for this LP).
    Profit is unchanged.
    Up to $8.4$ the price $1$ does apply.

    In a minimisation with bounds, which non-basic variable satisfies the optimality condition?

    At its lower bound with $\bar c=-2$.
    Raising it would improve the cost.
    At its upper bound with $\bar c=-2$.
    It can only decrease, and the cost would rise by $2$ per unit.
    At its upper bound with $\bar c=+2$.
    Lowering it would improve the cost.

    In a primal simplex ratio test the basic values are $(6,4,9)$ and the direction entries are $d_B=(-3,2,-1)$. Which basic variable leaves, and what is the step length?

    The second, step $2$.
    The second entry is positive: that variable grows and never blocks the step.
    The first, step $2$.
    Ratios: $6/3=2$ and $9/1=9$. The smaller one, $2$, belongs to the first variable.
    The third, step $9$.
    The step is the smallest ratio, not the largest.

    The lines $2x_1+x_2=12$ and $x_1+3x_2=18$ meet at which point?

    $(4,4)$
    That is where $x_1+x_2=8$ meets $2x_1+x_2=12$. Check it in $x_1+3x_2=18$: $4+12=16$.
    $(3.6,4.8)$
    From the first, $x_2=12-2x_1$; then $x_1+36-6x_1=18$ gives $x_1=3.6$, $x_2=4.8$.
    $(6,0)$
    At $(6,0)$ the second line gives $6\ne18$.

    Lecture 3 adds one restriction to linear programming, that some variables must be whole numbers, and shows how many routing and logistics decisions (pack this van, open that depot, assign this job) become integer programmes. The second half of the lecture asks which of several correct formulations a solver can actually use: the strong ones. The labs on facility location (Lab 1) and the generalised assignment problem (Lab 2) are the case studies. Throughout Parts 3 to 6 we follow one small, fictional firm, Kaveri Courier in Bengaluru: its owner decides which depot sites to open and how to load parcels onto vans here, then hands those decisions to a solver (Part 4), routes one van (Part 5) and finally the whole fleet (Part 6).

    You need: Part B (turning a word problem into variables, objective and constraints), Part D (binary logic, forcing constraints, big-M, cover and packing matrices) and Part 1 (polyhedra, convex hulls, corners of an LP).

    Modelling with integer variables: six classical formulations

    An integer programme (IP) is a linear programme in which some or all variables must take whole-number values, most often 0 or 1.

    Choosing which depot to open or which parcel to load is a yes/no or a count, never a fraction, so every plan in this course is an integer programme at heart. The formulations of this chapter are the templates you will recognise again in Parts 4 to 6.

    It is like a seating plan: a guest sits in one chair or another, never in 0.4 of two chairs.

    From LP to IP

    Recall the LP in canonical form, $\min c^\top x$ subject to $Ax\ge b$, $x\ge0$. Add the requirement that the variables are whole numbers and we get the integer programme $$\min\ c^\top x\quad\text{s.t.}\quad Ax\ge b,\quad x\in\mathbb Z^n_+ .$$ Here $\mathbb Z^n_+$ means vectors of non-negative integers, so the separate constraint $x\ge0$ is no longer needed. If every variable is restricted to $\{0,1\}$ it is a binary programme; if some variables are integer and others continuous it is a mixed integer programme (MIP).

    The picture changes in an important way. The feasible set of an LP is a polyhedron and its best point is at a corner (Part 1). The feasible set of an IP is a cloud of isolated points, and the best of them is generally not a corner of the polyhedron defined by $Ax\ge b$. Chapter 3.2 explores this. For now we learn to write down the models.

    A running story: a courier company has five parcels to load onto a van, several depots from which to dispatch, and a planning horizon of a few days. Every model below answers one question from that story. We write $x$ for quantities or assignments and $y$ for yes/no switches.

    Kaveri Courier

    The owner of Kaveri Courier has a few candidate depot sites around Bengaluru, a handful of vans and parcels for customers across the city. Two questions come up every day: which parcels go on this van, and which depots are worth opening? The first is the knapsack and bin packing formulation below, the second is facility location, and the question of who does which job is the assignment family. Each formulation is one decision the owner really faces.

    A van of capacity $C$ kg may carry parcel $j$ (weight $a_j$, value $c_j$) or not. Let $x_j=1$ if parcel $j$ is loaded. $$\max\ \sum_{j=1}^n c_jx_j\quad\text{s.t.}\quad \sum_{j=1}^n a_jx_j\le C,\quad x_j\in\{0,1\}.$$ One constraint, binary variables, maximise value. It is the simplest IP and the building block of cover inequalities (Chapter 3.3).

    Try it

    Five parcels with weights 9, 8, 5, 4, 3 kg and values 9, 5, 14, 11, 12 must fit a van of capacity 16 kg. Click parcels to load them and try to beat your own score. Then press "LP relaxation" to see what happens when parcels may be loaded in parts. Notice that the fractional plan is worth more than any whole-parcel plan.

    $n$ couriers and $n$ parcels; courier $i$ delivering parcel $j$ costs $c_{ij}$. Let $x_{ij}=1$ if courier $i$ takes parcel $j$. $$\min\ \sum_{i=1}^n\sum_{j=1}^n c_{ij}x_{ij}\quad\text{s.t.}\quad \sum_{j}x_{ij}=1\ \ \forall i,\qquad \sum_{i}x_{ij}=1\ \ \forall j,\qquad x_{ij}\in\{0,1\}.$$ Each courier gets exactly one parcel and each parcel exactly one courier. A remarkable fact, proved in the "go deeper" box of Chapter 3.2, is that the LP relaxation of this model already has integer corners, so a plain LP solver solves it.

    $n$ items of weight $w_j$ are packed into identical bins (vans) of capacity $C$, and we want to use as few bins as possible. Let $y_i=1$ if bin $i$ is used and $x_{ij}=1$ if item $j$ goes into bin $i$. $$\min\ \sum_{i=1}^n y_i\quad\text{s.t.}\quad \sum_{j}w_jx_{ij}\le C\,y_i\ \ \forall i,\qquad \sum_{i}x_{ij}=1\ \ \forall j,\qquad x_{ij},y_i\in\{0,1\}.$$ The first row is a forcing constraint (Part D): an unused bin ($y_i=0$) can hold nothing, a used bin holds at most $C$. We use $n$ bins because $n$ items never need more than $n$ bins.

    Careful: the objective counts bins used and we want fewer of them, so it is a minimisation. The lecture slide writes "max" here; that is a slip, and with "max" a solver would happily open every bin.

    Over periods $t=1,\dots,n$ a depot faces demand $d_t$. Producing in period $t$ costs a fixed set-up $f_t$ plus $p_t$ per unit, and each unit left in stock at the end of period $t$ costs $h_t$. Let $x_t$ be the amount produced, $s_t$ the stock at the end of period $t$ and $y_t=1$ if production happens in period $t$. $$\min\ \sum_{t=1}^n\big(p_tx_t+h_ts_t+f_ty_t\big)\quad\text{s.t.}\quad s_{t-1}+x_t=d_t+s_t,\quad x_t\le M\,y_t,\quad s_0=0,\quad x_t,s_t\ge0,\ y_t\in\{0,1\}.$$ The first row is a stock balance (what we hold plus what we make equals what we ship plus what we keep). The second is the forcing constraint "no production unless the set-up is paid"; $M$ is a big-M that must be at least as large as any possible production quantity. A mixed integer programme: $x,s$ continuous, $y$ binary.

    Careful: this too is a minimisation of cost; the slide's "max" is a slip. Also note that $f_ty_t$ is paid only when $y_t=1$: the forcing row ties $y_t$ to $x_t$.

    $m$ customers can be served from $n$ candidate depots. Opening depot $j$ costs $f_j$; serving customer $i$ from depot $j$ costs $c_{ij}$. Let $y_j=1$ if depot $j$ is open and $x_{ij}=1$ if customer $i$ is served from $j$. $$\min\ \sum_{j}f_jy_j+\sum_{i}\sum_{j}c_{ij}x_{ij}\quad\text{s.t.}\quad \sum_jx_{ij}=1\ \ \forall i,\qquad x_{ij}\le y_j\ \ \forall i,j,\qquad x_{ij},y_j\in\{0,1\}.$$ "Uncapacitated" means depots can serve any number of customers. The rows $x_{ij}\le y_j$ are forcing constraints again: no service from a closed depot. This is the model of Lab 1.

    $m$ agents (vans, crews) and $n$ jobs. Agent $i$ needs time $t_{ij}$ for job $j$ and has a time budget $s_i$; the assignment costs $c_{ij}$ (or earns profit $p_{ij}$, with "max" instead of "min"). Let $x_{ij}=1$ if agent $i$ does job $j$. $$\min\ \sum_{i}\sum_{j}c_{ij}x_{ij}\quad\text{s.t.}\quad \sum_{i}x_{ij}=1\ \ \forall j,\qquad \sum_{j}t_{ij}x_{ij}\le s_i\ \ \forall i,\qquad x_{ij}\in\{0,1\}.$$ Every job has exactly one agent (a column of the table sums to 1) and no agent exceeds its budget (a row of times is bounded). It generalises the assignment problem: one agent may take several jobs. This is the model of Lab 2.

    ModelVariablesObjectiveConstraint patterns
    Knapsack$x_j$ binarymax valueone capacity row
    Assignment$x_{ij}$ binarymin cost"exactly one" in every row and column
    Bin packing$y_i,x_{ij}$ binarymin binscapacity with forcing $\le Cy_i$; "exactly one" per item
    Lot sizing$x_t,s_t\ge0$, $y_t$ binarymin coststock balance; forcing $x_t\le My_t$
    Facility location$y_j,x_{ij}$ binarymin cost"exactly one" per customer; forcing $x_{ij}\le y_j$
    GAP$x_{ij}$ binarymin cost"exactly one" per job; budget row per agent

    Six items of weights $5,4,3,3,2,2$ are packed into bins of capacity $C=8$. (a) How many variables and constraints does the bin packing model have? (b) What is the fewest bins any plan can use, and is there a plan achieving it?

    1. With $n=6$ items we allow $n=6$ bins. The variables are $x_{ij}$ for 6 bins and 6 items, which is $36$, plus $y_1,\dots,y_6$: in all $36+6=42$ binary variables.

      One $x_{ij}$ for every (bin, item) pair, one $y_i$ for every bin.

    2. Constraints: 6 capacity rows (one per bin) and 6 "exactly one" rows (one per item): $12$ constraints, apart from the binary restrictions.

      Capacity is per bin, assignment is per item.

    3. The total weight is $5+4+3+3+2+2=19$. Two bins hold at most $16\lt19$, so at least $\lceil19/8\rceil=3$ bins are needed.

      A lower bound from adding up weights; no plan can beat it.

    4. Three bins suffice: $\{5,3\}$ weighs $8$, $\{4,2,2\}$ weighs $8$, $\{3\}$ weighs $3$.

      Each bin is within capacity and every item appears once, so the plan is feasible with 3 bins. It meets the lower bound, so it is optimal.

    Lot sizing with demands $d=(20,30,0,40,10)$ in five periods, set-up costs $f=(90,80,70,85,60)$, unit production cost $p_t=2$, holding cost $h_t=1$ per unit per period. Evaluate the plan: produce $50$ in period 1 and $50$ in period 4, nothing else.

    1. Stock balance with $s_0=0$: $s_1=0+50-20=30$, $s_2=30+0-30=0$, $s_3=0+0-0=0$, $s_4=0+50-40=10$, $s_5=10+0-10=0$.

      Apply $s_t=s_{t-1}+x_t-d_t$ period by period; all stocks stay non-negative, so the plan is feasible.

    2. Set-ups: $y_1=y_4=1$, so $90+85=175$.

      Only periods that produce pay their fixed cost.

    3. Production: $2\times(50+50)=200$. Holding: $1\times(30+0+0+10+0)=40$.

      Variable cost is per unit made; holding is per unit left over at the end of each period.

    4. Total cost: $175+200+40=415$.

      This happens to be the optimum (Chapter 3.3 shows that no integer plan is cheaper).

    Go deeper: why $M=\text{total demand}$ is valid but poor

    In lot sizing no period will ever produce more than the demand still to come, $d_t+\dots+d_n$. Any $M$ at least that large is valid, including the total demand over all periods, but the larger $M$ is, the weaker the LP bound (Chapter 3.3). The same remark holds for the bin packing row $\sum_jw_jx_{ij}\le Cy_i$, where $C$ is already the smallest sensible multiplier.

    In the van example (weights 9, 8, 5, 4, 3 kg; values 9, 5, 14, 11, 12; capacity 16 kg) the plan "load parcels 3, 4 and 5" is feasible. What is its total value?

    Add the values of parcels 3, 4 and 5, and check that their weights add up to at most 16.

    Weights $5+4+3=12\le16$; values $14+11+12=37$. (This is the optimum.)

    A bin packing model for $n=5$ items with $n$ bins available uses $x_{ij}$ and $y_i$. How many binary variables does it have?

    Count the (bin, item) pairs, then add one switch per bin.

    $5\times5=25$ variables $x_{ij}$ plus $5$ variables $y_i$: $30$.

    A facility location model has $m=8$ customers and $n=5$ candidate depots. Using the individual forcing rows $x_{ij}\le y_j$, how many constraints are there, not counting the binary restrictions?

    One "exactly one" row per customer, plus one forcing row per (customer, depot) pair.

    $8$ assignment rows plus $8\times5=40$ forcing rows: $48$.

    Same lot sizing data as in the worked example ($d=(20,30,0,40,10)$, $f=(90,80,70,85,60)$, $p_t=2$, $h_t=1$). Evaluate the plan "produce all $100$ units in period 1". What is its total cost?

    Stocks at the ends of periods 1 to 5 are $80,50,50,10,0$.

    Set-up $90$; production $2\times100=200$; holding $80+50+50+10+0=190$. Total $90+200+190=480$, worse than the plan of cost 415.

    In the bin packing model, which is the correct sense of the objective $\sum_iy_i$?

    $y_i=1$ means a bin is used. Do we want more bins or fewer?

    We want as few used bins as possible, so the objective is minimised. Maximising would open all bins.

    • Say in words what each variable means before writing a constraint.
    • Link every yes/no variable to the quantity it controls with a forcing row.
    • Check the objective sense: counts and costs are minimised, values and profits maximised.
    • Writing "max" for bin packing or lot sizing.
    • Forgetting that an unused bin or an idle period must hold or produce exactly zero.
    • Treating the IP as an LP and rounding at the end.
    1. An integer programme is an LP with whole-number requirements; mixed integer programmes keep some continuous variables.
    2. Knapsack, assignment, bin packing, lot sizing, facility location and GAP are built from three patterns: capacity rows, "exactly one" rows and forcing rows.
    3. Bin packing and lot sizing are minimisation problems; always check the sense of the objective.

    Which constraint family makes bin $i$ available for items only if it is used?

    $\sum_iw_jx_{ij}=1$
    That sum mixes bins and has no capacity; look for the row with $y_i$ on the right.
    $\sum_jw_jx_{ij}\le C\,y_i$
    When $y_i=0$ the right side is 0 and no item can be placed; when $y_i=1$ the capacity $C$ applies.
    $\sum_jx_{ij}\ge y_i$
    That forces a used bin to hold something but does not limit its load.

    In lot sizing, period 2 has $s_1=30$, $d_2=30$ and production $x_2=0$. What is $s_2$?

    30
    Apply $s_1+x_2=d_2+s_2$.
    60
    Stock cannot grow without production.
    0
    $30+0=30+s_2$ gives $s_2=0$.

    What does the generalised assignment problem allow that the plain assignment problem does not?

    One agent may take several jobs, as long as its budget allows.
    The "exactly one" row for agents is replaced by a budget row $\sum_jt_{ij}x_{ij}\le s_i$.
    A job may be split between agents.
    The variables are still binary, so each job goes to one agent.
    Agents may refuse all jobs and the problem has no objective.
    The objective is still the total cost or profit of the assignment.

    An integer programme has LP corner points that are not integers. What does this tell you?

    The IP is infeasible.
    Integer points may still exist inside the region.
    The best integer point need not be a corner of the LP region.
    The feasible set is a cloud of integer points, and the LP optimum may be fractional.
    Rounding the LP optimum always gives the optimum.
    Rounding may leave the feasible region or miss better points.

    The LP relaxation: bounds, gaps and the convex hull

    The LP relaxation of an IP drops the integrality requirement; its optimal value is a bound on the IP's optimum, and the closer the relaxed region hugs the integer points, the better the bound.

    Branch and bound (Part 4) is only as fast as these bounds are tight, and two models that look equivalent can differ by orders of magnitude in solving time.

    It is like wrapping a gift: a loose sheet of paper (weak formulation) leaves empty space around the box, a tight one (strong formulation) clings to the corners.

    Relaxing the integrality

    Take an IP $z_{IP}=\min\{c^\top x: Ax\ge b,\ x\in\mathbb Z^n_+\}$. Its LP relaxation replaces $x\in\mathbb Z^n_+$ by $x\ge0$ (for binary variables, $0\le x\le1$) and gives $z_{LP}=\min\{c^\top x: Ax\ge b,\ x\ge0\}$. Every integer feasible point is also feasible for the relaxation, so the relaxation can only do better: $$z_{LP}\le z_{IP}\ \text{ for a minimisation},\qquad z_{LP}\ge z_{IP}\ \text{ for a maximisation}.$$ So the LP value is a bound, and the integrality gap $\dfrac{|z_{IP}-z_{LP}|}{|z_{IP}|}$ measures how far it is from the truth. A zero gap means the LP solves the IP.

    Rounding the LP solution is no cure. In the van example the LP plan loads $4/9$ of parcel 1, and loading the whole parcel would overload the van; in facility location the LP may open every depot a sixth of the way, and rounding up opens them all. Rounding may be infeasible, or feasible but far from optimal.

    Many formulations, one set of integer points

    Let $X$ be the set of feasible integer points. A formulation is any polyhedron $P$ whose integer points are exactly $X$, that is $P\cap\mathbb Z^n=X$. There are infinitely many: we may rescale a constraint, add a redundant one or move a line without passing a new integer point.

    If $P_1$ and $P_2$ are two formulations of the same IP and $P_1\subset P_2$, then $P_1$ is stronger than $P_2$. A stronger formulation never gives a worse bound: minimising over a smaller set can only raise the minimum (and lower the maximum), so $z_{LP}(P_2)\le z_{LP}(P_1)\le z_{IP}$ for a minimisation.

    For $X=\{x^1,\dots,x^k\}$ the convex hull is $\operatorname{Conv}(X)=\big\{\sum_i\lambda_ix^i:\ \sum_i\lambda_i=1,\ \lambda_i\ge0\big\}$ (Part 1: the rubber band around the points). It is the smallest convex set containing $X$. When $X$ is finite it is a polytope, so it can be written as $\{x: A^{conv}x\le b^{conv}\}$. It is the strongest possible formulation: it is contained in every convex formulation of $X$.

    Try it

    The dots are the 15 feasible integer points of a small IP (maximise $c_1x_1+c_2x_2$). Switch between three polygons that all have exactly these integer points: "Loose", "As first written" and "Convex hull". Move the objective sliders. For each setting compare the LP optimum (the large dot, red when fractional) with the best integer point (green ring). Notice that on the convex hull the LP optimum is always one of the dots.

    Let $X$ be a finite set of points. Then $\min\{c^\top x:x\in X\}=\min\{c^\top x:x\in\operatorname{Conv}(X)\}$, and the LP over $\operatorname{Conv}(X)$ has an optimal corner that lies in $X$. The same holds for mixed integer programmes (with $X$ the feasible set, then a polyhedron).

    Prove the theorem for the minimisation of $c^\top x$ over a finite $X=\{x^1,\dots,x^k\}$.

    1. Because $X\subseteq\operatorname{Conv}(X)$ (take one $\lambda_i=1$), $\min_{\operatorname{Conv}(X)}c^\top x\le\min_Xc^\top x$.

      The left side minimises over a bigger set.

    2. Let $v=\min_ic^\top x^i$ be the best value over $X$. Take any $x=\sum_i\lambda_ix^i\in\operatorname{Conv}(X)$.

      Every point of the hull has this form by definition.

    3. Then $c^\top x=\sum_i\lambda_i\,c^\top x^i\ge\sum_i\lambda_i\,v=v$, using $\lambda_i\ge0$, $\sum_i\lambda_i=1$.

      A weighted average of numbers each at least $v$ is at least $v$.

    4. Hence $\min_{\operatorname{Conv}(X)}c^\top x\ge v$, so the two minima are equal. A corner (extreme point) of $\operatorname{Conv}(X)$ cannot be a mix of two other points of the hull, so each corner is one of the $x^i$.

      Part 1: an LP over a polytope is optimal at a corner; here every corner is in $X$.

    Careful: the theorem says the convex hull is ideal, but finding its inequalities is usually as hard as the IP itself. In practice we look for formulations close to the hull and add valid inequalities (Chapter 3.3).

    The van knapsack: weights $(9,8,5,4,3)$, values $(9,5,14,11,12)$, capacity $16$. Compute the LP bound and the integrality gap.

    1. Value per kg: $12/3=4$ (parcel 5), $14/5=2.8$ (parcel 3), $11/4=2.75$ (parcel 4), $9/9=1$ (parcel 1), $5/8=0.625$ (parcel 2).

      In the LP relaxation of a knapsack the best use of capacity is by value per kg: fill with the best ratio first.

    2. Load parcels 5, 3, 4 whole: weight $3+5+4=12$, value $12+14+11=37$. Four kg remain.

      Whole items while they fit.

    3. Fill the remaining 4 kg with parcel 1: fraction $4/9$ of it, value $\tfrac49\cdot9=4$. LP bound: $37+4=41$ at $x=(4/9,0,1,1,1)$.

      The LP may split a parcel; the IP may not.

    4. The best whole plan has value $37$ (parcels 3, 4, 5; adding any other parcel breaks the 16 kg limit), so the gap is $(41-37)/37\approx10.8\%$.

      Since this is a maximisation, the LP bound lies above the optimum.

    Go deeper: why the assignment problem needs no integrality

    In the assignment model every variable appears in exactly two equality rows, one for its courier and one for its parcel, with coefficient 1. Such a constraint matrix is totally unimodular (every square submatrix has determinant $0$, $1$ or $-1$). Then every corner solves $Bx_B=b$ with $\det B=\pm1$, and by Cramer's rule $x_B=B^{-1}b$ is integral when $b$ is. So the LP relaxation is the convex hull and a plain LP solver returns an integer optimum. Shortest-path and transportation models have the same property; GAP and bin packing do not, because of their capacity rows.

    Take the same five parcels (weights 9, 8, 5, 4, 3; values 9, 5, 14, 11, 12) but a van of capacity $11$ kg. What is the LP relaxation bound (fractional loading allowed)?

    Fill by value per kg: parcel 5 (3 kg), parcel 3 (5 kg), then parcel 4 (4 kg) but only what fits.

    Parcels 5 and 3 weigh 8 kg and are worth $26$. Three kg remain, so load $3/4$ of parcel 4 (value $8.25$). Bound $=34.25$. The best whole plan is parcels 3 and 5, value $26$.

    For a minimisation IP, the LP relaxation optimum is a ...

    The relaxation is allowed more points than the IP.

    More feasible points can only lower the minimum, so the LP value is a lower bound on the IP optimum.

    In the Try it widget the integer points are the 15 dots, for example $(4,0)$, $(3,1)$, $(2,3)$. What is the largest value of $3x_1+2x_2$ over these points?

    Check the three candidates $(4,0)$, $(3,1)$ and $(2,3)$.

    $(4,0)\to12$, $(3,1)\to11$, $(2,3)\to12$. No dot does better, so the maximum is $12$.

    Maximise $3x_1+2x_2$ over the polygon $5x_1+4x_2\le22$, $2x_1+5x_2\le19$, $x\ge0$ ("As first written"). Its corners are $(0,0)$, $(4.4,0)$, $(2,3)$ and $(0,3.8)$. What is the LP optimum?

    Evaluate the objective at the four corners and take the largest.

    Values: $0$, $13.2$, $12$, $7.6$. The LP optimum is $13.2$ at $(4.4,0)$, above the integer optimum $12$: a gap of $10\%$.

    The convex hull in the widget is $3x_1+2x_2\le12$, $x_2\le3$, $x\ge0$. Is the inequality $x_2\le3$ valid for all 15 integer points?

    What is the largest $x_2$ among the dots?

    The largest second coordinate among the dots is $3$ (at $(0,3),(1,3),(2,3)$), so $x_2\le3$ holds for every point, though the polygon "as first written" allows $x_2$ up to $3.8$.

    • Compare formulations by inclusion: the smaller polyhedron with the same integer points is stronger.
    • Report the gap as a percentage of the integer optimum.
    • Remember the sign: minimisation bounds from below, maximisation from above.
    • Assuming a fractional LP value is "close enough" to round.
    • Believing that adding constraints always shrinks the integer set; valid ones keep every integer point.
    • Thinking the convex hull can always be written down easily.
    1. The LP relaxation gives a bound on the IP; the gap measures its quality.
    2. A formulation $P_1\subset P_2$ with the same integer points is stronger and never gives a worse bound.
    3. Over the convex hull of the integer points the LP and the IP have the same optimum, but the hull is hard to describe.

    For a maximisation IP, the LP relaxation value is 41 and the best integer solution found has value 37. What can you say?

    The optimum lies between 41 and 45.
    The LP is a bound in a definite direction for a maximisation.
    The optimum lies between 37 and 41.
    37 is achievable and 41 is an upper bound.
    The optimum is 41.
    An LP optimum is only attained if it is integer.

    Two formulations $P_1\subset P_2$ describe the same integer points of a minimisation. Which is true?

    $z_{LP}(P_1)\le z_{LP}(P_2)$.
    A smaller region cannot give a smaller minimum.
    $z_{LP}(P_1)\ge z_{LP}(P_2)$.
    Minimising over a smaller set can only raise the minimum, closer to the IP value.
    They always give the same bound.
    Then no formulation would be better than another.

    Why is every corner of $\operatorname{Conv}(X)$ a point of $X$?

    A point of the hull that is not in $X$ is a mix of points of $X$, so it is not extreme.
    Extreme points cannot be convex combinations of other points of the set.
    Because the hull is defined by integer coefficients.
    Integer coefficients are not the reason.
    Because $X$ has more than two points.
    The count of points does not matter.

    An LP relaxation returns an integer optimal solution. For the IP this means:

    It is a feasible integer point and its value equals the LP bound, so it is optimal.
    Any integer solution is feasible for the relaxation; reaching the bound means nothing better exists.
    Nothing; the IP must be solved separately.
    No further search is needed.
    The problem has several optima.
    That does not follow from an integer LP solution.

    Strong formulations: facility location, tight $M$ and cover inequalities

    Two ways of writing the same forcing constraint can give very different LP bounds, and a handful of extra valid inequalities can close most of a gap.

    This is the difference between a solver finishing in seconds and one that runs overnight, and you can control it when you write the model.

    It is like two tax forms asking for the same information: one tells you exactly where each number goes, the other lets you spread it across the page and still get past the clerk.

    Kaveri Courier

    The owner is now choosing which depot sites to open. Writing the model so that the LP relaxation hugs the integer plans decides whether the solver confirms the choice in seconds or searches for hours. The same advice covers the van loads: a tight forcing constraint or a cover inequality is what keeps the loading decision of Chapter 3.1 cheap to solve.

    Facility location: individual versus aggregated forcing

    Part D introduced the forcing constraint and the rule "choose the tightest $M$". Lecture 3 applies it to facility location. Call $P_1$ the formulation with a forcing row for every pair, $x_{ij}\le y_j$, and $P_2$ the one with one aggregated row per depot, $$\sum_{i=1}^m x_{ij}\le m\,y_j\qquad\forall j .$$ Both enforce "no service from a closed depot" for 0/1 variables. But $P_2$ has fewer rows ($n$ instead of $mn$), so which is better?

    $P_1\subseteq P_2$, and the inclusion is strict in general; for example when $n\ge2$ and $m=kn$ with $k\ge2$. Hence the LP bound of $P_1$ is at least the LP bound of $P_2$ for a minimisation.

    Show that every point of $P_1$ lies in $P_2$ but not the other way round (take $m=kn$ with $k\ge2$).

    1. Sum the $m$ rows $x_{ij}\le y_j$ over $i$: $\sum_ix_{ij}\le m\,y_j$. So any point satisfying all individual rows satisfies the aggregated row: $P_1\subseteq P_2$.

      The aggregated row is a sum of the individual ones, so it is implied.

    2. Assign customers to depots in $n$ groups of $k$ customers: $x_{ij}=1$ if customer $i$ is in group $j$, else $0$. Take $y_j=k/m=1/n$ for every depot.

      Each customer is served in full (assignment rows hold) but each depot is only "$1/n$ open".

    3. Aggregated row: $\sum_ix_{ij}=k\le m\cdot(k/m)=k$. It holds with equality: the point is in $P_2$.

      The load $k$ is exactly what $m\,y_j$ allows.

    4. Individual row: for a customer in group $j$ we need $1=x_{ij}\le y_j=1/n$, which is false when $n\ge2$. So the point is not in $P_1$ and $P_1\subsetneq P_2$.

      Fractional openings are allowed by $P_2$ but each customer's own row says "depot must be fully open".

    Try it

    Three depots with fixed costs $30,40,40$ and six customers. Switch between the weak (aggregated) and the strong (individual) formulation and read the LP bound and the opening values $y$. Then slide the fixed-cost scale. Notice how many depots the weak LP opens and how little it pays for them.

    There is even a closed form for the weak bound. In the aggregated model, given the assignments $x$, the cheapest openings are $y_j=\tfrac1m\sum_ix_{ij}$ (the smallest value the row allows). Each customer then pays a $1/m$ share of the fixed cost of every depot it uses, and the LP just lets each customer pick the cheapest depot: $$z_{LP}^{weak}=\sum_{i=1}^m\ \min_j\Big(c_{ij}+\frac{f_j}{m}\Big).$$ The weak bound is typically far below the integer cost, as the next example shows.

    customerdepot A ($f=30$)depot B ($f=40$)depot C ($f=40$)
    15216
    211194
    31139
    42024
    55418
    69185

    For the table above compute (a) the weak LP bound, (b) the optimal integer cost, and say how the strong bound ($86.5$ from the widget) compares.

    1. Shares of the fixed cost, $f_j/6$: $5$, $6.67$, $6.67$. Row minima of $c_{ij}+f_j/6$: customer 1: $\min(10,8.67,22.67)=8.67$; customer 2: $\min(16,25.67,10.67)=10.67$; customer 3: $\min(16,9.67,15.67)=9.67$.

      Each customer pays the cheapest "cost plus share of the fixed cost".

    2. Customers 4, 5, 6: $\min(25,8.67,10.67)=8.67$; $\min(10,10.67,24.67)=10$; $\min(14,24.67,11.67)=11.67$.

      Same rule for the remaining rows.

    3. Weak bound: $8.67+10.67+9.67+8.67+10+11.67=59.33$.

      This is the sum of six row minima, an LP value computed without solving an LP.

    4. Integer optimum: check opening patterns. Depot B alone costs $40+(2+19+3+2+4+18)=88$. No pair of depots does better (for instance B and C costs $80+2+4+3+2+4+5=100$).

      With three depots only $7$ non-empty patterns exist, so enumeration is easy.

    5. The weak bound $59.33$ is $32.6\%$ below $88$; the strong bound $86.5$ is only $1.7\%$ below.

      The same IP, the same optimum: only the way $y_j$ is linked to the $x_{ij}$ changed.

    Tight $M$ in lot sizing, and a better formulation

    The same lesson governs lot sizing. The row $x_t\le M\,y_t$ is valid with $M=\sum_kd_k$ (all demand), but period $t$ never needs to produce more than the demand of periods $t,\dots,n$, so $M_t=d_t+d_{t+1}+\dots+d_n$ is valid and smaller, hence stronger.

    A third, still stronger formulation changes the variables. Let $w_{kt}$ be the quantity produced in period $k$ to meet the demand of period $t$ (with $k\le t$). Then $$\sum_{k=1}^tw_{kt}=d_t,\qquad w_{kt}\le d_t\,y_k\ \ (k\le t),\qquad x_k=\sum_{t\ge k}w_{kt}.$$ Each row $w_{kt}\le d_ty_k$ has the tightest possible multiplier: the whole amount $d_t$ that period $t$ needs. Compare the three on the instance of Chapter 3.1.

    Try it

    Demands $(20,30,0,40,10)$, set-up costs $(90,80,70,85,60)$, $p=2$, $h=1$. Switch between the three formulations and read the LP bounds. The black dots mark the optimal integer plan. Notice how the values of $y$ in the weak formulation are all tiny fractions, and what happens to them in the extended one.

    Compute the weak LP bound for the instance by hand, using the point $x_t=d_t$, $s_t=0$, $y_t=d_t/M$ with $M=100$.

    1. With $y_t=d_t/100$: $y=(0.2,0.3,0,0.4,0.1)$. The rows $x_t\le100y_t$ hold with equality, and the balance rows hold with $s_t=0$.

      The point produces each period's demand in that period, paying only a fraction of each set-up.

    2. Set-up cost: $90(0.2)+80(0.3)+70(0)+85(0.4)+60(0.1)=18+24+0+34+6=82$.

      Fractional set-ups cost a fraction of the fixed cost.

    3. Production cost: $2\times100=200$; no stock, so no holding cost. Bound: $82+200=282$.

      This point is optimal for the weak relaxation, matching the widget's $282$.

    formulationLP boundgap to 415
    $M=\sum_kd_k=100$28232.0%
    $M_t=d_t+\dots+d_n$34317.3%
    extended ($w_{kt}$)4150%

    The extended formulation reaches the integer optimum here, and this is no accident: for uncapacitated single-item lot sizing, a classical result says its LP relaxation is integral at the corners, so it describes the convex hull in the original variables. To compare formulations in different variable spaces we project out the extra variables: the extended formulation is better if the set $\{(x,y):(x,y,w)\in Q\text{ for some }w\}$ lies inside the original polyhedron. The point $x_t=d_t$, $y_t=d_t/M$ is feasible for the weak formulation but violates $w_{tt}\le d_t\,y_t$ unless $y_t=1$, so it is cut off.

    Valid inequalities and cover cuts

    A second way to strengthen a model is to add inequalities that every integer point already satisfies but some fractional LP points violate.

    An inequality $\pi^\top x\le\pi_0$ is valid for $X$ if every $x\in X$ satisfies it. It is a cut for the LP relaxation if it also excludes the current optimal LP point. Adding valid inequalities keeps all integer points and shrinks the relaxation towards the convex hull.

    For the knapsack row $\sum_ja_jx_j\le C$ (all $a_j\gt0$), a set $S$ of items is a cover if $\sum_{j\in S}a_j\gt C$: it cannot all be loaded together. It is a minimal cover if removing any one item makes it fit.

    If $S$ is a cover then $\displaystyle\sum_{j\in S}x_j\le|S|-1$ is valid for every knapsack solution.

    Prove the cover inequality and apply it to the van: $S=\{1,3,4\}$ (weights $9,5,4$, capacity $16$).

    1. Suppose a feasible binary $x$ had $\sum_{j\in S}x_j=|S|$, so all items of $S$ are loaded.

      Proof by contradiction: the only way to break the inequality is to load every item of $S$.

    2. Then the weight of the load is at least $\sum_{j\in S}a_j\gt C$, because the other loaded items only add weight.

      This is the definition of a cover.

    3. That violates the capacity row, so no feasible $x$ loads all of $S$, and $\sum_{j\in S}x_j\le|S|-1$.

      Integers: a sum of $|S|$ binaries that is not $|S|$ is at most $|S|-1$.

    4. For $S=\{1,3,4\}$: $9+5+4=18\gt16$ and removing item 1, 3 or 4 leaves $9$, $13$ or $14$, all at most $16$, so it is a minimal cover and $x_1+x_3+x_4\le2$ is valid.

      The LP point $(4/9,0,1,1,1)$ has $4/9+1+1=22/9\approx2.44\gt2$, so the cut removes it.

    Try it

    The bars show the LP-optimal loading of each parcel; the black dots are the best integer plan. Choose sets $C$ of parcels, see whether they form a cover, and add their cut. Then press "Add all minimal covers". Notice how the LP bound falls from 41 to the integer optimum. Try also a set that is not a cover: the tool tells you its cut would be invalid.

    Go deeper: lifting and the strength of a cover cut

    A minimal cover inequality is usually not a facet of the knapsack polytope. It can be lifted: items outside the cover that weigh at least as much as the heaviest item inside can be added with coefficient 1, giving an extended cover inequality such as $x_1+x_2+x_3+x_4\le2$ for the cover $\{2,3,4\}$ (weights $8,5,4$): item 1 weighs $9\ge8$, and any three of the four items weigh at least $4+5+8=17\gt16$, so at most two can be loaded. Modern MIP solvers separate such cuts automatically at the root node of branch and bound.

    Two depots with fixed costs $f=(12,18)$, three customers with costs $c_{i1},c_{i2}$: $(2,9)$, $(8,3)$, $(5,5)$. Compute the weak (aggregated) LP bound $\sum_i\min_j(c_{ij}+f_j/m)$ with $m=3$.

    The shares are $f_1/3=4$ and $f_2/3=6$. Take the cheaper of the two sums for each customer.

    Customer 1: $\min(2+4,9+6)=6$; customer 2: $\min(8+4,3+6)=9$; customer 3: $\min(5+4,5+6)=9$. Total $24$. (The integer optimum is $27$: open depot 1 only, $12+2+8+5$.)

    Lot sizing with demands $d=(20,30,0,40,10)$. What is the tightest valid $M_2$ in $x_2\le M_2y_2$, namely $d_2+d_3+d_4+d_5$?

    Add the demand of period 2 and every later period.

    $30+0+40+10=80$.

    For weights $(9,8,5,4,3)$ and capacity $16$, how many minimal covers are there? (They are sets such as $\{1,2\}$ with weight $17$; list all sets whose weight exceeds 16 but which fit after removing any item.)

    Start with pairs: only $\{1,2\}$ works. For triples, list those with weight above 16 where removing the lightest item brings it to at most 16.

    $\{1,2\}$ (17), $\{1,3,4\}$ (18), $\{1,3,5\}$ (17) and $\{2,3,4\}$ (17). Pairs such as $\{1,3\}$ weigh 14 and are not covers; sets with four items always contain a smaller cover. Total: $4$.

    The LP optimum of the van knapsack is $x=(4/9,0,1,1,1)$. What is the left side $x_1+x_3+x_4$ of the cover inequality for $S=\{1,3,4\}$? (A fraction such as 22/9 is accepted.)

    Substitute $x_1=4/9$, $x_3=x_4=1$.

    $4/9+1+1=22/9\approx2.44$, which exceeds the allowed $|S|-1=2$: the cut is violated and removes this LP point.

    Which facility location formulation has the stronger LP relaxation, even though it has more constraints?

    The aggregated row is the sum of the individual ones.

    $x_{ij}\le y_j$ for every pair implies the aggregated row but not conversely, so the individual-row formulation is contained in the aggregated one.

    • Prefer many small, tight forcing rows over a few aggregated ones when the LP solves fast enough.
    • Derive $M$ from the data: remaining demand, capacity, or a bound on the variable.
    • Add cover cuts from minimal covers of capacity rows.
    • Using $M=10^6$ "to be safe".
    • Adding a cut that excludes a feasible integer point.
    • Comparing formulations by the number of constraints rather than by their relaxations.
    1. For facility location, individual rows $x_{ij}\le y_j$ give a stronger relaxation than aggregated rows, and the weak bound has a closed form $\sum_i\min_j(c_{ij}+f_j/m)$.
    2. Tight big-M values (such as the demand still to come) and extended formulations tighten fixed-charge models; the extended lot-sizing formulation is exact.
    3. Valid inequalities such as cover cuts shrink the relaxation without removing integer points.

    The weak facility location LP opens a depot $20\%$ and serves $20\%$ of the customers from it, each one completely ($x_{ij}=1$). Which is true?

    It satisfies every individual row $x_{ij}\le y_j$.
    Check one customer: $x_{ij}=1$ against $y_j=0.2$.
    It satisfies the aggregated row but violates individual rows.
    The aggregated row $\sum_ix_{ij}\le m\,y_j$ holds for this point (with equality), while $x_{ij}=1\gt y_j=0.2$ breaks the individual rows.
    It is an integer point.
    A depot open $20\%$ is fractional.

    Why is a cover inequality valid?

    It is the sum of the knapsack row and the bounds.
    The sum would carry the weights $a_j$ and the capacity $C$, not $|S|-1$.
    Loading every item of a cover would break the capacity.
    So at most $|S|-1$ of them can be loaded together.
    Because every cover contains at most one item.
    Covers contain several items.

    Weights $(6,5,4,3)$ and capacity $10$. Which set is a minimal cover?

    $\{1,2,3\}$ with weight 15.
    Is the cover still a cover after removing item 3?
    $\{1,2\}$ with weight 11.
    $11\gt10$, and removing either item leaves 6 or 5.
    $\{3,4\}$ with weight 7.
    7 fits in 10, so it is not a cover.

    An extended formulation with extra variables $w_{kt}$ is declared stronger. What do we compare?

    Its projection onto the original variables, which must lie inside the original relaxation.
    Only then can the two be compared in the same space.
    The number of rows of each model.
    More rows do not mean a tighter relaxation.
    The number of binary variables.
    They can be equal in both.

    Case studies: facility location variants (Lab 1) and the GAP (Lab 2)

    Lab 1 stretches the facility location model to capacities, a fixed number of depots and a worst-case objective; Lab 2 solves the GAP with an LP-based search.

    These are the models you will actually type into Gurobi, and the reading skills from Chapters 3.2 and 3.3 tell you which version to expect to be fast.

    It is like learning four dishes from one base recipe: each variant changes one ingredient and the cooking time changes with it.

    Lab 1 question by question

    Question 1: aggregated rows with the integrality dropped. The lab asks you to run the facility location model with $\sum_ix_{ij}\le m\,y_j$ and $x_{ij}\ge0$ instead of binary variables. Expect from Chapter 3.3 that the optimal $y_j$ are small fractions and that the objective is far below the integer optimum. The point of the experiment is the bound, not the plan. The trade-off to notice: with $m=1000$ customers and $n=100$ candidate depots the aggregated model has $n=100$ forcing rows, while individual rows would need $mn=100{,}000$. The tighter model is larger.

    Question 2: the capacitated version (CFLP). Customer $i$ has demand $d_i$ and depot $j$ handles at most $q_j$ units. A natural model, if each customer is served by exactly one depot, is $$\min\ \sum_jf_jy_j+\sum_{i,j}c_{ij}x_{ij}\ \ \text{s.t.}\ \ \sum_jx_{ij}=1,\quad \sum_id_ix_{ij}\le q_j\,y_j,\quad x_{ij}\in\{0,1\},\ y_j\in\{0,1\}.$$ The capacity row doubles as the forcing row: a closed depot has capacity $0$. Two versions follow the lab's wording. The aggregated version uses just this row. The disaggregated version adds $x_{ij}\le y_j$ for every pair; they are redundant for integer $y$ but tighten the LP. If demand may be split, let $x_{ij}\in[0,1]$ be the share of customer $i$'s demand served from $j$: the same rows apply and the model becomes a mixed integer programme with only the $y_j$ integer.

    Question 3: the $p$-median problem. No fixed costs, but exactly $p$ depots must open: $$\min\ \sum_{i,j}c_{ij}x_{ij}\ \ \text{s.t.}\ \ \sum_jx_{ij}=1,\quad x_{ij}\le y_j,\quad \sum_jy_j=p,\quad x_{ij},y_j\in\{0,1\}.$$ Question 4: the $p$-center problem. Instead of the total distance we minimise the largest distance between a customer and its depot. Introduce a variable $z$ for that largest distance: $$\min\ z\ \ \text{s.t.}\ \ z\ge\sum_jc_{ij}x_{ij}\ \ \forall i,\quad \sum_jx_{ij}=1,\quad x_{ij}\le y_j,\quad \sum_jy_j=p,\quad x_{ij},y_j\in\{0,1\}.$$ Because exactly one $x_{ij}$ equals 1 in each customer's row, $\sum_jc_{ij}x_{ij}$ is customer $i$'s distance, and minimising $z$ pushes it down onto the largest of them (the min-max trick). The lab runs the two $p$-problems with $p$ equal to $10\%$ and $20\%$ of the potential facilities, rounded to a whole number.

    Six sites on a highway lie at kilometre marks $2,7,10,11,12,18$; every site is both a customer and a candidate depot, $c_{ij}=|{\rm km}_i-{\rm km}_j|$, and $p=2$. Compare the $p$-median and $p$-center solutions.

    1. There are $\binom62=15$ choices of two depots; for each, each customer goes to the closer one.

      Given the open depots, the best assignment is nearest-open-depot, so we only enumerate the open sets.

    2. Open the sites at km $2$ and $11$: distances $0,4,1,0,1,7$. Total $13$, maximum $7$.

      The site at 7 is nearer to 11 (4 km) than to 2 (5 km); the site at 18 is 7 km from 11.

    3. Open km $7$ and $18$: distances $5,0,3,4,5,0$. Total $17$, maximum $5$.

      The far site at 18 now has its own depot, so the worst case drops.

    4. Checking all 15 pairs, $\{2,11\}$ is the unique minimiser of the total ($13$) and $\{7,18\}$ the unique minimiser of the maximum ($5$).

      Different objectives, different depots: the $p$-median serves the cluster of sites near 10 to 12 well; the $p$-center protects the worst-off site.

    CFLP check. Customers have demands $d=(4,6,5)$; two depots have capacities $q=(10,9)$ and fixed costs $f=(20,15)$. Is the plan "depot 1 open serving customers 1 and 2, depot 2 open serving customer 3" feasible, and what do the capacity rows say?

    1. Depot 1 load: $d_1x_{11}+d_2x_{21}+d_3x_{31}=4+6+0=10\le q_1y_1=10\cdot1$. Depot 2 load: $5\le9\cdot1$.

      Each capacity row compares the load with $q_jy_j$.

    2. Every customer appears in exactly one depot, so the assignment rows hold.

      Each row $\sum_jx_{ij}=1$ is satisfied.

    3. Fixed cost $20+15=35$. Total demand is $15$ and total open capacity is $19\ge15$, which is necessary.

      If you closed depot 1, open capacity $9\lt15$ would make the model infeasible.

    Lab 2: the generalised assignment problem

    Lab 2 reads GAP instances from files whose first line gives the number of agents and jobs, followed by the cost matrix, the resource (time) matrix and the capacity of each agent, then solves the instances two ways: a hand-written branch and bound that calls an LP solver for the relaxation, and Gurobi with presolve and cuts switched off (both are compared in Part 4). The lecture states GAP as a profit maximisation; the Gurobi script of the lab minimises cost, and the two are equivalent since $\max\sum p_{ij}x_{ij}$ is $-\min\sum(-p_{ij})x_{ij}$.

    Why does the lab need a search at all? Because the capacity rows make the LP relaxation fractional. Below is a small instance of the same model.

    Try it

    Three agents and six jobs; each button shows cost / time. Agents have time budgets 12, 12 and 10. Assign each job to one agent, watch the bars of time used, and try to beat the cost shown for the "Best assignment". Then press "Show LP relaxation": notice which job the LP splits between agents and how much cheaper the LP plan is.

    In a basic (corner) solution of the GAP relaxation, at most $m$ jobs are split between agents, where $m$ is the number of agents.

    Prove the fact above, then check it on the widget's instance, where the LP corner splits one job.

    1. The model has $n$ job rows and $m$ budget rows, so $n+m$ constraints besides the bounds. A basic solution has at most $n+m$ non-zero variables $x_{ij}$.

      Part 1: a basis has one column per constraint row, so at most that many variables are non-zero.

    2. Every job has at least one non-zero $x_{ij}$ (its row sums to 1). A job split between agents has at least two.

      One non-zero entry would have to equal 1, so the job is not split.

    3. If $r$ jobs are split, the number of non-zeros is at least $n+r$. So $n+r\le n+m$, giving $r\le m$.

      Each split job contributes at least one extra non-zero beyond its first.

    4. On the widget instance ($m=3$) the LP optimum splits only job 3, half to agent 1 and half to agent 3, with cost $46$ against the integer optimum $53$.

      One split job is within the bound of 3, and the bound explains why a few branching decisions suffice to remove it.

    Go deeper: reading the lab code

    The lab's script builds exactly the model above with addVars for $x_{ij}$, addConstrs for the "exactly one" rows and the budget rows, and the objective with quicksum (see Part D, Chapter 3 and Practice/L3). The Lab 1 reader keeps only numeric tokens from the instance file, so any text label in a data file silently shifts the position of every later number. Always print the first few parsed values and compare them with the file before trusting a result.

    A GAP instance has $m=5$ agents and $n=100$ jobs. How many binary variables $x_{ij}$ does the model have?

    One variable per (agent, job) pair.

    $5\times100=500$.

    For the same instance, how many constraints are there besides the binary restrictions?

    One "exactly one" row per job and one budget row per agent.

    $100+5=105$.

    In the widget table, agent 2's cost / time pairs for jobs 1 to 6 are $11/3$, $12/7$, $11/3$, $13/6$, $9/3$, $8/7$. Agent 2 is given jobs 1, 3 and 5. What is the total cost of these three jobs?

    Add the cost (first number) of jobs 1, 3 and 5; the time used is $3+3+3$, within the budget of 12.

    Costs $11+11+9=31$, and the time used is $9\le12$, so the plan is within budget.

    In the highway example, depots at km $7$ and $18$ are open. What is the largest distance between a site and its nearest open depot?

    Check sites at km 2, 10, 11, 12.

    Distances from the sites at 2, 7, 10, 11, 12, 18: $5,0,3,4,5,0$. The largest is $5$.

    A GAP relaxation has $m=3$ agents. At most how many jobs can be split in a basic LP solution?

    Use the counting argument: non-zeros $\le n+m$.

    At most $m=3$.

    • Start every variant from the base facility location model and change one thing: capacity, a count of depots or the objective.
    • Use the min-max trick for worst-case objectives.
    • Print and check parsed instance data.
    • Using the aggregated capacity row alone and expecting a tight LP.
    • Letting the objective of $p$-median drive a $p$-center decision.
    • Assuming a GAP solves as an LP.
    1. Capacitated, $p$-median and $p$-center facility location are small changes to the base model: capacity rows $\sum_id_ix_{ij}\le q_jy_j$, a count row $\sum_jy_j=p$, and a min-max variable $z$.
    2. The GAP relaxation is generally fractional, with at most $m$ split jobs in a basic solution, so a solver needs branching or cuts.
    3. The lectures' maximise-profit GAP and the labs' minimise-cost GAP are the same model.

    Which row turns the uncapacitated facility location model into the $p$-median model (besides removing fixed costs)?

    $\sum_ix_{ij}\le p$
    That limits customers per depot, not depots.
    $\sum_jy_j=p$
    Exactly $p$ depots must be open.
    $z\ge x_{ij}$
    That belongs to a min-max objective.

    In the $p$-center model what does $z$ represent at the optimum?

    The largest distance from any customer to its assigned depot.
    The rows $z\ge\sum_jc_{ij}x_{ij}$ bound every customer's distance.
    The sum of all distances.
    That would be the $p$-median objective.
    The number of open depots.
    That is fixed to $p$.

    Splittable demand in the CFLP changes the model how?

    The variables $y_j$ become continuous.
    Opening is still a yes/no decision.
    The $x_{ij}$ become continuous shares in $[0,1]$.
    Only the $y_j$ stay binary, giving a MIP.
    The capacity rows are dropped.
    Depots still have limited capacity.

    A GAP relaxation has 4 agents. A basic LP solution can have at most how many split jobs?

    2
    The bound is the number of agents, not half of it.
    4
    At most $m=4$ jobs are split.
    As many as there are jobs.
    The counting argument caps the splits.
    Where we are in the story

    Part 3 has given Kaveri Courier its models: which depots to open (facility location), how to load a van (knapsack and bin packing) and who does which job (the generalised assignment problem). Two things are still missing, a way to actually find the best integer plan and a way to prove it is best. Part 4 supplies both with branch and bound, starting from a two-van planning model of the same kind as the loading decision of Chapter 3.1, and returns to the GAP in Lab 2.

    A depot model uses $x_t\le M\,y_t$. If the largest possible production is 50, which $M$ gives the strongest valid LP relaxation?

    $M=50$
    The smallest valid $M$ forces $y_t\ge x_t/50$, the least fractional opening.
    $M=500$
    Valid but weaker: $y_t$ may be a tenth of what it should be.
    $M=1$
    That would cut off real production quantities.

    For a minimisation, a stronger formulation $P_1\subset P_2$ of the same IP has LP bound ...

    no larger than that of $P_2$
    Think about minimising over a smaller set.
    at least as large as that of $P_2$, and at most the IP optimum
    The smaller region can only raise the LP minimum, never above the IP minimum.
    always equal to the IP optimum
    Only for the convex hull.

    Weights $(9,8,5,4,3)$, capacity 16. The set $\{2,3,4\}$ has weight 17. The cover inequality is:

    $x_2+x_3+x_4\le3$
    That allows all three, which the capacity forbids.
    $x_2+x_3+x_4\le2$
    At most $|S|-1=2$ of the three can be loaded together.
    $x_2+x_3+x_4\le17$
    The weight total is not the right-hand side.

    Which statement about the GAP relaxation is correct?

    It is always integral because the constraint matrix has "exactly one" rows.
    The budget rows break total unimodularity.
    It can split jobs, with at most $m$ split jobs at a corner.
    Counting non-zeros of a basic solution gives $n+r\le n+m$.
    It is infeasible whenever some agent's budget is small.
    The relaxation can use other agents.

    Which constraint says "depot $j$ may serve customers only if it is open" for one customer $i$?

    $y_j\le x_{ij}$
    That reverses cause and effect: opening would force service.
    $x_{ij}\le y_j$
    If $y_j=0$ then $x_{ij}=0$.
    $x_{ij}+y_j\ge1$
    That says "serve or open", a different rule.

    An LP has an optimal solution at a non-integer corner. The same polyhedron's integer points have best value 12 and the LP optimum is 13.2 (maximise). The gap is about:

    1.2%
    Divide the difference by the integer value 12.
    10%
    $(13.2-12)/12=0.1$.
    13.2%
    That is the LP value, not a ratio.

    Lecture 4 shows how an integer programme is actually solved: bracket the unknown optimum between a plan you can achieve and a bound you can prove, then split the problem into smaller pieces until the two meet. This part covers LP-based bounding, branching and the three ways to prune, node and variable choice, GUB/SOS branching, preprocessing, and finally what Gurobi prints while it does all this (Lab 2).

    You need: Part 1 (LP optimum at a corner), Part 2 (dual prices and the dual simplex method, used lightly), and Part 3 (integer programmes, the LP relaxation and the integrality gap, strong formulations, the GAP model of Lab 2).

    Bounds, relaxations and the optimality gap

    To solve an integer programme you squeeze its unknown optimum between a plan you can actually carry out (an upper bound, for a minimisation) and a number you can prove nobody can beat (a lower bound from a relaxation).

    Every solver log you will read at the end of this part reports exactly these two numbers and the gap between them, and branch and bound is the machine that closes that gap. Part 3 ended with Kaveri Courier's models written down; here the owner hands one of them to a solver. The two-van problem below has the same ingredients as the formulations of Chapter 3.1: whole-number variables, a linear cost and linear requirement rows. Only the numbers are new, and Lab 2 later returns to the assign-jobs-to-agents model of Chapter 3.4.

    It is like estimating a journey time: the fastest conceivable time (straight line at top speed) is a lower bound, a trip you have really driven is an upper bound, and the closer they are, the better you know the answer.

    The two-van problem

    One example runs through the next two chapters. Kaveri Courier serves two routes, A and B, every shift. A shift of a type-1 van costs $4$ (in thousands of rupees) and delivers $6$ crates on route A and $6$ crates on route B. A shift of a type-2 van costs $3$ and delivers $2$ crates on route A and $7$ on route B. Route A must receive at least $43$ crates and route B at least $55$. The firm owns at most $12$ vans of each type. How many van shifts $x_1$ (type 1) and $x_2$ (type 2) minimise the cost?

    $$\min\ 4x_1+3x_2\quad\text{s.t.}\quad 6x_1+2x_2\ge 43,\quad 6x_1+7x_2\ge 55,\quad 0\le x_1,x_2\le 12,\quad x_1,x_2\in\mathbb Z.$$

    Vans come whole, so this is an integer programme (IP). Call its optimal value $z^*$; we do not know it yet.

    Drop the integers: the LP relaxation

    Recall from Part 3 that the LP relaxation keeps every constraint but allows fractional $x$. Its feasible region contains every integer plan, so its optimum $z_{LP}$ can only be as good or better: for a minimisation $z_{LP}\le z^*$.

    For the two-van problem both route rows are tight at the LP optimum. Subtracting them gives $5x_2=12$, so $x_2=2.4$, and then $6x_1=43-4.8$, so $x_1=38.2/6\approx6.367$. The cost is $4\cdot6.367+3\cdot2.4=32.667$ (exactly $98/3$).

    Why can nothing cheaper exist, integer or not? Add the two route rows and divide by $3$: $\tfrac13(6x_1+2x_2)+\tfrac13(6x_1+7x_2)=4x_1+3x_2$. Every feasible plan therefore costs at least $\tfrac13(43+55)=98/3$. That one-line argument is a certificate for the lower bound; the weights $\tfrac13,\tfrac13$ are the dual prices of Part 2.

    The LP plan uses $6.367$ type-1 vans and $2.4$ type-2 vans, which no courier can run. A manager rounds each number to the nearest whole van, giving $(6,2)$. What do you expect?

    It is feasible and optimal.
    Check the crates delivered on route A: $6\cdot6+2\cdot2$.
    It is infeasible: route A falls short.
    $6\cdot6+2\cdot2=40<43$.
    It is feasible but costs more than the true optimum.
    It is not feasible at all, so it cannot be compared.

    Rounding down (or to the nearest) removes crates that the LP needed. Rounding every number up gives $(7,3)$, which is feasible but costs $37$. The true optimum is cheaper than that, and the next panel lets you see all of these points.

    Try it

    Click through the five chips: the LP optimum, three roundings and the true integer optimum. Dots on the grid are whole-number plans (solid dots are feasible). Slide the cost level $k$ and watch which feasible dots lie on or below the dashed cost line. Notice that the cheapest rounding is not the optimum, and that the LP value is below every feasible plan.

    Two kinds of bound

    Rounding fails for the reason you just saw: with $n$ variables there are $2^n$ ways to round each up or down, none of them is guaranteed feasible, and a feasible one can be far from optimal. Instead we use two cheap numbers that sandwich $z^*$.

    For a minimisation:

    • An upper bound $z_{UB}$ (also primal bound) is the cost of any feasible integer plan. The best one found so far is the incumbent.
    • A lower bound $z_{LB}$ (also dual bound) is a number that no feasible plan can beat, typically the value of a relaxation such as the LP relaxation.
    • The optimality gap is $$\text{gap}=\frac{z_{UB}-z_{LB}}{|z_{UB}|}\times100\%.$$ It is the largest possible percentage by which the incumbent can still be improved. Gap $=0$ proves the incumbent optimal.

    For a minimisation, $z_{LB}\le z^*\le z_{UB}$ at every moment of a solve. The lower bound can only rise, the upper bound can only fall, and the search stops when they meet.

    Careful: the gap is measured against the incumbent, not against the unknown optimum, so it is a guarantee, not an estimate. It is also undefined when $z_{UB}=0$. If all costs and variables are whole numbers, every plan has a whole-number cost, so you may round a lower bound up: from $32.667$ to $33$.

    Bracket the optimum of the two-van problem using only the LP and a rounding, then tighten the bracket when someone finds the plan $(7,2)$.

    1. Lower bound: $z_{LP}=98/3\approx32.667$. All data are whole, so $z^*\ge33$.

      The cost of a whole plan is a whole number, and the smallest whole number at least $32.667$ is $33$.

    2. Upper bound: round the LP point up to $(7,3)$. Route A: $42+6=48\ge43$. Route B: $42+21=63\ge55$. Feasible, cost $4\cdot7+3\cdot3=37$.

      A feasible plan is all we need for an upper bound, however clumsy.

    3. So $33\le z^*\le37$. Gap with the raw LP value: $(37-32.667)/37=11.7\%$. With the rounded bound $33$: $(37-33)/37=10.8\%$.

      The gap tells us how much we could still be wasting.

    4. Now take the plan $(7,2)$: route A $42+4=46\ge43$, route B $42+14=56\ge55$, cost $28+6=34$. The bracket shrinks to $33\le z^*\le34$ and the gap to $(34-33)/34=2.9\%$.

      A better plan lowers $z_{UB}$; it does not change the lower bound.

    5. The true optimum is $34$ (the next chapter proves it by branch and bound), so the gap of $2.9\%$ was never a mistake of the plan; it was only the lower bound being too low.

      A gap can stay open because the bound is weak even when the incumbent is already optimal. Closing it requires better bounds, which is what branching provides.

    The strength of a formulation is the strength of its bound

    Part 3 showed that two formulations with the same integer points can have different LP relaxations. If $P_1\subset P_2$, then $P_1$ is the stronger formulation and its LP bound is at least as high (for a minimisation). A weak formulation gives a low $z_{LB}$, a large gap, and a long search later. A formulation whose LP region is the convex hull of the integer points would give $z_{LB}=z^*$ at once.

    Application

    Two jobs, $x_1$ and $x_2$, cannot run in the same shift, and we want to schedule as many as possible: $\max x_1+x_2$ with $x_1,x_2\in\{0,1\}$. Writing the conflict as $2x_1+2x_2\le3$ is correct for integers, but its LP bound is $1.5$. Writing it as $x_1+x_2\le1$ describes the same integer points, and its LP bound is $1$, the true answer. Same problem, same integer points, different bound.

    The toolbox around the bounds

    MethodWhat it doesGives
    LP relaxationdrop integrality and solve an LPlower bound (this part)
    Other relaxationsreplace the objective by an easier lower estimate, or move hard constraints into the objective (Lagrangian relaxation, which Lecture 4 postpones to a later lecture; it appears with Dantzig–Wolfe decomposition in Ch. 10.3)lower bound
    Cutting planesrepeatedly find an inequality that cuts off the LP point but no integer point, and add ittighter lower bound (used again for the TSP, Part 5; in full in Parts 7 to 9)
    Branch and boundsplit the feasible set and bound each pieceexact optimum (next chapter)
    Branch and cutbranch and bound with cuts added inside the nodesexact optimum, stronger bounds
    Branch and pricewhen there are huge numbers of variables, add columns only when the dual prices say they can improve the LP (column generation)exact optimum for routing-type models
    Heuristicsgreedy rules, local search, large neighbourhood search, genetic algorithms, simulated annealing, tabu searchupper bounds (good plans, no proof)
    Go deeper: why the gap is divided by the incumbent

    Different programs divide by the incumbent, by the bound or by the larger of the two. Gurobi divides the difference by the absolute incumbent value, as above, and stops by default when this falls below $10^{-4}$ ($0.01\%$). The choice matters only when the objective is close to zero, where every definition blows up; in that case solvers also check an absolute gap.

    A minimisation run has an incumbent of $46$ and a best lower bound of $40$. What is the optimality gap in percent?

    Divide the difference by the incumbent, not by the bound.

    $(46-40)/46=0.1304$, so $13.04\%$.

    In the two-van problem the plan $x=(6,4)$ is checked: route A gets $36+8=44$ crates and route B gets $36+28=64$. What does its cost of $36$ tell us?

    Is the plan feasible? What does any feasible plan tell us about the optimum of a minimisation?

    Both routes are served ($44\ge43$, $64\ge55$), so the plan is feasible and the optimum cannot be worse than its cost: an upper bound of $36$.

    All costs and all variables of a minimisation IP are whole numbers, and the LP relaxation has value $18.4$. What is the best lower bound you can state for the IP?

    The IP optimum is a whole number that is at least $18.4$.

    The smallest whole number not below $18.4$ is $19$.

    Two binary variables with $\max x_1+x_2$ and the constraint $2x_1+2x_2\le3$. What is the optimal value of the LP relaxation?

    Take $x_1+x_2$ as large as the constraint allows with $0\le x_i\le1$.

    $x_1+x_2\le1.5$ and $(0.75,0.75)$ reaches it, so the LP value is $1.5$ while the IP value is $1$.

    $P_1\subset P_2$ are two formulations of the same minimisation IP. How does the LP bound over $P_1$ compare with the LP bound over $P_2$?

    Minimising over a smaller set can only give a larger or equal minimum.

    Every point of $P_1$ is in $P_2$, so $P_2$'s minimum is at most $P_1$'s. The stronger formulation has the higher (better) lower bound.

    • State both bounds and the gap whenever you quote a result.
    • Round a lower bound up when all costs and variables are whole numbers.
    • Check that a rounded plan is feasible before calling it an upper bound.
    • Rounding the LP point and calling it the answer.
    • Dividing the gap by the lower bound or by $z^*$ (which you do not know).
    • Thinking a large gap means the incumbent is poor: it may be optimal with a weak bound.
    1. The LP relaxation value is a lower bound (for a minimisation) and any feasible integer plan is an upper bound; the optimum lies between them.
    2. The gap $(z_{UB}-z_{LB})/|z_{UB}|$ is a guarantee of how much the incumbent could still be improved, and it is zero exactly when optimality is proved.
    3. Rounding the LP solution may be infeasible or poor; stronger formulations raise the lower bound, and branch and bound is the systematic way to close what remains.

    For a minimisation IP, which statement is always true?

    The LP relaxation value is an upper bound on the IP optimum.
    The relaxation has more feasible points, so it can only do better (lower).
    The LP relaxation value is at most the IP optimum.
    Every integer plan is also an LP plan, so the LP minimum cannot be larger.
    The LP relaxation value equals the IP optimum after rounding.
    Rounding can break feasibility, so the values can differ.

    Gap $=0$ means:

    The LP relaxation is integral.
    It could be, but the gap compares the incumbent with the best bound, not with the root.
    The solver stopped at its time limit.
    A time limit usually leaves a positive gap.
    The incumbent is proved optimal.
    No plan can beat the lower bound, and the incumbent has that value.

    The gap is $5\%$ and nothing else is known. How much cheaper than the incumbent could the true optimum be?

    At most $5\%$ of the incumbent's cost.
    The gap is defined as the largest possible relative improvement.
    Exactly $5\%$.
    The optimum may well be equal to the incumbent.
    At least $5\%$.
    It is a ceiling on improvement, not a floor.

    Which tool normally produces a good upper bound on a hard IP?

    The LP relaxation.
    That is a lower bound for a minimisation.
    A cutting plane.
    Cuts improve lower bounds.
    A heuristic such as local search.
    A heuristic returns a real feasible plan, hence an upper bound.

    Branch and bound: split, solve, prune

    Branch and bound cuts an integer programme into smaller integer programmes by adding a bound on one variable, solves the LP relaxation of each piece, and throws a piece away as soon as its bound proves it cannot hold a better plan.

    It is the engine inside every IP solver, and the exam asks you to run it by hand: solve node LPs, choose a branch, apply the three pruning rules and read off the optimum.

    It is like searching a huge library for the cheapest book: you do not open every book, you read the sign on each section and skip any section whose cheapest possible book already costs more than the one in your hand.

    Divide and conquer

    Let $X$ be the set of feasible integer plans and $z^*=\min\{c^\top x:x\in X\}$. Suppose we split $X$ into smaller sets $X_1,\dots,X_k$ whose union is $X$. If $z_i$ is the best cost inside $X_i$, then $$z^*=\min_i z_i.$$ So it is enough to solve the pieces, and each piece may again be split. The only open question is how to split.

    The standard answer uses the LP solution. Suppose the relaxation of the current piece returns a value $v$ for an integer variable $x_j$ and $v$ is not a whole number. No integer plan has $x_j$ strictly between $\lfloor v\rfloor$ and $\lceil v\rceil$, so every integer plan lies in one of two pieces: $$x_j\le\lfloor v\rfloor\qquad\text{or}\qquad x_j\ge\lceil v\rceil .$$ This is branching. No integer plan is lost, and the fractional LP point is cut off from both pieces, so the next LP must move. For a binary variable the pieces are simply $x_j=0$ and $x_j=1$.

    Each piece is a node of a tree. The root is the original problem, and each node carries its own list of added bounds. Splitting in two is common but not required: for the TSP one can create one child per choice of the first city visited, a multi-way branch.

    For a minimisation, the LP value of a child node is at least the LP value of its parent. The child's feasible region is the parent's with one extra constraint, and minimising over a smaller set cannot give a smaller value. Hence bounds only rise as you descend, and the LP value of a node is a lower bound for every plan in its whole subtree.

    A node whose LP relaxation has been solved is pruned (closed, not split further) if

    1. Infeasibility: its LP has no feasible point. Its plans are a subset of its LP's points, so it has none either.
    2. Bound (incumbent): its LP value is at least $z_{UB}$. Every plan below it costs at least that much, so none improves on the incumbent.
    3. Integrality: its LP solution is already integer. It is then the best plan of the node; if it beats $z_{UB}$ it becomes the new incumbent.

    Otherwise the node is split by branching.

    1. Set $z_{UB}=\infty$. Put the root problem on the list of active nodes.
    2. If the list is empty, stop: the incumbent is optimal (or the problem is infeasible if there is none). Otherwise remove one node, and solve its LP relaxation.
    3. If the LP is infeasible or its value is $\ge z_{UB}$, discard the node and return to step 2.
    4. If the LP solution is integer, set $z_{UB}$ to its value, record the plan, and return to step 2.
    5. Otherwise pick a fractional $x_j$ with LP value $v$, create the children $x_j\le\lfloor v\rfloor$ and $x_j\ge\lceil v\rceil$, add both to the list, and return to step 2.

    The bounds while it runs

    At any moment the incumbent gives $z_{UB}$ and the smallest bound among the nodes still waiting gives $z_{LB}$ (a waiting node is labelled with the LP value of its parent). The gap $(z_{UB}-z_{LB})/|z_{UB}|$ of Chapter 4.1 is therefore computed live. When the list empties, $z_{LB}$ jumps up to $z_{UB}$ and the gap is zero.

    Why is the result correct? Every integer plan sits in some leaf region. A region is only discarded when it is empty, when its LP bound is no better than a plan we already hold, or when its best plan has been recorded. So the best plan overall survives.

    When a new incumbent arrives, waiting nodes whose stored parent value is at least the new $z_{UB}$ can be deleted without solving their LPs. That saves a whole LP per node.

    Try it

    Run branch and bound on the two-van problem. First pick "My choice" for both rules: click the root to solve it, then choose which variable to branch on, then click waiting (dashed) nodes to solve them. Read the incumbent, bound and gap after every step. Then press Reset and finish with "Run to the end" under each strategy. Notice that the optimum (value $34$ at $(7,2)$) is always the same, but the number of LPs solved changes.

    Solve $\min 4x_1+3x_2$ s.t. $6x_1+2x_2\ge43$, $6x_1+7x_2\ge55$, $0\le x\le12$, $x$ integer, by branch and bound. Branch on $x_1$ at the root and always solve the waiting node with the smallest parent value.

    1. Node 1 (root). The LP optimum is $(6.367,\,2.4)$ with value $32.667$. Both coordinates are fractional; branch on $x_1$ with $\lfloor6.367\rfloor=6$: node 2 adds $x_1\le6$, node 3 adds $x_1\ge7$.

      $z_{UB}=\infty$, so nothing can be pruned yet. The gap is undefined until a plan is found.

    2. Node 2 ($x_1\le6$). Route A needs $6x_1+2x_2\ge43$. With $x_1$ at most $6$, each unit of $x_1$ we give up costs $4$ less but needs $3$ more units of $x_2$ (cost $9$). So keep $x_1=6$: then $x_2\ge3.5$, and route B holds ($36+24.5=60.5\ge55$). LP: $(6,\,3.5)$, value $34.5$. Fractional: branch on $x_2$ into node 4 ($x_2\le3$) and node 5 ($x_2\ge4$), both labelled with parent value $34.5$.

      Each child's LP value is at least $34.5$ (children are never better).

    3. Node 3 ($x_1\ge7$). Route B is now the binding row: at $x_1=7$ it needs $7x_2\ge13$, so $x_2=13/7\approx1.857$; route A holds ($42+3.71\ge43$). LP: $(7,\,1.857)$, value $28+5.571=33.571$. Branch on $x_2$: node 6 ($x_2\le1$) and node 7 ($x_2\ge2$), parent value $33.571$.

      Raising $x_1$ above $7$ would cost $4$ per unit and save only $6/7$ of an $x_2$ (worth $2.57$), so $x_1=7$ stays.

    4. Choose the next node. Waiting: nodes 4, 5 (parent $34.5$) and nodes 6, 7 (parent $33.571$). Smallest parent value: node 6.

      The most promising region is the one whose bound is lowest.

    5. Node 6 ($x_1\ge7$, $x_2\le1$). With $x_2\le1$ the best choice is $x_2=1$ (each unit of $x_2$ given up forces $7/6$ of an $x_1$, costing $4.67$ against a saving of $3$), and route B then forces $6x_1\ge48$, so $x_1=8$: LP $(8,1)$, value $35$. It is integer: new incumbent $z_{UB}=35$. Nodes 4, 5 have parent value $34.5<35$, so they stay. Lower bound now $\min(34.5,\,33.571)=33.571$, gap $(35-33.571)/35=4.1\%$.

      Integrality pruning: a node whose LP is integer needs no more splitting.

    6. Node 7 ($x_1\ge7$, $x_2\ge2$). At $x_2=2$, route B needs $6x_1\ge41$, but $x_1\ge7$ already, so $x_1=7$: LP $(7,2)$, value $34$. Integer and better than $35$: new incumbent $z_{UB}=34$.

      Route A: $42+4=46\ge43$. Route B: $42+14=56\ge55$. Feasible and integer.

    7. Clean up. Nodes 4 and 5 carry parent value $34.5\ge34$. Delete them without solving. The list is empty, so the plan $(7,2)$ with cost $34$ is optimal. Five LPs were solved (nodes 1, 2, 3, 6, 7).

      Bound pruning without even solving the LP. Had we solved them: node 4 ($x_1\le6$, $x_2\le3$) is infeasible since $6x_1+2x_2\le42<43$, and node 5 has value $35.33\ge34$.

    NodeAdded boundsLP solutionLP valueOutcome
    1none(6.367, 2.4)32.667fractional, branch on $x_1$
    2$x_1\le6$(6, 3.5)34.5fractional, branch on $x_2$
    3$x_1\ge7$(7, 1.857)33.571fractional, branch on $x_2$
    6$x_1\ge7,\ x_2\le1$(8, 1)35integer: incumbent 35
    7$x_1\ge7,\ x_2\ge2$(7, 2)34integer: incumbent 34, optimal
    4, 5$x_1\le6$ with $x_2\le3$ or $x_2\ge4$not solvedparent 34.5deleted by bound
    Careful: the order in which you solve nodes changes the work, never the answer. If you had solved node 7 before node 6, the incumbent would have been $34$ at once, and node 6 (value $35$) would have been pruned by bound instead of becoming an incumbent. Also, prune on "value $\ge z_{UB}$", not "$\gt z_{UB}$": a node that can only tie the incumbent is not worth exploring.
    Go deeper: pruning with whole-number objectives

    If all costs and variables are whole, every plan below a node has a whole-number cost, so a node with LP value $33.571$ can only contain plans costing at least $34$. Solvers therefore prune when the rounded-up LP value is at least $z_{UB}$. Here node 5 has value $35.33$, rounded up $36$, which is far above $z_{UB}=34$. This is also why Gurobi's best bound at the end of a time-limited run is often a whole number (Chapter 4.4).

    In the two-van problem, what is the optimal LP value after adding $x_1\ge7$?

    At $x_1=7$ route B needs $7x_2\ge13$. Check that route A is then satisfied.

    $x=(7,13/7)$: cost $28+3\cdot13/7=28+5.571=33.571$. Route A: $42+3.71=45.71\ge43$.

    The node with bounds $x_1\le6$ and $x_2\le3$ is reached. What happens when its LP is solved?

    What is the largest value of $6x_1+2x_2$ under these bounds?

    $6x_1+2x_2\le36+6=42<43$, so route A can never be met. The LP is infeasible.

    With incumbent $34$, the node $x_1\le6$, $x_2\ge4$ has LP solution $(5.833,\,4)$ with value $35.33$. What happens?

    Compare $35.33$ with $34$.

    Its LP value is at least $z_{UB}=34$, so nothing below it can beat the incumbent. (The point is also fractional, but the bound test comes first.)

    A waiting node has stored parent value $34.5$ and the incumbent is now $34$. Do you need to solve its LP?

    Its LP value is at least the parent's value.

    Children are never better than the parent, so this node's LP value is at least $34.5\ge34$: it would be pruned by bound anyway. Delete it unsolved.

    How many node LPs does the solved example solve in total (including the root)?

    Count nodes 1, 2, 3, 6 and 7, and check what happened to nodes 4 and 5.

    Nodes 1, 2, 3, 6, 7 are solved. Nodes 4 and 5 are deleted when the incumbent reaches $34$ without solving them. Total $5$.

    • Label every child with its parent's LP value, so you can delete it later without solving.
    • Update $z_{LB}$ as the smallest value among waiting nodes and quote the gap.
    • Check that the fractional LP point violates both children.
    • Pruning a node just because its LP solution is fractional.
    • Branching on a variable that is already integer in the LP solution.
    • Forgetting that a tie with the incumbent also prunes the node.
    1. Branching on a fractional variable splits the feasible set into $x_j\le\lfloor v\rfloor$ and $x_j\ge\lceil v\rceil$: no integer plan is lost and the fractional LP point is cut away.
    2. A node is pruned when its LP is infeasible, when its LP value is no better than the incumbent, or when its LP solution is integer; child LP values never fall below the parent's.
    3. The search ends when no node is waiting; the incumbent is then optimal, and the gap between the incumbent and the smallest waiting bound shows progress all along.

    A node's LP value is $50.0$ and the incumbent is $50.0$ (minimisation). The node is:

    branched, because it may still hide a tie.
    A tie is not an improvement, so exploring it cannot help.
    pruned by bound.
    The rule is LP value $\ge z_{UB}$; no plan below can be strictly cheaper.
    pruned by infeasibility.
    The node has a feasible LP point.

    LP solution at a node: $x=(2.0,\,3.4,\,1.0)$. The node is branched on $x_2$. The children add:

    $x_2\le3$ and $x_2\ge3$
    The point $x_2=3$ would stay in both children.
    $x_2\le3.4$ and $x_2\ge3.4$
    Branches use whole numbers so that the LP point is cut away.
    $x_2\le3$ and $x_2\ge4$
    No whole number lies strictly between $3$ and $4$, and $3.4$ lies in neither child.

    Which statement about the bound of a child node is correct for a minimisation?

    It is at most the parent's bound, because more constraints help.
    More constraints shrink the feasible set.
    It is at least the parent's bound.
    Minimising over a smaller set cannot decrease the minimum.
    It can be either, depending on the branching variable.
    The set inclusion argument works for any branch.

    The tree is finished when:

    the first integer solution is found.
    Better plans may be hiding in waiting nodes.
    the LP at the root is integer only.
    That is one special case that ends the search at the root.
    no node is waiting.
    Every region has been solved or pruned, so the incumbent is optimal.

    Preprocessing, and what a solver prints: Lab 2

    Before the first LP is solved, a solver shrinks the model by tightening variable bounds, deleting rows that can never bind, fixing variables whose best value is obvious, and sharpening big-M coefficients. Lab 2 then runs branch and bound on the generalised assignment problem with these tricks switched off, and you learn to read the log it prints.

    Preprocessing can turn a hopeless model into an easy one, and the log is how you tell whether a run is converging; both are standard exam material, and the log is what you actually see when you use Gurobi.

    It is like tidying the workshop before starting a job: nothing you do changes what the job is, but every later step is faster, and a progress report on the wall tells you when to stop.

    The activity range of a row

    Take a row $\sum_{j}a_jx_j\le b$ with bounds $\ell_j\le x_j\le u_j$ on every variable. Even without knowing the $x_j$ we can say how small and how large the left side can be. The smallest value uses the lower bound where $a_j>0$ and the upper bound where $a_j<0$; the largest does the opposite: $$L=\sum_{a_j>0}a_j\ell_j+\sum_{a_j<0}a_ju_j,\qquad U=\sum_{a_j>0}a_ju_j+\sum_{a_j<0}a_j\ell_j.$$ Everything preprocessing does with a row starts from $L$ and $U$. (A "$\ge$" row is multiplied by $-1$ first.)

    1. Infeasible: if $L>b$, the row can never hold, so the whole problem is infeasible.
    2. Redundant: if $U\le b$, the row holds for every choice of bounds and can be deleted.
    3. Tighten: the other variables contribute at least $L-a_k\ell_k$ (for $a_k>0$), so $a_kx_k\le b-(L-a_k\ell_k)$: $$a_k>0:\ x_k\le\frac{b-(L-a_k\ell_k)}{a_k},\qquad a_k<0:\ x_k\ge\frac{b-(L-a_ku_k)}{a_k}.$$ For an integer variable round the new upper bound down and the new lower bound up. Repeat over all rows until nothing changes.
    Try it

    Choose a row and slide $b$. Read the smallest and largest left side, then the verdict: infeasible, redundant, or able to bite, and the tightened bounds. Switch rounding off to see what integrality adds. In the second row (all variables binary) find a value of $b$ where one variable is forced to $0$, and one where the row disappears.

    Integer variables with $0\le x_1\le5$, $0\le x_2\le4$, $0\le x_3\le3$ and the rows R1: $4x_1+3x_2-2x_3\le9$; R2: $x_1+x_2+x_3\le9$; R3: $2x_2+x_3\ge8$. Preprocess.

    1. R1. $L=0+0-2\cdot3=-6$. For $x_1$: $x_1\le(9-(-6))/4=3.75$, rounded down to $3$. For $x_2$: $x_2\le(9+6)/3=5$, already weaker than $4$. For $x_3$ ($a_3=-2$): $x_3\ge(9-0)/(-2)=-4.5$, nothing new. Now $x_1\le3$.

      The other terms of R1 can be as low as $-6$, so $4x_1$ can be at most $15$.

    2. R3 in $\le$ form is $-2x_2-x_3\le-8$. $L=-2\cdot4-3=-11$. For $x_2$: $x_2\ge(-8-(-11+8))/(-2)=2.5$, rounded up to $3$. For $x_3$: $x_3\ge0$, nothing new. Now $x_2\ge3$.

      Even with $x_3=3$, the term $2x_2$ must supply at least $5$, so $x_2\ge2.5$, hence $3$.

    3. R1 again, now with $\ell_2=3$: $L=0+9-6=3$, and $x_1\le(9-3)/4=1.5$, rounded down to $1$. Now $x_1\le1$.

      The new lower bound on $x_2$ raises $L$ and tightens R1. This is why we repeat until nothing changes.

    4. R2. With the new bounds the largest left side is $1+4+3=8\le9$, so R2 is redundant and is deleted. (With the original bounds it was $5+4+3=12>9$ and could bite.)

      Tightening one row made another redundant.

    5. Result: $x_1\in[0,1]$, $x_2\in[3,4]$, $x_3\in[0,3]$; R1 and R3 remain, R2 is gone. The box shrank from $6\cdot5\cdot4=120$ points to $2\cdot2\cdot4=16$ points.

      No integer solution was lost: each bound change only removed values that violate a row.

    Fixing variables

    Some variables can be set to a bound before any search, either from the signs in the model or from the bounds of the LP.

    For $\min c^\top x$ s.t. $Ax\ge b$, $\ell\le x\le u$: if $a_{ij}\ge0$ in every row $i$ and $c_j<0$, set $x_j=u_j$; if $a_{ij}\le0$ in every row and $c_j>0$, set $x_j=\ell_j$. Raising a variable with non-negative coefficients never harms a "$\ge$" row, and with $c_j<0$ it lowers the cost (the second rule is the mirror image). In dual language, the reduced cost then has the sign that keeps the variable at that bound.

    $\min\,-2x_1+3x_2+x_3$ s.t. $x_1+2x_2\ge3$, $3x_1-x_3\ge-2$, $0\le x_j\le5$. Fix what you can.

    1. $x_1$: cost $-2<0$, coefficients $(1,3)$ both $\ge0$. Fix $x_1=u_1=5$.

      More of $x_1$ helps both rows and lowers the cost.

    2. $x_3$: cost $+1>0$, coefficients $(0,-1)$ both $\le0$. Fix $x_3=\ell_3=0$.

      Less of $x_3$ costs less and only loosens the second row, which has $x_3$ with a negative sign.

    3. The rows become $5+2x_2\ge3$ (always true) and $15\ge-2$ (always true): both redundant. Then $x_2$ has $c=3>0$ and no coefficients left, so $x_2=\ell_2=0$.

      Fixing is repeated after every deletion.

    4. Solution: $x=(5,0,0)$ with value $-10$ found with no search at all.

      Enumerating the 216 integer points confirms it is optimal.

    Fixing with the incumbent: reduced-cost fixing

    Once an incumbent $z_{UB}$ exists, the LP of a node can eliminate values using its reduced costs. Suppose the LP value is $z_{LP}$ and a non-basic variable $x_j$ sits at its lower bound with reduced cost $\bar c_j>0$ (Part 1). Raising $x_j$ by $t$ raises the LP objective by at least $\bar c_jt$. Any plan that can beat the incumbent has LP objective at most $z_{UB}$, so $$x_j\le\ell_j+\frac{z_{UB}-z_{LP}}{\bar c_j}.$$ For a non-basic variable at its upper bound the same argument bounds it from below.

    In the two-van problem the root LP has value $98/3=32.667$. Use reduced-cost fixing with the incumbent $35$ found at node 6 in Chapter 4.2.

    1. Let $s_A=6x_1+2x_2-43\ge0$ and $s_B=6x_1+7x_2-55\ge0$ be the surplus crates on each route. These are the non-basic variables at the root, and each has reduced cost $\tfrac13$ (the dual prices).

      Part 2: the reduced cost of a surplus variable equals the dual price of its row.

    2. The identity behind the bound: $s_A+s_B=12x_1+9x_2-98=3(4x_1+3x_2)-98$, so the cost equals $\tfrac{98+s_A+s_B}{3}$.

      The cost exceeds the LP value by exactly $\tfrac13$ of the total surplus.

    3. A plan costing at most $35$ needs $s_A+s_B\le3\cdot35-98=7$. So each route can be oversupplied by at most $7$ crates: $6x_1+2x_2\le50$ and $6x_1+7x_2\le62$.

      This matches the formula $(z_{UB}-z_{LP})/\bar c_j=(35-32.667)/(1/3)=7$.

    4. With the final incumbent $34$ the limit shrinks to $3\cdot34-98=4$. The optimum $(7,2)$ has surpluses $3$ and $1$, total $4$, so it sits exactly on the limit.

      A tighter incumbent removes more of the region, and the optimum stays.

    Coefficient tightening and big-M

    Logical models use rows such as $x\le My$ (Part 3): if the depot is closed ($y=0$) nothing is shipped, and if it is open the row should do nothing. The constant $M$ only has to be large enough for the second case; anything larger is legal but weakens the LP, because the relaxation lets $y$ be tiny while $x$ is large.

    Try it

    A depot must ship at least the demand of $30$ units, so $x\ge30$, opening costs $60$ and each unit costs $2$: $\min 60y+2x$, $x\le My$, $y\in\{0,1\}$. Move $M$ and watch the LP optimum (red dot) slide along the bottom edge. Then choose "M = 30 (tight)". Notice the root gap, and that the integer answer never changes.

    Here no optimal plan ships more than the demand, so $M=30$ loses nothing; $M=300$ is valid but wasteful. The LP bound is $60\cdot\tfrac{30}{M}+60$: $66$ for $M=300$, $72$ for $150$, $90$ for $60$ and $120$ for $30$, against the true optimum $120$. The root gaps are $45\%$, $40\%$, $25\%$ and $0\%$.

    The same idea works on any row. For $\sum a_jx_j\le b$ with a binary $x_k$, $a_k>0$, and maximum activity $U$: if $U-a_k

    Tighten $8y_1+3y_2+2y_3\le10$ with binary $y$.

    1. Maximum activity $U=8+3+2=13$. For $y_1$ ($a_1=8$): $U-a_1=5<10$, so the test passes.

      With $y_1=0$ the left side is at most $5$, far below $10$.

    2. New coefficient $U-b=13-10=3$ and new right-hand side $U-a_1=5$: the row becomes $3y_1+3y_2+2y_3\le5$.

      With $y_1=1$ the original row reads $3y_2+2y_3\le2$ and the new row reads $3y_2+2y_3\le2$: identical. With $y_1=0$ both allow every $(y_2,y_3)$.

    3. The six feasible binary points are the same in both rows. But the fractional point $(0.5,1,1)$ is feasible for the original row ($4+5=9\le10$) and infeasible for the new one ($1.5+5=6.5>5$).

      If we maximise $y_1+y_2+y_3$, the original LP gives $2.625$ and the tightened LP gives $2$, which equals the integer optimum.

    Probing

    Bound tightening looks at one row at a time. Probing tries a binary variable at one value, propagates the consequences through all rows, and learns from the outcome: if setting $x_k=1$ leads to a contradiction, then $x_k=0$ in every feasible plan, so fix it. If both values of $x_k$ force the same value of another variable, fix that variable. If only one value forces something, remember the implication.

    Binary variables with R1: $6x_1+4x_2+3x_3\le8$, R2: $x_1+x_2+x_3\ge2$, R3: $x_3+x_4\le1$. Looking at each row on its own, can you fix any variable?

    No: every row alone leaves all four variables free.
    R1 alone only says $x_1\le1.33$; R2 alone needs two of three; R3 alone allows both.
    Yes, $x_1=0$ from R1.
    $6x_1\le8$ allows $x_1=1$ when $x_2=x_3=0$ (and then R2 fails, but that needs two rows).
    Yes, $x_4=0$ from R3.
    $x_3+x_4\le1$ allows $x_4=1$ with $x_3=0$.

    Single-row propagation is stuck, and probing breaks the deadlock. Try it in the panel.

    Try it

    Probe $x_1=1$ and read the messages: which variables does it force, and what contradiction follows? Once $x_1$ is fixed, probe $x_3=0$, then continue until every variable is fixed. Press Reset and probe $x_4=1$ first to see a different route to a contradiction.

    Solve the three-row system above by probing.

    1. Probe $x_1=1$. R1 becomes $4x_2+3x_3\le2$, so $x_2=0$ and $x_3=0$. R2 then reads $1+0+0\ge2$, false.

      A contradiction: $x_1=1$ is impossible in any feasible plan, so $x_1=0$.

    2. With $x_1=0$, R2 needs $x_2+x_3\ge2$, forcing $x_2=x_3=1$. Check R1: $4+3=7\le8$. Then R3 gives $x_4\le0$, so $x_4=0$.

      Plain propagation now runs through all rows.

    3. The only feasible plan is $(0,1,1,0)$.

      The model was solved by preprocessing alone, and branch and bound never starts.

    Careful: preprocessing never changes the optimal value of the IP. It may remove tied optimal plans and it only ever tightens the LP relaxation, raising a lower bound. In Lab 2 it is switched off on purpose, so that you see plain branch and bound.

    Case study: Lab 2, the generalised assignment problem

    The GAP of Part 3: $m$ agents, $n$ jobs, $x_{ij}=1$ if agent $i$ does job $j$, cost $c_{ij}$, resource use $r_{ij}$, agent capacity $s_i$: $$\min\sum_{i,j}c_{ij}x_{ij}\quad\text{s.t.}\quad\sum_ix_{ij}=1\ \ \forall j,\qquad\sum_jr_{ij}x_{ij}\le s_i\ \ \forall i,\qquad x_{ij}\in\{0,1\}.$$ The six instances come from Beasley's OR-Library, named by size: b05100 has $5$ agents and $100$ jobs, b10200 has $10$ agents and $200$ jobs, and so on, from $500$ to $4000$ binary variables. Each job row is an exactly-one set.

    The lab has two programs, and the contrast is the lesson.

    • Your own branch and bound (GAP_Exercise.py): Gurobi only solves the LP at each node (dual simplex, presolve off). You code the tree: depth-first until an incumbent exists then best-first by parent bound, most-fractional branching, deleting nodes against the incumbent, a 120 s limit.
    • Gurobi's own MIP engine (GAP_Gurobi.py): the same model, with Presolve = 0 (no preprocessing), Cuts = 0 (no cutting planes), TimeLimit = 120, branching direction left automatic. It is plain branch and bound, but still with Gurobi's heuristics and its fast node processing.

    Gurobi offers a free academic licence for students; Part D points to the set-up notes.

    InstanceRoot LPGurobi: best plan (nodes)Own B&B after 120 s: best plan (nodes)
    b051001831.331843 (3,244)2319 (38,359)
    b052003547.413552 (8,971)4056 (32,133)
    b101001400.671407 (751)1739 (48,642)
    b102002815.052827 (1,318,914); bound 2823 at the limit3365 (21,323)
    b201001155.181166 (21,059)no plan found (31,922)
    b202002331.142339 (504,407)no plan found (14,715)
    Try it

    Select an instance and switch between the three bar charts. Compare the root gap with the number of nodes Gurobi needed. Which instance has the smallest root gap, and which needs the most nodes? Then look at the hand-written results: which instances never found a plan?

    Four observations from the data:

    • The LP root bound is already within $0.13\%$ to $0.93\%$ of the optimum, yet hundreds to millions of nodes are needed. The bound is good, but proving that no plan hides in the last fraction is hard.
    • Difficulty follows neither size nor root gap: b10200 ($2000$ binaries, root gap $0.42\%$) is the only instance that hit the time limit, while b20200 ($4000$ binaries) finished in about $72$ s.
    • The hand-written search solves a node with the same LP engine but explores about $60$ times fewer nodes per second on b10200 ($21{,}323$ against $1{,}318{,}914$), has no heuristics, and on the $20$-agent instances its dive never reached an integer leaf.
    • Gurobi's own run closes five of six instances even with presolve and cuts off; with them on, instances like b10200 usually become much easier (that is why solvers enable both by default).

    Reading a MIP log

    Gurobi prints a table while it searches. Here are its columns.

    Columns of the log
    Expl / Unexpl
    nodes explored so far, and nodes created but still waiting
    Obj
    LP value of the node just solved; the words cutoff (pruned by bound) or infeasible (pruned by infeasibility) can appear here
    Depth, IntInf
    depth of that node in the tree, and how many integer variables are fractional in its LP
    Incumbent
    the best plan found: the upper bound $z_{UB}$
    BestBd
    the best lower bound: the smallest bound among waiting nodes
    Gap
    $(\text{Incumbent}-\text{BestBd})/|\text{Incumbent}|$
    It/Node, Time
    average simplex iterations per node, and seconds so far

    In the first column, H marks a plan found by a heuristic and * a plan found because a node's LP happened to be integer. Lines before the table show a heuristic solution found before the root and the root relaxation value. After the table, Gurobi reports why it stopped ("Optimal solution found" or "Time limit reached"), the best objective, the best bound and the final gap.

    Try it

    Answer the questions by clicking the right number in the log. Use the chips to switch between a log that finished (b05100) and one that hit the time limit (b10200). These are real excerpts from running the lab model with presolve and cuts off.

    Read the end of the b10200 log: last row Incumbent $2827$, BestBd $2823.6849$; footer "Time limit reached ... best bound $2.824\times10^3$, gap $0.1061\%$". Explain each number.

    1. The plan has cost $2827$ and nobody found a better one since second $3$ of the run.

      The incumbent column stays at $2827$ for the last $117$ seconds.

    2. The row gap is $(2827-2823.6849)/2827=0.1173\%$, shown as $0.12\%$. The bound has risen from $2815.05$ (the root LP) to $2823.68$.

      All progress after second $3$ was in the bound, not the plan.

    3. The footer bound is $2824$, not $2823.68$: every plan has a whole-number cost, so the bound is rounded up. The gap is $(2827-2824)/2827=0.1061\%$.

      This is the rounding of Chapter 4.1: a lower bound for whole-number costs may be rounded up.

    4. The true optimum is therefore between $2824$ and $2827$. The lab run on the course machine ended with bound $2823$ and gap $0.14\%$; repeated runs differ because the multi-threaded search takes different paths.

      A time-limited run proves a bracket, not an optimum.

    Integer variables $0\le x_1,x_2\le10$ and the row $3x_1+5x_2\le31$. What is the best upper bound on $x_2$ that bound tightening gives?

    The smallest possible value of $3x_1$ is $0$. Then round down.

    $L=0$, so $5x_2\le31$, $x_2\le6.2$, rounded down: $6$.

    The row $2x_1+3x_2\le20$ with $0\le x_1\le4$ and $0\le x_2\le3$ is checked. What is the verdict?

    Compute the largest possible left side $U$ and compare with $20$.

    $U=2\cdot4+3\cdot3=17\le20$, so the row holds for every point of the box and can be deleted.

    At a node the LP value is $100$, a non-basic variable $x_j$ at lower bound $0$ has reduced cost $4$, and the incumbent is $112$ (minimisation). Reduced-cost fixing bounds $x_j$ by what?

    Use $x_j\le\ell_j+(z_{UB}-z_{LP})/\bar c_j$.

    $(112-100)/4=3$, so $x_j\le3$.

    Tighten the coefficient of $y_1$ in $5y_1+4y_2+3y_3\le8$ with binary variables, using $a_k'=U-b$.

    Find the maximum activity $U$ and check that $U-a_1

    $U=12$, $U-5=7<8$. New coefficient $12-8=4$, new right-hand side $12-5=7$: $4y_1+4y_2+3y_3\le7$. It allows the same six binary points.

    A log row shows Incumbent $1849$ and BestBd $1833.18429$. What gap does Gurobi print (in percent)?

    Divide the difference by the incumbent.

    $(1849-1833.18429)/1849=0.00855$, printed as $0.86\%$.

    • Tighten bounds, delete redundant rows and fix variables before blaming the solver.
    • Use the smallest valid big-M; derive it from the bounds of the variables.
    • Read three numbers first in any log: Incumbent, BestBd and Gap.
    • Using $M=10^6$ "to be safe".
    • Expecting a time-limited run to prove optimality.
    • Judging difficulty by instance size alone: b10200 beat b20200.
    1. Preprocessing uses each row's smallest and largest left side to detect infeasible and redundant rows, tighten bounds, fix variables, shrink big-M coefficients and (by probing) learn implications; it never changes the optimum.
    2. With an incumbent, reduced costs let a node fix more variables: a non-basic variable cannot rise by more than $(z_{UB}-z_{LP})/\bar c_j$.
    3. A solver log shows Incumbent (upper bound), BestBd (lower bound) and their gap; H, *, cutoff and infeasible name how plans and prunings arise, and Lab 2 shows the same algorithm taking seconds or hitting the time limit depending on the instance and the engineering around it.

    Setting x_k = 1 in a probe leads to a violated row. What may you conclude?

    $x_k=1$ in every optimal plan.
    The contradiction concerns $x_k=1$, so it is excluded.
    $x_k=0$ in every feasible plan, so $x_k$ can be fixed to $0$.
    The only other value of a binary variable is $0$.
    The model is infeasible.
    Only if $x_k=0$ also fails.

    Two models have the same integer points. One uses $x\le300y$, the other $x\le30y$ where $x\le30$ always. Which gives the higher LP lower bound for a minimisation with a positive fixed cost?

    The one with $300$.
    It allows $y$ to be ten times smaller in the relaxation, hence a lower bound.
    The one with $30$.
    It forces $y\ge x/30$, so the fixed cost is paid more fully in the LP.
    They are equal because the integer points are equal.
    The LP relaxations differ even when the integer points do not.

    The Obj column of a log row says cutoff. The node was:

    infeasible.
    That would be printed as infeasible.
    found to have an integer LP solution.
    That is marked by * in the first column.
    pruned by bound: its LP value was not better than the incumbent.
    The word means the node was cut off by the incumbent.

    Why does Lab 2 set Presolve = 0 and Cuts = 0?

    Gurobi cannot solve the GAP with them.
    It can, and usually faster.
    So that the search is plain branch and bound on the model exactly as written, making node counts and times a measure of the algorithm itself.
    Presolve and cuts would hide most of the tree.
    To make the LP relaxation tighter.
    Switching them off makes bounds weaker, not tighter.
    Where we are in the story

    Kaveri Courier's owner now has a solver that brackets the best plan between an incumbent and a bound, branches on fractional variables and prunes with preprocessing. That covers the choice of depots, loads and assignments. What it does not yet cover is the order in which one van visits its customers. Once the customers on a van are known, that order is a travelling salesman problem, and Part 5 takes it up with the same bounding mindset: an integer programme, an LP relaxation and cuts added where the relaxation misleads.

    A minimisation has root LP value $198$ and the best plan found costs $210$. What does the gap tell you?

    The optimum is exactly $204$.
    The gap gives a range, not a point.
    The incumbent can be improved by at most $(210-198)/210\approx5.7\%$.
    The optimum lies in $[198,210]$.
    The LP is infeasible.
    It has a value, so it is feasible.

    $P_1$ and $P_2$ are two formulations of the same IP with $P_1\subset P_2$. Which statement is true for a minimisation?

    Branch and bound with $P_1$ starts from a lower bound that is at least as high.
    A smaller relaxation region cannot lower the minimum.
    Branch and bound with $P_1$ may find a worse optimum.
    Both formulations have the same integer points and so the same optimum.
    The bounds are always equal.
    That holds only if the extra part of $P_2$ contains no better LP point.

    In the two-van problem the dual prices of both route rows are $\tfrac13$. If route A's requirement rises from $43$ to $44$ crates (the basis staying optimal), the root LP bound moves from $32.667$ to about:

    $32.667$ (no change)
    A tight row with a positive price does change the optimum.
    $33$
    The optimum rises by the dual price $\tfrac13$.
    $33.667$
    That would be a price of $1$.

    After branching on $x_j$, the child LP is solved starting from the parent's final basis by the dual simplex method because:

    the child has more variables.
    The variable set is unchanged; only a bound changed.
    the parent's basis is still dual feasible but the new bound makes it primal infeasible.
    That is exactly the situation the dual simplex method is built for.
    the primal simplex cannot handle bounds.
    It can (Chapter 2.1); the dual is just faster here.

    An LP optimum of an integer programme is $(3.0,\,4.6)$. By Part 1 it is a corner of the LP region. After branching on $x_2$ into $x_2\le4$ and $x_2\ge5$, what happens to this corner?

    It stays a feasible corner of both children.
    $4.6$ violates both $x_2\le4$ and $x_2\ge5$.
    It is cut off from both children, and every whole-number point is kept in exactly one child.
    That is the purpose of the branch.
    It becomes the new incumbent.
    It is not integer, so it cannot be an incumbent.

    An assignment row $\sum_{i=1}^{16}x_{ij}=1$ has LP values $(0.4,\,0.3,\,0.3,\,0,\dots,0)$. Where does a GUB/SOS split put $Q$?

    $Q=\{1\}$, because the largest value is first.
    The running sum $0.4$ is below $\tfrac12$.
    $Q=\{1,2\}$, since $0.4+0.3=0.7\ge\tfrac12$ first at $t=2$.
    The other side has weight $0.3>0$, so both children cut the LP point.
    $Q=\{1,2,3\}$, because the sum must reach $1$.
    The threshold is $\tfrac12$.

    Lecture 5 studies the most famous routing problem: one vehicle, many stops, the cheapest closed route. We write it as an integer programme with exponentially many constraints (the DFJ formulation), learn how a solver adds them only when needed, meet the compact alternatives of Miller–Tucker–Zemlin and of flow models, compare their strength, and finish with the variants of the lecture (time windows, optional customers, road networks, clusters, street-covering routes) and the heuristics that find good tours quickly.

    You need: Part C (graphs, the notation $E(S)$ and $\delta(S)$, tours, Euler circuits, spanning trees and matchings; maximum flow and minimum cut are introduced in Ch. C.2 and used again in Ch. 5.2), Part D (forcing constraints and why a small big-$M$ matters), Part 3 (LP relaxation and formulation strength), and Part 1 (what an LP bound means).

    From tours to the DFJ formulation

    The travelling salesman problem asks for the cheapest closed route that visits every city once. Writing it as an integer programme takes one yes/no variable per road, a rule that every city has two chosen roads, and a family of rules that forbids a route from breaking into separate loops.

    In the story of Kaveri Courier, the small Bengaluru courier firm of Part 3, the owner has by now chosen the depot and the loads for the vans (Ch. 3.1 and Ch. 3.4) and has seen how a solver finds such answers (Part 4). After Part 4 the owner knows which customers go on this van; what remains is the order in which it should visit them. Every vehicle routing model in Part 6 contains a TSP inside it, and the "forbid separate loops" idea of this chapter returns in every one of them. The two equivalent forms of that rule, and the proof that they agree, are standard exam material.

    It is like threading one string through all the beads of a necklace: giving every bead two neighbours is not enough, because you might end up with two small necklaces instead of one large one.

    The problem and a six-city example

    Take one van of Kaveri Courier. It starts at the depot that was opened in Part 3 (the choice of Ch. 3.3 and Lab 1 in Ch. 3.4), must call at every customer on its load exactly once, and returns to the depot. Driving between places $u$ and $v$ costs $c_{uv}$, the same in both directions. Call the places cities; there are $n$ of them. Take the complete graph $G=(V,E)$ on the cities (Part C): every pair of cities is joined by an edge $e=\{u,v\}$ with cost $c_e$. A tour is a cycle through all cities, and the TSP asks for the tour of least total cost.

    Because the first city is only a starting point, there are $(n-1)!/2$ different tours: $60$ for six cities, $181{,}440$ for ten, about $6.1\times10^{16}$ for twenty (Part C turned that into years of computing). We cannot list them, so we need a model.

    Our running example has six cities with these costs (an edge not in the table costs $9$). For the story, city $1$ is the depot, cities $2$ and $3$ are the customers in Indiranagar and Domlur, and cities $4$, $5$ and $6$ are the customers in Jayanagar, BTM Layout and Banashankari. The names are only labels: the costs below are the teaching numbers, not measured road distances, and everything that follows uses the numbers $1,\dots,6$.

    edge1–21–32–33–42–54–54–65–61–6
    cost453674538

    Cities 1, 2, 3 (the depot and the two eastern customers) sit close together, and so do 4, 5, 6 (the southern customers). Keep this in mind: it is what makes the naive model fail.

    One variable per edge, and the notation of Lecture 5

    For every edge $e$ let $x_e=1$ if the tour uses it and $x_e=0$ otherwise. The vector $x$ is the incidence vector of the chosen edges; the edges with $x_e\gt0$ form the support graph of $x$ (for a fractional LP solution it is the graph of roads the LP uses at least a little).

    Notation for a set of cities $S\subseteq V$ (complement $S^c=V\setminus S$)
    $E(S)$
    edges with both ends in $S$ (the edge set of $S$)
    $\delta(S)$
    edges with exactly one end in $S$ (the cut set, "the boundary of $S$")
    $\delta(u)$
    shorthand for $\delta(\{u\})$: the edges touching city $u$
    $x(F)$
    $\sum_{e\in F}x_e$ for an edge set $F$; so $x(\delta(u))$ is the degree of $u$
    Careful: write $x(\delta(S))=\sum_{u\in S}\sum_{v\in S^c}x_{\{u,v\}}$, with the second sum over the other side $S^c$. Printing the second sum over $v\in S$, as the slide does, would describe $E(S)$ instead. And $x(E(S))$ adds each unordered pair $\{u,v\}\subseteq S$ once, not twice.

    For every $x$ and every $S\subseteq V$, $$\sum_{u\in S}x(\delta(u))\;=\;2\,x(E(S))+x(\delta(S)).$$

    Proof. Add the degrees of the cities in $S$. An edge with both ends in $S$ is counted at both ends, so twice. An edge of the cut has one end in $S$, so it is counted once. An edge with no end in $S$ is not counted. $\blacksquare$

    Step 1: every city gets two edges

    In a tour each city is entered once and left once, so exactly two tour edges touch it: $x(\delta(u))=2$ for every city $u$. With the objective $\min\sum_e c_ex_e$ and $x$ binary we get a first model. It is an easy relative of the assignment problem of Part 3, but it does not describe tours: it describes any collection of cycles that together cover all cities.

    On our example the cheapest such collection is the two triangles $1\text{–}2\text{–}3$ and $4\text{–}5\text{–}6$, with cost $(4+5+3)+(4+5+3)=24$. Every city has two edges, yet nobody drives from the first triangle to the second. These separate loops are called subtours, and because nearby cities are cheap to join, the model loves them.

    Cities form two clusters, and the model only demands "two edges at every city". What does its cheapest solution usually look like?

    One long tour that crosses between the clusters.
    Crossing between clusters is expensive, and nothing in the model rewards it.
    Several small cycles, usually one or more inside each cluster.
    Short edges between neighbours are cheap, and each small cycle already satisfies the degree rule.
    An unpredictable mixture; no pattern.
    The pattern is strong: the cheapest edges are the short ones.

    The widget below does this exactly for eight cities: it lists every way of giving each city two edges and picks the cheapest. Drag the cities, then add cuts one at a time.

    Try it

    Leave the chip on "Model with cuts so far" and read the colours: each cycle gets its own colour, and the readout says how many separate cycles the cheapest solution has. Then drag the cities to make the two groups closer and watch it change. Press "Add the cut for the smallest piece" repeatedly and notice that the model value never decreases and finally becomes a tour. Compare with "Shortest real tour".

    Step 2: a counting argument forbids subtours

    Take any set $S$ of $k$ cities, with $2\le k\le n-1$. If a tour used $k$ edges inside $S$, those $k$ edges among $k$ cities would close into a cycle on $S$ alone, and the tour could never reach the other cities. A cycle through $S$ and beyond must leave $S$ after passing through some cities of $S$, so it uses at most $k-1$ edges inside $S$.

    $$\begin{aligned}\min\ &\sum_{e\in E}c_ex_e\\ \text{s.t. }&x(\delta(u))=2&&\forall u\in V\\ &x(E(S))\le |S|-1&&\forall S\subset V,\ 2\le|S|\le n-1\\ &x_e\in\{0,1\}&&\forall e\in E.\end{aligned}$$

    The second family is the subtour elimination constraints (SEC). For $|S|=1$ the inequality reads $0\le0$, so the slide's "all non-empty $S$" costs nothing.

    When is a SEC tight, and when slack?

    Restrict a tour to the cities of $S$. It falls apart into pieces: maximal runs of consecutive tour cities that lie in $S$. A piece of $k_i$ cities is a path with $k_i-1$ edges. So $$x(E(S))=\sum_i (k_i-1)=|S|-\#\text{pieces}.$$ The constraint is an equality exactly when the tour visits $S$ in one stretch, and strict when it visits $S$ in two or more stretches.

    Step 3: the cut form

    A second way to say the same thing: a tour is connected, so it must cross the boundary of every set $S$ at least twice (once to leave, once to come back).

    $$x(\delta(S))\ge 2\qquad\forall S\subset V,\ S\ne\emptyset.$$ The number of pieces of a tour inside $S$ is $x(\delta(S))/2$.

    Examinable proof. Show that, when the degree constraints hold, $x(E(S))\le|S|-1$ and $x(\delta(S))\ge2$ are the same inequality.

    1. Start from the handshake rule: $\sum_{u\in S}x(\delta(u))=2x(E(S))+x(\delta(S))$.

      This identity is true for every $x$; it only counts degrees.

    2. Insert the degree constraints $x(\delta(u))=2$: the left side becomes $2|S|$. So $x(\delta(S))=2|S|-2x(E(S))$.

      This is the only place where the degree constraints are used, so the equivalence holds under them and not without them.

    3. Now $x(\delta(S))\ge2\iff 2|S|-2x(E(S))\ge2\iff x(E(S))\le|S|-1$. $\blacksquare$

      Subtract, then divide by $2$. Each cut inequality is a SEC plus a multiple of degree equations, so the two models have the same LP relaxation.

    On the six-city example, find the cheapest solution of the degree-only model, show which SEC it violates, and find the optimum of the DFJ model.

    1. Degree-only optimum: two triangles, cost $24$ (computed above).

      All six edges used are among the cheapest, and every city has two of them.

    2. Take $S=\{1,2,3\}$. Then $x(E(S))=3\gt|S|-1=2$, and $x(\delta(S))=0\lt2$. Both forms are violated.

      All three edges of the triangle lie inside $S$ and nothing leaves it, so the check is immediate.

    3. Add the cut for $S=\{1,2,3\}$. It is the same constraint as for $S^c=\{4,5,6\}$, because $\delta(S)=\delta(S^c)$.

      There are $\binom63/2=10$ ways to split six cities into two triples, and each of the $10$ two-triangle solutions breaks exactly one of these cuts. Of all $70$ ways to give each city two edges, $60$ are tours and $10$ are two triangles.

    4. The cheapest solution that remains is the tour $1\text{–}2\text{–}3\text{–}4\text{–}5\text{–}6\text{–}1$ with cost $4+3+6+4+3+8=28$.

      A computer lists all $60$ tours; this is the least. The bound rose from $24$ to $28$ after one cut.

    For the tour $1\text{–}2\text{–}3\text{–}4\text{–}5\text{–}6\text{–}1$ test two sets: $S=\{1,2,3\}$ and $S=\{1,2,4,5\}$.

    1. $S=\{1,2,3\}$: the tour edges inside are $12$ and $23$, so $x(E(S))=2=|S|-1$: tight. The edges leaving are $34$ and $61$, so $x(\delta(S))=2$: tight.

      The tour passes through $S$ in a single stretch, one piece.

    2. $S=\{1,2,4,5\}$: inside are $12$ and $45$, so $x(E(S))=2\lt3$: slack. Leaving are $23$, $34$, $56$, $61$, so $x(\delta(S))=4\gt2$: slack.

      Two pieces: $\{1,2\}$ and $\{4,5\}$. Then $|S|-\#\text{pieces}=4-2=2$ and $x(\delta(S))/2=2$.

    3. Check the handshake rule on the second set: $\sum_{u\in S}x(\delta(u))=8=2\cdot2+4$.

      This is a quick way to find a mistake in a count.

    Step 4: which sets $S$ are really needed?

    • Complements are twins. $\delta(S)=\delta(S^c)$, so the cut constraints for $S$ and $S^c$ are identical. Keep only $|S|\le\lfloor n/2\rfloor$.
    • Single cities are redundant. For $|S|=1$ the cut form is the degree constraint itself ($2\ge2$).
    • Pairs are redundant. For $S=\{u,v\}$, $x(\delta(S))=x(\delta(u))+x(\delta(v))-2x_{uv}=4-2x_{uv}\ge2$ because $x_{uv}\le1$.

    So only $3\le|S|\le\lfloor n/2\rfloor$ remain. For $n=8$ that is $\binom83+\binom84/2=56+35=91$ constraints, and for large $n$ it is still about $2^{n-1}$.

    Go deeper: why a tour can have several pieces in $S$ but never "zero"

    If $S$ is non-empty and not everything, a tour must contain at least one piece inside $S$ and at least one outside, so $x(\delta(S))\ge2$ automatically. The cut form therefore says more than "visit $S$": it says "$S$ is connected to the rest". Under the degree constraints a solution is a union of disjoint cycles, and the cut form rules out exactly the case of two or more cycles.

    How many different tours does a symmetric TSP on $7$ cities have?

    Fix the starting city, order the other six, and then identify each tour with its reverse.

    $(7-1)!/2=720/2=360$.

    The tour $1\text{–}2\text{–}\dots\text{–}8\text{–}1$ visits eight cities in numerical order. For $S=\{2,3,4,7,8\}$ find $x(E(S))$ and $x(\delta(S))$.

    Edges inside $S$: both ends in $S$. Edges leaving: exactly one end in $S$. Check with the handshake rule.

    Inside: $23$, $34$, $78$, so $3$. Leaving: $12$, $45$, $67$, $81$, so $4$. Check: $5\cdot2=10=2\cdot3+4$. The set is visited in two pieces, $\{2,3,4\}$ and $\{7,8\}$, and $|S|-2=3$.

    All degrees are $2$. A set $S$ has $5$ cities and $x(\delta(S))=6$. What is $x(E(S))$?

    Use $\sum_{u\in S}x(\delta(u))=2x(E(S))+x(\delta(S))$.

    $10=2x(E(S))+6$, so $x(E(S))=2$. Check the cut form: $6\ge2$ holds; the edge form says $2\le4$, also slack.

    For $n=8$ cities, how many different cut constraints $x(\delta(S))\ge2$ remain after dropping complements, single cities and pairs?

    Count sets with $|S|=3$ and with $|S|=4$; sets of size $4$ come in complementary pairs.

    Size $3$: $\binom83=56$. Size $4$: $\binom84/2=35$, since $S$ and $S^c$ are twins. Total $91$.

    A solution of the degree-only model consists of a triangle $\{1,2,3\}$ and a 4-cycle $\{4,5,6,7\}$ on seven cities. Is the SEC for $S=\{4,5,6,7\}$ satisfied?

    Compute $x(E(S))$ and compare with $|S|-1$.

    The four edges of the 4-cycle lie inside $S$, so $x(E(S))=4\gt3$. The constraint is violated (equivalently $x(\delta(S))=0\lt2$).

    • Say "every city has two edges" and "no subset closes into its own cycle" as two separate requirements.
    • Check a SEC by counting both $x(E(S))$ and $x(\delta(S))$ and verifying the handshake rule.
    • Writing the second sum of $x(\delta(S))$ over $v\in S$ instead of $S^c$.
    • Believing the degree constraints alone give a tour; they give any union of cycles.
    1. The TSP has one binary variable per edge, the degree rule $x(\delta(u))=2$, and the subtour constraints $x(E(S))\le|S|-1$.
    2. Under the degree rule the edge form and the cut form $x(\delta(S))\ge2$ are the same inequality, by the identity $\sum_{u\in S}x(\delta(u))=2x(E(S))+x(\delta(S))$.
    3. Only sets with $3\le|S|\le n/2$ are needed, but that is still about $2^{n-1}$ constraints.

    A tour visits the cities of $S$ in three separate stretches, and $|S|=9$. What is $x(E(S))$ for this tour?

    8
    That is the value for a single stretch, $|S|-1$.
    6
    $x(E(S))=|S|-\#\text{pieces}=9-3=6$.
    3
    That is the number of pieces, not the number of edges inside.

    Why is the cut constraint for a pair $S=\{u,v\}$ not needed?

    Pairs are always visited in one stretch.
    Not true for tours; the real reason follows from the degrees.
    Under the degree constraints $x(\delta(S))=4-2x_{uv}\ge2$ automatically.
    Both cities have degree 2 and $x_{uv}\le1$.
    Because $\delta(S)=\delta(S^c)$.
    That removes duplicates between $S$ and its complement, but does not make a pair constraint redundant.

    Which statement about the degree-only model (all degrees equal $2$, $x$ binary) is correct?

    Its optimum is a tour whenever costs satisfy the triangle inequality.
    Clusters of nearby cities give cheap small cycles even with a metric.
    Its optimum is the cheapest collection of cycles covering all cities, so its value is a lower bound on the optimal tour cost.
    Every tour is feasible for it, so minimising over a larger set cannot give a larger value.
    Its value is always equal to the tour cost.
    In the six-city example it is 24 against 28.

    In the six-city example, which sets $S$ with $|S|=3$ can be violated by a solution of the degree-only model?

    Only $\{1,2,3\}$.
    The degree-only model could choose other triples if the costs were different.
    Any of the $10$ triples (up to complement); a solution made of two triangles on that split violates it.
    Each of the 10 two-triangle solutions breaks exactly one of the 10 cuts.
    None, because $|S|\le n/2$ is excluded.
    For $n=6$ the triples are exactly the sets of size $n/2$ that the rule keeps.

    Cutting planes, separation by minimum cut, and the directed case

    The DFJ model has far too many constraints to write down, but a solver never needs them all. It starts with the degree rules, solves, finds one violated subtour constraint by a minimum-cut computation, adds it, and repeats.

    This is how the best TSP codes work, and the same loop, with different constraint families, drives branch-and-cut for vehicle routing. The directed version (the asymmetric TSP) is on the exam too.

    It is like proofreading a long contract: you do not read every possible clause, you read the draft once, fix the clause that is clearly wrong, and read again.

    Too many constraints

    The number of distinct cut constraints is about $2^{n-1}$: roughly $512$ for ten cities, $5\times10^5$ for twenty, $5\times10^8$ for thirty and $5.6\times10^{14}$ for fifty. Writing them all down is impossible beyond about thirty cities, yet the TSP is solved for tens of thousands of cities. The reason is that only a few of the constraints matter at the optimum.

    1. Start with the degree constraints and $0\le x_e\le1$. Solve the LP.
    2. Look for a set $S$ with $x(\delta(S))\lt2$. If there is none, every subtour constraint holds. If $x$ is also integral, it is an optimal tour; otherwise branch (Part 4).
    3. Otherwise add the cut for that $S$ and solve again. Go to step 2.

    Step 2 is a minimum-cut problem

    Treat $x^*_e$ as the capacity of edge $e$ in the support graph. Then $x^*(\delta(S))$ is the capacity of the cut separating $S$ from $S^c$. Finding a violated SEC means finding a cut of capacity below $2$. So we compute the smallest cut of the whole graph. If its capacity is at least $2$, all $2^{n-1}$ constraints hold; if not, the minimising set is a violated constraint.

    A global minimum cut can be found in polynomial time: fix city $1$ on one side, and for each other city $t$ compute the smallest cut separating $1$ from $t$ by a max-flow computation. The max-flow min-cut theorem says that the largest flow that can be sent from $1$ to $t$ equals the capacity of the smallest cut separating them, so a max-flow routine returns that cut. That is $n-1$ max-flows. A cheaper first test: if the support graph is disconnected, every component is a violated set because $x(\delta(S))=0$.

    Eight cities carry the fractional point $x_{12}=x_{23}=x_{34}=1$, $x_{56}=x_{67}=x_{78}=1$ and $x_{41}=x_{85}=x_{15}=x_{48}=\tfrac12$ (all other edges $0$). Find a violated subtour constraint.

    1. Check the degrees. City $1$: $x_{12}+x_{41}+x_{15}=1+\tfrac12+\tfrac12=2$. Cities $4,5,8$ are the same by symmetry; cities $2,3,6,7$ each touch two edges of value $1$. All degrees equal $2$.

      The degree constraints hold, so the point is feasible for the LP we have been solving.

    2. The support graph is connected (edges $15$ and $48$ join the two sides), so the components test finds nothing.

      The fractional edges hide the problem; this is why we need the cut computation.

    3. Look for a thin place. Take $S=\{1,2,3,4\}$. Only $15$ and $48$ leave it: $x(\delta(S))=\tfrac12+\tfrac12=1\lt2$.

      A minimum-cut routine would return exactly this set, with capacity $1$.

    4. The equivalent edge form: $x(E(S))=x_{12}+x_{23}+x_{34}+x_{41}=3.5\gt|S|-1=3$. Handshake check: $8=2\cdot3.5+1$.

      Both forms are violated; add either one and re-solve. The new LP must now send at least $2$ units across the middle.

    Try it

    Choose "Two clusters", then tap cities (or use the number buttons) to build the set $S=\{1,2,3,4\}$ and read the three numbers. Then press "Choose the smallest cut" and see what the algorithm finds (it may name the other side of the same cut, $\{5,6,7,8\}$). Switch to "Prism" and "A tour" and watch the smallest cut change.

    How strong is the bound? The subtour LP

    Replace $x_e\in\{0,1\}$ by $0\le x_e\le1$ and keep the degree and subtour constraints. This is the subtour LP (also called the Held–Karp relaxation). Its optimum is a lower bound on the best tour (Part 3). The ideal formulation would describe the convex hull of tours exactly; the subtour LP is a slightly larger polytope, so its optimum can be a fractional corner.

    The classic fractional corner is a prism: two triangles with value $\tfrac12$ on each triangle edge, joined by three edges of value $1$ (the "Prism" preset of the widget). Each city has degree $\tfrac12+\tfrac12+1=2$, and a check of all sets shows every cut has capacity at least $2$, yet the point is not a convex combination of tours.

    Prism: triangle edges cost $3$, joining edges cost $1$, all other edges cost $50$. Compare the prism point with the best tour.

    1. Cost of the prism point: six triangle edges at $\tfrac12\cdot3$ plus three joining edges at $1\cdot1$: $6\cdot1.5+3=12$.

      Fractional values simply multiply the edge costs.

    2. A tour crosses between the triangles an even number of times, and it cannot avoid crossing, so it uses two of the three joining edges ($2$) and four triangle edges ($12$): cost $14$. Any other tour needs an edge costing $50$.

      The tour $1\text{–}2\text{–}3\text{–}6\text{–}5\text{–}4\text{–}1$ has this cost.

    3. So the subtour LP value is at most $12$, strictly below the tour cost $14$: an integrality gap of at least $14/12$.

      The LP prefers to "cheat" with halves. A solver would branch, or add a comb inequality that this point violates.

    Go deeper: the comb inequality that cuts off the prism

    Take the handle $H=\{1,2,3\}$ (the three cities of one triangle) and three teeth $T_i=\{i,i+3\}$ (each joining edge with its two ends). The comb inequality $$x(E(H))+\sum_{i=1}^3x(E(T_i))\le |H|+\sum_i(|T_i|-1)-\tfrac{3+1}{2}=3+3-2=4$$ holds for every tour, but the prism gives $1.5+3\cdot1=4.5\gt4$. Combs, blossoms and other families are what the Concorde solver adds beyond the SEC. You are not asked to prove validity.

    Go deeper: how good is the subtour bound in practice?

    On random uniform instances the Held–Karp (subtour LP) value is reported to be only about one percent below the optimum, and rarely more than two percent. That small gap, together with fast separation, is why instances with tens of thousands of cities are solved to proven optimality. In theory the subtour LP can be solved in polynomial time even though it has exponentially many constraints, because separation is a min-cut problem.

    The directed version: the asymmetric TSP

    Sometimes $c_{ij}\ne c_{ji}$ (one-way streets, uphill and downhill). Use the directed complete graph $G=(N,A)$ with an arc variable $x_{ij}=1$ if the vehicle drives directly from $i$ to $j$. For a set $S$, $A(S)$ are the arcs inside $S$, $\delta^+(S)$ the arcs leaving $S$ (tail in $S$) and $\delta^-(S)$ the arcs entering $S$.

    $$\begin{aligned}\min\ &\sum_{(i,j)\in A}c_{ij}x_{ij}\\ \text{s.t. }&x(\delta^+(i))=1,\quad x(\delta^-(i))=1&&\forall i\in N\\ &x(A(S))\le|S|-1&&\forall S\subset N,\ 2\le|S|\le n-1\\ &x_{ij}\in\{0,1\}.\end{aligned}$$

    Leave every city once, enter every city once, and no subset closes into its own directed cycle.

    Cut form. Add the leave-once equalities over $i\in S$: $|S|=x(A(S))+x(\delta^+(S))$. Hence $x(A(S))\le|S|-1\iff x(\delta^+(S))\ge1$. Adding the enter-once equalities gives $x(\delta^-(S))=x(\delta^+(S))$, so also $x(\delta^+(S))+x(\delta^-(S))\ge2$ is equivalent. This matches the undirected cut form.

    Size. There are $n(n-1)$ variables, $2n$ degree constraints and $2^n-n-2$ subtour constraints (every subset except the empty set, the $n$ singletons and the whole set): $2^n+n-2$ constraints in all. For $n=6$ that is $30$ variables and $68$ constraints.

    Where subtours come from. Without the SEC, the model is an assignment problem: every city picks its successor, and every city is picked once. Its LP is integral (Part 3), but its solutions are cycle covers: collections of directed cycles. The SEC are exactly what turns a cycle cover into one tour.

    A four-city ATSP has cost matrix (row = from, column = to): $$C=\begin{pmatrix}-&2&7&9\\3&-&8&6\\8&5&-&2\\4&9&3&-\end{pmatrix}.$$ Compare the assignment relaxation with the best tour.

    1. The cheapest arcs out of each city are $1\to2$ (cost $2$), $2\to1$ ($3$), $3\to4$ ($2$), $4\to3$ ($3$), and each city is entered once. Cost: $2+3+2+3=10$.

      This is the cheapest assignment; it consists of the two 2-cycles $1\leftrightarrow2$ and $3\leftrightarrow4$, so it is a cycle cover, not a tour.

    2. There are $(4-1)!=6$ tours: $1\to2\to3\to4\to1$ costs $2+8+2+4=16$; $1\to2\to4\to3\to1$: $2+6+3+8=19$; $1\to3\to4\to2\to1$: $7+2+9+3=21$; $1\to4\to3\to2\to1$: $9+3+5+3=20$; the other two cost $22$ and $34$.

      Each tour is a cycle through all four cities; add the four arc costs.

    3. The best tour costs $16$; the relaxation gave only $10$.

      The assignment bound is weak because small cycles are cheap.

    4. Add the SEC for $S=\{1,2\}$: $x_{12}+x_{21}\le1$. The cheapest cycle cover that remains is $1\to2\to3\to4\to1$ itself, cost $16$.

      One violated constraint closed the whole gap here; in general a loop of a few cuts is needed.

    In the prism point, take $S=\{1,2,3\}$ (one triangle, with value $\tfrac12$ on each of its three edges). Find $x(E(S))$ and $x(\delta(S))$.

    The three joining edges, each of value $1$, are the only edges leaving the triangle.

    Inside: $3\cdot\tfrac12=1.5$. Leaving: three edges of value $1$, so $3$. Handshake check: $6=2\cdot1.5+3$. The cut form $3\ge2$ holds.

    Repeat the prism comparison with triangle edges costing $4$ and joining edges costing $2$ (all other edges cost $50$). Find the cost of the prism point and the cost of the best tour.

    Point: six half-weighted triangle edges and three joining edges. Tour: two joining edges and four triangle edges.

    Point: $6\cdot\tfrac12\cdot4+3\cdot2=12+6=18$. Tour: $2\cdot2+4\cdot4=20$.

    The support graph of an LP solution consists of two disconnected pieces. Is at least one subtour constraint violated?

    Take $S$ to be one of the pieces and compute $x(\delta(S))$.

    No edge with positive $x$ joins the pieces, so $x(\delta(S))=0\lt2$ for $S$ equal to one piece. The cut for $S$ is violated.

    In the four-city ATSP of this chapter, what is the cost of the tour $1\to2\to4\to3\to1$?

    Add $c_{12}$, $c_{24}$, $c_{43}$ and $c_{31}$.

    $2+6+3+8=19$.

    How many constraints (degree plus subtour) does the directed DFJ formulation have for $n=6$?

    The count is $2n+(2^n-n-2)$.

    $12+(64-6-2)=12+56=68$.

    • Treat $x^*$ as capacities and search for a cut below $2$; one min-cut call checks all subsets.
    • Test for disconnected components first; it is the cheapest check.
    • Believing that a point satisfying every SEC must be a tour (the prism is a counterexample).
    • Forgetting that the assignment relaxation of the ATSP gives cycle covers, not tours.
    1. The solver adds subtour cuts lazily; finding a violated one is a minimum-cut problem on the support graph with capacities $x^*_e$.
    2. The subtour LP bound is strong in practice, but its optimum can still be fractional (the prism); stronger cuts such as combs close what remains.
    3. The ATSP uses arc variables with $x(\delta^+(i))=x(\delta^-(i))=1$ and $x(A(S))\le|S|-1$; dropping the SEC leaves the assignment problem, whose solutions are cycle covers.

    A solver finds that the smallest cut of the support graph of $x^*$ has capacity $2$. What can you conclude?

    The solution is a tour.
    The prism has smallest cut $2$ but is not a tour.
    Every subtour constraint holds for $x^*$, but $x^*$ may still be fractional.
    The smallest cut is the worst case over all sets, so none is below 2.
    The LP is infeasible.
    A cut of capacity 2 is exactly what a tour has.

    To search for a violated SEC in a graph on $12$ cities by fixing city $1$ and testing each other city, how many max-flow computations are needed?

    $2^{11}$
    That would be checking every subset directly.
    $11$
    One max-flow from city 1 to each of the other 11 cities.
    $12!$
    The number of tours, not of flows.

    Why does the optimum of the assignment relaxation of the ATSP typically contain several small cycles?

    Because the assignment LP is fractional.
    Its LP is integral; the issue is a different one.
    Because the degree constraints do not link different cycles, and short cycles of nearby cities are cheap.
    Nothing forces the cycles to join; the SEC are what do that.
    Because the costs are asymmetric.
    Symmetric costs show the same effect.

    Which pair is equivalent for the ATSP under the degree constraints?

    $x(A(S))\le|S|-1$ and $x(\delta^+(S))\ge2$
    Check the right-hand side: the leaving flow only needs to be at least 1.
    $x(A(S))\le|S|-1$ and $x(\delta^+(S))\ge1$
    From $|S|=x(A(S))+x(\delta^+(S))$.
    $x(A(S))\ge|S|-1$ and $x(\delta^+(S))\le1$
    The inequalities point the wrong way.

    Compact formulations: MTZ and flow models, and how to compare them

    DFJ has exponentially many constraints. The Miller–Tucker–Zemlin (MTZ) model and the flow models use polynomially many constraints by adding extra variables: position labels in the first case, goods being delivered in the second.

    You must know how each forbids subtours, why MTZ is weaker than DFJ, and which models are as strong as DFJ. These are regular exam questions, and the same ideas (labels, flows) appear again in vehicle routing.

    It is like proving that two roads join: either you number the stops along the way (MTZ), or you show that a parcel can be delivered from the depot to each stop (flows).

    Comparing models with different variables

    DFJ uses only $x$; MTZ uses $x$ and labels $u$; flow models use $x$ and flows $y$. To say which is stronger we compare their LP regions in the same space, the $x$-space, by projection (Part 3): $\operatorname{proj}_x(Q)=\{x:(x,w)\in Q\text{ for some }w\}$. For a minimisation, a formulation whose projected LP region is smaller has a larger (better) LP bound, and branch and bound needs fewer nodes. The comparison below always means this.

    MTZ: label every city with its position

    City $1$ is the depot. Give every other city $i$ a number $u_i$ with $2\le u_i\le n$, meant to be the position of $i$ on the tour (the depot is position $1$). If the vehicle drives from $i$ to $j$ (both customers), then $j$ comes later: $u_j\ge u_i+1$.

    $$\begin{aligned}\min\ &\sum_{(i,j)\in A}c_{ij}x_{ij}\\ \text{s.t. }&x(\delta^+(i))=1,\ \ x(\delta^-(i))=1&&\forall i\in N\\ &u_i-u_j+1\le(n-1)(1-x_{ij})&&\forall i,j\in\{2,\dots,n\},\ i\ne j\\ &2\le u_i\le n&&\forall i\in\{2,\dots,n\}\\ &x_{ij}\in\{0,1\}.\end{aligned}$$

    The two cases of the label row.

    • If $x_{ij}=1$ the row reads $u_i-u_j+1\le0$, that is $u_j\ge u_i+1$: the label must rise by at least one along the arc.
    • If $x_{ij}=0$ it reads $u_i-u_j\le n-2$. Since all labels lie in $[2,n]$, the difference is at most $n-2$ anyway, so the row is always true: it is switched off. That is why $M=n-1$ is exactly the right big-$M$ (the smallest that switches the row off; Part D).

    Arcs into and out of the depot have no label row. This is what lets the counter "restart": the last customer has label $n$, but the arc back to the depot puts no condition on any label.

    Three customers $2,3,4$ form a cycle $2\to3\to4\to2$ that avoids the depot, and every arc of the cycle must increase the label by at least $1$. Can labels $u_2,u_3,u_4$ exist?

    Yes, if the labels are chosen big enough.
    Each step goes up, and after three steps you are back at the start. Try it with numbers.
    No; going once around the cycle would require a number to be at least $3$ larger than itself.
    That contradiction is the heart of the proof.

    Use the widget to see it. Choose "Two triangles" or "A 2-cycle and a 4-cycle", set labels with the sliders, and see that some arc always fails.

    Try it

    Start with "A single tour": every arc between customers goes up by $1$. Then choose a solution with a cycle that avoids the depot and try to find labels with the sliders that make every arc hold. Notice that you cannot, and read the sum in the readout.

    Examinable proof. Show that the MTZ constraints allow exactly the tours: (a) every tour has labels, (b) a solution of the degree constraints with a cycle that avoids city 1 has no labels.

    1. (a) Give each customer its position on the tour as its label. An arc between customers that is used raises the label by exactly $1$, so its row holds. An unused arc has $x_{ij}=0$ and its row is automatically true.

      So every tour satisfies all constraints.

    2. (b) The degree constraints force $x$ to be a union of disjoint directed cycles covering all cities. Suppose a cycle $C$ avoids city $1$. Every arc $(i,j)$ of $C$ has $x_{ij}=1$ and both ends are customers, so $u_j\ge u_i+1$.

      The label rows exist for all arcs between customers.

    3. Add these inequalities over all arcs of $C$. On the left each label appears once with $+$ and once with $-$, so the sum is $0$; on the right we get $|C|$. So $0\ge|C|\ge2$, which is false.

      This is the contradiction shown in the widget.

    4. Hence every cycle contains city $1$. Disjoint cycles that all contain city $1$ means there is exactly one cycle, a tour. $\blacksquare$

      So the integer solutions of MTZ are exactly the tours.

    Size

    MTZ has $n(n-1)$ binary variables, $n-1$ continuous label variables and $2n+(n-1)(n-2)$ constraints, in total $O(n^2)$. It needs no lazy constraints and can be handed directly to a MIP solver. The labels can be reused as arrival times or loads in extensions such as time windows.

    The price: MTZ is weaker than DFJ

    Take a directed cycle $C$ of customers. Rewrite each label row as $u_i-u_j+(n-1)x_{ij}\le n-2$ and add over the arcs of $C$. The labels cancel: $$(n-1)\,x(C)\le(n-2)|C|\quad\Longrightarrow\quad x(C)\le\Bigl(1-\frac1{n-1}\Bigr)|C|.$$ DFJ says $x(C)\le|C|-1$. Which is smaller? $|C|-\frac{|C|}{n-1}$ against $|C|-1$: since $|C|\le n-1$, the MTZ right-hand side is larger, with equality only when $|C|=n-1$. So MTZ is the looser inequality, and the larger $n$ is, the looser it gets.

    Five cities, depot $1$. Show a fractional point that MTZ allows but DFJ forbids.

    1. Put $x=\tfrac34$ on the three arcs $2\to3$, $3\to4$, $4\to2$; $x=\tfrac14$ on $1\to2$, $1\to3$, $1\to4$ and on $1\to5$; $x=\tfrac14$ on $2\to5$, $3\to5$, $4\to5$; and $x=1$ on $5\to1$.

      Check the degrees. City $2$: out $=\tfrac34+\tfrac14=1$, in $=\tfrac34+\tfrac14=1$. Cities $3,4$ the same. City $5$: in $=\tfrac14\cdot4=1$, out $=1$. Depot: out $=4\cdot\tfrac14=1$, in $=1$. All degrees are $1$.

    2. Set $u_2=u_3=u_4=2$ (and $u_5=2$). Each triangle arc has the row $2-2+1\le 4(1-\tfrac34)$, that is $1\le1$. Every other arc between customers has $x\le\tfrac14$ and the right side is at least $3$. All label rows hold.

      The point satisfies every MTZ constraint, so it lies in the MTZ LP.

    3. For $S=\{2,3,4\}$: $x(A(S))=3\cdot\tfrac34=2.25\gt|S|-1=2$. Equivalently, the arcs entering $S$ carry only $3\cdot\tfrac14=0.75\lt1$. The DFJ cut is violated.

      With $n=5$ the MTZ bound is $x(C)\le3\cdot\frac34=2.25$, exactly this point.

    Try it

    Move the sliders for the number of cities $n$ and the length $|C|$ of a short cycle. Read how much value on the cycle each model allows. Notice that DFJ is flat in $n$ while the MTZ allowance rises towards the whole cycle as $n$ grows.

    Go deeper: lifting MTZ (Desrochers–Laporte)

    Using the reverse arc improves the big-$M$: $u_i-u_j+(n-1)x_{ij}+(n-3)x_{ji}\le n-2$. If $x_{ij}=1$ it is the usual rule. If $x_{ji}=1$ then $u_i=u_j+1$ on a tour, so the left side is $1+(n-3)=n-2$: tight, no tour is cut off. If both are $0$ it is the usual switched-off row. On fractional points it removes some weak solutions, but it does not reach the strength of DFJ.

    Flow formulations: can goods reach every city?

    Imagine the vehicle leaves the depot loaded with goods, drops one unit at each customer, and returns empty. If a group of customers formed its own loop apart from the depot, no goods could ever reach it. Let $y_{ij}\ge0$ be the quantity carried on arc $(i,j)$.

    Add to the degree constraints on $x$: $$y(\delta^+(1))=n-1,\qquad y(\delta^-(i))-y(\delta^+(i))=1\ \ \forall i\in\{2,\dots,n\},\qquad y_{ij}\le(n-1)x_{ij}.$$ The depot sends out $n-1$ units, every customer keeps one (inflow minus outflow equals one), and goods travel only on used arcs.

    Careful: slide 20 writes the middle row as $y(\delta^+(i))-y(\delta^-(i))=1$. With $\delta^+$ meaning arcs leaving $i$, that says "outflow minus inflow equals one", i.e. each city creates a unit, and the model would be infeasible. The meaning is inflow minus outflow equals one, as written above.

    Why a subtour is impossible. Suppose $S\subseteq\{2,\dots,n\}$ is a cycle apart from the depot. Add the balance rows over $S$: flows on arcs inside $S$ cancel, leaving $y(\delta^-(S))-y(\delta^+(S))=|S|\gt0$. So some goods must enter $S$ from outside, on an arc $(a,b)$ with $y_{ab}\gt0$. That needs $x_{ab}\gt0$, but in an integer solution $b$ already has its one entering arc inside $S$. Contradiction.

    Multi-commodity (Claus–Wong). Give every customer $k$ its own commodity: one unit of commodity $k$ leaves the depot and is absorbed at $k$. The flow variables $y^k_{ij}$ obey conservation at all other cities, and the linking row is $y^k_{ij}\le x_{ij}$, with coefficient $1$ instead of $n-1$. Each commodity is a single unit, so the big-$M$ is $1$.

    Try it

    With "A single tour" check that the flow drops by $1$ at every customer. Then choose the cycle apart from the depot and move the slider for the flow on arc $2\to3$: try to make all three balances in the cycle equal $1$, and read the sum of the balances.

    Use the five-city fractional point of the previous example. Does the single-commodity flow model allow it? The multi-commodity model?

    1. Single commodity, $n-1=4$: set $y_{12}=y_{13}=y_{14}=y_{15}=1$ (each at its cap $4\cdot\tfrac14$), triangle flow $2$ on each of $2\to3$, $3\to4$, $4\to2$, and $0$ elsewhere.

      The depot sends $4$ units. Linking: $1\le4\cdot\tfrac14$ and $2\le4\cdot\tfrac34$.

    2. Balances: city $2$ has inflow $1+2=3$ and outflow $2+0=2$: net $1$ ✓. Cities $3,4$ the same. City $5$ has inflow $1$ and outflow $y_{51}=0$: net $1$ ✓.

      Every customer keeps one unit, so the point is feasible in the single-commodity LP.

    3. Multi-commodity: commodity $2$ needs one full unit to flow from the depot into $S=\{2,3,4\}$, but each arc carries at most $x_{ij}$. The arcs entering $S$ have total $x$ only $0.75$, so at most $0.75$ of a unit can enter.

      By max-flow/min-cut this is infeasible. Every set $S$ not containing the depot gives the constraint $x(\delta^-(S))\ge1$, which is exactly the DFJ cut.

    The comparison

    The multi-commodity LP projects exactly onto the DFJ LP: it has the same bound. The single-commodity flow model and MTZ project onto strictly larger regions (Padberg–Sung and later authors); both have a big-$M$ equal to $n-1$ (or $n_R-1$ in the Steiner variant, where $n_R$ is the number of required nodes). The lesson of the whole chapter: a big-$M$ weakens the LP bound, and a model with $M=1$ is as strong as it can be.

    modelvariablesconstraints, $n=10$constraints, $n=50$strength
    DFJ (directed)$n(n-1)$1,032$1.1\times10^{15}$strongest
    MTZ$n(n-1)+n-1$922,452weak
    GG single flow$2n(n-1)$1202,600weaker than DFJ
    CW multi flow$n^2(n-1)$920122,600same as DFJ

    So multi-commodity trades exponentially many constraints for a cubic number of variables ($900$ at $n=10$, $122{,}500$ at $n=50$). MTZ is the shortest to write and the easiest to extend (time windows reuse the labels as times), but it is only suitable for small instances. DFJ with lazy cuts scales best.

    $n=8$ cities and a directed cycle $C$ of $4$ customers. What is the largest value of $x(C)$ allowed by the label-eliminated MTZ inequality? (DFJ allows $3$.)

    Use $x(C)\le\bigl(1-\tfrac1{n-1}\bigr)|C|$.

    $\bigl(1-\tfrac17\bigr)\cdot4=\tfrac{24}{7}\approx3.43\gt3$.

    For $n=9$, for which cycle length $|C|$ do MTZ and DFJ allow the same value of $x(C)$?

    Set $(1-\tfrac1{n-1})|C|=|C|-1$.

    $|C|/(n-1)=1$, so $|C|=n-1=8$: the cycle that contains all customers.

    Single-commodity flow, $n=5$, the tour $1\to3\to5\to2\to4\to1$. How many units travel on arc $5\to2$?

    The depot sends $4$ units and each customer along the tour keeps one.

    Flows along the tour: $4,3,2,1,0$ on $1\to3$, $3\to5$, $5\to2$, $2\to4$, $4\to1$. So arc $5\to2$ carries $2$.

    How many flow variables $y^k_{ij}$ does the multi-commodity formulation have for $n=6$ cities (one commodity per customer, one variable per arc and commodity)?

    There are $n(n-1)$ arcs and $n-1$ commodities.

    $30\cdot5=150$.

    Which compact formulation has the same LP bound as DFJ?

    Look for the model whose big-$M$ equals $1$.

    Multi-commodity flow: its linking rows force $x(\delta^-(S))\ge1$ for every set avoiding the depot, which are the DFJ cuts.

    • Check the range of the labels against the big-$M$: if $u\in[2,n]$ then $M=n-1$.
    • Say which arcs have no label row (those touching the depot).
    • Claiming MTZ is as strong as DFJ because both are correct for integers.
    • Writing the flow balance with the wrong sign.
    1. MTZ labels cities by position; the row $u_i-u_j+1\le(n-1)(1-x_{ij})$ forces labels to rise along used arcs, so a cycle avoiding the depot is impossible.
    2. MTZ and single-commodity flow have big-$M$ $=n-1$ and are weaker than DFJ; the DFJ inequality is $|C|-1$ while MTZ allows $(1-\tfrac1{n-1})|C|$.
    3. Multi-commodity flow has linking coefficient $1$ and projects exactly onto the DFJ LP, at the cost of a cubic number of variables.

    In MTZ, why are the label rows written only for $i,j\in\{2,\dots,n\}$?

    The depot is visited twice.
    The depot is left once and entered once.
    The depot's label would clash with the return arc; leaving it out lets the counter restart at city $1$.
    Without the exception, the last customer could not return to the depot.
    The depot has no arcs.
    It has $n-1$ outgoing and incoming arcs, just no label row.

    Adding the MTZ rows around a cycle that avoids the depot gives which contradiction?

    $0\ge1$ only when the cycle has length 1.
    The length of the cycle is at least 2.
    $0\ge|C|$.
    The labels cancel; the right-hand sides add up to the length of the cycle.
    $|C|\ge n$.
    The length of the cycle does not need to reach $n$.

    Which statement is correct for the fractional point with $x=\tfrac34$ on a triangle of customers, $n=5$?

    DFJ allows it, MTZ forbids it.
    The triangle has $x(A(S))=2.25\gt2$.
    MTZ and single-commodity flow allow it, DFJ and multi-commodity flow forbid it.
    The inflow to the set is $0.75$: enough for $y\le4x$ (needs $\ge\tfrac34$) but not for $y\le x$.
    All four formulations allow it.
    Multi-commodity needs inflow at least 1.

    What is the main practical reason to prefer DFJ with lazy cuts over MTZ for large instances?

    DFJ has fewer variables.
    Their numbers of variables are similar; the difference is elsewhere.
    DFJ gives a much tighter LP bound, so branch and bound needs far fewer nodes.
    MTZ's big-$M$ allows large fractional values on short cycles.
    MTZ cannot be solved by a MIP solver.
    It can; it is just weak.

    Variants of the TSP, and heuristics with bounds

    Real routes are never a plain TSP: customers have opening hours, some can be skipped, the road network is not complete, customers come in clusters, or the service is on the streets instead of at the stops. Each twist changes the model in one clear way.

    The exam asks you to modify the TSP model for a new twist, and to find quick tours and lower bounds by hand. This chapter gives you both.

    It is like the difference between a bus timetable and a taxi: the same map, but the rules you must respect decide the whole model.

    TSP with time windows (TSPTW)

    Customer $i$ must be reached between times $a_i$ and $b_i$. Arriving early means waiting until $a_i$; arriving after $b_i$ is not allowed. Let $y_i$ be the time at which service at $i$ starts, $t_{ij}$ the travel time, and $0$ the depot. On the directed graph add to the degree constraints $$y_j\ge y_i+t_{ij}-M(1-x_{ij})\quad\forall i,\ j\ne0,\qquad a_i\le y_i\le b_i.$$ If $x_{ij}=1$ this says "start at $j$ no earlier than start at $i$ plus the drive"; the "$\ge$" allows waiting. If $x_{ij}=0$ the big-$M$ switches it off. It is MTZ in disguise: MTZ is the case $t_{ij}=1$.

    Subtours vanish for free. Add the rows around a cycle avoiding the depot: the $y$ cancel and $0\ge\sum t_{ij}\gt0$ if all travel times are positive. No SEC is needed. Choosing $M$: use $M_{ij}=\max(0,\,b_i+t_{ij}-a_j)$, the largest amount by which $y_i+t_{ij}$ can exceed $y_j$. Windows make the big-$M$ small, which is why this model is far better than plain MTZ.

    Try it

    The van leaves the depot at time $0$. Add the customers one at a time and read the arrival time, the waiting, and the windows. Find all orders that are feasible. Notice how few of the $24$ orders survive, and which customers must come first.

    Using the data of the widget (windows $A[8,13]$, $B[11,16]$, $C[6,9]$, $D[6,9]$; depot times $A3,B5,C4,D6$; $AB2,AC4,AD5,BC3,BD4,CD2$), is the order $D,C,B,A$ feasible, and what is $M_{AB}$?

    1. Depot to $D$: arrive $6$ (window $[6,9]$ ✓). $D\to C$: arrive $6+2=8$ ✓. $C\to B$: arrive $8+3=11$ (window $[11,16]$ ✓, no waiting). $B\to A$: arrive $11+2=13$ ($[8,13]$ ✓). $A\to$ depot: $13+3=16$.

      At each step compare the arrival with the window; wait if early, reject if late.

    2. The order $A,B,C,D$ fails: arrive at $A$ at $3$, wait until $8$; arrive at $B$ at $10$, wait until $11$; arrive at $C$ at $14\gt9$: too late.

      $C$ and $D$ close early, so they must be visited first.

    3. $M_{AB}=\max(0,b_A+t_{AB}-a_B)=\max(0,13+2-11)=4$.

      If $x_{AB}=0$ the row $y_B\ge y_A+2-4$ must be true for every $y_A\le13$, $y_B\ge11$, and indeed $y_A-2\le11\le y_B$.

    Prize-collecting TSP (optional customers)

    The vehicle need not visit every city. City $i$ gives a prize $w_i$ if visited, costs a penalty $p_i$ if skipped, and the total prize must be at least $U$. Let $y_i=1$ if $i$ is on the tour: $$\min\sum c_{ij}x_{ij}+\sum_i p_i(1-y_i)\ \text{ s.t. }\ \sum_{j\ne i}x_{ij}=y_i,\ \sum_{j\ne i}x_{ji}=y_i,\ \sum_iw_iy_i\ge U.$$ The subtour constraints must be conditional: $$x(A(S))\le\sum_{i\in S\setminus\{k\}}y_i+(1-y_l)\qquad\forall k\in S,\ l\in S^c,\ |S|\ge2.$$ If cities $k\in S$ and $l\in S^c$ are both visited, the tour must pass through both, so at most $\sum_{i\in S}y_i-1$ arcs lie inside $S$; if $y_l=0$ the term $(1-y_l)=1$ relaxes the row by one so that $S$ may hold the whole tour. An alternative adds self-loops $x_{ii}=1-y_i$ with cost $p_i$, making a skipped city "stay at home" and turning the model into an assignment-type model.

    Steiner TSP (roads that must be reused)

    On a road network, cities are not all joined directly, and the route may pass through the same node or road more than once; only a set $V_R$ of required nodes must be visited. Let $x_e\in\mathbb Z_+$ be the number of times edge $e$ is traversed: $$\min\sum_e c_ex_e\ \text{ s.t. }\ x(\delta(u))\text{ even }\forall u,\quad x(\delta(S))\ge2\ \ \forall S\text{ with }S\cap V_R\ne\emptyset\ne V_R\setminus S.$$ Even degrees make an Euler circuit possible (Part C); the cut rows keep the required nodes connected. To enforce evenness, write $x(\delta(u))=2z_u$ with an integer $z_u$.

    Revisiting can pay even when all cities are required. A Steiner TSP is the same as a plain metric TSP on the required nodes, using shortest-path distances.

    Three required cities $A,B,C$ with direct roads of length $7$ between them, and a non-required hub $H$ with roads of length $2$ to each. Compare the cheapest tour that uses only direct roads with the cheapest closed walk.

    1. Tour on direct roads: $A\to B\to C\to A$ costs $7+7+7=21$.

      Each city is visited once, but each side is long.

    2. Walk through the hub: $A\to H\to B\to H\to C\to H\to A$ costs $6\cdot2=12$.

      The hub is revisited three times, which the TSP would not allow, but it is much cheaper.

    3. Shortest path distances: $d_{AB}=d_{BC}=d_{AC}=\min(7,2+2)=4$. A TSP on the shortest-path complete graph gives $3\cdot4=12$, the same.

      So Steiner TSP reduces to a TSP on shortest-path distances.

    Generalised TSP (clusters)

    Cities are grouped into clusters $S_1,\dots,S_m$; the tour must visit exactly one city of each cluster. Using only arc variables: $$x(\delta^+(S_k))=x(\delta^-(S_k))=1\ \ \forall k,\qquad x(\delta^+(i))=x(\delta^-(i))\ \ \forall i,$$ plus subtour constraints on sets of clusters. The balance row at each city forces the arc leaving a cluster to start from the very city that was entered. If every cluster is a single city we recover the TSP. With $m$ clusters of $3$ cities the number of choices of representatives is $3^m$, each followed by an ordinary TSP on $m$ cities.

    Arc routing: the Chinese postman problem

    Now the streets must be traversed, not the stops: garbage collection, snow ploughing, meter reading. A connected graph has a closed walk using every street exactly once if and only if every intersection has an even number of streets (Euler, Part C). If some intersections have an odd number of streets, some streets must be repeated. A closed walk that covers all streets at least once and has least length is the Chinese postman problem.

    Let $x_{uv}$ be the number of times the walk goes from $u$ to $v$: $$\min\sum_{\{u,v\}\in E}c_{uv}(x_{uv}+x_{vu})\ \text{ s.t. }\ x_{uv}+x_{vu}\ge1\ \ \forall\{u,v\}\in E,\quad x(\delta^+(u))=x(\delta^-(u))\ \ \forall u,\quad x_{uv},x_{vu}\in\mathbb Z_+.$$ The objective sums over the undirected edges $E$ (each street once, with both directions), not over arcs; summing over a directed arc set would count every street twice.

    Algorithm (polynomial). (1) Find the odd-degree intersections; there is an even number of them. (2) Compute shortest-path distances between them. (3) Choose the cheapest way to pair them up (a minimum-cost perfect matching). (4) Repeat the streets along the paired shortest paths. (5) Take an Euler circuit. The directed postman problem is also polynomial; the rural postman (only some streets must be served) and capacitated arc routing are NP-hard.

    Try it

    The orange intersections have an odd number of streets. Try the three ways to pair them up and compare the lengths of the resulting closed walks. Find the cheapest pairing and see which streets it repeats.

    In the street network of the widget the streets total $29$ units, and the odd intersections are $2,3,6,7$. The three possible pairings cost $9$ (pair $2$–$3$ and $6$–$7$), $3$ ($2$–$6$ and $3$–$7$) and $11$ ($2$–$7$ and $3$–$6$). What is the length of the shortest closed walk covering every street?

    1. Cheapest pairing: $2$–$6$ (street length $1$) and $3$–$7$ (street length $2$), extra cost $3$.

      The shortest path between each pair is a single street; the other pairings use longer paths.

    2. The walk has length $29+3=32$.

      Repeating the two streets makes every degree even, so an Euler circuit exists.

    Quick tours and bounds

    Good tours are found by heuristics, and lower bounds come from relaxations; the gap between them is a certificate of quality. Our running data: seven cities at coordinates $1(0,2)$, $2(2,5)$, $3(2,0)$, $4(6,0)$, $5(1,3)$, $6(9,6)$, $7(9,3)$, with straight-line distances rounded to one decimal.

    dist.234567
    13.62.86.31.49.89.1
    25.06.42.27.17.3
    34.03.29.27.6
    45.86.74.2
    58.58.0
    63.0

    Nearest neighbour. Start at the depot and repeatedly go to the closest unvisited city, finally return. It is fast but short-sighted: the last cities may force a long return.

    Cheapest insertion. Start with a small tour (the depot and the city farthest from it). Repeatedly pick the unvisited city and the position in the tour where inserting it adds the least length, $c_{ik}+c_{kj}-c_{ij}$ for inserting $k$ between neighbours $i$ and $j$.

    2-opt. Take two tour edges $(a,b)$ and $(c,d)$, remove them and reconnect the pieces the other way, $(a,c)$ and $(b,d)$. The change in length is $c_{ac}+c_{bd}-c_{ab}-c_{cd}$. If it is negative keep the move; repeat until no pair of edges helps. In the plane, two edges that cross can always be uncrossed to shorten the tour.

    On the seven-city data, build the nearest-neighbour tour from city $1$ and improve it with 2-opt.

    1. From $1$ the closest is $5$ ($1.4$); from $5$ it is $2$ ($2.2$); from $2$ it is $3$ ($5.0$); from $3$ it is $4$ ($4.0$); from $4$ it is $7$ ($4.2$); from $7$ it is $6$ ($3.0$); back to $1$: $9.8$.

      At each step look in the row of the current city for the smallest entry among unvisited cities.

    2. Length: $1.4+2.2+5.0+4.0+4.2+3.0+9.8=29.6$.

      The long final edge $6\to1$ is typical of nearest neighbour.

    3. 2-opt: remove $(2,3)$ and $(6,1)$ and add $(2,6)$ and $(3,1)$. Change: $7.1+2.8-5.0-9.8=-4.9$.

      The long edge $6\to1$ is the one to attack.

    4. The new tour $1\to5\to2\to6\to7\to4\to3\to1$ has length $29.6-4.9=24.7$. This is optimal (a brute-force check of all $360$ tours confirms it).

      One 2-opt move recovered the whole $20\%$ excess; in general 2-opt ends at a local optimum, not always the global one.

    Try it

    Drag the cities, then step through nearest neighbour and cheapest insertion, and watch the dashed optimal tour. Press "New random cities" a few times. Notice how often each method is within a few percent and when it is not. Then use the 2-opt widget and compare.

    Try it

    Start from the tour in numbered order, apply the best 2-opt move step by step, and watch the tour untangle. Switch to the nearest-neighbour start and compare where each ends. Is the final tour always the optimum?

    Lower bounds from spanning trees

    A heuristic gives an upper bound; a lower bound proves how far from optimal you can be. Assume costs satisfy the triangle inequality ($c_{ik}\le c_{ij}+c_{jk}$).

    Examinable. Show that the cost of a minimum spanning tree $T$ is at most the optimal tour cost $\mathrm{OPT}$, and that the "double-tree" tour costs at most $2\,c(T)\le2\,\mathrm{OPT}$.

    1. Delete one edge from an optimal tour. What remains is a path through all cities, which is a spanning tree. Its cost is at most $\mathrm{OPT}$ (edge costs are non-negative).

      The cheapest spanning tree cannot cost more than this particular one, so $c(T)\le\mathrm{OPT}$.

    2. Double every edge of $T$. All degrees become even and the graph is connected, so it has an Euler circuit of cost $2c(T)$.

      Euler's theorem (Part C).

    3. Walk the circuit and skip every city already seen. By the triangle inequality, skipping never makes the walk longer, so the resulting tour has cost at most $2c(T)\le2\,\mathrm{OPT}$. $\blacksquare$

      So the double-tree heuristic is a 2-approximation on metric instances.

    On the seven-city data compute the minimum spanning tree, the 1-tree bound, the double-tree tour, and compare with the optimum $24.7$.

    1. MST (add the cheapest edge reaching a new city, starting from $1$): $1\text{–}5$ ($1.4$), $5\text{–}2$ ($2.2$), $1\text{–}3$ ($2.8$), $3\text{–}4$ ($4.0$), $4\text{–}7$ ($4.2$), $7\text{–}6$ ($3.0$). Cost $17.6\le24.7$.

      Six edges for seven cities.

    2. 1-tree bound: MST on cities $2,\dots,7$ only has cost $16.6$; add the two cheapest edges at city $1$ ($1.4$ and $2.8$): $20.8\le24.7$.

      A tour is a 1-tree (a path through the other cities plus two edges at city 1), so the cheapest 1-tree is a lower bound, and it is stronger than the plain MST bound.

    3. Double-tree tour, visiting the tree in depth-first order from $1$ with smaller labels first: $1,3,4,7,6,5,2$ with cost $2.8+4.0+4.2+3.0+8.5+2.2+3.6=28.3\le2\cdot17.6=35.2$.

      The guarantee is far from tight on this instance; the true gap is $28.3/24.7\approx1.15$.

    4. Cheapest insertion from $\{1,6\}$ adds $0.1$ (city $5$), $0.8$ ($2$), $2.2$ ($3$), $1.4$ ($7$), $0.6$ ($4$) to the starting length $19.6$: total $24.7$, again optimal.

      Insertion is usually better than nearest neighbour because it considers positions inside the tour.

    Try it

    Move the cities and read the lower bounds in the readout: the spanning tree, then the 1-tree, against the optimal tour. Look at the double-tree tour and the Christofides tour (the tree plus a cheapest matching of the odd-degree cities) and see how close each gets.

    Go deeper: Christofides' 3/2-approximation

    Instead of doubling the whole tree, fix only its odd-degree cities. Take a minimum-cost perfect matching $M$ on them and join $T\cup M$ (all degrees even), take an Euler circuit and shortcut. Why $c(M)\le\frac12\mathrm{OPT}$: shortcut an optimal tour to visit only the odd-degree cities; it is an even cycle through them whose edges split into two perfect matchings, and the cheaper one costs at most $\frac12\mathrm{OPT}$. So the result costs at most $c(T)+c(M)\le\frac32\mathrm{OPT}$. It combines Euler (Part C) with the matching idea of the Chinese postman problem. In practice local search such as 2-opt and Lin–Kernighan produces better tours.

    With the time-window data of this chapter, the van drives $D,C,B,A$ and leaves at time $0$. At what time does it return to the depot?

    Take the maximum of arrival time and window opening at each stop.

    $D$ at $6$, $C$ at $8$, $B$ at $11$, $A$ at $13$, depot at $13+3=16$.

    For the same data compute $M_{BA}=\max(0,\,b_B+t_{BA}-a_A)$.

    $b_B=16$, $t_{BA}=2$, $a_A=8$.

    $16+2-8=10$.

    A street network has total length $29$. After the cheapest pairing of its odd intersections, the extra repeated streets have length $3$. How long is the shortest closed walk covering all streets?

    Total length plus the extra length.

    $29+3=32$.

    On the seven-city data, by how much does the 2-opt move that removes $(2,3)$ and $(6,1)$ and adds $(2,6)$ and $(3,1)$ change the tour length? (A negative number means shorter.)

    New edges minus old edges: $c_{26}+c_{31}-c_{23}-c_{61}$.

    $7.1+2.8-5.0-9.8=-4.9$.

    A generalised TSP has $4$ clusters of $3$ cities each. How many different ways are there to choose one city per cluster and then a tour on the four chosen cities?

    $3^4$ choices of representatives, times the number of tours on $4$ cities.

    $3^4=81$ and $(4-1)!/2=3$ tours: $81\cdot3=243$.

    • Start every new twist by asking: which variable is new (time, visited yes/no, traversal count) and what does it do to the subtour constraints?
    • Quote a lower bound together with the tour you compare it to.
    • Summing the Chinese postman objective over arcs instead of the undirected edges $E$.
    • Quoting the 2-approximation guarantee for non-metric costs.
    Where we are in the story

    Kaveri Courier's owner can now order the stops of one van, test the route against a lower bound, and adapt the model when customers have opening hours or may be skipped. One van is rarely enough. In Part 6 several vans leave the same depot with a weight limit each, so the owner must also decide who rides with whom: the packing side of Ch. 3.1 and the routing side of this part are solved together.

    1. Each variant changes the plain TSP in one way: time variables with a tight big-$M$ (TSPTW), a visit indicator and conditional subtour rows (prize collecting), integer traversal counts with even degrees (Steiner), cluster degrees (generalised), parity repair by a matching (Chinese postman).
    2. Nearest neighbour, cheapest insertion and 2-opt give tours in moments; 2-opt untangles crossings and ends at a local optimum.
    3. A minimum spanning tree and, better, a 1-tree are lower bounds; doubling the tree gives a tour within a factor $2$ on metric instances.

    Why does the TSPTW model not need subtour constraints when travel times are positive?

    Because the windows already force a single tour.
    The windows restrict times, but the argument is about adding the time rows.
    Adding the time rows around a cycle that avoids the depot gives $0\ge$ the cycle's travel time $\gt0$.
    The start times cancel, as in MTZ.
    Because $M$ is large.
    A large $M$ only weakens the LP.

    In the Steiner TSP we write $x(\delta(u))=2z_u$ with $z_u$ integer. What does this enforce?

    That every node is visited exactly once.
    The model allows revisits.
    That every node has an even number of traversed edge-ends, so an Euler circuit can exist.
    $2z_u$ is even for every integer $z_u$.
    That all required nodes are connected.
    That is the job of the cut rows.

    Why is the minimum spanning tree cost at most the optimal tour cost?

    Because a tour is a tree.
    A tour contains a cycle.
    Deleting one edge of an optimal tour leaves a spanning tree of cost at most the tour cost.
    The MST is the cheapest of all spanning trees.
    Because the triangle inequality holds.
    The statement holds for any non-negative costs.

    The Chinese postman problem is polynomial but the rural postman problem is NP-hard. What changes?

    Only a subset of streets must be served, so the cheapest connection of those streets is a Steiner-type choice.
    Correct: parity repair is no longer a single matching problem.
    The rural version has directed streets.
    Direction is a separate variation.
    The rural version must use each street exactly once.
    Repeats are allowed in both.

    A tour on $10$ cities visits a set $S$ of $6$ cities in two stretches. What are $x(E(S))$ and $x(\delta(S))$?

    $5$ and $2$
    That is one stretch; here the tour enters and leaves $S$ twice.
    $4$ and $4$
    $x(E(S))=6-2=4$; the handshake rule gives $12=2\cdot4+x(\delta(S))$, so $4$.
    $6$ and $0$
    That would mean $S$ is a separate cycle.

    Why can a solver check all $2^{n-1}$ subtour constraints with only $n-1$ max-flow computations?

    Each max-flow checks the constraints of one city only.
    One flow tests many sets at once.
    A violated constraint is a cut of capacity below $2$ in the support graph, and every cut separates city 1 from at least one other city.
    The smallest cut separating city 1 from $t$ is found by max-flow/min-cut; the minimum over all $t$ is the global minimum cut.
    Because the number of tours is only $n-1$.
    It is $(n-1)!/2$.

    With $n=10$, for an arc $(i,j)$ between customers that is not used ($x_{ij}=0$), the MTZ row reads $u_i-u_j\le\ ?$ Why is it harmless?

    $u_i-u_j\le9$; it is harmless because labels are at most $10$.
    Recompute: the right side is $(n-1)-1$.
    $u_i-u_j\le8$; it is harmless because labels lie in $[2,10]$, so the difference is at most $8$ anyway.
    $(n-1)(1-0)-1=8=n-2$, the largest possible difference.
    $u_i-u_j\le0$; it forces equal labels.
    That is the case $x_{ij}=1$ with the sign reversed.

    A connected street network has $6$ intersections with an odd number of streets. How many odd intersections must be paired up in the postman algorithm, and into how many pairs?

    6 intersections, 6 pairs
    Each pair uses two intersections.
    6 intersections, 3 pairs
    Odd intersections come in pairs; 6 of them make 3 pairs.
    3 intersections, 3 pairs
    The 6 odd intersections are all paired.

    A forcing row $y\le Mx$ with binary $x$: which choice of $M$ gives the best LP bound?

    A very large $M$, to be safe.
    A large $M$ lets $x$ be nearly 0 with $y$ positive.
    The smallest $M$ that is still valid.
    This is the same principle that makes MTZ weaker than multi-commodity flow.
    $M=0$.
    That would force $y=0$ always.

    Formulation A has LP bound $21.4$, formulation B has $27.9$, for the same minimisation IP with optimum $29$. Which statement is correct?

    A is stronger; its bound is smaller.
    For a minimisation a larger lower bound is better.
    B is stronger on this instance; its gap to the optimum is $1.1$ against $7.6$.
    The bound closer to the optimum prunes more of the branch-and-bound tree.
    They are equally strong, since both are below $29$.
    Strength is about how close to $29$ the bound gets.

    Lecture 12 (numbered Lecture 6 in earlier versions of the slides) asks a simple question with a hard answer: given a depot, a fleet of vans of limited capacity and a list of customers, which van visits whom, and in what order, at least cost? The part builds the main integer-programming models of the capacitated vehicle routing problem, compares how strong their LP relaxations are on one small instance, tours the variants of Lecture 12 (time windows, pickup and delivery, backhauls, several echelons, depot location), and ends with the standard heuristics and with the CVRP project of this course as a case study.

    You need: Part 3 (integer programmes, bin packing in Ch. 3.1, LP bounds and strong formulations), Part 4 (branch and bound and its pruning rules, Ch. 4.2), Part 5 (the TSP: degree constraints and subtour cuts in Ch. 5.1, MTZ in Ch. 5.3, time windows in Ch. 5.4), Part 2 (dual prices and reduced costs, for column generation) and Part D (set partitioning, big-M).

    The capacitated VRP and its two-index model

    The capacitated vehicle routing problem (CVRP) is the TSP with a weight limit: several vans leave one depot, each van does one closed round trip, every customer is served exactly once, and no van carries more than its capacity.

    Almost every delivery business, from parcels to milk rounds, is a CVRP with extras. Many of the best exact solvers of the last two decades are built on the model of this chapter, and it is the model used in the course project.

    It is like dividing a pile of deliveries among a few couriers: first decide who takes which parcels, then decide the best order for each courier.

    Where we are in the story

    Kaveri Courier, our Bengaluru firm, has so far met three separate steps. Part 3 chose the depot and the loads (bin packing, Ch. 3.1, is the capacity side), Part 4 showed how a solver finds and proves such answers, and Part 5 routed a single van through its customers (the TSP, Ch. 5.1, is the routing side). Now the owner must do all vans together: split the customers among several vans of capacity $C$ and route each van, which is the CVRP.

    What is being asked

    A depot (numbered $0$) stores goods. There are $n$ customers $1,\dots,n$, and customer $i$ wants an amount $d_i$ (its demand). A fleet of $K$ identical vans, each of capacity $C$, starts and ends at the depot. Travelling between two locations $i,j$ costs $c_{ij}$ (distance, time or money), and we assume $c_{ij}=c_{ji}$ and $d_i\le C$ for every customer.

    A route is a closed trip depot $\to$ customers $\to$ depot. A plan is a set of routes. It is feasible when every customer lies on exactly one route and the demands on each route add up to at most $C$. The goal is a feasible plan of least total cost.

    Given a graph $G=(V,E)$ with depot $0$ and customers $V_c=V\setminus\{0\}=\{1,\dots,n\}$, costs $c_e$ on edges, demands $d_i$, $K$ vehicles of capacity $C$: find a partition of the customers into at most $K$ groups, each of total demand at most $C$, together with a cheapest closed tour through the depot and each group. Minimise the total tour cost.

    Notation for this part
    $V=\{0\}\cup V_c$
    depot $0$ and the customers $1,\dots,n$
    $d_i,\ d(S)$
    demand of customer $i$; total demand $\sum_{i\in S}d_i$ of a set $S$
    $K,\ C$
    number of vehicles; capacity of one vehicle
    $\delta(S)$
    cut set: edges with exactly one end in $S$
    $E(S)$
    edges with both ends in $S$
    $x(F)$
    $\sum_{e\in F}x_e$, the total value of $x$ on an edge set $F$
    $r(S)$
    fewest vehicles that can carry all the demand of $S$
    Running example: the firm's day

    This is one delivery day of Kaveri Courier: one depot at $(10,10)$ and eight customers. Costs are straight-line distances. The van capacity is $C=10$ and total demand is $35$. We use this instance in all four chapters.

    customer $i$12345678
    position(4,16)(7,18)(15,17)(17,12)(16,4)(9,3)(3,6)(2,11)
    demand $d_i$66634253

    Total demand is $35$ and one van carries $10$. Looking at total weight alone, how few vans could possibly serve all eight customers? (Demands cannot be split between vans.)

    $3$, because $35/10=3.5$ rounds down.
    Three vans carry at most $30$, which is less than $35$.
    At least $4$, since $\lceil 35/10\rceil=4$; whether four really suffice depends on how the whole demands pack.
    Weight gives only a lower bound. For this instance four vans do suffice (the widget will show how), but for other numbers rounding up is not enough.
    Exactly $35$, one per unit of demand.
    A van serves many customers on one trip.
    Try it

    Tap a customer (or its button) to give it to van 1, 2, 3 or 4; the best tour of each van is drawn and priced automatically. Aim for a feasible plan with four vans, then try to beat it. Press "Show an optimal plan" to compare. Notice that overloading a van is flagged and that the cheapest-looking assignment is often infeasible.

    How many vans are needed: the function $r(S)$

    Capacity limits are what separate the CVRP from the TSP. To state them we need the number of vans a group of customers requires.

    For a set $S$ of customers, $r(S)$ is the smallest number of vans that can carry the demands of $S$ with no demand split. It is the answer to a bin-packing problem (Ch. 3.1): items are the demands $d_i$, $i\in S$, bins have size $C$, and we minimise the number of bins used. (Lecture 3 and the recap on slide 3 of Lecture 12 write this objective as a maximisation by mistake; bins are to be minimised.) A quick lower bound is $r(S)\ge\lceil d(S)/C\rceil$, because $r$ vans carry at most $rC$.

    Careful: $\lceil d(S)/C\rceil$ can be strictly smaller than $r(S)$. In the running example $S=\{1,2,3\}$ has $d(S)=18$ and $\lceil 18/10\rceil=2$, but any two of these customers together weigh $12>10$, so each needs its own van: $r(S)=3$. Computing $r(S)$ is itself an NP-hard problem, which is why solvers sometimes settle for the cheap bound.

    Two special cases show why the CVRP is hard (it is strongly NP-hard). If one van has unlimited capacity ($K=1$, $C=\infty$), the CVRP is the TSP of Ch. 5.1. If all costs are zero, only the packing remains, and the CVRP contains bin packing. The VRP is the TSP and bin packing glued together.

    Building the two-index model

    Take a binary variable for every edge: $x_e=1$ if some van drives along edge $e$ and $0$ otherwise. An edge to the depot is special: a van serving a single customer $i$ drives out and back along the same edge, so $x_{0i}$ may be $0$, $1$ or $2$. The model has three groups of constraints.

    • Degrees. Each customer is entered once and left once: $x(\delta(i))=2$. The depot is entered and left once per van: $x(\delta(0))=2K$.
    • Capacity cuts. For every non-empty set $S$ of customers, at least $r(S)$ vans must visit $S$, and each visit crosses the boundary of $S$ twice (in and out): $x(\delta(S))\ge 2r(S)$.
    • Integrality. $x_e\in\{0,1\}$ for customer-customer edges and $x_{0i}\in\{0,1,2\}$.
    $$\begin{aligned}\min\ &\sum_{e\in E}c_e x_e\\ \text{s.t. }&x(\delta(0))=2K\\ &x(\delta(i))=2 &&\forall\, i\in V_c\\ &x(\delta(S))\ge 2\,r(S) &&\forall\, \emptyset\ne S\subseteq V_c\\ &x_e\in\{0,1\}\ (e\in E(V_c)),\quad x_{0i}\in\{0,1,2\}.\end{aligned}$$

    The third family is called the rounded capacity cuts (the "capacity-cut constraints" of the slides). One family does two jobs: it forces enough vans through a heavy set of customers, and it stops loops that do not reach the depot, because such a loop would have $x(\delta(S))=0$.

    Try it

    Pick a plan with the chips, choose a set $S$ by tapping customers, and compare the number of used edges leaving $S$ (red) with the demand $2r(S)$. Start with the "Detached cycle" and $S=\{1,2,3\}$. Then try "Fractional blend" and press "Find the most violated cut". Notice that $2\lceil d(S)/C\rceil=4$ would be met by the blend, while the true $2r(S)=6$ is not.

    Three plans on the running example all satisfy the degree constraints with $K=4$. Show with one cut that each of the first three is not an allowed plan, and check the fourth. (a) A loop $1\!-\!2\!-\!3\!-\!1$ that never touches the depot, with four vans serving customers 4–8; (b) one van doing $0\!-\!1\!-\!2\!-\!3\!-\!0$, three more vans serving the others; (c) half of plan (b) plus half of the optimal plan; (d) the optimal plan.

    1. Take $S=\{1,2,3\}$. Its demand is $6+6+6=18$, and $r(S)=3$, so the cut demands $x(\delta(S))\ge 6$.

      All three customers have demand 6, and two of them exceed the capacity 10, so each needs its own van.

    2. (a) No edge leaves $S$, so $x(\delta(S))=0<6$. The cut is violated by $6$.

      A loop disconnected from the depot is exactly a set with nothing crossing its boundary.

    3. (b) The edges leaving $S$ are $0\text{-}1$ and $3\text{-}0$, so $x(\delta(S))=2<6$: violated by $4$. The van carries $18>10$.

      One round trip crosses the boundary twice, so it can only pay for one van, but this set needs three.

    4. (c) The blend crosses $S$ with value $\tfrac12\cdot 2+\tfrac12\cdot 6=4<6$: violated by $2$, although all degrees are right. Using $\lceil 18/10\rceil=2$ would ask only for $4$ and let it pass.

      This is why the true $r(S)$ (a bin-packing value) is used, and why an LP with only degree constraints would happily return such a blend.

    5. (d) The optimal plan crosses $S$ through six edges ($0\text{-}1$, $1\text{-}8$, $0\text{-}2$, $2\text{-}5$, $0\text{-}3$, $3\text{-}4$), so $6\ge6$ holds with equality: each of the three customers has a van to itself.

      Equality means the cut is tight; the plan cannot use fewer vans on this set.

    Show that the cut $x(\delta(S))\ge 2r(S)$ is equivalent to the "subtour" form $x(E(S))\le |S|-r(S)$, which is the form familiar from the TSP of Ch. 5.1.

    1. Add the degree constraints over all $i\in S$: $\sum_{i\in S}x(\delta(i))=2|S|$.

      Each customer has degree 2.

    2. On the left, an edge with both ends in $S$ is counted twice and an edge leaving $S$ once, so $\sum_{i\in S}x(\delta(i))=2x(E(S))+x(\delta(S))$.

      Count the ends of the used edges that lie in $S$.

    3. Hence $x(\delta(S))=2|S|-2x(E(S))$. Substituting into $x(\delta(S))\ge 2r(S)$ gives $2|S|-2x(E(S))\ge 2r(S)$, that is, $x(E(S))\le |S|-r(S)$.

      All steps are reversible, so the two forms are equivalent.

    4. Check on $S=\{1,2,3\}$: $|S|-r(S)=3-3=0$, so no edge may join two of them. For a one-van set ($r=1$) it says $x(E(S))\le|S|-1$, the TSP subtour bound.

      The TSP is the special case $r(S)=1$ for every $S$.

    Go deeper: unused vans, fixed costs, directed form, load variables

    Unused vans. If $K>r(V_c)$, writing $x(\delta(0))=2K$ forces every van to leave, which can raise the cost. On the running example the cheapest plan with exactly $4,5,6,7,8$ routes costs $98.71$, $99.04$, $107.53$, $118.02$, $129.19$. Replace the depot equation by "$\le 2K$" to allow idle vans. A fixed cost per used van can be added to the depot edges.

    Directed form. With arcs, the slides use $x(\delta^+(i))=x(\delta^-(i))=1$ and $x(\delta^+(S))\ge r(S)$. A feasible plan uses $n+K$ arcs, which is how one shows the equivalence there.

    Load variables. Instead of exponentially many cuts, one may add a load $u_i\in[d_i,C]$ for each customer with $u_j\ge u_i+d_j$ whenever arc $(i,j)$ is used (written with a big-M). A loop without the depot would need the loads to grow forever around the loop, which is impossible. Like MTZ in Ch. 5.3, this is compact but its LP relaxation is weak (Chapter 6.2 gives numbers).

    Seven customers each demand $5$ and the capacity is $C=12$. What is $r(S)$ for the set of all seven?

    How many demands of $5$ fit into one van of capacity $12$?

    Two demands fit ($10\le12$) but three do not ($15>12$). Seven items at two per van need $\lceil 7/2\rceil=4$ vans. The bound $\lceil 35/12\rceil=3$ is too small.

    Customers $1,\dots,4$, $K=2$. The plan uses the edges $0\text{-}1$, $1\text{-}2$, $2\text{-}0$, $0\text{-}3$, $3\text{-}4$, $4\text{-}0$ (each once). Compute $x(\delta(S))$ for $S=\{2,3\}$.

    Count used edges with exactly one end in $S$. List the edges that touch $2$ or $3$ first.

    $1\text{-}2$ (end 2 in $S$), $2\text{-}0$, $0\text{-}3$ and $3\text{-}4$ cross; $0\text{-}1$ and $4\text{-}0$ do not touch $S$. So $x(\delta(S))=4$.

    A plan contains a loop $1\text{-}2\text{-}3\text{-}1$ that does not touch the depot. The demands are $2,3,4$ and $C=10$. Is the capacity cut for $S=\{1,2,3\}$ violated?

    Find $r(S)$ first, then compare $2r(S)$ with the number of edges leaving $S$.

    $d(S)=9\le10$, so $r(S)=1$ and the cut asks for $x(\delta(S))\ge2$. The loop has no edge leaving $S$: $0<2$. Violated, even though the load is small: the cut also removes disconnected loops.

    Five customers each demand $4$ and $C=10$. What is the smallest number of vans $K$ for which a feasible plan exists?

    Two customers fit in a van; can three? Compare with $\lceil 20/10\rceil$.

    $4+4=8\le10$ but $4+4+4=12>10$, so two customers per van, and $\lceil 5/2\rceil=3$ vans. The weight bound $\lceil20/10\rceil=2$ is not achievable.

    • Use the true $r(S)$ (or at least say that $\lceil d(S)/C\rceil$ is a weaker substitute).
    • Check any proposed plan against a few cut sets: a disconnected loop and the heaviest group.
    • Assuming that "degree 2 everywhere" gives routes through the depot.
    • Forgetting that $x_{0i}$ can equal $2$ for a one-customer route.
    1. The CVRP picks routes and customer groups together: it is a TSP whose total load per route is limited, so it contains both the TSP and bin packing.
    2. The two-index model uses one binary per edge, degree constraints and rounded capacity cuts $x(\delta(S))\ge 2r(S)$; the cuts forbid both overloaded routes and loops that miss the depot.
    3. $r(S)$ is a bin-packing number, never smaller than $\lceil d(S)/C\rceil$ and sometimes larger; the family of cuts has $2^n-1$ members, so it is added only when violated.

    Which statement about the cut $x(\delta(S))\ge 2r(S)$ is correct?

    It only limits the load of routes and says nothing about loops.
    A loop that never reaches the depot has $x(\delta(S))=0$ for its customer set.
    It limits the load and also forbids loops that miss the depot.
    Both an overloaded group and a detached loop leave too few edges crossing the boundary of $S$.
    It only holds for sets $S$ that form a single route.
    It is written for every non-empty set of customers.

    Four customers each demand $6$ and $C=10$. What is $r(S)$ for all four?

    $3$, from $\lceil 24/10\rceil$.
    That is only the weight bound; check whether two demands of $6$ can share a van.
    $4$, one van per customer.
    Two sixes weigh $12>10$, so no two share a van, although the weight bound only says 3.
    $2$, since $2\times10\ge 24$.
    Two vans carry at most $20<24$.

    Why is the two-index family of capacity cuts not written out in full?

    The cuts are redundant with the degree constraints.
    A plan satisfying only the degrees can still be disconnected or overloaded.
    Gurobi cannot read constraints with $r(S)$.
    The problem is size, not syntax.
    There are $2^n-1$ of them, and only a few ever matter, so they are generated when violated.
    This is the same idea as the lazy subtour cuts of Part 5.

    In the model, what does a value $x_{0i}=2$ mean?

    Customer $i$ is visited twice.
    It is visited once; the edge is used in both directions.
    Two vans use the same road in the same direction.
    Think of one van serving only customer $i$.
    One van goes depot $\to i\to$ depot.
    Its round trip uses the edge twice, and customer $i$ still has degree 2.

    Three-index and set-partitioning models, and which LP is strongest

    The two-index model forgets which van drives where. The three-index model remembers it, and the set-partitioning model chooses whole routes instead of edges.

    These models differ greatly in size and in the strength of their LP relaxations, and Part 3 taught how to compare LP bounds, while Part 4 showed that a stronger bound prunes more of the search tree. The comparison here is the heart of the course project.

    It is like three ways of writing a timetable: record each leg, record each leg for each driver, or list complete shifts and choose which ones to run.

    Three-index (vehicle-flow) model

    Now we use arcs $(i,j)\in A$ of a directed graph on $N=\{0,\dots,n\}$ and give every van $k=1,\dots,K$ (with capacity $C_k$) its own variables. The binary $x^k_{ij}=1$ if van $k$ drives arc $(i,j)$, and $y^k_i=1$ if van $k$ serves location $i$.

    $$\begin{aligned}\min\ &\sum_{k=1}^{K}\sum_{(i,j)\in A}c^k_{ij}\,x^k_{ij}\\ \text{s.t. }&\sum_{k}y^k_i=1 &&\forall\, i\in V_c\\ &y^k_0=1 &&\forall\, k\\ &x^k(\delta^+(i))=x^k(\delta^-(i))=y^k_i &&\forall\, i\in N,\ \forall k\\ &\sum_{i\in V_c}d_i\,y^k_i\le C_k &&\forall\, k\\ &x^k(\delta^+(S))\ge y^k_h &&\forall\, S\subseteq V_c,\ h\in S,\ \forall k\\ &x^k_{ij},\,y^k_i\in\{0,1\}.\end{aligned}$$

    Read it as: every customer gets exactly one van; whoever enters a location leaves it; a van's load fits; and if van $k$ serves $h\in S$, then some arc of van $k$ leaves $S$ (so $h$ is connected to the depot).

    The cost is indexed by the van, $c^k_{ij}$, so a small electric van and a large diesel truck can have different capacities and different costs. This is the way to model a heterogeneous fleet, which the two-index model cannot do because it never says which van drives which edge. The price is size: $K$ copies of every variable, and symmetry. If the vans are identical, relabelling them gives $K!$ solutions that are the same plan (for $K=4$, $24$ copies), which slows branch and bound.

    The slides also list a commodity-flow family: extra continuous variables that carry the remaining load along the arcs, so capacity logic needs no cuts. The project of Chapter 6.4 uses such a multi-commodity flow model as comparison.

    Try it

    Move the sliders and read the variable counts of each model. Start at $n=20$, $K=5$, four customers per route. Counts use the symmetric (one variable per edge) version of each model. Notice which model has few variables but exponentially many rows, and which has few rows but exponentially many columns.

    For $n=20$ customers, $K=5$ vans and routes of at most $4$ customers, count the variables of the undirected two-index model, the three-index model, and the set-partitioning model (one column for each set of at most 4 customers).

    1. Two-index: one variable per edge of the complete graph on $21$ locations: $\binom{21}{2}=210$.

      $n$ customer-depot edges plus $\binom{n}{2}$ customer-customer edges, $20+190$.

    2. Three-index: $x$ has $5\cdot210=1050$ variables and $y$ has $5\cdot21=105$, in total $1155$.

      Every variable is copied for each van.

    3. Set partitioning: $\binom{20}{1}+\binom{20}{2}+\binom{20}{3}+\binom{20}{4}=20+190+1140+4845=6195$.

      A column is a set of customers; the best order for that set is a TSP that can be solved beforehand, so order is not a variable.

    4. Rows: two-index has $1+n=21$ plus up to $2^{20}-1=1{,}048{,}575$ capacity cuts; set partitioning has only $n+1=21$.

      The exponential count moves from rows (two-index) to columns (set partitioning) as the size of routes grows.

    Set partitioning: choose whole routes

    Let $J$ be the set of all feasible routes (sets of customers whose demand fits in a van, with the best order for them). Route $j$ has cost $c_j$ and a 0/1 incidence $a_{ij}=1$ if it serves customer $i$. The binary $x_j=1$ means route $j$ is run. This is the set-partitioning idea of Part D applied to routes.

    $$\min\ \sum_{j\in J}c_jx_j\quad\text{s.t.}\quad \sum_{j\in J}a_{ij}x_j=1\ \ \forall\, i\in V_c,\qquad \sum_{j\in J}x_j=K,\qquad x_j\in\{0,1\}.$$

    Every customer is covered exactly once and exactly $K$ routes are used (use "$\le K$" if vans may stay home).

    Three advantages follow. The cost $c_j$ of a route need not be a sum of edge costs, so overtime, driver breaks or a different cost per vehicle type fit in. Time windows and similar rules are hidden inside the definition of "feasible route" and need no big-M. And the LP relaxation is typically strong. The disadvantage is the number of columns.

    If the costs obey the triangle inequality, skipping a customer on a route never costs more, so one may replace "$=1$" by "$\ge1$": the covering version. Its advantage is that only maximal routes need to be listed (a route $0\text{-}4\text{-}0$ is not needed if $0\text{-}4\text{-}10\text{-}5\text{-}0$ is a route), and its dual variables are better behaved. A customer served twice in the answer is repaired by short-cutting.

    Try it

    All 36 routes that respect the capacity are listed as (customers · load · cost). Tick routes until every customer is covered exactly once, or press "Show the optimum". Notice that covering a customer twice or missing one is flagged, and that many partitions exist but few are cheap.

    Column generation: never write all the columns

    With many thousands of routes, the LP relaxation is solved with only a few columns present. The idea, which builds on the duality of Part 2, is a loop.

    1. Start with a small set of routes that makes the LP feasible (for example one route per customer): the restricted master problem.
    2. Solve it and read the dual prices: $\pi_i$ for the cover row of customer $i$ (and $\mu$ for the "$K$ routes" row, if present).
    3. Pricing. The reduced cost of a route is $\bar c_j=c_j-\sum_{i}a_{ij}\pi_i-\mu$. Search all feasible routes for one with $\bar c_j<0$.
    4. If one exists, add it as a new column and go to step 2. If none exists, the current LP solution is optimal for the full LP.

    The pricing step is a shortest-path problem with a capacity (resource) limit, and for routes that may not repeat customers it is itself NP-hard, so codes use relaxed route families and clever dynamic programmes (the papers in Project/Candidate_Papers call them ng-routes and similar). Once the LP is solved, branching on fractional routes gives branch and price, with the capacity cuts added as well in the state-of-the-art "branch-cut-and-price".

    On the running example start with the eight one-customer routes $0\text{-}i\text{-}0$ (cost $2c_{0i}$) and no route-count row. Find the duals, and price the route $\{1,8\}$ and the best route overall.

    1. The eight columns form a basis and each row has a single column, so $\pi_i=2c_{0i}$: $\pi=(16.97,\,17.09,\,17.20,\,14.56,\,16.97,\,14.14,\,16.12,\,16.12)$. The master objective is $129.19$.

      The dual price of a customer is what serving it currently costs.

    2. Route $0\text{-}1\text{-}8\text{-}0$ costs $c_{01}+c_{18}+c_{80}=8.49+5.39+8.06\approx21.93$, and $\pi_1+\pi_8=16.97+16.12=33.09$. So $\bar c=21.93-33.09=-11.16$.

      Negative: adding this route lowers the objective.

    3. Observe $\bar c=c_{18}-c_{01}-c_{08}=-(c_{01}+c_{08}-c_{18})$, the negative of the saving of Chapter 6.4.

      So the first pricing round of column generation on these columns is the savings list of the Clarke-Wright heuristic.

    4. Pricing all $36$ routes gives $27$ with negative reduced cost. The best is $0\text{-}6\text{-}7\text{-}8\text{-}0$ with cost $26.94$ and $\bar c\approx-19.45$. It enters; the master is re-solved, new duals appear, and so on.

      The routes that look best at the current prices are the ones the LP wants.

    How strong are the LP relaxations?

    Part 3 (Ch. 3.2) showed that for a minimisation a stronger formulation has a higher LP bound, and the bound-pruning rule of Part 4 (Ch. 4.2) shows why a higher bound prunes more of the branch-and-bound tree. We now measure it. For the running example with $K=4$ vans, the exact LP bounds (computed with a simplex code; no heuristics) are below. The integer optimum is $98.71$.

    LP relaxationbound% of optimum
    Two-index, degrees only83.0884.2
    + fractional capacity cuts $x(\delta(S))\ge 2d(S)/C$86.0887.2
    Load variables (MTZ-type, arcs between customers that do not fit together removed)87.8088.9
    + rounded capacity cuts $x(\delta(S))\ge 2r(S)$96.2097.5
    Set-partitioning LP98.71100

    The lesson matches Part 3. Rounding the vehicle count (from $2.4$ vans to $3$) is what turns a weak model into a strong one, and the MTZ-type compact model is weak because its load variables can be fractional. The set-partitioning LP is at least as strong on this instance (it reaches the integer optimum) and, in the literature on exact CVRP methods, is usually among the strongest, but with exponentially many columns. This is an observation about the example, not a theorem: a set-partitioning LP solution can violate a rounded capacity cut, because a fractional mix of routes can serve a set of customers with fewer than $r(S)$ vans (three customers of demand $4$ with $C=10$, covered by the three two-customer routes at weight $\tfrac12$ each, use $1.5$ vans for a set that needs $r(S)=2$). The two-index model with cuts lies close behind with a trivial number of variables, which is why it is the workhorse of branch and cut.

    The three-index model, with identical vans, adds no strength: averaging the $K$ vans' variables $x^k$ gives a two-index point of the same cost, and conversely a two-index point is split into $K$ equal parts. Its LP bound on the running example is $83.08$, the same as the degree-only two-index bound (it never reaches the $96.20$ of the rounded cuts). It is useful when the vans differ.

    Try it

    Step through the five relaxations and the optimum. Notice that the biggest single jump (steps 3 to 4) comes from rounding the vehicle count in the cuts, not from adding variables, and that the last step needs exponentially many columns.

    A solver reports the LP bound $96.20$ at the root and has found a plan of cost $99.04$. What can you say about the best possible cost, and what is the gap?

    1. The optimum $z^*$ satisfies $96.20\le z^*\le 99.04$.

      The LP gives a lower bound for a minimisation, the feasible plan an upper bound.

    2. The gap, as defined in Part 4, is $(99.04-96.20)/99.04\approx 2.87\%$.

      The gap is measured against the incumbent (the plan in hand); at most $2.87\%$ of its cost can still be saved.

    3. With the degree-only bound $83.08$ the same plan only certifies a gap of $(99.04-83.08)/99.04\approx16.1\%$.

      A weaker bound gives the same plan a worse certificate and leaves more nodes to explore.

    Undirected three-index model, $n=10$ customers, $K=3$ vans, variables $x^k_e$ for all edges of the complete graph on $11$ locations and $y^k_i$ for all $11$ locations. How many variables?

    Edges: $\binom{11}{2}$. Multiply each family by $K$.

    Edges $=55$, so $x$ has $3\cdot55=165$ variables; $y$ has $3\cdot11=33$. Total $198$.

    Four identical vans are all used. How many relabellings of the vans give the same plan (and hence equivalent three-index solutions)?

    Count the orderings of four vans.

    $4!=24$.

    With $n=6$ customers, how many customer subsets of size at most $3$ (candidate columns, assuming all fit in a van) are there?

    Add $\binom61+\binom62+\binom63$.

    $6+15+20=41$.

    In a restricted master, the duals of customers $a$ and $b$ are $\pi_a=18$ and $\pi_b=16$ (there is no route-count row). A candidate route serving exactly $a$ and $b$ costs $30$. What is its reduced cost?

    $\bar c=c_j-\sum_i a_{ij}\pi_i$.

    $30-(18+16)=-4$. Negative, so the column should enter the master.

    A minimisation has an LP bound of $90$ and the optimum is $100$. What is the relative gap $(z^*-\text{bound})/z^*$ in percent?

    Divide the difference by the optimum.

    $(100-90)/100=10\%$.

    • Choose set partitioning when route costs are complicated or when you need a strong bound, and pay with column generation.
    • Choose the three-index model when the vans differ in capacity or cost.
    • Using three-index with identical vans "for strength": it gives none and adds symmetry.
    • Believing a compact load-variable model matches rounded capacity cuts: on the example it reaches 88.9% of the optimum against 97.5%.
    1. The three-index model adds a van index to every variable; it can say who drives what (heterogeneous fleets) but is large and symmetric.
    2. Set partitioning chooses whole routes, keeps rows few and columns exponential, and is solved by column generation: price routes with the duals until none has negative reduced cost.
    3. LP strength differs sharply: on the running example the bounds are 84% (degrees), 89% (load variables), 97.5% (rounded cuts) and 100% (set partitioning) of the optimum; rounding the vehicle count is what makes the difference.

    Which model can price a route that has overtime charges and a different cost for each van type?

    The two-index model, by changing the edge costs.
    It cannot tell which van uses an edge, nor price a whole route in one number.
    None; route costs must be sums of edge costs.
    This is exactly what set partitioning relaxes.
    The set-partitioning model, since each column carries its own cost $c_j$.
    The cost of a route is computed beforehand in any way you like.

    In column generation, a candidate route has $\bar c_j=-3$. What do you do?

    Discard it: only positive reduced costs help a minimisation.
    Recall from Part 2: a negative reduced cost means entering the column lowers the objective.
    Add it to the master and re-solve.
    It improves the restricted LP; new duals then price the remaining routes again.
    Stop: the LP is optimal.
    Optimality needs no column with negative reduced cost.

    Why does rounding $2d(S)/C$ up to $2r(S)$ strengthen the two-index LP?

    It reduces the number of variables.
    The variables are unchanged; only right-hand sides rise.
    It makes the cuts easier to separate.
    Finding violated rounded cuts is not easier.
    It raises right-hand sides, removing fractional points such as the blend that used 2.4 vans' worth of crossing.
    A smaller feasible region can only raise the LP minimum, as Part 3 showed.

    Identical vans, three-index model: what does the extra index mostly buy?

    A stronger LP bound.
    Averaging the vans gives a two-index point of equal cost, so no.
    Nothing useful, apart from symmetry ($K!$ copies of each plan).
    It becomes useful only when vans differ in capacity or cost.
    Fewer constraints.
    It has more variables and constraints.

    Variants: when the real world adds rules

    Real routing problems add rules to the CVRP: customers want delivery within a time window, goods must be picked up before they are dropped off, vans differ, depots must be chosen. Each rule changes a few constraints.

    You will be asked to write or recognise these models, and a project in practice almost never meets the plain CVRP. The skill is to see which part of the base model each rule touches.

    It is like adapting a recipe for allergies: the ingredients list changes in one or two lines, the method stays.

    Time windows (VRPTW)

    Customer $i$ must begin service in a window $[a_i,b_i]$ and service takes $s_i$ time units. A van arriving early waits; arriving after $b_i$ is not allowed. As in Ch. 5.4 (TSP with time windows, where the start time is called $y_i$), a continuous variable $w^k_i$ records the time at which van $k$ starts serving $i$. The lecture adds a copy $n+1$ of the depot as the end of every route with $d_0=s_0=d_{n+1}=s_{n+1}=0$, so every route is a path from $0$ to $n+1$.

    $$w^k_j\ \ge\ w^k_i+s_i+t_{ij}-M_{ij}\,(1-x^k_{ij})\ \ \forall k,\ (i,j)\in A,\qquad a_i\le w^k_i\le b_i,$$

    together with route constraints (each van leaves $0$ once and arrives at $n+1$ once, flow conservation at customers, exactly one van serves each customer) and the load limit $\sum_{i}d_i\,x^k(\delta^+(i))\le C_k$. Here $t_{ij}$ is the travel time. The first constraint says: if van $k$ drives $i\to j$, service at $j$ starts no earlier than service at $i$ ends plus the drive. If $x^k_{ij}=0$ the constraint must be harmless, which is the job of $M_{ij}$. A tight choice is $M_{ij}=b_i+s_i+t_{ij}-a_j$.

    Why that $M_{ij}$ works: with $x^k_{ij}=0$ the constraint reads $w_j\ge w_i+s_i+t_{ij}-M_{ij}$. Its hardest case is the latest start $w_i=b_i$ with the earliest start $w_j=a_j$, and it still holds there exactly when $M_{ij}\ge b_i+s_i+t_{ij}-a_j$. A smaller valid $M$ gives a stronger LP (Part 3: use the smallest valid big-M). In addition, an arc $(i,j)$ can be deleted from the model before solving if $a_i+s_i+t_{ij}>b_j$ (even leaving $i$ at the earliest moment, one arrives at $j$ too late) or if $d_i+d_j>\max_kC_k$.

    Running example for time windows

    A van leaves the depot at time $0$ and must serve four stops. Windows and service times: stop 1 $[8,20]$, 3 min; stop 2 $[15,30]$, 4 min; stop 3 $[5,14]$, 2 min; stop 4 $[34,45]$, 5 min. The depot is open $[0,60]$. Travel times (symmetric): $t_{01}=6$, $t_{02}=9$, $t_{03}=5$, $t_{04}=12$, $t_{12}=7$, $t_{13}=4$, $t_{14}=10$, $t_{23}=8$, $t_{24}=6$, $t_{34}=11$.

    Try it

    Choose the stops one by one. The bars show each window, the green blocks show service, the gold line shows waiting. Find the visiting order that works. Notice that an early arrival is harmless (the van waits) while a late arrival cannot be repaired, so tight windows fix the order.

    Check the order $0\to3\to1\to2\to4\to0$ for the example, and find $M_{31}$ and decide whether the arc $1\to3$ can be deleted.

    1. Stop 3: arrive $0+5=5$, window starts at $5$, so serve $5\text{–}7$.

      Service start is $\max(\text{arrival},a_i)$; it must not exceed $b_i$.

    2. Stop 1: arrive $7+4=11\in[8,20]$, serve $11\text{–}14$. Stop 2: arrive $14+7=21\in[15,30]$, serve $21\text{–}25$.

      Arrival is the end of the previous service plus the drive.

    3. Stop 4: arrive $25+6=31$, wait until $34$, serve $34\text{–}39$. Back at the depot at $39+12=51\le60$. Feasible.

      The van waits $3$ minutes, as the gold line showed.

    4. $M_{31}=b_3+s_3+t_{31}-a_1=14+2+4-8=12$.

      The largest amount by which the constraint might otherwise be violated when arc $3\to1$ is unused.

    5. Arc $1\to3$: $a_1+s_1+t_{13}=8+3+4=15>b_3=14$, so the arc can be deleted.

      Even the earliest possible departure from stop 1 reaches stop 3 after its window closes. Checking all $24$ orders, only $3\text{-}1\text{-}2\text{-}4$ is feasible.

    Pickup and delivery (VRPPDTW, dial-a-ride)

    Now a request is a pair: pick up at node $i$, drop off at node $n+i$. Pickups are $P=\{1,\dots,n\}$, drop-offs $D=\{n+1,\dots,2n\}$, and each van $k$ has its own start $o_k$ and end $e_k$ (it need not return to a common depot). The model, written with the vehicle index, keeps three families of conditions beyond the VRPTW time constraints.

    • Same van, in order. The van that visits $i$ must visit $n+i$ (a pairing constraint on $x^k$), and the pickup comes first: $w^k_i+t_{i,n+i}\le w^k_{n+i}$.
    • Load. The load variable $q^k_i$ after visiting $i$ obeys $q^k_j\ge q^k_i+d_j-O_{ij}(1-x^k_{ij})$ with $d_j>0$ at pickups and negative at drop-offs, and $q^k_i\le C_k$; here $O_{ij}$ is a big-$M$ constant, chosen as small as possible like $M_{ij}$.
    • Time windows as before; for people (dial-a-ride) a maximum ride time is added to stop long detours.

    The point of the example below is that capacity depends on order: the same set of requests can be feasible in one order and not in another.

    Van capacity $6$. Request 1 carries $3$ units, request 2 carries $4$. Compare the visiting orders $P_1,P_2,D_1,D_2$ and $P_1,D_1,P_2,D_2$.

    1. Order $P_1,P_2,D_1,D_2$: loads after each stop are $3,\ 7,\ 4,\ 0$. Maximum $7>6$: infeasible.

      Both parcels are on board at once.

    2. Order $P_1,D_1,P_2,D_2$: loads $3,\,0,\,4,\,0$. Maximum $4\le6$: feasible.

      The first parcel leaves before the second joins; the cost may be higher in distance, but it respects capacity.

    The rest of the family

    VariantWhat changesModel effect
    Backhauls (VRPB)Some customers are delivered to (linehaul $L$), some are collected from (backhaul $B$); all linehaul stops come first on a route.Delete arcs $B\to L$ and depot$\to B$; capacity is checked separately for the delivery load and for the collection load. For a set $S$ that mixes both kinds, the vans needed are the larger of the two bin-packing numbers $r(L\cap S)$ and $r(B\cap S)$.
    Two-echelon (2E-CVRP)Large trucks bring goods from the depot to satellites (small depots); small vans take them on to customers.Two levels of arcs $A_1$ (depot, satellites) and $A_2$ (satellites, customers); variables $x_{ij}$ (first level), $y_{ijs}$ (second level from satellite $s$) and $z_{si}$ (customer $i$ served from satellite $s$); satellite capacities.
    Location routing (LRP)The depots themselves are chosen from candidate sites $D$ with fixed costs $f_i$ and capacities $W_i$.Objective $\sum c\,x+\sum_{i\in D}f_iy_i$; assignment $z_{ij}$ of customer $j$ to depot $i$; capacity $\sum_jd_jz_{ij}\le W_iy_i$; linking constraints forbid a van from depot $i$ serving a customer assigned elsewhere. Facility location of Part 3 and routing together.
    Multi-depot and heterogeneous fleetVans start from different depots, or vans differ in capacity and cost. (Not separate models on the slides; they are what the vehicle index and the depot sets already allow.)Use the three-index form with $C_k$, $c^k_{ij}$ and a start depot $o_k$ per van; the two-index model cannot express it.

    A pattern emerges. Time, order and precedence require time or load variables, so the model becomes a three-index model with big-M constraints (weak LP, as in Part 3), or a set-partitioning model where the route-feasibility test hides the complication. Choosing where to put things (depots, satellites) brings in the binary open/close variables and forcing constraints of facility location.

    Go deeper: why set partitioning absorbs time windows

    In the route-based model the question "is this route feasible?" is answered outside the LP, by a dynamic programme that tracks time and load along the route. Column generation then needs a pricing problem that respects those resources, a shortest path with resource constraints. That is why the strongest exact codes for time-window problems use branch and price (the Baldacci et al. paper in Project/Candidate_Papers treats the CVRP and VRPTW with the same method).

    For arc $(i,j)$: $b_i=20$, $s_i=3$, $t_{ij}=6$, $a_j=8$. Compute the tight $M_{ij}=b_i+s_i+t_{ij}-a_j$.

    Just add and subtract.

    $20+3+6-8=21$.

    $a_i=10$, $s_i=4$, $t_{ij}=7$, $b_j=20$. Can the arc $(i,j)$ be deleted?

    Compare $a_i+s_i+t_{ij}$ with $b_j$.

    $10+4+7=21>20$: even the earliest possible arrival is too late. Delete it.

    A van leaves the depot at time $0$. Stop A has window $[10,20]$, service $3$, depot-to-A time $7$. Stop B has window $[12,30]$, A-to-B time $5$. At what time does service at B start?

    Arrive at A at 7, but A opens at 10: the van waits. Service at A then lasts 3.

    Start at A $=\max(7,10)=10$; finish $13$. Arrive at B $13+5=18\ge12$, so service at B starts at $18$.

    Pickup loads $+3$ at $P_1$ and $+4$ at $P_2$ (drop-offs release the same amounts). In the order $P_1,P_2,D_1,D_2$ what is the maximum load?

    Both parcels are on board after the second pickup.

    $3$, then $3+4=7$, then $4$, then $0$. Maximum $7$.

    Backhaul problem, $C=10$: linehaul demands $(6,6,5)$ and backhaul demands $(4,3)$. What is the smallest number of vans?

    Pack each side separately and take the larger of the two answers: a van delivers first, then collects.

    Linehaul: any two weigh at least $11>10$, so $3$ vans. Backhaul: $4+3=7\le10$, so $1$ van. A van can serve both sides, so $\max(3,1)=3$.

    • Delete impossible arcs before solving: it shrinks the model and strengthens the LP.
    • Use the smallest valid big-M for each arc, not one global constant.
    • Treating a time window as a constraint on arrival: early arrival is allowed, the van waits.
    • Forgetting the precedence "pickup before drop-off" and the same-van requirement.
    1. Time windows add continuous start-time variables with big-M constraints $w_j\ge w_i+s_i+t_{ij}-M_{ij}(1-x_{ij})$; a tight $M_{ij}=b_i+s_i+t_{ij}-a_j$ and arc deletion keep the model small.
    2. Pickup and delivery adds pairing, precedence and a load variable that goes up at pickups and down at drop-offs, so capacity depends on the order of visits.
    3. Backhauls, satellites, depot choice and mixed fleets each edit a few constraints of the base model; set partitioning absorbs complicated route rules into the definition of a feasible route.

    A van reaches stop $j$ before the window opens. What happens in the VRPTW?

    The route is infeasible.
    Only arrival after $b_j$ is a violation.
    It waits until $a_j$ and then serves.
    That is why the time variable is $\max(\text{arrival},a_j)$ and why $a_j\le w_j$.
    It skips the stop and returns later.
    The model requires that every customer be served once.

    Why is $M_{ij}=b_i+s_i+t_{ij}-a_j$ preferred to a huge $M$ such as $10^6$?

    It guarantees an integer solution.
    Integrality does not depend on $M$.
    It is the smallest value that makes the constraint harmless when $x_{ij}=0$, so the LP relaxation is tighter.
    Same lesson as the facility-location forcing constraints in Part 3.
    The solver rejects constants larger than $1000$.
    Solvers accept them, but they cause numerical trouble and weak bounds.

    Which variant makes the model contain depot-opening binaries and customer-to-depot assignment variables?

    Backhauls.
    Backhauls change arcs and capacities, not depots.
    Location routing.
    It combines facility location (Part 3) with routing: $y_i$ open, $z_{ij}$ assignment.
    VRPTW.
    That adds time variables.

    Why can a two-index model not handle a fleet with different capacities?

    It uses too few constraints.
    The issue is information, not the count.
    Different capacities make the problem infeasible.
    Feasible plans exist; the model just cannot express them.
    It never records which van drives which edge.
    Capacity and cost depend on the van, which needs a vehicle index.

    Heuristics, bounds and the CVRP project

    Exact methods prove optimality but slow down as the number of customers grows. Heuristics give a good plan in seconds, with no proof. Together, a heuristic plan (upper bound) and an LP bound (lower bound) pin the optimum between them.

    You will use a heuristic to provide a starting solution, to judge a model's answer, and to check the course project's results. You must also be able to run the savings algorithm by hand.

    It is like a taxi driver's rule of thumb against a route planner with a guarantee: the rule is fast and usually good; the planner proves that nothing better exists.

    Clarke-Wright savings

    Start with the worst plan: each customer on its own out-and-back route. Joining two routes into one saves a trip to and from the depot. Joining customers $i$ and $j$ replaces $c_{0i}+c_{j0}$ (end of one trip, start of the other) with the direct edge $c_{ij}$, so the saving is $$s_{ij}=c_{0i}+c_{0j}-c_{ij}.$$ Large savings come from customers that are far from the depot but close to each other.

    1. Compute $s_{ij}$ for all pairs and sort them in decreasing order. Start with one route per customer.
    2. Take the next pair $(i,j)$. If $i$ and $j$ are the ends of two different routes next to the depot, and the combined load is at most $C$, merge the two routes at those ends.
    3. Otherwise skip the pair. Repeat until the list is exhausted.
    Try it

    Step through the pairs with "Next pair". Watch which merges are rejected (capacity or not route ends). Drag customers to change the savings, and switch $C$ to $14$ and $20$. Notice that with $C=10$ the final plan uses five routes, one more than the minimum, and still lies within a fraction of a percent of the optimum.

    Run the savings algorithm on the running example ($C=10$). The largest savings are $s_{12}=13.42$, $s_{18}=11.16$, $s_{78}=11.03$, $s_{34}=10.50$, $s_{23}=9.08$, $s_{56}=8.49$, $s_{67}=8.43$.

    1. $(1,2)$: loads $6+6=12>10$. Rejected.

      Capacity is the only reason a high saving is skipped here; customers 1 and 2 alone weigh too much.

    2. $(1,8)$: loads $6+3=9\le10$. Merge: route $[1,8]$.

      Both are single-customer routes, so both are ends.

    3. $(7,8)$: customer 8 is in $[1,8]$ with load $9$, customer 7 has load $5$: $14>10$. Rejected.

      Merging routes sums their loads, not only the two customers.

    4. $(3,4)$: $6+3=9$. Merge: $[3,4]$. $(2,3)$: $6+9=15$. Rejected. $(5,6)$: $4+2=6$. Merge: $[5,6]$. $(6,7)$: $6+5=11>10$. Rejected.

      Later pairs with positive savings fail on capacity too.

    5. Final plan: $[1,8],[2],[3,4],[5,6],[7]$, five routes, cost $99.04$. The optimum is $98.71$, so the gap is $0.33\%$.

      The savings plan is also the cheapest possible plan with exactly five routes; it uses one route more than the optimum, which packs the loads more tightly.

    Sweep

    The sweep algorithm (cluster first, route second) works with coordinates. Compute the angle of each customer around the depot, sort by angle, and sweep a ray around the depot, adding customers to the current route until the next one would exceed $C$, then start a new route. Finally, order the customers of each route by solving a small TSP. It is fast and natural for round regions, but it needs plane coordinates and ignores distance from the depot.

    Sweep the running example. Angles around the depot (degrees, anticlockwise from east): customer 4: $15.9$, 3: $54.5$, 2: $110.6$, 1: $135.0$, 8: $172.9$, 7: $209.7$, 6: $261.9$, 5: $315.0$. Start at customer 4.

    1. Customers 4, 3: load $3+6=9$. Adding 2 gives $15>10$: close route $[4,3]$.

      Capacity decides where to cut the sweep.

    2. Customer 2 ($6$): adding 1 gives $12>10$: close $[2]$. Customers 1, 8: $6+3=9$; adding 7 gives $14$: close $[1,8]$.

      The same rule each time.

    3. Customers 7, 6: $5+2=7$; adding 5 gives $11$: close $[7,6]$. Last: $[5]$.

      The ray has come full circle.

    4. Five routes, cost $99.10$ (for the sweep order within each route). Starting from other customers gives costs between $101.8$ and $102.0$, so the starting ray matters.

      A common remedy is to try every starting customer and keep the best.

    Local search

    Take any feasible plan and try small changes that keep feasibility and lower the cost: relocate a customer to another route or position, swap two customers between routes, 2-opt (reverse a stretch inside a route, as in Ch. 5.4). Repeat while some move helps. The plan then is a local optimum: no single move improves it, but a better plan may exist. Metaheuristics (simulated annealing, tabu search, large-neighbourhood search) accept some worsening moves to escape.

    Savings plan $[1,8],[2],[3,4],[5,6],[7]$ costs $99.04$. Is it a local optimum for single relocations? Can two moves reach the optimum?

    1. Test all single relocations that respect capacity. The least costly one (moving 6 into route $[7]$) raises the cost to $99.10$. None improves.

      The plan is a local optimum for this neighbourhood.

    2. Move customer 5 into route $[2]$ (loads $6+4=10$). New routes $[1,8],[2,5],[3,4],[6],[7]$ cost $107.14$, up by $8.10$.

      This single move is bad: customer 5 lies far from customer 2.

    3. Now merge $[6]$ and $[7]$ (loads $2+5=7$). The plan $[1,8],[2,5],[3,4],[6,7]$ costs $98.71$.

      It is the optimal plan. The first move worsens, the second repairs it more than enough: a local search that takes only improving single moves cannot see this, which is why richer neighbourhoods and metaheuristics exist.

    Bounds and the gap

    A heuristic only provides an upper bound. The LP of a formulation gives a lower bound (Chapter 6.2). On the running example the savings plan ($99.04$) and the LP with rounded capacity cuts ($96.20$) already guarantee that no plan is more than $2.87\%$ cheaper than the savings plan (gap $=(99.04-96.20)/99.04$, as in Part 4). Real instances are larger, but the logic is the same.

    Case study: the CVRP project

    Project

    The course project asks each student to present and re-implement one exact method for the CVRP from a list of papers (the branch-and-cut paper of Achuthan, Caccetta and Hill, 2003, has its own companion course, Tight Cuts, at /achuthan-cvrp/). An earlier proposal for this project (Exact solution approaches for the CVRP), described below, compares two formulations with Gurobi on benchmark instances, following the pattern of Labs 1 and 2: model, solve, study the LP bound and the solve time.

    Baseline. The two-index model of Chapter 6.1 with rounded capacity cuts, added lazily. The solver starts with only the degree constraints. Whenever it finds an integer solution, a callback looks for a violated cut and, if there is one, adds it and rejects the solution.

    Comparison. A multi-commodity flow (MCF) formulation (the paper by Letchford and Salazar-González, 2015, in Project/Candidate_Papers, whose abstract says its relaxations are stronger than earlier compact flow models). Extra flow variables track load along each route, so the model is a single static integer programme and no cutting is needed. As Chapter 6.2 showed, compact load models can be weak, so how much the MCF models improve on them is exactly what the project tests.

    Data and measures. Augerat A- and B-series instances with 15 to 50 customers (names such as A-n32-k5 usually mean 32 locations including the depot and 5 vehicles). For each instance and model, record the LP bound, branch-and-bound nodes, solve time and optimality gap at a time limit.

    1. Build the degree constraints and set the solver's lazy-constraint parameter (in Gurobi: Model.Params.LazyConstraints = 1).
    2. In the callback, when the solver reports a new integer solution (where == GRB.Callback.MIPSOL), read the values with cbGetSolution.
    3. Separate: build the used-edge graph, remove the depot, and take each connected group $S$ of customers. If $x(\delta(S))<2r(S)$ (use $\lceil d(S)/C\rceil$ if $r(S)$ is too slow), the cut is violated.
    4. Add the violated cut with cbLazy. If no group violates its cut, the solution is a feasible plan; accept it.

    On a fractional point of the LP there may be violated cuts that no connected group reveals; codes then use greedy growth heuristics to find sets $S$, since finding the most violated rounded capacity cut exactly is NP-hard in general (already evaluating $r(S)$ is a bin-packing problem). For integer solutions, components suffice, as the next example shows.

    The solver proposes the plan "loop $1\text{-}2\text{-}3\text{-}1$, and vans $0\text{-}4\text{-}0$, $0\text{-}5\text{-}0$, $0\text{-}6\text{-}7\text{-}0$, $0\text{-}8\text{-}0$". Find the cut to add, and say why a heavy-route plan $0\text{-}1\text{-}2\text{-}3\text{-}0$ with three further vans would also be caught.

    1. Remove the depot. The used edges leave components $\{1,2,3\}$, $\{4\}$, $\{5\}$, $\{6,7\}$, $\{8\}$.

      Each component is a candidate set $S$.

    2. For $S=\{1,2,3\}$: $x(\delta(S))=0$, while $2r(S)=6$ (or $2\lceil18/10\rceil=4$ with the cheap bound). Violated. Add $x(\delta(\{1,2,3\}))\ge6$.

      The next solution must connect these customers to the depot through enough vans.

    3. For the heavy-route plan the component $\{1,2,3\}$ has $x(\delta(S))=2<4\le6$. Violated as well.

      Both defects are caught by the same cut family, as Chapter 6.1 showed.

    Depot costs $c_{0i}=12$, $c_{0j}=15$ and $c_{ij}=9$. Compute the Clarke-Wright saving $s_{ij}$.

    $s_{ij}=c_{0i}+c_{0j}-c_{ij}$.

    $12+15-9=18$.

    Routes $[1,2]$ (load $6$) and $[3,4]$ (load $5$), capacity $10$. The next pair is $(2,3)$ and these are route ends. Is the merge allowed?

    Add the loads of the two routes.

    $6+5=11>10$: the merge would overload the van. Skip.

    Sweep with capacity $C=8$. In angular order the customers $1,2,3,4$ have demands $4,5,3,4$. How many routes does the sweep produce?

    Add customers until the next one does not fit: $4$, then $4+5$?

    Customer $1$ alone ($4+5=9>8$); then customers $2,3$ ($5+3=8$, adding customer $4$ gives $12$); then customer $4$. Three routes.

    Relocate move: customer $i$ lies between $p$ and $q$ with $c_{pi}=5$, $c_{iq}=6$, $c_{pq}=8$. It is inserted between $u$ and $v$ with $c_{ui}=4$, $c_{iv}=7$, $c_{uv}=6$. What is the total change in cost (negative means improvement)?

    Removing saves $c_{pi}+c_{iq}-c_{pq}$; inserting costs $c_{ui}+c_{iv}-c_{uv}$.

    Remove: $-(5+6-8)=-3$. Insert: $4+7-6=+5$. Net $+2$, a worse plan, so reject.

    A heuristic plan costs $99.04$ and an LP lower bound is $96.20$. Give the optimality gap $(\text{UB}-\text{LB})/\text{UB}$ of Part 4 in percent.

    $99.04-96.20=2.84$; divide by the incumbent $99.04$, not by the bound.

    $2.84/99.04\approx0.0287$, i.e. $2.87\%$. (Dividing by the bound $96.20$ would give $2.95\%$, which is not the gap a solver prints.)

    • Report a heuristic result together with a lower bound or the exact optimum when you have one.
    • Run a heuristic from several starting points or with several rules and keep the best.
    • Reading a local optimum as a global one.
    • Merging routes at customers that are not ends of their routes.
    Where we are in the story

    Kaveri Courier's owner now has the whole chain: choose the depot and the loads (Part 3), solve the models exactly (Part 4), route one van (Part 5) and plan the whole fleet (this part), with heuristics for a quick plan and a lower bound to judge it. The course project repeats this chain on benchmark instances.

    1. Savings merges routes in decreasing order of $s_{ij}=c_{0i}+c_{0j}-c_{ij}$ while capacity allows; sweep clusters by angle and then solves a TSP per cluster; local search improves a plan by small moves but can stop at a local optimum.
    2. A heuristic plan (upper bound) and a formulation's LP bound (lower bound) bracket the optimum; on the example the gap is at most 2.87%.
    3. The project compares a two-index model with lazily separated rounded capacity cuts against a compact multi-commodity-flow model, measuring LP bound, nodes, time and gap.

    Which pair of customers has the largest saving?

    Two customers right next to the depot.
    Their $c_{0i}$ and $c_{0j}$ are small, so $s_{ij}$ is small.
    Two customers far from the depot but close to each other.
    $c_{0i}+c_{0j}$ is large and $c_{ij}$ small.
    Two customers on opposite sides, far from each other.
    A large $c_{ij}$ subtracts from the saving.

    On the running example, the savings algorithm with $C=10$ gives five routes while the optimum has four. What does this show?

    The algorithm is wrong.
    It follows its rules; it is a heuristic, not an exact method.
    A greedy merge order can leave loads packed worse than the best plan, but here the cost is only $0.33\%$ above the optimum.
    Greedy choices are made one pair at a time, with no look-ahead at packing.
    Four routes are infeasible.
    The widget's optimal plan uses four routes with loads 9, 10, 9, 7.

    In the lazy-cut loop, when is a candidate solution accepted?

    When every connected group of customers $S$ satisfies $x(\delta(S))\ge 2r(S)$.
    Then no cut is violated and the plan is feasible.
    When the solver reports that its LP bound equals the best known solution.
    That concerns the gap, not feasibility.
    When at least one cut has been added.
    Adding a cut means the solution was rejected.

    A local search finds no improving relocation or swap. What can you conclude?

    The plan is optimal.
    The example showed a plan that is stuck at $99.04$ while $98.71$ exists.
    The plan is infeasible.
    Local search keeps feasibility.
    It is a local optimum for these moves only; a better plan may exist.
    Only an exact method or a bound can certify optimality.

    Seven customers each demand $5$ and $C=12$. What is $r(S)$ for all seven, and what does the capacity cut need?

    $r(S)=3$ from $\lceil 35/12\rceil$; the cut needs $x(\delta(S))\ge6$.
    Check whether three demands of $5$ fit in one van of capacity $12$.
    $r(S)=4$ since only two $5$s fit per van; the cut needs $x(\delta(S))\ge 8$.
    Seven items at two per van need four vans, and each van's round trip crosses the boundary twice.
    $r(S)=7$; the cut needs $x(\delta(S))\ge14$.
    Two customers do fit together, so one van per customer is wasteful.

    Which relaxation of the CVRP is typically the strongest?

    The two-index model with degree constraints only.
    Loops and overloaded routes are allowed, which gave 84% of the optimum.
    The MTZ-type load-variable model.
    Its fractional loads gave 89% on the example.
    The set-partitioning LP, solved by column generation.
    It optimises over fractions of whole feasible routes.

    For arc $(i,j)$: $b_i=30$, $s_i=5$, $t_{ij}=10$, $a_j=25$. The tight big-M is:

    $M_{ij}=30+5+10+25=70$
    $a_j$ is subtracted, not added.
    $M_{ij}=30+5+10-25=20$
    The worst-case lateness when the arc is not used.
    $M_{ij}=30-25=5$
    Do not forget service and travel times.

    The savings plan costs $104$ and the best known lower bound is $100$. What is the largest possible relative improvement over the plan (the gap of Part 4)?

    0%
    The bound and plan differ, so some improvement may exist.
    $(104-100)/100=4\%$
    That divides by the lower bound. The gap divides by the incumbent, the plan in hand.
    At most $(104-100)/104\approx3.8\%$
    The optimum lies between $100$ and $104$, so at most $4$ of the $104$ can be saved.

    The bin-packing model "assign items to bins of capacity $C$ with $y_i=1$ if bin $i$ is used" has which objective?

    Maximise $\sum_iy_i$.
    That would use as many bins as possible; the Lecture 3 slides and the recap in Lecture 12 print this by mistake.
    Minimise $\sum_iy_i$.
    We want the fewest bins, i.e. the fewest vans.
    Minimise $\sum_i\sum_jx_{ij}$.
    That sum is always $n$ because every item is placed once.

    With $K=1$ van and capacity large enough for everyone, the two-index model with cuts becomes:

    The TSP with degree 2 and subtour cuts $x(\delta(S))\ge2$.
    Here $r(S)=1$ for every $S$, so the cuts are the TSP's connectivity cuts.
    A bin-packing problem.
    One bin only, nothing to choose.
    The assignment problem.
    Assignment has no subtour condition, and the cuts here exclude subtours.

    In branch and bound for a minimisation, a node whose LP bound is $97$ with an incumbent of $96.5$ is:

    Branched on, since its bound is below the incumbent.
    Compare the signs: the bound is above the incumbent.
    Pruned, since no plan in that subtree can cost less than $97$.
    A stronger LP relaxation raises such bounds, so more nodes are pruned.
    Accepted as the new incumbent.
    An LP bound is not a feasible plan unless integral.

    Lectures 6 and 7 study the inequalities that can be added to an integer programme without losing a single integer solution. Such inequalities shrink the LP relaxation towards the convex hull of the integer points, so the LP bound rises and branch and bound has less to do. This part shows how to build them (by combining and rounding constraints, from covers, cliques and odd holes, and by lifting), how to check that one is valid, and how to tell the strongest ones, the facets, from the rest.

    You need: Part 3 (LP relaxation, convex hull and formulation strength in Ch. 3.2, the cover inequality in Ch. 3.3), Part 2 (LP duality, Ch. 2.2), Part 1 (polyhedra and extreme points, Ch. 1.2) and Part D (set packing and logical conditions on binaries).

    Valid inequalities and Chvátal–Gomory rounding

    A valid inequality is a constraint that every integer solution already satisfies; adding it changes nothing for the integer programme but can cut away fractional LP points.

    Part 3 showed that the LP bound depends on how tightly the formulation wraps the integer points. This chapter gives a general recipe for tightening any formulation: combine constraints with non-negative weights, then round. Cutting-plane solvers (Part 8) and the TSP cuts of Part 9 are applications of it.

    It is like trimming a tent that is pegged too loosely around a group of people: every person must stay inside, but the extra canvas can go.

    What "valid" means

    Let $X$ be the set of feasible points of an integer programme, for example $X=\{x\in\Z^n_+ : Ax\le b\}$, and let $P=\{x\in\R^n_+ : Ax\le b\}$ be its LP relaxation. Recall from Ch. 3.2 that the best possible formulation is the convex hull $\operatorname{conv}(X)$: an LP over it returns an integer optimum. Valid inequalities are the tools for moving $P$ towards $\operatorname{conv}(X)$.

    An inequality $w^\top x\le w_0$, written $(w,w_0)$, is valid for a set $X\subseteq\R^n$ if $w^\top x\le w_0$ holds for every $x\in X$. It is a cut for a given LP point $x^*$ if in addition $w^\top x^*\gt w_0$.

    Two small examples show where valid inequalities come from.

    • Fixed charge. A depot ships $x$ tonnes only if it is open ($y=1$): $x\le My$, $0\le x\le b$, $y\in\{0,1\}$, with $b\lt M$. Since $x$ can never exceed $b$, the inequality $x\le by$ is valid, and it is stronger: the LP point $(x,y)=(b,\,b/M)$ satisfies $x\le My$ but violates $x\le by$. This is the "smallest valid big-$M$" rule of Part D and Part 3, seen as a valid inequality.
    • Probing. Take $X=\{x\in\{0,1\}^4: 2x_1-3x_2+4x_3-2x_4\le-1\}$. If $x_2=x_4=0$ the left side is at least $0$, which is not $\le-1$; so $x_2+x_4\ge1$ is valid. If $x_3=1$ the only way to reach $-1$ is $x_2=x_4=1$ and $x_1=0$; so $x_3\le x_2$, $x_3\le x_4$ and $x_1+x_3\le1$ are valid too. Asking "what if this variable were 0 or 1?" is called probing, and solvers do it during preprocessing (Ch. 4.4).

    Combining constraints

    Any non-negative combination of valid inequalities is valid. For $P=\{x\ge0: Ax\le b\}$ and multipliers $\lambda\ge0$, the inequality $\lambda^\top Ax\le\lambda^\top b$ holds on $P$. Lowering coefficients of non-negative variables, or raising the right-hand side, keeps it valid. The converse is also true, and it gives a test for validity.

    For $P=\{x\in\R^n: Ax\le b,\ x\ge0\}$ (non-empty), the inequality $w^\top x\le w_0$ is valid for $P$ if and only if there is $y\ge0$ with $A^\top y\ge w$ and $b^\top y\le w_0$.

    Why. Validity means $\max\{w^\top x: x\in P\}\le w_0$. The dual of that LP is $\min\{b^\top y: A^\top y\ge w,\ y\ge0\}$ (Ch. 2.2), and by strong duality the two optimal values are equal. So the maximum is at most $w_0$ exactly when some dual-feasible $y$ has $b^\top y\le w_0$. The vector $y$ is a certificate: anyone can check it without solving an LP.

    Rounding: the Chvátal–Gomory procedure

    For the LP set $P$ the combinations above are all one can get. Integrality gives more. If $x$ is a non-negative integer vector, rounding coefficients down keeps the left side from growing, and the left side is then an integer, so the right side may be rounded down as well.

    Given $X=\{x\in\Z^n_+: Ax\le b\}$ and multipliers $\lambda\ge0$:

    1. $\sum_j(\lambda^\top A_{\cdot j})\,x_j\le\lambda^\top b$ is valid (a non-negative combination).
    2. $\sum_j\lfloor\lambda^\top A_{\cdot j}\rfloor x_j\le\lambda^\top b$ is valid, because $x\ge0$ and each coefficient went down.
    3. $\sum_j\lfloor\lambda^\top A_{\cdot j}\rfloor x_j\le\lfloor\lambda^\top b\rfloor$ is valid for $X$, because the left side is an integer.

    For a mixed-integer set, choose $\lambda$ so that the combined coefficients of the continuous variables are $\le0$, drop those terms, and round the integer part.

    For a pure integer programme with a bounded LP relaxation, every valid inequality for $\operatorname{conv}(X)$ can be obtained by applying the CG procedure a finite number of times, each round using the original constraints and the CG inequalities found so far.

    Kaveri Courier

    The owner loads $x_1$ crates of one kind and $x_2$ of another into a small van and wants as many crates as possible: maximise $x_1+x_2$ subject to $x_1+2x_2\le9$ (floor space), $x_1-x_2\le2$ (balance) and $-3x_1+x_2\le1$ (a stacking rule), $x\in\Z^2_+$. The LP optimum is $(13/3,\,7/3)$ with value $20/3\approx6.67$; the best integer plan carries $6$ crates.

    Try it

    Choose multipliers for the three rows. The dashed purple line is the combination $\lambda^\top Ax\le\lambda^\top b$, the red line its rounded version, and the dashed green polygon the integer hull. Start with the first preset, then the second. Notice that both cut off the LP optimum, but only one of them is an edge of the integer hull; then find multipliers whose coefficients round to zero.

    For the crate problem, derive the CG inequalities with $\lambda=(\tfrac23,\tfrac13,0)$ and with $\lambda=(\tfrac13,\tfrac23,0)$, say which one closes the gap, and give a certificate that $x_1+x_2\le\tfrac{20}{3}$ is valid for $P$.

    1. $\lambda=(\tfrac23,\tfrac13,0)$: $\tfrac23(x_1+2x_2)+\tfrac13(x_1-x_2)=x_1+x_2$ and $\tfrac23\cdot9+\tfrac13\cdot2=\tfrac{20}{3}$. So $x_1+x_2\le\tfrac{20}{3}$ on $P$.

      The combination is chosen so that both coefficients come out as whole numbers.

    2. Rounding gives $x_1+x_2\le\lfloor 20/3\rfloor=6$. The LP optimum has $x_1+x_2=20/3\gt6$, so this is a cut, and adding it brings the LP value down to $6$, the integer optimum.

      Only the right side needed rounding; the left side is an integer for integer $x$.

    3. $\lambda=(\tfrac13,\tfrac23,0)$: the combination is $x_1+0\cdot x_2\le\tfrac{13}{3}$, so $x_1\le4$. It also cuts off $(13/3,7/3)$, but the LP optimum after adding it is $(4,\,2.5)$ with value $6.5$.

      A cut can be valid and violated and still leave a gap: the integer hull touches $x_1=4$ only at the single point $(4,2)$.

    4. Certificate for $x_1+x_2\le\tfrac{20}{3}$: take $y=(\tfrac23,\tfrac13,0)$. Then $A^\top y=(1,1)\ge w=(1,1)$ and $b^\top y=\tfrac{20}{3}\le w_0$, so the duality test confirms validity on $P$.

      The multipliers of a CG cut are exactly a dual certificate for the unrounded combination.

    A graph example: odd sets in matching

    A matching chooses edges with no common end: $x(\delta(i))\le1$ for every node $i$ (Part D). Take a set $S$ of nodes and the multipliers $\lambda_i=\tfrac12$ for $i\in S$, $0$ elsewhere. Adding the rows gives $x(E(S))+\tfrac12x(\delta(S))\le\tfrac{|S|}{2}$, because an edge inside $S$ appears in two rows and an edge leaving $S$ in one. Dropping the non-negative term $\tfrac12x(\delta(S))$ and rounding gives

    $$x(E(S))\le\Big\lfloor\tfrac{|S|}{2}\Big\rfloor=\tfrac{|S|-1}{2}\quad\text{for } |S| \text{ odd.}$$

    On a $5$-cycle the LP point $x_e=\tfrac12$ on all five edges satisfies every degree row but has $x(E(S))=2.5\gt2$. These odd-set inequalities return in Part 9 as the blossom inequalities of the TSP.

    Go deeper: disjunctions and mixed-integer rounding

    If $X=X_1\cup X_2$ (an "either–or" set, or the two children of a branch-and-bound node), and $(w^1,w^1_0)$ is valid for $X_1$ and $(w^2,w^2_0)$ for $X_2$ with $x\ge0$, then $\sum_j\min(w^1_j,w^2_j)x_j\le\max(w^1_0,w^2_0)$ is valid for $X$. Applied to the set $\{(x,y)\in\Z_+\times\R_+: x-y\le b\}$ with fractional part $f_0=b-\lfloor b\rfloor$ and the disjunction $x\le\lfloor b\rfloor$ or $x\ge\lfloor b\rfloor+1$, it gives the mixed-integer rounding inequality $x-\tfrac{1}{1-f_0}y\le\lfloor b\rfloor$. For $b=2.5$ that is $x-2y\le2$: the LP point $(x,y)=(2.5,0)$ violates it, while every point with integer $x$ satisfies it. Solvers generate such MIR cuts automatically.

    $X=\{x\in\Z^2_+: 2x_1+3x_2\le11\}$. Apply the CG procedure with $\lambda=\tfrac12$. The result reads $x_1+a\,x_2\le c$. Give $a$ and $c$.

    Halve the row, then round each coefficient and the right side down.

    Halving gives $x_1+1.5x_2\le5.5$. Rounding: $x_1+x_2\le5$, so $a=1$, $c=5$. It is tight at $(5,0)$, which uses $10\le11$.

    In the crate problem, is $x_1+x_2\le6$ valid for the LP relaxation $P$ (not only for the integer points)?

    Compare $6$ with the largest value of $x_1+x_2$ over $P$.

    No. The LP optimum $(13/3,7/3)$ has $x_1+x_2=20/3\gt6$. The inequality is valid for the integer points only, which is exactly why it is a cut.

    A matching problem has a set $S$ of $7$ nodes. What is the right-hand side of the odd-set inequality $x(E(S))\le\,?$

    Each matched edge inside $S$ uses two of its nodes.

    $\lfloor 7/2\rfloor=(7-1)/2=3$.

    For the crate polygon $P$, the dual vector $y=(\tfrac23,\tfrac13,0)$ satisfies $A^\top y\ge(1,1)$. What is the smallest $w_0$ for which this $y$ certifies that $x_1+x_2\le w_0$ is valid on $P$?

    The certificate needs $b^\top y\le w_0$, with $b=(9,2,1)$.

    $b^\top y=\tfrac23\cdot9+\tfrac13\cdot2+0=\tfrac{20}{3}$. So $w_0=20/3$, which is also the LP maximum.

    • Check a proposed valid inequality on every integer point of a small example, or give a dual certificate.
    • Choose CG multipliers so that the combined coefficients are whole numbers and the right side is fractional: that is where rounding gains.
    • Rounding the right side of an inequality whose left side can be fractional (continuous variables or fractional coefficients).
    • Calling an inequality useful because it is valid: $0\le3$ is valid too.
    1. A valid inequality keeps every integer point; it is a cut when it removes the current LP point, and the ideal ones describe the convex hull.
    2. Non-negative combinations of constraints are valid, and LP duality turns validity into a certificate $y\ge0$ with $A^\top y\ge w$, $b^\top y\le w_0$.
    3. Chvátal–Gomory rounding (combine, round coefficients down, round the right side down) generates every valid inequality of a bounded pure IP in finitely many rounds; odd-set inequalities for matching are one-round examples.

    Why may the right-hand side be rounded down in the last CG step?

    Because $\lambda\ge0$.
    That justifies the combination, not the rounding of the right side.
    Because the left side has integer coefficients and is evaluated at integer $x$, so it is an integer.
    An integer that is at most $4.67$ is at most $4$.
    Because the LP optimum is fractional.
    Validity has nothing to do with the LP point.

    What does a vector $y\ge0$ with $A^\top y\ge w$ and $b^\top y\le w_0$ prove?

    That $w^\top x\le w_0$ is a facet.
    It proves validity only; facets come in Ch. 7.3.
    That $w^\top x\le w_0$ cuts off the LP optimum.
    The opposite: it is valid for the whole LP relaxation.
    That $w^\top x\le w_0$ holds on all of $P=\{x\ge0: Ax\le b\}$.
    For $x\in P$: $w^\top x\le y^\top Ax\le y^\top b\le w_0$.

    For the crate problem, which CG cut makes the LP relaxation reach the integer optimum $6$?

    $x_1\le4$
    After it the LP value is $6.5$ at $(4,2.5)$.
    $x_1+x_2\le6$
    With $\lambda=(2/3,1/3,0)$; the LP value drops from $20/3$ to $6$.
    $x_2\le4$
    The LP optimum has $x_2=7/3$, so it is not cut off.

    A fractional matching puts $x_e=\tfrac12$ on the five edges of a $5$-cycle. Which inequality cuts it off?

    $x(\delta(i))\le1$ at some node.
    Each node has two halves, so degree $1$: satisfied.
    $x(E(S))\le2$ for the five nodes of the cycle.
    The left side is $2.5$; the odd-set inequality has right side $(5-1)/2$.
    $x_e\le1$ for each edge.
    Every $x_e=\tfrac12$ already satisfies it.

    Covers, cliques, odd holes and lifting

    Some families of valid inequalities come from the structure of a problem: a set of parcels that cannot all fit, a group of jobs that pairwise conflict, an odd cycle of conflicts. Lifting then strengthens such an inequality by giving the remaining variables the largest coefficients that keep it valid.

    These families are what commercial solvers separate automatically (cover, clique and flow-cover cuts in a solver log), and the clique inequality reappears in the route-based VRP models of Parts 6 and 11.

    It is like a seating rule at a dinner: "of these three people, at most one sits at the head table" is stronger than three separate rules about pairs.

    Kaveri Courier

    A van holds $15$ kg. Seven parcels weigh $9,6,5,5,4,3,1$ kg, and $x_j=1$ if parcel $j$ is loaded: $X=\{x\in\{0,1\}^7: 9x_1+6x_2+5x_3+5x_4+4x_5+3x_6+x_7\le15\}$. This knapsack is used for the rest of this chapter and again in Part 8.

    Covers, recalled and extended

    Ch. 3.3 introduced the cover inequality. A set $C$ of items is a cover if $\sum_{j\in C}a_j\gt b$: they cannot all be loaded. It is minimal if removing any one item leaves a set that fits. For the van, $C=\{3,4,5,6\}$ weighs $5+5+4+3=17\gt15$, and dropping any item leaves at most $14$, so it is minimal and gives $x_3+x_4+x_5+x_6\le3$.

    If $C$ is a cover for $X=\{x\in\{0,1\}^n: \sum_ja_jx_j\le b\}$ (with $a_j\gt0$), then $\sum_{j\in C}x_j\le|C|-1$ is valid. If in addition $E(C)=\{j\notin C: a_j\ge a_i \text{ for all } i\in C\}$, then the extended cover inequality $\sum_{j\in C\cup E(C)}x_j\le|C|-1$ is valid.

    Why. Suppose $|C|$ items of $C\cup E(C)$ were loaded. Match each loaded item of $E(C)$ with a different item of $C$ that is not loaded; it weighs at least as much as that item. So the load weighs at least $\sum_{j\in C}a_j\gt b$, which is impossible.

    For the van, every item outside $C$ that weighs at least $5$ (the heaviest item of $C$) can join: $x_1+x_2+x_3+x_4+x_5+x_6\le3$. Extending only uses coefficient $1$. Lifting asks how large each coefficient can be.

    Start from $\sum_{j\in C}x_j\le|C|-1$. Take the items outside $C$ in some order $j_1,j_2,\dots$. For item $j_k$, with the coefficients $\alpha_{j_1},\dots,\alpha_{j_{k-1}}$ already fixed, solve

    $$\zeta_k=\max\Big\{\sum_{i\lt k}\alpha_{j_i}x_{j_i}+\sum_{j\in C}x_j:\ \sum_{i\lt k}a_{j_i}x_{j_i}+\sum_{j\in C}a_jx_j\le b-a_{j_k},\ x\ \text{binary}\Big\}$$

    and set $\alpha_{j_k}=|C|-1-\zeta_k$. The small knapsack asks: if item $j_k$ is loaded, how much of the left side can the other items still contribute? Whatever room is left over is given to $j_k$.

    Try it

    The set $C=\{3,4,5,6\}$ is selected. Read its cover, extended cover and lifted inequalities. Then try $\{1,2,3\}$ and $\{2,3,5,6\}$, and a set that is a cover but not minimal, such as $\{1,2,3,4\}$. Notice that lifting gives item 1 the coefficient $2$, more than extending can.

    Lift $x_3+x_4+x_5+x_6\le3$ for the van in the order $x_1,x_2,x_7$, and compare the result with the extended cover inequality.

    1. Item 1 ($a_1=9$): if it is loaded, $15-9=6$ kg remain for items $3,4,5,6$ (weights $5,5,4,3$). At most one of them fits ($4+3=7\gt6$), so $\zeta_1=1$ and $\alpha_1=3-1=2$.

      When item 1 is in, the cover items can contribute at most $1$, leaving room $2$ on the left side.

    2. Item 2 ($a_2=6$): $9$ kg remain for items $1,3,4,5,6$ with values $2,1,1,1,1$. The best is $2$ (item 1 alone, or two light items such as $5+4$; three cover items weigh at least $12$). So $\zeta_2=2$ and $\alpha_2=1$.

      The coefficient $\alpha_1=2$ found in step 1 is used in this knapsack.

    3. Item 7 ($a_7=1$): $14$ kg remain. Values of $3$ are reachable (items $1$ and $3$: weight $14$, value $3$), and $4$ is not. So $\zeta_7=3$ and $\alpha_7=0$.

      A light item never helps: loading it still leaves room for a full left side.

    4. Result: $2x_1+x_2+x_3+x_4+x_5+x_6\le3$. It dominates the extended cover inequality $x_1+\dots+x_6\le3$ (a larger coefficient on $x_1$, the same right side). Enumerating the $59$ feasible loads shows that its face contains $7$ affinely independent points, so it is a facet of $\operatorname{conv}(X)$ (Ch. 7.3), while the faces of the cover and extended cover inequalities have dimension only $4$ and $5$.

      Lifting moved a weak inequality all the way to a facet.

    Cliques and odd holes

    In a node packing problem we choose nodes of a graph, no two joined by an edge: $x_i+x_j\le1$ for every edge. A clique is a set of nodes that are pairwise joined; at most one of them can be chosen, so $\sum_{i\in K}x_i\le1$ is valid. For a triangle the three edge rows allow $x=(\tfrac12,\tfrac12,\tfrac12)$ with total $1.5$, while the clique inequality allows $1$. A clique inequality from a maximal clique (one that cannot be enlarged) implies those of all its sub-cliques, so only maximal cliques are worth adding.

    An odd hole is a cycle of odd length $|H|\ge5$ without chords. Around such a cycle at most $(|H|-1)/2$ nodes can be chosen, so $\sum_{i\in H}x_i\le\tfrac{|H|-1}{2}$; on a $5$-cycle the edge rows allow $2.5$, the odd-hole inequality $2$.

    Conflict graphs turn logic into cliques. For any two binaries, "not both $1$" is $x_i+x_j\le1$, and with complemented variables $1-x_i$ the other three logical conflicts look the same. In a set-partitioning model of routes (Ch. 6.2), two routes conflict if they share a customer. On the eight-customer day of Part 6, the routes $\{5,6\}$, $\{5,7\}$ and $\{6,7\}$ pairwise share a customer, so $y_{56}+y_{57}+y_{67}\le1$ is a clique inequality, although no single customer row contains all three. The LP that takes each of them at $\tfrac12$ violates it; Part 11 meets exactly this LP point.

    Go deeper: flow covers for fixed-charge networks

    For a node with inflow arcs $N_1$, outflow arcs $N_2$, net inflow $\sum_{N_1}x_j-\sum_{N_2}x_j\le b$ and arc capacities $x_j\le a_jy_j$ with binary $y_j$ (an arc may carry flow only if it is opened), a generalised cover is $C=C_1\cup C_2$ with $\lambda=\sum_{C_1}a_j-\sum_{C_2}a_j-b\gt0$. The flow cover inequality $\sum_{C_1}x_j+\sum_{C_1}(a_j-\lambda)^+(1-y_j)\le b+\sum_{C_2}a_j+\lambda\sum_{L_2}y_j+\sum_{N_2\setminus(C_2\cup L_2)}x_j$ (for any $L_2\subseteq N_2\setminus C_2$) generalises the knapsack cover; the knapsack is the case $N_2=\emptyset$ with $x_j=a_jy_j$.

    For the van ($9,6,5,5,4,3,1$; capacity $15$), is $\{2,3,5,6\}$ a minimal cover?

    Check the total, then drop each item in turn.

    Weight $6+5+4+3=18\gt15$: a cover. Dropping item 2, 3, 5 or 6 leaves $12$, $13$, $14$ or $15$, all $\le15$. So it is minimal.

    $X=\{x\in\{0,1\}^4: 8x_1+5x_2+5x_3+5x_4\le12\}$ has the minimal cover $C=\{2,3,4\}$ and inequality $x_2+x_3+x_4\le2$. Lift $x_1$: what is the largest $\alpha_1$ with $\alpha_1x_1+x_2+x_3+x_4\le2$ valid?

    With $x_1=1$, how many items of weight $5$ fit into the remaining $4$?

    $12-8=4$ kg remain, so no item of $C$ fits: $\zeta=0$ and $\alpha_1=2-0=2$. The lifted inequality is $2x_1+x_2+x_3+x_4\le2$.

    A node packing problem on a chordless $7$-cycle. The LP with only edge rows $x_i+x_{i+1}\le1$ is maximised at $x_i=\tfrac12$. Give $\sum_ix_i$ there and the right side of the odd-hole inequality.

    Seven halves; and the odd-hole bound is $(|H|-1)/2$.

    $7\cdot\tfrac12=3.5$, while the odd-hole inequality says $\sum x_i\le3$. The cut removes $0.5$.

    Four jobs conflict pairwise (a clique of size $4$), written only as the six pair rows $x_i+x_j\le1$. The point $x=(\tfrac12,\tfrac12,\tfrac12,\tfrac12)$ satisfies all six. What is $\sum x_i$ there? (The clique inequality would cap it at $1$.)

    Add the four values.

    $4\cdot\tfrac12=2$. The single clique inequality $x_1+x_2+x_3+x_4\le1$ halves this LP value, which six pair rows cannot do.

    • Use minimal covers, then lift; check each lifted coefficient with its small knapsack.
    • Look for maximal cliques in a conflict graph before writing many pairwise rows.
    • Extending a cover with an item lighter than the heaviest cover item.
    • Assuming the lifting order does not matter: in general it changes the coefficients (on the van every order happens to give the same result).
    1. Covers give $\sum_Cx_j\le|C|-1$; extending adds every heavier item with coefficient $1$; sequential lifting gives each outside item the largest coefficient a small knapsack allows, here reaching the facet $2x_1+x_2+x_3+x_4+x_5+x_6\le3$.
    2. In packing problems, clique inequalities from maximal cliques and odd-hole inequalities $\sum_Hx_i\le(|H|-1)/2$ cut off the all-halves LP points.
    3. Conflict graphs turn pairwise logic, including routes that share a customer, into clique inequalities.

    Which item may join the extended cover of $C=\{3,4,5,6\}$ (weights $5,5,4,3$) in the van?

    Item 7 (1 kg).
    It must weigh at least as much as every item of $C$.
    Item 2 (6 kg).
    $6\ge5$, the heaviest weight in $C$.
    No item: covers cannot be extended.
    Items 1 and 2 are heavy enough.

    In sequential lifting, $\zeta_k=1$ for a cover with $|C|=4$. What is $\alpha_{j_k}$?

    $1$
    Recall $\alpha=|C|-1-\zeta$.
    $3$
    That would ignore the contribution $\zeta$ of the other items.
    $2$
    $4-1-1=2$.

    Why prefer the clique inequality of a maximal clique?

    It implies the clique inequalities of all its sub-cliques, so it is at least as strong.
    Dropping non-negative terms from the left side gives each smaller one.
    It has a larger right side.
    Every clique inequality has right side $1$.
    It is easier to separate.
    Finding maximum cliques is hard; strength is the reason.

    Routes $\{5,6\}$, $\{5,7\}$, $\{6,7\}$ each at $\tfrac12$ cover customers $5,6,7$ exactly once. Which inequality removes this point?

    The partitioning row of customer $5$.
    It sums to $\tfrac12+\tfrac12=1$: satisfied.
    $y_r\le1$ for each route.
    All values are $\tfrac12$.
    The clique inequality $y_{56}+y_{57}+y_{67}\le1$.
    The three routes conflict pairwise; the point gives $1.5$.

    Faces, facets and dimension

    Among all valid inequalities, the facets are the ones that cannot be improved: each one is a face of the convex hull of the largest possible size, and together they describe the hull exactly.

    Lecture 7 asks you to compute the dimension of a polyhedron, to decide whether an inequality is redundant, and to prove that an inequality defines a facet by listing enough affinely independent points. These are standard exam tasks, and they explain why some cut families (subtour, comb) are prized.

    It is like the walls of a room: a wall is a flat piece of full height; a skirting board along the floor touches the room only on an edge and holds nothing up.

    Dominance and redundancy

    For $x\ge0$, the inequality $w^\top x\le w_0$ dominates $v^\top x\le v_0$ if $w\ge\lambda v$ and $w_0\le\lambda v_0$ for some $\lambda\gt0$, not both with equality: every non-negative $x$ satisfying the first satisfies the second. An inequality is redundant if a positive combination of other valid inequalities dominates it. In the crate polygon of Ch. 7.1 the cut $x_1\le4$ is redundant once $x_1+x_2\le6$ and $x_1-x_2\le2$ are present: their sum is $2x_1\le8$.

    Affine independence and dimension

    Points $x^1,\dots,x^k$ are affinely independent if $\sum_i\lambda_ix^i=0$ and $\sum_i\lambda_i=0$ force all $\lambda_i=0$. Equivalently, the differences $x^2-x^1,\dots,x^k-x^1$ are linearly independent: shift the origin to $x^1$ and test linear independence. In $\R^n$ at most $n$ vectors are linearly independent, but $n+1$ points can be affinely independent (the origin and the $n$ unit vectors). Three points are affinely independent exactly when they do not lie on one line.

    A polyhedron $X$ has dimension $k$ if the largest number of affinely independent points in $X$ is $k+1$. It is full-dimensional if $\dim X=n$.

    For a valid inequality $(w,w_0)$, the set $F=\{x\in X: w^\top x=w_0\}$ is a face of $X$; the inequality defines or represents $F$. A face is proper if it is neither empty nor all of $X$. A face $F$ is a facet if $\dim F=\dim X-1$.

    Split the rows of $X=\{x: Ax\le b\}$ into those that hold with equality at every point of $X$, $(A^=,b^=)$, and the rest. Then $\dim X+\operatorname{rank}(A^=,b^=)=n$. A full-dimensional polyhedron has, up to positive multiples, a unique minimal description, and it consists of one inequality per facet. An inequality whose face has dimension below $\dim X-1$ is redundant.

    1. Show that it is valid.
    2. Find $\dim(\operatorname{conv}X)$, usually by listing $\dim+1$ affinely independent feasible points and using the formula above to show no more exist.
    3. List $\dim(\operatorname{conv}X)$ affinely independent feasible points that satisfy the inequality with equality; this shows $\dim F\ge\dim X-1$.
    4. Show one feasible point with strict inequality, so $F\ne X$ and $\dim F\le\dim X-1$.
    Try it

    This widget from Ch. 3.2 shows three polygons with the same integer points. Choose "Convex hull" and count its edges: each edge is a facet (a face of dimension $1$ in the plane). Then choose "As first written": each of its two lines touches the integer hull in the single point $(2,3)$, so neither defines a facet of the hull.

    (a) Find the dimension of $X=\{x\in\R^3: x_1+x_2+x_3=2,\ 0\le x_j\le1\}$ and decide which of $x_1\le1$ and $x_1\ge0$ define facets. (b) For one depot that may serve three customers, $X=\{(x,y)\in\R^3_+\times\{0,1\}: x_1+x_2+x_3\le3y,\ x_i\le1\}$, show that $x_1\le y$ defines a facet of $\operatorname{conv}(X)$.

    1. (a) The equation is the only implicit equality (the point $(\tfrac23,\tfrac23,\tfrac23)$ satisfies every bound strictly), so $\operatorname{rank}(A^=,b^=)=1$ and $\dim X=3-1=2$. $X$ is the triangle with corners $(1,1,0)$, $(1,0,1)$, $(0,1,1)$.

      The formula $\dim X+\operatorname{rank}(A^=,b^=)=n$ with $n=3$.

    2. $x_1\le1$ holds with equality at $(1,1,0)$ and $(1,0,1)$, two affinely independent points, so its face has dimension $1=\dim X-1$: a facet. $x_1\ge0$ is tight only at $(0,1,1)$, a face of dimension $0$, so it is redundant (indeed $x_1=2-x_2-x_3\ge0$ follows from $x_2,x_3\le1$).

      A facet of a triangle is an edge; a corner is a smaller face.

    3. (b) Dimension: the five points $(0,0,0,0)$, $(0,0,0,1)$, $(1,0,0,1)$, $(0,1,0,1)$, $(0,0,1,1)$ (written $(x_1,x_2,x_3,y)$) lie in $X$ and are affinely independent, so $\dim\operatorname{conv}(X)=4$: full-dimensional.

      Differences from the origin are four linearly independent vectors.

    4. Facet: $x_1\le y$ is valid (if $y=0$ then $x_1=0$; if $y=1$ then $x_1\le1$). The points $(0,0,0,0)$, $(1,0,0,1)$, $(1,1,0,1)$, $(1,0,1,1)$ satisfy $x_1=y$ and are affinely independent, so the face has dimension $\ge3$. The point $(0,0,0,1)$ has $x_1\lt y$, so the face is not all of $\operatorname{conv}(X)$. Hence its dimension is $3=4-1$: a facet.

      This is the disaggregated forcing row of Ch. 3.3; the aggregated row $x_1+x_2+x_3\le3y$ is not a facet of the hull.

    Lecture 7 goes one step further for this example: the set $\{(x,y): 0\le x_i\le y\le1\}$ is exactly $\operatorname{conv}(X)$. Every point of it with $0\lt y\lt1$ is the convex combination $(1-y)\cdot(0,0)+y\cdot(x/y,\,1)$ of two other points of the set, so it is not a vertex; all vertices therefore have $y\in\{0,1\}$ and lie in $X$. This is why the strong facility-location formulation of Ch. 3.3 has an integral LP for a single depot.

    What is the dimension of $\{x\in\R^4: x_1+x_2+x_3+x_4=3,\ x_1=x_2,\ 0\le x_j\le1\}$?

    Count independent implicit equalities. Is there a point that satisfies all bounds strictly? Try $x_1=x_2=0.75$.

    With $x_1=x_2=0.75$ we need $x_3+x_4=1.5$, for example $x_3=x_4=0.75$: all bounds are strict. So only the two given equations are implicit, they are independent, and $\dim=4-2=2$.

    $X=\{x\in\{0,1\}^3: 4x_1+3x_2+3x_3\le6\}$, with $\dim\operatorname{conv}(X)=3$. Does the cover inequality $x_1+x_2\le1$ define a facet?

    List the feasible points with $x_1+x_2=1$ and test them for affine independence.

    The feasible points are $000, 001, 010, 011, 100$. Those with $x_1+x_2=1$ are $(0,1,0)$, $(0,1,1)$, $(1,0,0)$: three affinely independent points, so the face has dimension $2=3-1$. Yes, a facet.

    $\operatorname{conv}(X)$ has dimension $5$. How many affinely independent points of $X$ must satisfy an inequality with equality to show that it defines a facet (together with one point where it is strict)?

    A facet has dimension $\dim X-1$; a $k$-dimensional face needs $k+1$ points.

    The face must have dimension $4$, which needs $4+1=5$ affinely independent points.

    What is the largest number of affinely independent points in $\R^3$?

    Think of the origin and the unit vectors.

    $4=n+1$: for example $0, e_1, e_2, e_3$. (At most $3$ vectors can be linearly independent.)

    • Find the implicit equalities first; dimension is $n$ minus their rank.
    • For a facet proof, list points as rows of a table and check that their differences have full rank.
    • Counting linearly independent points instead of affinely independent ones (the origin can be one of them).
    • Forgetting the last step of a facet proof: one feasible point off the face.
    1. Dimension counts affinely independent points minus one, and $\dim X+\operatorname{rank}(A^=,b^=)=n$.
    2. A face is where a valid inequality is tight; a facet is a face of dimension $\dim X-1$, and the facets alone describe a full-dimensional polyhedron.
    3. To prove a facet, show validity, then $\dim X$ affinely independent tight points, then one feasible point where it is strict.

    A polytope in $\R^6$ has two linearly independent implicit equalities. Its dimension is:

    $6$
    Implicit equalities lower the dimension.
    $4$
    $6-2$.
    $2$
    That is the rank of the equalities, not the dimension.

    Which inequality can be removed from a description without changing the polyhedron?

    Any facet-defining inequality.
    Facets are exactly the ones that are needed.
    One whose face has dimension less than $\dim X-1$.
    Such an inequality is redundant.
    One that is tight at a vertex.
    Facet inequalities are tight at vertices too.

    To prove that $x_1\le y$ is a facet of a $4$-dimensional hull, you exhibited $4$ affinely independent tight points. What is still missing?

    A fifth tight point.
    Four is the number a facet needs.
    An LP solution.
    No LP is involved.
    Validity and one feasible point with $x_1\lt y$.
    Validity makes it a face; the strict point shows the face is proper.

    Can the origin belong to a set of affinely independent points?

    Yes, for example $\{0,e_1,e_2\}$.
    Affine independence tests the differences from one point.
    No, the origin makes any set dependent.
    That is true for linear, not affine, independence.
    Only in $\R^1$.
    It works in any dimension.

    CG with $\lambda=\tfrac13$ on $3x_1+4x_2\le10$, $x\in\Z^2_+$, gives:

    $x_1+\tfrac43x_2\le\tfrac{10}{3}$
    That is the combination before rounding.
    $x_1+x_2\le3$
    Round $\tfrac43$ down to $1$ and $\tfrac{10}3$ down to $3$.
    $x_1+2x_2\le4$
    Coefficients are rounded down, not up.

    Knapsack $7x_1+4x_2+4x_3+4x_4\le10$, binary. Which inequality is valid and strongest?

    $x_2+x_3+x_4\le3$
    Three fours weigh $12\gt10$, so not all three fit.
    $2x_1+x_2+x_3+x_4\le2$
    The cover $\{2,3,4\}$ gives right side $2$; with $x_1=1$ only $3$ kg remain, so $\alpha_1=2$.
    $x_1+x_2+x_3+x_4\le1$
    Two fours fit together ($8\le10$).

    The face of a valid inequality contains exactly three affinely independent points of a $3$-dimensional polytope, and the inequality is strict somewhere. It is:

    Redundant.
    Its face has dimension $2=3-1$.
    A facet.
    Three affinely independent points span a face of dimension $2$.
    An implicit equality.
    It is strict at some point.

    The dual certificate for validity of $w^\top x\le w_0$ on $\{x\ge0: Ax\le b\}$ comes from which LP?

    $\max\{b^\top y: A^\top y\le w\}$
    Check the direction and the sign of $y$.
    $\min\{b^\top y: A^\top y\ge w,\ y\ge0\}$, the dual of $\max\{w^\top x: x\in P\}$
    Strong duality equates its optimum with the LP maximum.
    The LP relaxation of the integer programme.
    Validity on $P$ is the question, and duality answers it.

    For one depot and three customers, which row is a facet of the convex hull?

    $x_1+x_2+x_3\le3y$
    The point $(1,0,0,\tfrac13)$ satisfies it but is not in the hull.
    $x_1\le y$
    It has four affinely independent tight points in a $4$-dimensional hull.
    $y\le3$
    $y$ is binary, so this never touches the hull.

    Lecture 8 turns the valid inequalities of Part 7 into algorithms. A cutting-plane method solves the LP relaxation, finds a valid inequality that the LP point violates (the separation problem), adds it and solves again. Gomory's version reads the cut straight off the simplex tableau and works for any pure integer programme. In practice, cuts are combined with branching: branch and cut, the method inside every modern solver and inside the TSP and VRP codes of Parts 9 and 11.

    You need: Part 7 (valid inequalities, CG rounding, covers), Part 4 (branch and bound, bounds and the gap, Ch. 4.1–4.2), Part 2 (the simplex tableau and dual simplex, Ch. 2.1 and 2.3) and Part 5 (lazy subtour cuts, Ch. 5.2).

    The cutting-plane loop and the separation problem

    A cutting-plane algorithm alternates two steps: solve the LP relaxation, then look for a valid inequality that the LP solution violates and add it. It stops when the LP solution is integral or no violated inequality can be found.

    Adding all useful inequalities in advance is impossible (there are exponentially many covers, subtours, combs), so a solver adds only those that the current LP point violates. The search for such an inequality, the separation problem, is the part you design for each family.

    It is like proofreading: rather than listing every rule of grammar in advance, you read the draft, find a sentence that breaks a rule, fix it, and read again.

    Integer programme $\min\{c^\top x: x\in X\}$ with $X=\{x\in\Z^n_+: Ax\le b\}$, LP relaxation $P$, and a family $\mathcal F$ of valid inequalities for $X$.

    1. Solve $x^*\in\arg\min\{c^\top x: x\in P\}$.
    2. If $x^*$ is integral, stop: it is optimal.
    3. Separation: find $(w,w_0)\in\mathcal F$ with $w^\top x^*\gt w_0$. If none exists, stop (and branch, see Ch. 8.3).
    4. Set $P\leftarrow P\cap\{x: w^\top x\le w_0\}$ and go to step 1.

    Three facts about the loop are worth stating carefully.

    • The bound never gets worse. Each cut shrinks $P$, so for a minimisation the LP value can only stay the same or rise (for a maximisation, stay or fall). It need not change at every round: a cut can remove one optimal LP point while another of equal value remains.
    • A family can run dry. If $\mathcal F$ is, say, only cover inequalities, there may be no violated member while $x^*$ is still fractional. The loop then stops with a better bound but no integer answer, and the tightened LP becomes the root of a branch-and-bound tree. Adding cuts at the root and then branching is called cut and branch.
    • Separation is an optimisation problem. "Is there a member of $\mathcal F$ violated by $x^*$?" is answered by maximising the violation $w^\top x^*-w_0$ over $\mathcal F$. For subtour cuts this was a minimum cut (Ch. 5.2). For covers it is a knapsack.

    For $X=\{x\in\{0,1\}^n: \sum_ja_jx_j\le b\}$ with integer $a_j,b$, write the cover inequality as $\sum_{j\in C}(1-x_j)\ge1$. A cover cuts off $x^*$ exactly when $\sum_{j\in C}(1-x^*_j)\lt1$. So solve

    $$\zeta=\min\Big\{\sum_j(1-x^*_j)\,z_j:\ \sum_ja_jz_j\ge b+1,\ z\in\{0,1\}^n\Big\}.$$

    If $\zeta\lt1$, the items with $z_j=1$ form a violated cover; if $\zeta\ge1$, no cover inequality is violated. The separation problem is itself a knapsack, but it is small, and greedy or dynamic-programming heuristics are good enough in practice: a cut found by a heuristic is still valid.

    Kaveri Courier

    The van of Ch. 7.2 again: weights $9,6,5,5,4,3,1$, capacity $15$. The parcels now earn $19,13,11,10,8,6,1$, and the owner maximises earnings. The LP relaxation loads items in order of earnings per kilogram: item 3 ($2.2$), item 2 ($2.17$), then $4/9$ of item 1 ($2.11$). So $x^*=(\tfrac49,1,1,0,0,0,0)$ with LP value $\tfrac{292}{9}\approx32.44$.

    Try it

    The widget shows the left side of each cover inequality at the LP point $x^*=(\tfrac49,1,1,0,0,0,0)$. The set $\{1,2,3\}$ is selected. Read whether its cover inequality is violated, then try $\{2,3,4\}$ and $\{3,4,5,6\}$. Notice that only covers built from items that are (nearly) fully loaded in $x^*$ can be violated.

    Run one round of cover separation on the van at $x^*=(\tfrac49,1,1,0,0,0,0)$, add the cut and re-solve.

    1. Costs in the separation knapsack: $1-x^*_j=(\tfrac59,0,0,1,1,1,1)$. We need total weight at least $16$.

      Items $2$ and $3$ are free (fully loaded), item $1$ costs $5/9$, the rest cost $1$ each.

    2. Items $2$ and $3$ weigh only $11$. Adding item 1 reaches $20\ge16$ at cost $\tfrac59$; any other way to reach $16$ uses at least one item of cost $1$. So $\zeta=\tfrac59\lt1$ with $C=\{1,2,3\}$.

      This is a minimal cover: dropping any one of the three items leaves at most $15$.

    3. Cut: $x_1+x_2+x_3\le2$. At $x^*$ the left side is $\tfrac49+1+1=2.44\gt2$: violated by $0.44$.

      $\zeta\lt1$ is the same statement as a violation, written with $1-x_j$.

    4. Re-solving the LP with the cut gives value $32$ at the integer load $\{1,2\}$ ($9+6=15$ kg). One cut closed the whole gap from $32.44$ to the integer optimum $32$.

      An integral LP solution ends the loop: it is feasible and its value matches the bound.

    Van knapsack ($9,6,5,5,4,3,1\le15$). The LP point is $x^*=(0,1,0.8,0.8,0,0,0)$. Evaluate the left side of the cover inequality for $C=\{2,3,4\}$.

    Check $C$ is a cover ($6+5+5$), then add $x^*_2+x^*_3+x^*_4$.

    $6+5+5=16\gt15$, so $x_2+x_3+x_4\le2$ is valid. At $x^*$: $1+0.8+0.8=2.6\gt2$, violated by $0.6$.

    For the same $x^*$ and $C=\{2,3,4\}$, compute the separation objective $\sum_{j\in C}(1-x^*_j)$.

    A cover is violated when this is below $1$.

    $0+0.2+0.2=0.4\lt1$, which confirms the violation found above ($|C|-\sum_Cx^*_j=3-2.6=0.4$).

    In a maximisation, can the LP value go up after a valid cut is added?

    What does a cut do to the feasible region?

    No. The region shrinks, so the maximum can only stay or fall. (For a minimisation it can only stay or rise.)

    • Write the separation problem as an optimisation problem over the family and maximise the violation.
    • Use heuristic separation when exact separation is hard; every cut it returns is still valid.
    • Concluding "no violated cut exists" from a heuristic that found none.
    • Expecting the LP value to change at every round.
    1. The cutting-plane loop solves the LP, separates a violated valid inequality, adds it and repeats; the bound improves monotonically.
    2. Separation is an optimisation over the cut family: a minimum cut for subtours, a knapsack $\min\sum(1-x^*_j)z_j$ with $\sum a_jz_j\ge b+1$ for covers.
    3. When the family runs dry the LP can still be fractional; then branch (cut and branch, branch and cut).

    The cover separation problem returns $\zeta=1.2$. What follows?

    A cover inequality is violated by $0.2$.
    Violation needs $\zeta\lt1$.
    No cover inequality is violated by $x^*$.
    Every cover has $\sum_C(1-x^*_j)\ge1.2\ge1$.
    The LP point is integral.
    A fractional point can satisfy all cover inequalities.

    Why is a cover inequality written as $\sum_{C}(1-x_j)\ge1$ for separation?

    It is a stronger inequality.
    It is the same inequality rearranged.
    It makes the cut valid for continuous $x$.
    Validity is unchanged.
    It turns "find a violated cover" into a knapsack with costs $1-x^*_j$.
    Minimising those costs over covers finds the most violated one.

    What is "cut and branch"?

    Add cuts to the root LP, then run branch and bound without further cuts.
    Branch and cut also adds cuts inside the tree (Ch. 8.3).
    Branch first, then add cuts only at the leaves.
    The cuts come first, at the root.
    Cut off branches whose bound is worse than the incumbent.
    That is pruning by bound (Part 4).

    Gomory's fractional cuts from the simplex tableau

    Gomory's method needs no knowledge of the problem: it takes a row of the optimal simplex tableau whose basic variable is fractional and reads off a valid inequality that the current LP point violates.

    It is the first cutting-plane method shown to reach the integer optimum after finitely many cuts, it is the "Gomory cuts" line in a solver log, and the derivation is a standard exam exercise that combines the tableau of Part 2 with the rounding of Part 7.

    It is like reading an odometer to the nearest kilometre: whatever fraction shows on the last digit must be made up by the whole kilometres still to come.

    The derivation

    Write the LP relaxation in standard form, $Ax=b$, $x\ge0$, with integer data so that slack variables are integers too. At an optimal basis $B$ every row of the tableau reads

    $$x_{B_i}+\sum_{j\in N}\bar a_{ij}\,x_j=\bar b_i,\qquad \bar a=B^{-1}N,\ \ \bar b=B^{-1}b.$$

    If $\bar b_i$ is fractional, the current solution is not integral. Because $x\ge0$, rounding the coefficients down gives the CG inequality $x_{B_i}+\sum_j\lfloor\bar a_{ij}\rfloor x_j\le\lfloor\bar b_i\rfloor$ (Ch. 7.1). Subtracting it from the equation removes $x_{B_i}$ and leaves only fractional parts.

    Let $f_{ij}=\bar a_{ij}-\lfloor\bar a_{ij}\rfloor$ and $f_0=\bar b_i-\lfloor\bar b_i\rfloor\gt0$. Then

    $$\sum_{j\in N}f_{ij}\,x_j\ \ge\ f_0$$

    is valid for every integer solution and is violated by the current LP solution, where all non-basic $x_j=0$ give left side $0\lt f_0$.

    Note that fractional parts are always in $[0,1)$: for $\bar a=-\tfrac54$, $f=-\tfrac54-(-2)=\tfrac34$.

    The Gomory cut from row $i$ equals the CG cut built on the original constraints with multipliers $\lambda=$ the fractional parts of row $i$ of $B^{-1}$. So Gomory's method is a systematic way of choosing CG multipliers. It is problem-independent and converges in theory (with careful row choice), but in practice the cuts often become nearly parallel and the bound creeps up slowly, which is why solvers mix them with problem-specific cuts and branching.

    Try it

    Press "Add the next Gomory cut" twice. Each time read the tableau row, the fractional-part inequality and the same cut in the original variables, and watch the LP optimum (red) move until it lands on an integer point (green).

    Solve $\max\ 4x_1+x_2$ subject to $5x_1+4x_2\le17$, $x_2\le2$, $x\in\Z^2_+$ with Gomory cuts. Slacks are $s_1,s_2$ (and $s_3$ for the first cut).

    1. LP: the best ratio is $x_1$ alone, $x^*=(\tfrac{17}{5},0)$, value $\tfrac{68}{5}=13.6$. Basic: $x_1,s_2$. The row of $x_1$ is $x_1+\tfrac45x_2+\tfrac15s_1=\tfrac{17}{5}$.

      Divide the first constraint by $5$; $x_2$ and $s_1$ are non-basic.

    2. Fractional parts: $\tfrac45x_2+\tfrac15s_1\ge\tfrac25$. Substitute $s_1=17-5x_1-4x_2$: $\tfrac45x_2+\tfrac{17}{5}-x_1-\tfrac45x_2\ge\tfrac25$, that is $x_1\le3$.

      In original variables the first cut reads "at most three of item 1", the CG cut with $\lambda=(\tfrac15,0)$.

    3. Add $x_1+s_3=3$. New LP optimum $(3,\tfrac12)$, value $12.5$. Basic $x_1,x_2,s_2$; the row of $x_2$ is $x_2+\tfrac14s_1-\tfrac54s_3=\tfrac12$.

      From $x_2=(17-5x_1-s_1)/4$ with $x_1=3-s_3$.

    4. Fractional parts: $\tfrac14s_1+\tfrac34s_3\ge\tfrac12$. With $s_1=17-5x_1-4x_2$ and $s_3=3-x_1$, multiplying by $4$: $17-5x_1-4x_2+9-3x_1\ge2$, so $2x_1+x_2\le6$.

      $-\tfrac54$ has fractional part $\tfrac34$. This is the CG cut with $\lambda=(\tfrac14,0,\tfrac34)$.

    5. New LP optimum $(3,0)$, value $12$: integral, so it is optimal. Check: $15\le17$, and no integer point does better ($x_1\le3$ because $5\cdot4\gt17$, and with $x_1=3$ only $x_2=0$ fits).

      Two cuts took the bound from $13.6$ to $12$.

    An optimal tableau row is $x_1+0.25x_3-1.5x_4=2.75$ with $x_3,x_4$ non-basic. Write the Gomory cut $f_3x_3+f_4x_4\ge f_0$.

    Fractional part of $-1.5$ is $-1.5-(-2)$.

    $f_3=0.25$, $f_4=0.5$, $f_0=0.75$: $0.25x_3+0.5x_4\ge0.75$.

    A basic variable has value $\bar b_i=\tfrac73$. What is the right side $f_0$ of its Gomory cut?

    $\tfrac73=2+\tfrac13$.

    $f_0=\tfrac73-2=\tfrac13$.

    For $\max\ x_2$ subject to $2x_1+2x_2\le9$, $x\in\Z^2_+$, the LP optimum is $(0,4.5)$ with row $x_2+x_1+\tfrac12s_1=\tfrac92$. Write the Gomory cut in the original variables as $x_1+x_2\le\,?$ (use $s_1=9-2x_1-2x_2$).

    The fractional parts give $\tfrac12s_1\ge\tfrac12$; substitute.

    $x_1$ has coefficient $1$ (fractional part $0$), so the cut is $\tfrac12s_1\ge\tfrac12$, i.e. $9-2x_1-2x_2\ge1$, i.e. $x_1+x_2\le4$. The new LP optimum is $(0,4)$, integral.

    • Choose a row with a fractional right side; take fractional parts as $a-\lfloor a\rfloor$, which is never negative.
    • Translate the cut back into the original variables to see it, and to add it without new slack columns.
    • Taking the fractional part of a negative number as $|a|-\lfloor|a|\rfloor$.
    • Applying the cut to a model with continuous variables: the derivation needs every variable in the row to be integer (mixed models use the MIR form of Ch. 7.1).
    1. From a tableau row $x_{B_i}+\sum\bar a_{ij}x_j=\bar b_i$ with fractional $\bar b_i$, the Gomory cut is $\sum_jf_{ij}x_j\ge f_0$, with fractional parts in $[0,1)$.
    2. It cuts off the current LP point and is a CG cut with multipliers given by the fractional parts of a row of $B^{-1}$.
    3. On the example two cuts, $x_1\le3$ and $2x_1+x_2\le6$, took the bound from $13.6$ to the integer optimum $12$; on large problems pure Gomory methods converge slowly, so they are combined with branching.

    Why is the Gomory cut violated by the current LP point?

    Because it is a facet.
    Gomory cuts are usually not facets.
    All non-basic variables are $0$ there, so the left side is $0\lt f_0$.
    And $f_0\gt0$ because the basic value is fractional.
    Because the basic variable appears with coefficient $1$.
    It has been eliminated from the cut.

    The fractional part of $-\tfrac23$ is:

    $\tfrac23$
    $\lfloor-\tfrac23\rfloor=-1$.
    $\tfrac13$
    $-\tfrac23-(-1)=\tfrac13$.
    $-\tfrac23$
    Fractional parts lie in $[0,1)$.

    Why do solvers not rely on Gomory cuts alone?

    They can cut off integer solutions.
    They are valid: no integer point is lost.
    They only work for minimisation.
    The sense does not matter.
    Successive cuts tend to be weak and nearly parallel, so the bound improves slowly.
    Branching and problem-specific cuts help much more per LP solved.

    Branch and cut in practice

    Branch and cut runs branch and bound (Part 4) and adds cutting planes at the nodes of the tree, not only at the root. Cuts raise the bounds so more nodes are pruned; branching guarantees an integer answer when cuts stall.

    Every MIP solver works this way, and Labs 4 and 5 asked you to write the TSP and TSPTW versions with Gurobi callbacks. Knowing which cuts are needed for correctness and which only for speed decides how you write such a callback.

    It is like a search party with a map that improves as it goes: whenever a team reaches a new area it redraws the boundaries before splitting up again.

    The design decisions

    Lecture 8 lists the choices that make or break a branch-and-cut code.

    • When to stop cutting and branch. The first rounds of cuts usually raise the bound a lot, later rounds little ("tailing off"). A common rule: branch when the last few rounds improved the bound by less than a small percentage.
    • Which cuts. Facet-defining families (subtours, combs, lifted covers) are worth more per cut. Every cut also makes the LP bigger and slower.
    • How much time to spend on separation. Exact separation can be expensive (blossoms need odd minimum cuts, Ch. 9.2); heuristics are fast and still give valid cuts.
    • Which cuts to keep. A cut found at a node may be valid only below that node (a local cut) or for the whole problem (a global cut). Solvers store cuts in pools, drop those with positive slack for many rounds, and move cuts that keep helping from the local to the global pool.

    Solvers have cut generators for the standard families (covers, cliques, flow covers, MIR, Gomory, implied bounds) and decide automatically how aggressively to use them. Your own problem-specific cuts enter through callbacks.

    A lazy constraint belongs to the model but is left out at the start because there are too many (subtour elimination constraints, capacity cuts). It is needed for correctness: an integer solution that violates it is not feasible. In Gurobi it is added in the callback at where == GRB.Callback.MIPSOL (a new integer solution) with cbLazy, after setting LazyConstraints = 1.

    A user cut is a valid inequality that only strengthens the LP (blossoms, combs, covers). Every integer solution already satisfies it. It is added at where == GRB.Callback.MIPNODE from the node's LP solution (cbGetNodeRel) with cbCut; set PreCrush = 1 so that cuts on the original variables remain usable after presolve.

    Try it

    This is the lazy-constraint loop of Ch. 5.2 on eight cities: the solver returns the cheapest set of cycles, the callback adds a subtour cut for the smallest cycle, and the solver tries again. Press "Add the cut for the smallest piece" until a single tour appears. Notice that each cut is needed for correctness: without it, a set of separate loops would be accepted.

    Measure what cuts buy on two examples: the van knapsack of Ch. 8.1, and Dantzig's 42-city TSP from Lab 4 (TSPLIB dantzig42).

    1. Van, plain branch and bound (best-first, branching on the first fractional item): $9$ LPs are solved before the optimum $32$ is proved. With the cover cut $x_1+x_2+x_3\le2$ added at the root: $1$ LP, because the root LP is already integral.

      A cut that closes the root gap replaces the whole tree.

    2. Dantzig42, LP with degree constraints only: bound $641$. After six rounds of subtour separation (connected components, then a global minimum cut; $12$ cuts): $697$. After two blossom inequalities found by the heuristic of Ch. 9.2: $698$. The optimal tour costs $699$.

      All numbers recomputed for this site with an LP solver and NetworkX; the optimum was confirmed by a branch-and-cut run with lazy subtour cuts.

    3. Root gap after subtour cuts: $(699-697)/699\approx0.29\%$; after blossoms $0.14\%$. The remaining gap is closed by branching, with subtour cuts as lazy constraints and blossoms as user cuts.

      Subtour cuts are needed for correctness; blossoms only make the bound tighter.

    Labs 4 and 5

    Lab 4 builds both pieces for the TSP: the root cutting-plane loop on dantzig42 and kroA100, and a callback code with subtour, 2-connectivity, minimum-cut and blossom separators. Lab 5 solves the TSP with time windows twice, once with MTZ-type big-M time constraints and once by branch and cut with infeasible-path cuts (Ch. 9.3), and compares the LP bounds and solve times of the two approaches.

    Dantzig42: the root LP bound with all subtour cuts is $697$, the optimal tour costs $699$. What is the gap $(z^*-\text{bound})/z^*$ in percent?

    $2/699$.

    $2/699\approx0.00286$, i.e. $0.286\%$.

    In a CVRP branch-and-cut code, rounded capacity cuts $x(\delta(S))\ge2r(S)$ are the only constraints that stop overloaded routes. Should they be added as lazy constraints or as user cuts?

    Can an integer solution of the model without them be infeasible?

    Lazy constraints: without them an integer solution can contain overloaded routes or loops that miss the depot, so they are needed for correctness and must be checked at every new integer solution. (They may also be added as user cuts at fractional nodes to tighten the LP.)

    A minimisation has root LP bound $80$; after two rounds of cuts the bound is $88$; the optimum is $92$. What percentage of the root gap did the cuts close?

    Closed gap $=(\text{new bound}-\text{root bound})/(z^*-\text{root bound})$.

    $(88-80)/(92-80)=8/12=66.67\%$.

    • Add cuts needed for feasibility as lazy constraints, checked at every integer solution.
    • Stop cutting when the bound stalls, and branch.
    • Adding a cut found at a node, using the node's branching bounds, to the global pool.
    • Separating expensive families at every node of a large tree without a time limit.
    1. Branch and cut adds cuts inside the branch-and-bound tree; cut pools keep good cuts and drop slack ones, and local cuts stay below their node.
    2. Lazy constraints (needed for correctness, e.g. subtours) are checked at integer solutions with cbLazy; user cuts (only for strength, e.g. blossoms) are added at fractional nodes with cbCut.
    3. On Dantzig's 42 cities the bound climbs $641\to697\to698$ with subtour and blossom cuts against the optimum $699$; branching closes the last gap.

    Blossom inequalities in a TSP code should be added as:

    Lazy constraints, because they forbid subtours.
    Every tour satisfies them; they are not needed for feasibility.
    User cuts, because every tour satisfies them and they only tighten the LP.
    They are separated from fractional node solutions.
    Constraints written into the model at the start.
    There are far too many of them.

    What is a local cut?

    A cut on few variables.
    Local refers to where it is valid, not its size.
    A cut found by a heuristic.
    Heuristic cuts can be global.
    A cut valid only in the subtree of the node where it was derived.
    It may rely on that node's branching bounds.

    The bound improves by $5\%$, $1\%$, $0.2\%$, $0.05\%$ of the gap over four rounds of cuts. What should the code do?

    Keep cutting until the gap is zero.
    The family may never close it, and LPs get slower.
    Stop cutting at this node and branch.
    The cuts are tailing off.
    Remove all cuts and restart.
    The cuts found so far are useful.

    LP point $x^*$ for a knapsack; the separation knapsack gives $\zeta=0.3$ with items $\{2,5\}$. Which cut is added?

    $x_2+x_5\le0.3$
    The right side of a cover inequality is $|C|-1$.
    $x_2+x_5\le1$
    $|C|-1=1$; it is violated by $0.7$.
    $x_2+x_5\ge1$
    The sense is $\le$.

    Tableau row $x_2+\tfrac13x_4+\tfrac43x_5=\tfrac{11}{3}$. The Gomory cut is:

    $\tfrac13x_4+\tfrac43x_5\ge\tfrac23$
    Take fractional parts of the coefficients too.
    $\tfrac13x_4+\tfrac13x_5\ge\tfrac23$
    $\tfrac43$ has fractional part $\tfrac13$, and $\tfrac{11}{3}$ has $\tfrac23$.
    $x_2\le3$
    That is the CG form only if the other coefficients round to $0$; here $\lfloor4/3\rfloor=1$.

    Which Gurobi callback event is used to add subtour constraints lazily?

    MIPSOL, with cbLazy.
    Each new integer solution is checked for subtours.
    MIPNODE, with cbLazy.
    MIPNODE is for user cuts on fractional node solutions.
    No callback; set Cuts = 2.
    That only controls Gurobi's own cut generators.

    Gomory's first cut on the example, $x_1\le3$, equals the CG cut with multipliers:

    $\lambda=(1,0)$
    That gives $5x_1+4x_2\le17$.
    $\lambda=(\tfrac15,0)$
    $x_1+\tfrac45x_2\le\tfrac{17}{5}$ rounds to $x_1\le3$.
    $\lambda=(0,1)$
    That gives $x_2\le2$.

    Why do cuts reduce the size of the branch-and-bound tree?

    They remove integer solutions.
    Valid cuts never do.
    They tighten node bounds, so more nodes are pruned by bound or become integral.
    Pruning by bound is the rule of Ch. 4.2.
    They choose the branching variable.
    Branching rules are separate.

    Lectures 9 and 10 return to the travelling salesman problem of Part 5 with the tools of Parts 7 and 8. Subtour cuts are separated with connected components, articulation points and minimum cuts (a Gomory–Hu tree gives all minimum cuts at once). When every subtour cut holds and the LP is still fractional, blossom and comb inequalities cut deeper; they are facets of the TSP polytope and can be separated exactly through odd minimum cuts. The part ends with the TSP with time windows, where infeasible-path and tournament inequalities replace weak big-M constraints, and with the TSP models of Lab 3.

    You need: Part 5 (DFJ, the cut form $x(\delta(S))\ge2$, separation by minimum cut in Ch. 5.2, time windows in Ch. 5.4), Part 8 (the cutting-plane loop, lazy constraints and user cuts), Part 7 (validity, facets, odd-set inequalities) and Part C (graphs, connected components, maximum flow and minimum cut).

    Connectivity cuts: components, 2-connectivity and minimum cuts

    A subtour cut $x(\delta(S))\ge2$ says that the tour must cross the boundary of $S$ at least twice. Finding a violated one in a fractional LP solution is a question about the graph of edges with $x_e\gt0$: is it disconnected, does it have a weak spot, where is its minimum cut?

    Ch. 5.2 introduced the minimum-cut test. Lecture 9 adds two cheap tests that catch most violations first, shows that subtour cuts are facets of the TSP polytope, and Lecture 10 shows how a Gomory–Hu tree answers every minimum-cut question with $n-1$ flow computations.

    It is like checking a road network after a storm: first see whether some towns are cut off entirely, then whether a single junction holds everything together, and only then measure how much traffic each narrow pass can carry.

    The support graph and three tests

    Given an LP solution $x^*$ that satisfies the degree constraints $x(\delta(v))=2$, the support graph $G^*$ has the cities as nodes and an edge $e$ wherever $x^*_e\gt0$, with weight $x^*_e$. A subtour cut is violated for $S$ exactly when the weight of the edges of $G^*$ leaving $S$ is below $2$.

    1. Connected components. If $G^*$ is disconnected, every component $S$ has $x^*(\delta(S))=0$: add the subtour cut for each component. This is the only test needed for integer solutions (lazy constraints).
    2. Articulation points. A graph is 2-connected if it stays connected after removing any one node; a node whose removal disconnects it is an articulation point. Every tour is 2-connected. If $v$ is an articulation point of $G^*$, the pieces $C_1,\dots,C_m$ ($m\ge2$) left after removing $v$ are joined to the rest only through $v$, so $\sum_ix^*(\delta(C_i))=x^*(\delta(v))=2$ and some piece has $x^*(\delta(C_i))\le1\lt2$: a violated cut.
    3. Minimum cut. If $G^*$ is 2-connected, compute the global minimum cut of $G^*$ with weights $x^*$. If it is below $2$, its smaller side gives the most violated subtour cut; if it is at least $2$, no subtour cut is violated (Hong and Padberg).

    For the TSP on a complete graph with $n\ge5$ cities, the subtour inequalities $x(\delta(S))\ge2$ with $3\le|S|\le n/2$ define facets of the convex hull of tours, and so do the bounds $0\le x_e\le1$ (Lecture 9 lists both). The polytope of tours has dimension $\binom n2-n$, because the $n$ degree equations are independent implicit equalities.

    A global minimum cut needs no guessing of $s$ and $t$: fix any node $s$, compute the minimum $s$–$t$ cut for each of the other $n-1$ nodes $t$, and keep the smallest. Some $t$ is always on the other side of the global minimum cut from $s$, so $n-1$ maximum-flow computations suffice, not $\binom n2$.

    For any undirected graph with non-negative capacities there is a tree $T$ on the same nodes, with weights on its edges, such that for every pair $u,v$ the minimum $u$–$v$ cut value in the graph equals the smallest weight on the path from $u$ to $v$ in $T$, and removing that tree edge gives a minimum cut. Such a tree exists because the cut function $f(S)=c(\delta(S))$ is submodular, $f(A)+f(B)\ge f(A\cup B)+f(A\cap B)$, and it is built with $n-1$ minimum-cut computations, each on a graph where parts of the tree found so far are contracted.

    Try it

    This is the separation widget of Ch. 5.2. Choose "Two clusters" and press "Choose the smallest cut": the minimum cut separates the clusters with value $1\lt2$. Then choose "Prism": every set you try has $x(\delta(S))\ge2$, yet the point is fractional. Ch. 9.2 cuts it off with a blossom.

    (a) In a fractional support graph, city $5$ has $x_{51}=x_{52}=\tfrac12$ to cities in $A=\{1,2,3,4\}$ and $x_{56}=1$ to $B=\{6,7,8\}$, and no other edge joins $A$ to $B$. Find a violated subtour cut. (b) A weighted graph on six nodes has capacities $c_{12}=4$, $c_{13}=2$, $c_{23}=3$, $c_{24}=1$, $c_{35}=2$, $c_{45}=3$, $c_{46}=4$, $c_{56}=2$. Its Gomory–Hu tree has edges $1\text{–}2\,(6)$, $2\text{–}3\,(6)$, $3\text{–}5\,(3)$, $5\text{–}4\,(6)$, $4\text{–}6\,(6)$. Read off the minimum $1$–$6$ cut and the global minimum cut.

    1. (a) Removing city $5$ separates $A$ from $B$, so $5$ is an articulation point. $x^*(\delta(A))=x_{51}+x_{52}=1\lt2$: the subtour cut for $A$ is violated by $1$.

      The two units of degree at city 5 are split between the two sides; one side gets at most one unit.

    2. (b) The tree path from $1$ to $6$ is $1\text{–}2\text{–}3\text{–}5\text{–}4\text{–}6$ with weights $6,6,3,6,6$; the minimum is $3$, so the minimum $1$–$6$ cut is $3$.

      Removing tree edge $3\text{–}5$ splits the nodes into $\{1,2,3\}$ and $\{4,5,6\}$.

    3. Check in the graph: the edges between $\{1,2,3\}$ and $\{4,5,6\}$ are $2\text{–}4$ ($1$) and $3\text{–}5$ ($2$), total $3$.

      The tree's claim is confirmed directly.

    4. The global minimum cut is the smallest tree weight, $3$. If these capacities were (scaled) LP values $x^*$ of a TSP, a global minimum below $2$ would be a violated subtour cut, and the tree would list the most violated one at once.

      All $\binom62=15$ pairwise minimum cuts come from $5$ tree edges.

    Dantzig's 42 cities (Lab 4)

    With degree constraints only, the LP bound is $641$ and the support graph falls apart into several loops. Adding a subtour cut for every component and, once the graph is connected, the global minimum cut, takes six rounds and twelve cuts to reach $697$; then every subtour cut holds and $16$ edges are still fractional. The optimal tour costs $699$.

    In the Gomory–Hu tree of the example (edges $1\text{–}2$ 6, $2\text{–}3$ 6, $3\text{–}5$ 3, $5\text{–}4$ 6, $4\text{–}6$ 6), what is the minimum cut between nodes $2$ and $5$?

    Find the tree path and take the smallest weight on it.

    Path $2\text{–}3\text{–}5$ with weights $6,3$: minimum $3$.

    How many maximum-flow (minimum $s$–$t$ cut) problems does the "fix $s$, vary $t$" method solve to find the global minimum cut of a 42-city support graph?

    Every node other than $s$ is tried once as $t$.

    $n-1=41$, against $\binom{42}{2}=861$ for all pairs.

    City $v$ is an articulation point of a support graph satisfying the degree constraints. Removing it leaves two pieces $C_1,C_2$, and $v$ sends $x=1.2$ into $C_1$. What is $x(\delta(C_2))$?

    $v$ has degree $2$, and $C_2$ touches the rest only through $v$.

    $2-1.2=0.8\lt2$: the subtour cut for $C_2$ is violated by $1.2$ (and the one for $C_1$ by $0.8$).

    What is the dimension of the convex hull of tours on $6$ cities?

    $\binom n2$ edge variables minus $n$ independent degree equations.

    $15-6=9$.

    • Run the cheap tests first (components, then articulation points) and the minimum cut only on a 2-connected support graph.
    • Use a Gomory–Hu tree when many cuts are wanted from one LP point.
    • Concluding that a fractional point is a tour because it satisfies every subtour cut.
    • Solving all $\binom n2$ pairwise flow problems to find one global minimum cut.
    1. Violated subtour cuts are found in the support graph: each component, each piece around an articulation point, and any cut of weight below $2$.
    2. Subtour cuts with $3\le|S|\le n/2$ and the bounds $0\le x_e\le1$ are facets of the TSP polytope, which has dimension $\binom n2-n$.
    3. The global minimum cut needs $n-1$ flow computations, and a Gomory–Hu tree stores all pairwise minimum cuts in $n-1$ weighted edges.

    The support graph of an integer solution of the degree-constrained LP is checked for subtours. Which test is enough?

    Connected components.
    An integer degree-2 solution is a set of disjoint cycles; it is a tour exactly when it is connected.
    The global minimum cut.
    It works but is more than needed for integer points.
    Articulation points.
    A disjoint union of cycles has no articulation points, yet may be several subtours.

    Why is every tour 2-connected?

    Every city has degree 2.
    Two disjoint triangles also have degree 2 everywhere.
    Removing one city from a cycle through all cities leaves a path, which is connected.
    So no city is an articulation point.
    Tours have no cut of weight below $3$.
    Every tour has cuts of weight exactly $2$.

    In a Gomory–Hu tree, the path between $u$ and $v$ has weights $5, 2.5, 4$. The minimum $u$–$v$ cut in the graph is:

    $11.5$
    Cut values are not added along the path.
    $5$
    The cut is limited by the weakest link.
    $2.5$
    The smallest weight on the tree path.

    The global minimum cut of a 2-connected support graph is $2$. What follows?

    The LP point is a tour.
    It may still be fractional, like the prism.
    No subtour cut is violated; other cut families are needed.
    Every set has $x(\delta(S))\ge2$.
    The LP is infeasible.
    The point satisfies all constraints so far.

    Blossoms and combs

    A comb is a handle $H$ with an odd number of teeth, each tooth reaching into and out of the handle. The comb inequality counts how often a tour must cross all these boundaries, and it cuts off fractional points that satisfy every subtour cut.

    Dantzig, Fulkerson and Johnson used such inequalities to solve their 49-city problem without branching, and modern TSP codes still separate them. On Dantzig's 42 cities two blossoms raise the bound from $697$ to $698$.

    It is like checking a hair comb's teeth: each tooth pokes through the handle's edge, and an odd number of teeth means the line through them cannot pair up neatly, so somewhere an extra crossing is forced.

    A comb consists of a handle $H\subset V$ and teeth $T_1,\dots,T_k\subset V$ such that each tooth has at least one city in $H$ and at least one outside $H$, the teeth are pairwise disjoint, and $k\ge3$ is odd. A blossom is a comb whose teeth have exactly two cities (one edge each). The comb inequality is

    $$x(\delta(H))+\sum_{i=1}^kx(\delta(T_i))\ \ge\ 3k+1,$$

    or equivalently, using $x(\delta(S))=2|S|-2x(E(S))$ (degree constraints),

    $$x(E(H))+\sum_{i=1}^kx(E(T_i))\ \le\ |H|+\sum_{i=1}^k(|T_i|-1)-\tfrac{k+1}{2}.$$

    Why a tour satisfies it

    Each tooth $T_i$ is crossed at least twice by any tour, $x(\delta(T_i))\ge2$, which gives $2k$. A tooth also meets the boundary of $H$: its part inside $H$ and its part outside must each be entered and left, so in total a tour crosses the boundaries of $T_i\cap H$ and $T_i\setminus H$ at least four times. Summing these counts and using that $H$ is crossed an even number of times, an odd number of teeth forces at least one extra crossing beyond $3k$, hence $3k+1$. Lecture 9 writes this as the inequality chain

    $$2x(E(H))+2\sum_ix(E(T_i))\le2|H|+2\sum_i(|T_i|-1)-k,$$

    obtained by adding the degree equations of $H$ and the subtour inequalities of $T_i$, $T_i\cap H$ and $T_i\setminus H$. Dividing by $2$ and rounding the right side down (the left side is an integer for a tour) turns $-\tfrac k2$ into $-\tfrac{k+1}{2}$ because $k$ is odd. So a comb inequality is a Chvátal–Gomory cut (Ch. 7.1) of the subtour polytope, and a blossom is the TSP version of the odd-set inequality for matching.

    Every comb inequality defines a facet of the TSP polytope (for $n\ge6$), and so do the more general clique-tree inequalities, which have several handles. The number of combs grows much faster with $n$ than the number of subtour cuts, so they too are added only when violated.

    Try it

    The "prism" point has $x_e=\tfrac12$ on two triangles and $x_e=1$ on the three edges joining them. Every subtour cut holds. Press "Load the blossom": handle $\{1,2,3\}$, teeth $1\text{–}4$, $2\text{–}5$, $3\text{–}6$. Read the left side $9$ against $3k+1=10$. Then remove one tooth, or put city $4$ into the handle, and see which condition of a comb fails.

    Show that the prism point violates the blossom with $H=\{1,2,3\}$ and teeth $\{1,4\},\{2,5\},\{3,6\}$, and check the same in the $E$-form.

    1. $x(\delta(H))$: the edges leaving $\{1,2,3\}$ are the three rungs, each $1$: total $3$.

      The triangle edges $1\text{–}2$, $2\text{–}3$, $1\text{–}3$ lie inside $H$.

    2. $x(\delta(\{1,4\}))$: city 1 sends $\tfrac12+\tfrac12$ to cities 2 and 3, city 4 sends $\tfrac12+\tfrac12$ to cities 5 and 6: total $2$. The same for the other two teeth.

      The rung $1\text{–}4$ is inside the tooth and does not count.

    3. Left side $3+3\cdot2=9\lt3\cdot3+1=10$: violated by $1$.

      No subtour cut sees this, because each set is crossed at least twice.

    4. $E$-form: $x(E(H))=\tfrac32$, each $x(E(T_i))=1$, so the left side is $4.5$. The right side is $|H|+\sum(|T_i|-1)-\tfrac{k+1}2=3+3-2=4$. Violated by $\tfrac12$, the same cut divided by $2$.

      The two forms differ by the factor $2$ from $x(\delta(S))=2|S|-2x(E(S))$.

    Finding violated blossoms

    A heuristic (Lecture 9). Keep only the fractional edges, $0\lt x^*_e\lt1$, call this graph $G_{1/2}$, and take its connected components $S$. For each $S$ look at the edges with $x^*_e=1$ that leave $S$. If there is an odd number of them, at least three, and they share no endpoints, they are the teeth of a blossom with handle $S$. If two of them meet at a city outside $S$, adding that city to $S$ removes two teeth; with three teeth this leaves a violated subtour cut, since then $x(\delta(S))=1$. On the prism, $G_{1/2}$ has the two triangles as components and three $1$-edges leave each: the blossom above. On Dantzig's 42 cities the heuristic finds two violated blossoms (one with five teeth, one with three) and the bound rises from $697$ to $698$.

    Exact separation (Lecture 10, Padberg and Rao, 1982). Write the blossom inequality as $x(\delta(H)\setminus T)+\sum_{e\in T}(1-x_e)\ge1$, where $T$ is the set of tooth edges. Build an auxiliary graph: split every support edge $e=\{u,v\}$ by a new node, give one half capacity $x_e$ and the other $1-x_e$, and call a node odd if it meets an odd number of $(1-x_e)$-halves. A minimum cut separating the odd nodes into two odd groups (an odd minimum cut, or T-cut) has value below $1$ exactly when some blossom is violated, and its sides give the handle and teeth. Odd minimum cuts can be found with a Gomory–Hu tree, by checking its edges that split the odd nodes oddly, so the separation is polynomial.

    A comb has $|H|=4$ and three teeth with $|T_1|=2$, $|T_2|=3$, $|T_3|=2$. What is the right side of its $E$-form inequality?

    $|H|+\sum(|T_i|-1)-\tfrac{k+1}2$.

    $4+(1+2+1)-2=6$.

    A blossom has five teeth. What is the right side of its $\delta$-form inequality?

    $3k+1$ with $k=5$.

    $16$.

    On the prism, take $H=\{1,2,3\}$ and only the two teeth $\{1,4\}$, $\{2,5\}$. Is the comb inequality violated, satisfied, or is this not a comb?

    Check the conditions on $k$.

    Not a comb: $k=2$ is even. (The sum would be $3+2+2=7=3\cdot2+1$, but the inequality is only valid for odd $k\ge3$.)

    Dantzig's 42 cities: by how much do the two blossoms found by the $G_{1/2}$ heuristic raise the LP bound that holds after all subtour cuts?

    Compare $697$ and $698$.

    From $697$ to $698$: by $1$. The optimum $699$ still needs branching (or more combs).

    • Verify the comb conditions (odd $k\ge3$, disjoint teeth, each tooth on both sides of $H$) before using the inequality.
    • Run the $G_{1/2}$ heuristic first; it is cheap and finds most violated blossoms in practice.
    • Counting a tooth's own edge in $x(\delta(T_i))$.
    • Adding blossoms as lazy constraints: tours satisfy them, so they are user cuts.
    1. A comb (handle, odd number $k\ge3$ of disjoint teeth meeting both sides of the handle) gives $x(\delta(H))+\sum x(\delta(T_i))\ge3k+1$; blossoms have two-city teeth.
    2. Comb inequalities are rounded combinations of degree and subtour constraints, and they are facets of the TSP polytope.
    3. Blossoms are separated by the $G_{1/2}$ heuristic or exactly through odd minimum cuts (Padberg–Rao); on Dantzig's 42 cities they move the bound from $697$ to $698$.

    Why must the number of teeth be odd?

    So that the handle has an odd number of cities.
    The handle size does not matter.
    The final rounding step gains only when $k$ is odd ($-\tfrac k2$ becomes $-\tfrac{k+1}{2}$).
    For even $k$ the inequality is implied by subtour cuts.
    Otherwise the teeth would overlap.
    Disjointness is a separate condition.

    On the prism, which cut family removes the point?

    Subtour cuts.
    The minimum cut is exactly $2$.
    Degree constraints.
    Every city has degree $2$.
    Blossoms.
    The left side is $9$, below $3k+1=10$.

    In the $G_{1/2}$ heuristic, a component $S$ has four $1$-edges leaving it. What can you conclude?

    A blossom with four teeth is violated.
    Blossoms need an odd number of teeth.
    This component gives no blossom by the heuristic.
    Lecture 9's dantzig42 example has such an even case.
    The point is a tour.
    Fractional edges remain.

    What does the Padberg–Rao method compute to separate blossoms exactly?

    A shortest path.
    The structure is a cut, not a path.
    A maximum matching.
    Close in spirit, but the method is a cut computation.
    An odd minimum cut in an auxiliary graph with capacities $x_e$ and $1-x_e$.
    A value below $1$ reveals a violated blossom.

    Time windows, infeasible paths and the TSP labs

    With time windows, a route can be connected and still impossible because some stretch of it arrives too late. Instead of time variables with big-M constraints, one can forbid each impossible stretch directly with an infeasible-path inequality, and strengthen it to a tournament inequality.

    Lab 5 compares exactly these two approaches, and Lab 3 asks for TSP formulations with pickups and deliveries, clusters and backhauls. Each is a small modification of the DFJ model of Part 5.

    It is like planning a day of errands: rather than writing down the clock time of every stop, list the sequences that cannot work ("bank, then post office, then market is too late") and avoid them.

    The big-M model and its weakness

    Lecture 10 uses an open-path TSPTW: start at city $0$, visit every city $i\in N$ in its window $[a_i,b_i]$, no return. With service time $s_i$ and travel time $t_{ij}$, let $\vartheta_{ij}=t_{ij}+s_i$ be the least delay between starting service at $i$ and at $j$. With start times $y_i$ the model is the assignment constraints plus

    $$y_j\ge y_i+\vartheta_{ij}-M(1-x_{ij}),\qquad a_i\le y_i\le b_i.$$

    As in Ch. 5.4 and Part 6, big-M rows make the LP weak: with $x_{ij}=\tfrac12$ the time link is almost switched off.

    A path $P=(i_1,\dots,i_k)$ is infeasible if it is not part of any feasible tour (a given path is checked by walking along it and compare arrival times with the windows). The infeasible-path inequality forbids using all its $k-1$ arcs: $\sum_{l=1}^{k-1}x_{i_li_{l+1}}\le k-2$. Its transitive closure $[P]=\{(i_l,i_m): 1\le l\lt m\le k\}$ contains every arc that goes forward along $P$, and the tournament inequality

    $$x([P])=\sum_{l=1}^{k-1}\sum_{m=l+1}^{k}x_{i_li_m}\ \le\ k-2$$

    is valid. (Lecture 10 writes the right side as $|P|-1$ with $|P|$ the number of arcs, $k-1$.)

    Suppose a feasible tour has $x([P])\ge k-1$. Each city $i_l$ has out-degree $1$, so $\sum_{m\gt l}x_{i_li_m}\le1$ for $l=1,\dots,k-1$; adding these $k-1$ bounds gives $x([P])\le k-1$, so every one of them holds with equality. For $l=k-1$ this says $x_{i_{k-1}i_k}=1$. Then city $i_{k-2}$ has its out-arc inside $\{i_{k-1},i_k\}$, and $i_k$ already has its in-arc from $i_{k-1}$, so $x_{i_{k-2}i_{k-1}}=1$; continuing backwards, the tour contains the whole path $P$, which is infeasible. Contradiction.

    Cities $A$, $B$, $C$ with zero service times: window of $A$ opens at $8$, $t_{AB}=5$, $t_{BC}=6$, window of $C$ closes at $18$. Show that $P=(A,B,C)$ is infeasible, write its two inequalities, and compare them at the LP point $x_{AB}=x_{BC}=x_{AC}=\tfrac12$.

    1. Earliest start at $A$ is $8$, arrival at $B$ at $13$, arrival at $C$ at $19\gt18$. So no tour can contain $A\to B\to C$.

      Waiting can only delay arrivals, so the earliest times decide.

    2. Infeasible-path inequality ($k=3$): $x_{AB}+x_{BC}\le1$. Tournament inequality: $x_{AB}+x_{AC}+x_{BC}\le1$.

      The closure adds the "shortcut" arc $A\to C$.

    3. At the LP point the path inequality reads $1\le1$: satisfied. The tournament inequality reads $1.5\gt1$: violated.

      The tournament inequality is stronger: it also forbids splitting the path across $A\to C$.

    Try it

    This is the time-window widget of Ch. 5.4. Build orders one stop at a time and note each order that fails, and at which stop. Every failing prefix is an infeasible path: one inequality for it removes every tour that starts with it.

    Lecture 10 adds that every TSP inequality stays valid for the TSPTW, that further families from precedence relations exist, and that even with a single time window the dimension of the TSPTW polytope is hard to determine. A branch-and-cut code with infeasible-path cuts and heuristic separation solved instances with about 250 cities (Ascheuer and co-authors, 2001).

    The TSP models of Lab 3

    • Milk van with pickups and deliveries. City $i$ has $q_i\gt0$ (supply) or $q_i\lt0$ (demand); the van starts empty with capacity $Q$. Add a load variable $u_i$ after visiting $i$, with $u_j\ge u_i+q_j-M(1-x_{ij})$ and $\max(0,q_i)\le u_i\le\min(Q,Q+q_i)$; the load constraint also removes subtours, as MTZ does.
    • Clustered TSP. Customers in a cluster must be visited one after another. In the model, each cluster $N_k$ has exactly one arc entering and one leaving: $x(\delta^-(N_k))=x(\delta^+(N_k))=1$. Without changing the model, add a large constant $L$ to the cost of every arc between different clusters (and the depot): a tour that visits clusters contiguously uses the fewest such arcs, $m+1$ with $m$ clusters, so any ordinary TSP solver returns a contiguous tour.
    • Linehaul before backhaul. Delete arcs from a backhaul customer to a linehaul customer and from the depot to a backhaul customer; arcs from linehauls to the depot are deleted too unless there are no backhauls. The two groups then appear as two contiguous blocks, deliveries first.

    An infeasible path has $k=5$ cities. How many arcs does its transitive closure $[P]$ contain, and what is the right side of the tournament inequality?

    Every ordered pair $l\lt m$ along the path; right side $k-2$.

    $\binom52=10$ arcs; right side $5-2=3$.

    Window of $A$ opens at $10$, service at $A$ takes $2$, $t_{AB}=4$, and the window of $B$ is $[0,15]$. Is the one-arc path $(A,B)$ infeasible, so that the arc $A\to B$ can be deleted?

    Earliest start at $B$ is $a_A+s_A+t_{AB}$.

    $10+2+4=16\gt15$: yes. This is the arc-deletion rule of Ch. 6.3, the case $k=2$ (right side $0$).

    A depot and three clusters. In a tour that visits each cluster contiguously, how many arcs join two different groups (counting the depot as its own group)?

    Think of the order depot, cluster, cluster, cluster, depot.

    $m+1=4$: depot to the first cluster, two arcs between clusters, and the last cluster back to the depot. Any non-contiguous tour uses more, so adding $L$ to these arcs penalises it.

    • Use the earliest possible start times when testing whether a path is infeasible.
    • Prefer the tournament form: it has the same right side and more arcs on the left.
    • Writing the right side as $k-1$: a path of $k$ cities has $k-1$ arcs and at most $k-2$ of them may be used.
    • Forgetting that in a clustered TSP the penalty $L$ must exceed any saving from breaking a cluster.
    1. Big-M time constraints give weak LPs; infeasible-path inequalities forbid each impossible stretch directly and are found by walking along a path.
    2. The tournament inequality $x([P])\le k-2$ over the transitive closure is valid by a degree-counting argument and dominates the path inequality.
    3. Lab 3's variants are small edits of the TSP: load variables for pickups and deliveries, cluster cuts or a cost penalty for clusters, arc deletion for linehaul-before-backhaul.

    The path $(A,B,C)$ is infeasible. Which arc appears in the tournament inequality but not in the path inequality?

    $B\to A$
    Only forward arcs along the path are included.
    $A\to C$
    The closure adds every forward pair, here the shortcut.
    $C\to A$
    That goes backwards.

    Why does a fractional $x_{ij}=\tfrac12$ weaken the big-M time row $y_j\ge y_i+\vartheta_{ij}-M(1-x_{ij})$?

    The row is relaxed by $M/2$, which is usually large enough to make it inactive.
    That is why such LPs give poor bounds.
    The row becomes infeasible.
    It becomes looser, not infeasible.
    $y_j$ must then equal $y_i$.
    Nothing forces equality.

    Should infeasible-path inequalities be lazy constraints or user cuts in a TSPTW code whose model has no time variables?

    User cuts, since tours satisfy them.
    Some tours (the infeasible ones) do not.
    Lazy constraints, since without them an integer solution may break the windows.
    They are what makes the model correct.
    Neither; they are added up front.
    There are exponentially many paths.

    A support graph is connected but city $7$ is an articulation point. What do you add?

    A blossom with handle $\{7\}$.
    A one-city handle with this structure is a subtour question.
    Subtour cuts for the pieces left after removing city $7$.
    One of them has $x(\delta(C))\le1$.
    Nothing; connected means no subtour cut is violated.
    Connectivity alone does not give $x(\delta(S))\ge2$.

    A blossom with $k=3$ teeth at an LP point has left side $9.4$. Is it violated?

    No, $9.4\gt9$.
    The right side is $3k+1$.
    Yes, $9.4\lt10$.
    $3\cdot3+1=10$.
    Only if $k$ were even.
    Combs need odd $k$.

    The tournament inequality for an infeasible path of $4$ cities has how many arcs on the left and what right side?

    $3$ arcs, right side $3$
    That is the path itself with no restriction.
    $4$ arcs, right side $2$
    Count all forward pairs.
    $6$ arcs, right side $2$
    $\binom42=6$ and $k-2=2$.

    The blossom inequality is the TSP relative of which Part 7 inequality?

    The cover inequality.
    Covers come from knapsack rows.
    The odd-set inequality for matchings, obtained by CG rounding.
    Both round away a half using an odd count.
    The clique inequality.
    Cliques come from conflict graphs.

    In a TSP branch-and-cut callback, at which event do you separate blossoms?

    MIPSOL, with cbLazy.
    Integer tours never violate blossoms.
    MIPNODE, with cbCut.
    They are user cuts on fractional node solutions.
    Only before the solve.
    They depend on the LP point.

    Lecture 13 solves linear programmes with far too many variables to write down. Column generation keeps a few columns, reads the dual prices, and asks a pricing problem for a column with negative reduced cost; when there is none, the LP is solved. The part works through the two examples of the lecture (cutting stock with a knapsack pricing problem, and a resource-constrained shortest path with a path formulation) and then Dantzig–Wolfe decomposition, which turns a problem with independent blocks and a few linking constraints into exactly such a master problem, and whose bound equals the Lagrangian bound.

    You need: Part 2 (reduced costs, dual prices, the dual simplex view, Ch. 2.1–2.3), Part 1 (extreme points and the resolution of a polyhedron into vertices and rays, Ch. 1.2), Ch. 6.2 (set partitioning and the first look at column generation), and Part C (shortest paths).

    Column generation and the cutting-stock problem

    Column generation solves an LP with a huge number of variables by keeping only a few of them, solving that small LP, and then searching, with the help of its dual prices, for a left-out variable whose reduced cost is negative.

    Most variables of such an LP are zero at the optimum, so a few columns are enough if they are the right ones. The search for them is a separate optimisation problem, often a classical one (a knapsack, a shortest path), and this is how the route-based VRP models of Ch. 6.2 and Part 11 are solved.

    It is like hiring for a project: you start with a small team, ask what each skill is currently worth to the team, and interview only candidates whose skills are worth more than their salary.

    Why the duals are enough

    For $\min\{c^\top x: Ax=b,\ x\ge0\}$ with basis $B$, the dual prices are $y^\top=c_B^\top B^{-1}$ and the reduced cost of column $j$ is $\bar c_j=c_j-y^\top A_{\cdot j}$ (Part 2). The basis is optimal when every $\bar c_j\ge0$, which is the same as $y$ being dual feasible: $A^\top y\le c$. Checking this for millions of columns one by one is hopeless, but if the columns have a structure, the most negative reduced cost can be found by optimisation.

    1. Restricted master problem (RMP). Choose a set $J$ of columns for which $\min\{\sum_{j\in J}c_jx_j: \sum_{j\in J}A_{\cdot j}x_j=b,\ x\ge0\}$ is feasible. Its optimal solution, padded with zeros, is a basic feasible solution of the full LP.
    2. Solve the RMP and take its optimal duals $y$.
    3. Pricing. Solve $z_{\text{sub}}=\min_{j\notin J}(c_j-y^\top A_{\cdot j})$, using the structure of the columns.
    4. If $z_{\text{sub}}\lt0$, add the minimising column (or several negative ones) to $J$ and go to step 2. Otherwise the RMP solution is optimal for the full LP.

    Row generation is the same idea applied to the dual: a problem with few variables and very many constraints is solved with a few constraints, and a separation problem finds a violated one. This is the cutting-plane loop of Ch. 8.1, and it is why "pricing" and "separation" are mirror images.

    Implementation choices (Lecture 13): keep all generated columns or drop columns that stay non-basic for a while; add several negative columns per round (any negative column improves the RMP or leaves it unchanged); price heuristically while it finds negative columns, and run an exact pricing only to prove optimality at the end. Degeneracy can make the RMP value stall for several rounds.

    If every feasible solution has $\sum_jx_j\le\kappa$, then $z_{\text{LP}}\ge z_{\text{RMP}}+\kappa\,z_{\text{sub}}$ (a Lagrangian bound). For cutting stock, where every column costs $1$, a sharper form is $z_{\text{LP}}\ge z_{\text{RMP}}/\max_j y^\top A_{\cdot j}$ (Farley's bound). So column generation can be stopped early with a known gap.

    Cutting stock

    Large rolls of width $W$ are cut into narrow rolls: width $w_i$ is needed $b_i$ times. A pattern $j$ says how many pieces $a_{ij}$ of each width one roll gives, with $\sum_iw_ia_{ij}\le W$. With $x_j$ = number of rolls cut by pattern $j$: $\min\sum_jx_j$ subject to $\sum_ja_{ij}x_j\ge b_i$, $x\ge0$ (and integer). Every column costs $1$, so the reduced cost of a pattern is $1-y^\top a$, and pricing is an integer knapsack:

    $$\max\Big\{\sum_iy_ia_i:\ \sum_iw_ia_i\le W,\ a\in\Z^m_+\Big\}.$$

    A pattern enters when this maximum exceeds $1$. A first RMP: one homogeneous pattern per width, $\lfloor W/w_i\rfloor$ pieces of width $i$.

    Kaveri Courier

    The firm's packaging supplier cuts rolls of width $25$ into widths $12,9,7,5$, needed $15,25,30,20$ times.

    Try it

    Press the button to solve the master, read the duals, solve the pricing knapsack and add the best pattern. Watch the master value fall from $34$ to $29.25$ while the lower bound rises to meet it. Notice that the final LP uses only four patterns out of the $30$ that fit in a roll.

    Run column generation on the cutting-stock instance (roll $25$; widths $12,9,7,5$; demands $15,25,30,20$) starting from the homogeneous patterns, and give an optimal integer plan's size.

    1. RMP 1: patterns $(2,0,0,0)$, $(0,2,0,0)$, $(0,0,3,0)$, $(0,0,0,5)$ give $x=(7.5,12.5,10,4)$ and $34$ rolls. Duals $y=(\tfrac12,\tfrac12,\tfrac13,\tfrac15)$: one piece is worth $1/(\text{pieces per roll})$.

      Each row has a single column, so each dual is the cost of the roll divided by the pieces it gives.

    2. Pricing: $9+9+7=25$ gives $y^\top a=\tfrac12+\tfrac12+\tfrac13=\tfrac43\gt1$, reduced cost $-\tfrac13$. It enters. Farley's bound: $34/\tfrac43=25.5$.

      The knapsack prefers pieces with high value per unit width, and $9+9+7$ fills the roll exactly.

    3. RMP 2: value $\tfrac{179}{6}\approx29.83$, duals $(\tfrac12,\tfrac13,\tfrac13,\tfrac15)$. Pricing finds $7+7+5+5=24$ with value $\tfrac23+\tfrac25=\tfrac{16}{15}$, reduced cost $-\tfrac1{15}$. It enters. Bound $27.97$.

      The price of width $9$ dropped because the new pattern makes it cheaper to produce.

    4. RMP 3: value $\tfrac{117}{4}=29.25$, duals $(\tfrac12,\tfrac7{20},\tfrac3{10},\tfrac15)$. The best pattern has value exactly $1$, so no column has negative reduced cost: the LP optimum is $29.25$, with $x=7.5$ of $12+12$, $0.5$ of $5\times5$, $12.5$ of $9+9+7$ and $8.75$ of $7+7+5+5$.

      Optimality is certified by the pricing problem, without listing all $30$ patterns.

    5. Every integer plan needs at least $\lceil29.25\rceil=30$ rolls, and a plan with $30$ rolls exists (found by solving the integer programme over all patterns). So $30$ is optimal.

      For cutting stock, rounding the LP bound up is often already tight.

    The class run of 29 October used roll width $100$ with widths $45,36,31,14$ and demands $97,610,395,211$: the RMP went $515.31\to485.17\to452.25$ in three solves, and the integer optimum is $453$ rolls.

    At the second master of the example the duals for widths $(12,9,7,5)$ are $y=(\tfrac12,\tfrac13,\tfrac13,\tfrac15)$. What is the reduced cost of the pattern $12+7+5$ (one piece each)?

    $\bar c=1-y^\top a$.

    $y^\top a=\tfrac12+\tfrac13+\tfrac15=\tfrac{31}{30}$, so $\bar c=1-\tfrac{31}{30}=-\tfrac1{30}$. It could enter too, but $7+7+5+5$ (reduced cost $-\tfrac1{15}$) is better.

    A cutting-stock RMP has value $36$ and the pricing knapsack's best value is $y^\top a=1.25$. What lower bound on the LP optimum does Farley's bound give?

    $z_{\text{RMP}}/\max y^\top a$.

    $36/1.25=28.8$. The LP optimum lies in $[28.8,36]$.

    Roll width $25$, widths $12,9,7,5$ with duals $(\tfrac12,\tfrac13,\tfrac13,\tfrac15)$. The pattern $7+7+5+5$ has value $\tfrac{16}{15}$. How many pieces of width $7$ does the homogeneous pattern for width $7$ contain?

    $\lfloor25/7\rfloor$.

    $3$ pieces ($21$ of the $25$ used). Its value is $3\cdot\tfrac13=1$, so it has reduced cost $0$.

    • Start from a feasible RMP (homogeneous patterns, single-customer routes, or artificial columns with a large cost).
    • Report a lower bound (Farley or Lagrangian) at each round so early stopping has a known gap.
    • Stopping when the RMP value does not change: it can stall under degeneracy while negative columns still exist.
    • Treating the LP optimum of the master as an integer solution: branching (Part 11) is still needed.
    1. Column generation alternates a restricted master LP (giving duals $y$) and a pricing problem $\min_j(c_j-y^\top A_{\cdot j})$; it stops when no column has negative reduced cost, which is dual feasibility.
    2. For cutting stock the pricing problem is an integer knapsack $\max\{y^\top a: w^\top a\le W\}$, and a pattern enters when its value exceeds $1$.
    3. A lower bound is available at every round ($z_{\text{RMP}}/\max y^\top a$ for cutting stock); on the example $34\to29.83\to29.25$, and rounding up gives the optimum $30$.

    Pricing returns $z_{\text{sub}}=0$. What do you conclude?

    The master is infeasible.
    It has an optimal solution, so it is feasible.
    No column has negative reduced cost: the RMP solution is optimal for the full LP.
    The duals are feasible for the full dual.
    The integer optimum is found.
    The LP may still be fractional.

    In cutting stock, which pattern enters?

    The one with the most pieces.
    Pieces are weighted by their dual prices.
    The one that fills the roll best.
    Waste is not the criterion; value is.
    One with $y^\top a\gt1$, best the one maximising $y^\top a$.
    Its reduced cost $1-y^\top a$ is negative.

    Row generation is to column generation as:

    Separation (finding a violated constraint) is to pricing (finding a negative reduced cost).
    They are the same idea on the primal and on the dual.
    Branching is to bounding.
    Those are parts of branch and bound.
    The simplex method is to interior points.
    Not related to this duality.

    Resource-constrained shortest paths by column generation

    A shortest path with a budget (cheapest route that arrives within a time limit) is no longer a polynomial network problem. Written with one variable per path, its LP is solved by column generation, and the pricing problem is an ordinary shortest path with modified arc weights.

    This is the core of the VRP pricing problem of Part 11 in its simplest form, and it is Lab 6, where the network is the New York road graph with $264{,}346$ nodes and $733{,}846$ arcs.

    It is like choosing a commute when time is money: put a price on each minute, add it to the fare of every leg, and the cheapest priced route is quick to find; the art is choosing the price.

    Arc formulation and why it is hard

    Each arc $(i,j)$ has a cost $c_{ij}$ and a time $t_{ij}$; find the cheapest path from $s$ to $t$ with total time at most $B$. With $x_{ij}\in\{0,1\}$: minimise $\sum c_{ij}x_{ij}$ subject to flow conservation (one unit out of $s$, into $t$) and $\sum t_{ij}x_{ij}\le B$. The flow constraints alone have a totally unimodular matrix, so their LP is integral (Part C); the single budget row destroys this, and the problem is NP-hard.

    With $\mathcal P$ the set of $s$–$t$ paths, path $p$ of cost $c_p$ and time $t_p$, and $y_p\in\{0,1\}$:

    $$\min\sum_pc_py_p\quad\text{s.t.}\quad\sum_pt_py_p\le B\ \ (w_1),\qquad\sum_py_p=1\ \ (w_2).$$

    The duals are $w_1\le0$ (a $\le$ row in a minimisation) and $w_2$ free. The reduced cost of a path is $\bar c_p=c_p-w_1t_p-w_2=\sum_{(i,j)\in p}(c_{ij}-w_1t_{ij})-w_2$. So pricing is a shortest path with arc weights $c_{ij}-w_1t_{ij}=c_{ij}+\mu t_{ij}$, where $\mu=-w_1\ge0$ is the price of one unit of time: the budget constraint is gone from the subproblem. A path enters if its weight is below $w_2$.

    Kaveri Courier

    A van must get from the depot (node $1$) to a client (node $6$) within $12$ minutes, at least cost. Arcs (cost, time): $1\to2$ $(2,6)$, $1\to3$ $(5,2)$, $2\to3$ $(1,1)$, $2\to4$ $(2,7)$, $2\to5$ $(6,4)$, $3\to4$ $(4,3)$, $3\to5$ $(7,1)$, $4\to5$ $(1,1)$, $4\to6$ $(2,5)$, $5\to6$ $(3,2)$. There are nine paths; the feasible ones cost at least $11$ ($1\text{-}2\text{-}5\text{-}6$ and $1\text{-}3\text{-}4\text{-}6$).

    Solve the LP of the path formulation by column generation, starting from the fastest path $1\text{-}3\text{-}5\text{-}6$ (cost $15$, time $5$).

    1. RMP 1: only one path, $y=1$, value $15$. The budget is slack, so $w_1=0$; $w_2=15$.

      A slack constraint has dual price $0$ (complementary slackness, Ch. 2.3).

    2. Pricing with weights $c_{ij}$ (time is free): the cheapest path is $1\text{-}2\text{-}4\text{-}6$, cost $6$, time $18$. $\bar c=6-15=-9$: enter.

      It is too slow on its own, but a mixture with the fast path can meet the budget in the LP.

    3. RMP 2: mix $\tfrac6{13}$ of the fast path and $\tfrac7{13}$ of the cheap one (time exactly $12$): value $\tfrac{132}{13}\approx10.15$. Duals $w_1=-\tfrac9{13}$, $w_2=\tfrac{240}{13}$. Pricing with weights $c_{ij}+\tfrac9{13}t_{ij}$ finds $1\text{-}3\text{-}4\text{-}6$ (cost $11$, time $10$): $\bar c=11+\tfrac{90}{13}-\tfrac{240}{13}=-\tfrac7{13}$. Enter.

      The price on time, $\mu=\tfrac9{13}$, is the slope between the two paths: $(15-6)/(18-5)$.

    4. RMP 3: $\tfrac14$ of $1\text{-}2\text{-}4\text{-}6$ and $\tfrac34$ of $1\text{-}3\text{-}4\text{-}6$, value $\tfrac{39}{4}=9.75$, duals $w_1=-\tfrac58$, $w_2=\tfrac{69}{4}$. With weights $c+\tfrac58t$ both paths in the mix weigh $17.25=w_2$ and every other path weighs more, so no reduced cost is negative: the LP optimum is $9.75$.

      The integer optimum is $11$; the gap is closed by branching.

    5. The arc formulation's LP (with $0\le x_{ij}\le1$) also has value $9.75$, with $x_{12}=x_{24}=\tfrac14$, $x_{13}=x_{34}=\tfrac34$, $x_{46}=1$.

      The pricing problem (paths) has an integral LP, so the path LP equals the arc LP: this is the Dantzig–Wolfe statement of Ch. 10.3.

    Try it

    Move the price $\mu$ on time. For each price the widget finds the cheapest path with weights $c+\mu t$ and plots $L(\mu)=\min_p(c_p+\mu t_p)-\mu B$, a lower bound on the optimum. Find the price that gives the largest bound, and compare it with the LP value $9.75$ and the integer optimum $11$.

    Two cautions carry over to Part 11. First, with general reduced costs some arc weights $c_{ij}-w_1t_{ij}-\dots$ can be negative, so the pricing path must be elementary (no repeated nodes) and a plain label-correcting algorithm is not enough; here all weights are positive because $w_1\le0$. Second, the LP bound is only a bound: Lab 6's New York instance shows the same pattern at scale, a fractional mix of a fast and a cheap path.

    At the final duals $w_1=-\tfrac58$, $w_2=\tfrac{69}4$, compute the reduced cost of path $1\text{-}2\text{-}5\text{-}6$ (cost $11$, time $12$).

    $\bar c_p=c_p-w_1t_p-w_2$.

    $11+\tfrac58\cdot12-17.25=11+7.5-17.25=1.25\ge0$.

    With price $\mu=\tfrac58$ on time, the cheapest priced path weighs $17.25$ and the budget is $B=12$. What is the Lagrangian bound $L(\mu)=\min_p(c_p+\mu t_p)-\mu B$?

    $17.25-\tfrac58\cdot12$.

    $17.25-7.5=9.75$, equal to the LP optimum.

    What bound does $\mu=0$ give for the same instance?

    With no price on time, the subproblem is the plain cheapest path.

    The cheapest path costs $6$ ($1\text{-}2\text{-}4\text{-}6$), so $L(0)=6$: a valid but weak bound.

    • Get the dual signs right: $w_1\le0$ for a $\le$ resource row in a minimisation, so the price $\mu=-w_1$ on time is non-negative.
    • Recognise that pricing removes the complicating row and keeps the network structure.
    • Expecting the path LP to be integral because the arc LP of the plain shortest path is.
    • Using a label-correcting shortest path when arc weights can be negative and cycles are forbidden.
    1. The budget row breaks the integrality of the shortest-path LP; the path formulation has two rows and one column per path.
    2. Pricing is a shortest path with weights $c_{ij}-w_1t_{ij}$: the dual of the budget row becomes a price on time.
    3. On the example column generation gives $15\to10.15\to9.75$, equal to the arc LP and to the best Lagrangian bound; the integer optimum is $11$.

    Why is $w_1\le0$ in the path formulation?

    Because times are positive.
    The sign comes from the row type, not the data.
    It is the dual of a $\le$ row in a minimisation.
    Relaxing the budget can only lower the cost.
    Because the convexity row is an equation.
    That makes $w_2$ free, not $w_1$ negative.

    What does the pricing problem look like?

    The same RCSP, with a budget.
    The budget has moved into the arc weights.
    A shortest path with weights $c_{ij}+\mu t_{ij}$, compared with $w_2$.
    Solvable by Dijkstra when weights are non-negative.
    A knapsack.
    That is cutting stock.

    Why does the path LP give the same bound as the arc LP here?

    Because both are integral.
    Both are $9.75$, the integer optimum is $11$.
    By coincidence on this instance.
    It holds in general for this structure.
    The subproblem (flow from $s$ to $t$) has an integral LP, so convexifying it adds nothing.
    Dantzig–Wolfe gains only when the subproblem lacks this property.

    Dantzig–Wolfe decomposition and Lagrangian bounds

    Dantzig–Wolfe decomposition rewrites a problem made of independent blocks joined by a few linking constraints: each block's variables are replaced by a weighted combination of the block's extreme points, and the master problem chooses the weights. Column generation then produces extreme points on demand.

    Applied to the three-index VRP of Ch. 6.2, with one block per vehicle, it gives the set-partitioning model; that is the bridge to branch and price in Part 11. Its LP bound equals the Lagrangian bound, which is never weaker than the LP of the original formulation.

    It is like a company with several departments and a shared budget: each department proposes complete plans, and head office only decides how much weight each proposal gets, sending back prices for the shared budget.

    Block structure and the master problem

    Consider $\min\ c^\top x+d^\top y$ subject to $D_1x+D_2y=b_0$ (the $m_0$ linking rows), $x\in X=\{x\ge0: A_1x=b_1\}$ and $y\in Y=\{y\ge0: A_2y=b_2\}$. By the resolution theorem (Ch. 1.2), every $x\in X$ is $x=\sum_j\lambda_jx^j+\sum_k\mu_ku^k$ with extreme points $x^j$, extreme rays $u^k$, $\lambda,\mu\ge0$ and $\sum_j\lambda_j=1$; similarly $y$ with weights $\pi,\theta$.

    $$\begin{aligned}\min\ &\textstyle\sum_j\lambda_j\,c^\top x^j+\sum_k\mu_k\,c^\top u^k+\sum_j\pi_j\,d^\top y^j+\sum_k\theta_k\,d^\top v^k\\ \text{s.t. }&\textstyle\sum_j\lambda_jD_1x^j+\sum_k\mu_kD_1u^k+\sum_j\pi_jD_2y^j+\sum_k\theta_kD_2v^k=b_0\quad(z)\\ &\textstyle\sum_j\lambda_j=1\ \ (w_1),\qquad\sum_j\pi_j=1\ \ (w_2),\qquad\lambda,\mu,\pi,\theta\ge0.\end{aligned}$$

    It has only $m_0+2$ rows but one column per extreme point and ray, so it is solved by column generation.

    With master duals $z$ (linking rows) and $w_1,w_2$ (convexity rows), the reduced cost of the column of extreme point $x^j$ is $(c^\top-z^\top D_1)x^j-w_1$, and of ray $u^k$ it is $(c^\top-z^\top D_1)u^k$. So one LP per block finds the best column:

    $$\min\{(c^\top-z^\top D_1)x:\ x\in X\}.$$

    If it is unbounded, the simplex method returns a ray with negative cost, and its $\mu$ column enters. If its optimum is an extreme point with value below $w_1$, its $\lambda$ column enters. The method stops when every block's subproblem has value at least its convexity dual.

    At any round, $z_{\text{RMP}}+\sum_{\text{blocks}}\min(0,\ \text{block value}-w_{\text{block}})$ is a lower bound on the master LP. For an integer programme decomposed with integer blocks ($X$ replaced by its integer points), the master LP bound $z_{\text{DW}}$ satisfies

    $$z_{\text{LP}}\ \le\ z_{\text{DW}}\ =\ z_{\text{LD}}\ \le\ z_{\text{IP}},$$

    where $z_{\text{LD}}=\max_{z}L(z)$ is the Lagrangian dual: $L(z)=z^\top b_0+\min_{x\in X}(c^\top-z^\top D_1)x+\min_{y\in Y}(d^\top-z^\top D_2)y$, the bound obtained by moving the linking rows into the objective with prices $z$. The first inequality is strict only when a block's LP is not integral (it lacks the integrality property); for paths (Ch. 10.2) it is integral, so there $z_{\text{DW}}=z_{\text{LP}}$.

    Kaveri Courier

    Two depots plan shipments. Depot X sends $x_1,x_2$ units on two lanes at costs $2,3$ per unit, with $x_1\le4$, $x_2\le3$, $x_1+x_2\le5$. Depot Y sends $y_1,y_2$ at costs $4,1$, with $y_1\le3$, $y_2\le4$, $y_1+y_2\le5$. Together they must ship at least $7$ units: $x_1+x_2+y_1+y_2\ge7$. The blocks have vertices $X$: $(0,0),(4,0),(4,1),(2,3),(0,3)$ and $Y$: $(0,0),(3,0),(3,2),(1,4),(0,4)$. Solved directly, the optimum is $x=(3,0)$, $y=(0,4)$ with cost $10$.

    Run Dantzig–Wolfe on the two-depot problem, starting from the columns $x=(4,1)$ and $y=(1,4)$, and track the lower bound.

    1. RMP 1: both columns at weight $1$, cost $11+8=19$, linking total $10\ge7$. The linking row is slack, so $z=0$; the convexity duals are $w_1=11$, $w_2=8$.

      With a single column per block, each block's dual is that column's cost.

    2. Subproblems with costs $c-z=(2,3)$ and $d-z=(4,1)$: both choose $(0,0)$, value $0$. Reduced costs $0-11=-11$ and $0-8=-8$: both enter. Bound $19-11-8=0$.

      Without a price on shipping, each depot would rather ship nothing.

    3. RMP 2: value $12.4$ ($x=0.4\cdot(4,1)$, $y=(1,4)$), $z=2.2$, $w_1=0$, $w_2=-3$. Subproblem X with costs $(-0.2,0.8)$ chooses $(4,0)$, value $-0.8$; Y with $(1.8,-1.2)$ chooses $(0,4)$, value $-4.8$, reduced cost $-4.8+3=-1.8$. Both enter. Bound $12.4-0.8-1.8=9.8$.

      The price $2.2$ per shipped unit makes the cheap lanes attractive.

    4. RMP 3: value $10$ with $x=\tfrac34(4,0)=(3,0)$ and $y=(0,4)$; $z=2$, $w_1=0$, $w_2=-4$. Both subproblems now have value equal to their duals ($0$ and $-4$): stop. Bound $=10$.

      Upper and lower bound meet; the solution is also integral here because the blocks' vertices are integral.

    5. Lagrangian check: $L(z)=7z+\min_X(2-z,3-z)\cdot x+\min_Y(4-z,1-z)\cdot y$ gives $L(0)=0$, $L(1)=7$, $L(2)=10$, $L(3)=9$: the maximum is $10$ at $z=2$, the final master dual.

      The DW bound and the Lagrangian dual coincide.

    Try it

    Move the price $z$ on the linking row. Each depot picks its cheapest vertex for the priced costs, and the curve shows $L(z)$. Find the price where the two depots' choices together ship exactly $7$ units, and check that the bound is largest there.

    From the three-index VRP to set partitioning

    In the three-index model of Ch. 6.2, every vehicle $k$ is a block: its constraints (flow conservation, capacity, time windows) describe one feasible route, and the linking rows say that each customer is served once. Dantzig–Wolfe replaces the block's variables by a convex combination of its integer points, the feasible routes. With identical vehicles the $K$ blocks are the same, their convexity rows add up to "the weights of all routes sum to $K$" (or "at most $K$"), and the master is exactly the set-partitioning model with the route-count row. Its pricing problem is a shortest path over a single vehicle's routes with resource limits: Part 11.

    A problem has $3$ linking rows and $2$ blocks. How many rows does its Dantzig–Wolfe master have?

    Linking rows plus one convexity row per block.

    $3+2=5$.

    For the two-depot problem compute $L(3)=7\cdot3+\min_{x\in X}(2-3)x_1+(3-3)x_2+\min_{y\in Y}(4-3)y_1+(1-3)y_2$.

    X: maximise $x_1$; Y: maximise $2y_2-y_1$ over the vertices.

    X: $-x_1$ is smallest at $x_1=4$: $-4$. Y: $y_1-2y_2$ is smallest at $(0,4)$: $-8$. $L(3)=21-4-8=9\le10$.

    Master duals: $z=2$ on a linking row $x_1+x_2+\dots\ge7$, convexity dual $w_1=1$ for block X with costs $(2,3)$. What is the reduced cost of the column for the point $x=(0,2.5)$ of X?

    $(c-zD_1)x-w_1$ with $D_1=(1,1)$.

    $(2-2)\cdot0+(3-2)\cdot2.5-1=1.5\ge0$, so this column would not enter.

    • Write one convexity row per block and price each block separately with $c-z^\top D$.
    • Use the bound $z_{\text{RMP}}+\sum\min(0,\text{reduced cost})$ to judge early stopping.
    • Forgetting extreme rays when a block is unbounded.
    • Expecting a better bound than the LP when every block has an integral LP.
    1. Dantzig–Wolfe writes each block as a convex combination of its extreme points (plus rays) and keeps only the linking rows and one convexity row per block in the master.
    2. Each block is priced by $\min\{(c-z^\top D)x: x\in X\}$, compared with its convexity dual; the master bound equals the Lagrangian dual, $z_{\text{LP}}\le z_{\text{DW}}=z_{\text{LD}}\le z_{\text{IP}}$.
    3. Decomposing the three-index VRP by vehicle gives the set-partitioning model, whose pricing problem is a resource-constrained shortest path.

    A block's subproblem is unbounded. What enters the master?

    Nothing; the problem is unbounded.
    The master may still be bounded.
    The column of an extreme ray with negative priced cost (a $\mu$ variable).
    Rays have no convexity row, so they are compared with $0$.
    An artificial variable.
    Artificials only start the master.

    When is $z_{\text{DW}}$ strictly larger than $z_{\text{LP}}$?

    Always.
    For the RCSP the two were equal.
    Never.
    Set partitioning beats the two-index degree LP by a lot.
    When some block's LP relaxation is not integral.
    Then convexifying the integer block points cuts off fractional block solutions.

    In the two-depot example the final price on the linking row is $z=2$. What does it mean?

    One more unit of required shipping would raise the optimal cost by about $2$.
    A dual price is a marginal cost (Part 2).
    Each depot pays $2$ per unit.
    The costs per lane are $2,3,4,1$; $z$ is the value of the shared requirement.
    The problem needs $2$ more iterations.
    It has stopped.

    Decomposing the three-index VRP with identical vans by vehicle gives a master whose columns are:

    Arcs.
    Arcs belong to the compact model.
    Feasible routes, with a row saying the route weights sum to $K$.
    The set-partitioning model of Ch. 6.2.
    Customers.
    Customers are the rows.

    Cutting-stock duals $y=(0.4,0.3,0.25)$ for widths $(10,8,6)$, roll $24$. Does the pattern $10+8+6$ enter?

    No, its value is below $1$.
    Add the duals: $0.4+0.3+0.25$.
    No: $y^\top a=0.95\lt1$, reduced cost $+0.05$.
    Only patterns with $y^\top a\gt1$ enter.
    Yes, it fills the roll exactly.
    A full roll is not the test.

    In the RCSP pricing problem, the arc weight is:

    $c_{ij}-w_2$
    $w_2$ is subtracted once per path, not per arc.
    $c_{ij}-w_1t_{ij}$
    With $w_1\le0$ this is $c_{ij}+\mu t_{ij}$.
    $t_{ij}$
    Cost must be included.

    Which inequality chain is right for an IP decomposed with integer blocks?

    $z_{\text{DW}}\le z_{\text{LP}}\le z_{\text{IP}}$
    DW is at least as strong as the LP.
    $z_{\text{LP}}\le z_{\text{DW}}=z_{\text{LD}}\le z_{\text{IP}}$
    The DW bound is the Lagrangian dual.
    $z_{\text{LP}}=z_{\text{DW}}\lt z_{\text{LD}}$
    DW and Lagrangian bounds are equal.

    Ch. 6.2 priced the route $\{1,8\}$ at duals $\pi_i=2c_{0i}$ and found $\bar c=-11.16$. In Lecture 13's terms that route is:

    A column with negative reduced cost, to be added to the restricted master.
    Exactly the column-generation step.
    A violated cut.
    Columns are priced, cuts are separated.
    An extreme ray.
    Routes are extreme points of a bounded block.

    Why is the dual of a slack resource row zero?

    Because the row is an equation.
    It is an inequality with slack.
    Because the primal is degenerate.
    Degeneracy is not needed.
    Complementary slackness: a row with positive slack has dual $0$.
    That is why $w_1=0$ in the first RCSP master.

    Lecture 14 puts the pieces together for the VRP. The set-partitioning model of Ch. 6.2 is the Dantzig–Wolfe master of Ch. 10.3; its LP is solved by column generation, and the pricing problem is an elementary shortest path with resource constraints (ESPPRC), solved by labelling with dominance. Branching on arcs inside the tree, and adding cuts on arcs, gives branch and price and branch-cut-and-price, the methods behind today's exact VRP codes. Lab 7 measures the payoff: on a 15-customer instance the path LP is within $2\%$ of the optimum, the compact arc LP $47\%$ below it.

    You need: Part 10 (column generation, the RCSP pricing problem, Dantzig–Wolfe), Part 6 (the CVRP, set partitioning and covering in Ch. 6.2, the eight-customer day of Kaveri Courier), Part 7 (clique inequalities, Ch. 7.2) and Part 4 (branch and bound).

    The route master problem and its pricing problem

    In the route-based VRP model each column is a whole feasible route, the rows say that each customer is served once, and the LP is solved by column generation. The pricing problem asks for the route with the most negative reduced cost, which is a shortest path for one vehicle with capacity (and time) limits on a graph with dual-adjusted arc costs.

    This model has the strongest LP bound among the CVRP models of Ch. 6.2, and all its complications (time windows, driver rules) live in the pricing problem, so the master never changes.

    It is like a dispatcher who keeps a short list of candidate van tours and, each morning, asks the planners for any new tour that would be worth more than it costs at today's prices for each customer.

    With $\mathcal R$ the feasible routes (capacity, and time windows for the VRPTW), route cost $c_r$, and $a_{ir}=1$ if route $r$ serves customer $i$, vehicles allowed to stay unused:

    $$\min\sum_{r\in\mathcal R}c_ry_r\quad\text{s.t.}\quad\sum_ra_{ir}y_r=1\ \ (\pi_i)\ \ \forall i\in V_c,\qquad y_r\in\{0,1\}.$$

    In the covering version the rows are $\ge1$ and $a_{ir}$ may count repeated visits. Its LP is a relaxation of the partitioning LP, so its value is at most as large (on the running example they are equal), its duals are $\pi_i\ge0$, and with the triangle inequality an integer covering solution can be repaired by skipping repeated customers. A fleet row $\sum_ry_r\le K$ (dual $\mu\le0$) can be added.

    The reduced cost of route $r=(0,i_1,\dots,i_m,0)$ is $\bar c_r=c_r-\sum_{i\in r}\pi_i-\mu$. Moving each dual onto the arc that enters its customer, $\bar c_{ij}=c_{ij}-\pi_j$ (with $\pi_0=0$), gives $\bar c_r=\sum_{(i,j)\in r}\bar c_{ij}-\mu$. So pricing is: find a route from the depot back to the depot, respecting the vehicle's resources, of least total arc cost $\bar c_{ij}$. Because the duals can exceed the arc costs, many $\bar c_{ij}$ are negative, and a route must not repeat a customer: an elementary shortest path with resource constraints (ESPPRC). The ESPPRC is NP-hard.

    As a MIP (Lecture 14) the ESPPRC looks like a prize-collecting TSP with time windows: arc variables $x_{ij}$, flow from $s$ to $t$, resource levels $u_{il}$ with $u_{jl}\ge u_{il}+d_{ijl}-M_{ij}(1-x_{ij})$ and limits $a_{il}\le u_{il}\le b_{il}$. Solving it by branch and bound at every pricing round would be far too slow; the labelling algorithm of Ch. 11.2 is used instead.

    Kaveri Courier

    Back to the firm's day of Ch. 6.1: depot and eight customers, capacity $10$, $36$ feasible customer sets. Column generation starts from the eight one-customer routes (master value $129.19$) and adds the best route each round: $\{6,7,8\}$ (reduced cost $-19.45$), then $\{4,5,6\}$, $\{1,8\}$, $\{3,4\}$, $\{3,5\}$, $\{5,7\}$, $\{5,6\}$, $\{6,7\}$. The master values are $129.19$, $109.73$, $109.73$, $101.83$, $99.24$, $98.51$, $97.62$, $97.44$ and finally $97.37$, where no route has negative reduced cost.

    Try it

    This is the route picker of Ch. 6.2 on the same day. Tick the routes $\{5,6\}$, $\{5,7\}$ and $\{6,7\}$ together: each of customers $5,6,7$ is covered twice, which an integer plan may not do, but taking each at weight $\tfrac12$ covers each exactly once, and that is what the LP does. Then press "Show the optimum" and compare its cost $98.71$ with the LP value $97.37$.

    Read the final LP of the firm's day: what is fractional, what bound does it give, and what does the fleet row change?

    1. LP value $97.37$: routes $\{2\}$, $\{1,8\}$, $\{3,4\}$ at $1$ and $\{5,6\}$, $\{5,7\}$, $\{6,7\}$ at $\tfrac12$. Customers $5,6,7$ weigh $4+2+5=11\gt10$, so they cannot share a van, but every pair fits.

      This is the odd-triangle point of Ch. 7.2: each customer is covered by two half routes.

    2. The optimum is $98.71$ (routes $\{1,8\},\{2,5\},\{3,4\},\{6,7\}$), so the root gap is $(98.71-97.37)/98.71\approx1.36\%$.

      Compare the two-index bounds of Ch. 6.2: $84\%$ to $97.5\%$ of the optimum.

    3. The LP uses $3+1.5=4.5$ vans. Adding the fleet row $\sum_ry_r=4$ (as Ch. 6.2 did) forbids this mix, and the LP becomes $98.71$, integral.

      A clique inequality $y_{56}+y_{57}+y_{67}\le1$ or a capacity cut on $\{5,6,7\}$ would also remove the point; Ch. 11.3 branches instead.

    4. The duals at the end are $\pi\approx(16.97,17.09,14.88,6.38,15.24,7.38,14.46,4.96)$. Route $\{6,7\}$ costs $21.84=\pi_6+\pi_7$: reduced cost $0$, as for every route in the LP solution.

      Basic columns have reduced cost zero.

    At the final duals $\pi_2=17.09$, $\pi_5=15.24$, route $0\text{-}2\text{-}5\text{-}0$ costs $33.67$. What is its reduced cost (no fleet row)?

    $\bar c_r=c_r-\sum_{i\in r}\pi_i$.

    $33.67-17.09-15.24=1.34\gt0$. This route is in the optimal integer plan but not in the LP solution.

    Arc $(3,5)$ costs $c_{35}=8$ and $\pi_5=12$. What is the dual-adjusted arc cost $\bar c_{35}$ used in pricing?

    The dual of the customer the arc enters is subtracted.

    $8-12=-4$. Negative arc costs are normal in VRP pricing, which is why routes must be kept elementary.

    Root LP $97.37$, optimum $98.71$. Give the gap $(z^*-z_{\text{LP}})/z^*$ in percent.

    $1.34/98.71$.

    $\approx1.36\%$.

    • Put every route rule (capacity, windows, driver hours) into the pricing problem; the master stays a partitioning model.
    • Use the covering version when costs satisfy the triangle inequality: non-negative duals and an easier master.
    • Pricing with a shortest-path code that allows repeated customers and reading its answer as a route.
    • Forgetting the fleet dual $\mu$ in the reduced cost when a fleet row is present.
    1. The route master has a row per customer and a column per feasible route; partitioning and covering versions give the same LP on the example, $97.37$.
    2. Pricing moves each dual onto the arc entering its customer, $\bar c_{ij}=c_{ij}-\pi_j$, and looks for a least-cost elementary route within the resources: the ESPPRC.
    3. On Kaveri's day the root gap is $1.36\%$; the fractional part is an odd triangle of half routes, which a fleet row, a clique cut, a capacity cut or branching removes.

    Why must VRP pricing routes be elementary?

    Because the costs are symmetric.
    Symmetry has nothing to do with it.
    Arc costs $c_{ij}-\pi_j$ can be negative, so a route that revisits a customer can look cheaper than any real route.
    Such a column would serve a customer twice.
    Because the master is a covering model.
    The covering master tolerates repeats; pricing still needs care.

    Compared with the partitioning LP, the covering LP value is:

    Always larger.
    Covering relaxes the equations.
    At most as large (equal on the example).
    A larger feasible set can only lower a minimum.
    Unrelated.
    One is a relaxation of the other.

    Where do time windows enter a branch-and-price VRPTW code?

    As big-M rows in the master.
    The master has no time variables.
    In the definition of a feasible route, enforced by the pricing algorithm.
    Time is a resource in the labels.
    As cuts added after column generation.
    Routes are generated feasible from the start.

    Labelling algorithms for the elementary pricing problem

    A labelling algorithm builds paths from the depot one arc at a time. Each partial path is stored as a label (cost so far, resources used, customers visited), and a label is discarded when another label at the same node is at least as good in every respect.

    This is how the pricing problem is solved in practice (the cspy library of Lab 7 implements such algorithms), and the dominance rule is what keeps the number of labels manageable.

    It is like route-finding with a fuel gauge: two ways of reaching the same town are compared, and one is forgotten only if it is both dearer and leaves you with less fuel and fewer options.

    A label at node $i$ for a path $p$ from the depot is $(C_p,\ U_{p1},\dots,U_{pL},\ V_p)$: its reduced cost, the amounts of each resource used (load, time), and the set of customers visited. Extending it along arc $(i,j)$ adds $\bar c_{ij}$ to the cost and the arc's resource use, adds $j$ to $V_p$, and is allowed only if $j\notin V_p$ and all resource limits at $j$ hold.

    Label $p$ dominates label $q$ at the same node if $C_p\le C_q$, $U_{pl}\le U_{ql}$ for every resource, and $V_p\subseteq V_q$, with at least one difference. Every completion of $q$ is then also a completion of $p$, at no higher cost, so $q$ can be deleted.

    1. Put the label $(0,0,\emptyset)$ at the depot and the depot in a list of nodes to process.
    2. Take a node $i$ from the list. For each arc $(i,j)$ and each label at $i$ that has not visited $j$, create the extended label if it respects the resources.
    3. At $j$, keep only the labels that no other label dominates (the slide's "RemoveNonDominatedLabels" should read: remove the dominated labels). If the label set at $j$ changed, put $j$ on the list.
    4. Stop when the list is empty. Close every label by its arc back to the depot; every closed route with negative reduced cost may be added to the master.

    Without the visited set (and with $V_p$ dropped from dominance) this is the older SPPRC labelling of Desrochers and co-authors: much faster, but routes may revisit customers, and with negative arc costs and no resource bound it can cycle forever. With a load resource the cycling stops, because each visit adds demand, but non-elementary routes still appear. Practical codes sit between the two: 2-cycle elimination or ng-routes forbid only short or nearby repeats, bidirectional search builds paths from both ends, and an exact elementary check is run only at the end.

    A pricing round

    Three customers with demands $3,4,5$ and a van of capacity $12$. Arc costs $c_{01}=6$, $c_{02}=7$, $c_{03}=8$, $c_{12}=3$, $c_{13}=5$, $c_{23}=4$ (symmetric). The master's duals are $\pi=(11,10,12)$, so $\bar c_{ij}=c_{ij}-\pi_j$ and $\bar c_{i0}=c_{i0}$.

    Try it

    Step through the stages. At each node read the labels (path, reduced cost, load). Notice that in stage 2 nothing is dominated, because the cheaper labels carry more load, and that in stage 3 three labels are deleted by labels with the same load and visited set.

    Run the elementary labelling algorithm on the pricing round above and find the best route.

    1. From the depot: label at $1$ is $(6-11,\ 3,\ \{1\})=(-5,3,\{1\})$; at $2$: $(-3,4,\{2\})$; at $3$: $(-4,5,\{3\})$.

      Each arc into a customer collects that customer's dual.

    2. Second customer: for example $0\text{-}1\text{-}2$ gives $(-5+3-10,\ 7,\ \{1,2\})=(-12,7,\{1,2\})$ at node $2$. At node 2 the labels $(-3,4,\{2\})$ and $(-12,7,\{1,2\})$ do not dominate each other: one is cheaper, the other has less load and a smaller visited set.

      Dominance needs "at least as good" in every component.

    3. Third customer: at node $3$ the paths $0\text{-}1\text{-}2\text{-}3$ $(-20,12)$ and $0\text{-}2\text{-}1\text{-}3$ $(-18,12)$ have the same visited set and load, so the first dominates and the second is deleted. The same happens at nodes $1$ and $2$.

      Same resources, same customers, higher cost: no completion can make it better.

    4. Close the labels: $0\text{-}1\text{-}2\text{-}3\text{-}0$ has reduced cost $-20+8=-12$ (cost $21$, duals $33$), as does its reverse. This route enters the master.

      The best two-customer route, $0\text{-}1\text{-}2\text{-}0$, reaches only $-5$.

    5. If revisits were allowed, $0\text{-}1\text{-}2\text{-}1\text{-}0$ (load $10\le12$) would have reduced cost $6-11+3-10+3-11+6=-14\lt-12$: it collects $\pi_1$ twice. A non-elementary pricing would return this false route.

      That is why elementarity (or a relaxation that the master can live with) matters.

    In the pricing round, extend the label of $0\text{-}2$, which is $(-3,4,\{2\})$, along arc $2\to1$. Give the new reduced cost and load.

    Add $c_{21}-\pi_1$ and $d_1$.

    $-3+3-11=-11$; load $4+3=7$.

    At node $1$, does the label $(-11,7,\{1,2\})$ dominate $(-5,3,\{1\})$?

    Compare cost, load and visited set.

    No. It is cheaper, but its load is larger and its visited set is not a subset. Both must be kept.

    Two labels at the same node: $(-7,\ 6,\ \{2,4\})$ and $(-5,\ 8,\ \{2,3,4\})$. Does the first dominate the second?

    Lower cost, lower load, subset of visits?

    Yes: $-7\le-5$, $6\le8$ and $\{2,4\}\subseteq\{2,3,4\}$.

    • Compare labels only at the same node, and only delete a label that is dominated in every component.
    • Return several negative routes per pricing call; the master benefits.
    • Dropping the visited set from dominance while still claiming an elementary pricing.
    • Extending a label when the next customer's demand or time window no longer fits.
    1. A label stores reduced cost, resources and visited customers; extension adds an arc if the customer is new and the resources fit.
    2. A label is deleted when another at the same node is no worse in cost, every resource and visited set; this keeps the search finite and small.
    3. Elementarity matters: with negative arc costs a non-elementary path can look better ($-14$) than the best real route ($-12$).

    Why is the visited set part of the dominance test?

    To speed up the algorithm.
    It actually keeps more labels.
    A label that has visited more customers has fewer ways to continue, so it can be worse even if it is cheaper.
    Its completions must avoid those customers.
    Because the master needs it.
    It is a pricing issue.

    The SPPRC labelling (cycles allowed) with negative arc costs and no resources:

    Can keep improving labels around a negative cycle and never stop.
    Lecture 14 shows labels cycling between two nodes.
    Always returns an elementary route.
    It does not track visits.
    Is NP-hard but finite.
    Without resources it may not be finite at all.

    A labelling run ends with best closed route of reduced cost $+0.3$. What does the master learn?

    Add that route anyway.
    It would not improve the LP.
    The LP is infeasible.
    The master has a solution.
    No route has negative reduced cost: the master LP is optimal.
    This needs an exact pricing; a heuristic one proves nothing.

    Branch and price, and how strong the root bound is

    Branch and price solves the route master by column generation at every node of a branch-and-bound tree. The branching decisions must be ones the pricing problem can respect, which is why one branches on arcs (customer $i$ next to customer $j$ or not) rather than on route variables.

    Exact VRP codes add cuts on the arc flows as well (branch-cut-and-price). Lab 7 shows why all this effort goes into the route model: its root bound is far stronger than that of compact models.

    It is like settling a timetable dispute by fixing one pair of adjacent stops at a time ("these two are always consecutive" or "never consecutive") and letting the planners redraw all routes under that rule.

    Why branch on arcs

    Branching on a fractional route variable is a poor choice. The branch $y_r=1$ fixes a whole route and is very strong, the branch $y_r=0$ removes one route out of millions and changes almost nothing, so the tree is unbalanced. Worse, the pricing problem may generate the forbidden route again, unless it is told to avoid one specific path, which spoils its structure. Branching on the arc flow $x_{ij}=\sum_rb_{ijr}y_r$ ($b_{ijr}$ = number of times route $r$ uses arc $(i,j)$) avoids both problems:

    • $x_{ij}=0$: delete arc $(i,j)$ from the pricing graph and drop master columns that use it.
    • $x_{ij}=1$: customers $i$ and $j$ must be consecutive. Delete the other arcs out of $i$ and into $j$ (for undirected edges: routes that visit exactly one of $i$, $j$, or both without the edge, are excluded).

    Both children keep the pricing problem a shortest path on a smaller graph. Lecture 14 notes that arc branching works better in practice than branching on route variables. Price and branch is a heuristic shortcut: generate columns only at the root, then solve the master as an integer programme over those columns; it is quick to implement but may miss the optimum.

    Try it

    Process the nodes of the branch-and-price tree for Kaveri's day in best-bound order. Read the fractional routes at each node and the arc chosen for branching. Notice that the first child repeats the odd-triangle pattern on other customers, and that the tree closes with five nodes.

    Branch on edges in the root LP of Kaveri's day (routes $\{2\},\{1,8\},\{3,4\}$ at $1$; $\{5,6\},\{5,7\},\{6,7\}$ at $\tfrac12$) until the optimum is proved.

    1. Edge flows: edge $5\text{–}6$ is used only by route $\{5,6\}$, so $x_{56}=\tfrac12$. Edge $0\text{–}5$ is used by $\{5,6\}$ and $\{5,7\}$: $x_{05}=1$. Branch on $x_{56}$.

      Choose a customer–customer edge with fractional flow.

    2. Child $x_{56}=0$: re-run column generation without edge $5\text{–}6$. LP $98.47$, again fractional: $\{3,4\},\{3,5\},\{4,5\}$ at $\tfrac12$. Child $x_{56}=1$: LP $99.04$, integral (the savings plan of Ch. 6.4).

      Each child's LP is at least the root's; the incumbent is now $99.04$.

    3. Best bound first: process $98.47$ and branch on $x_{34}=\tfrac12$. Child $x_{34}=1$: LP $98.71$, integral: routes $\{1,8\},\{2,5\},\{3,4\},\{6,7\}$. New incumbent $98.71$. Child $x_{34}=0$: LP $101.39$, pruned.

      Pruning by bound, as in Ch. 4.2.

    4. The node with LP $99.04$ is pruned too ($99.04\ge98.71$). Optimum $98.71$, proved with $5$ nodes.

      This matches the set-partitioning IP solved directly over all $36$ routes.

    Branch, cut and price

    Cuts can also be added to the master. A cut written on arc flows, such as a rounded capacity cut $x(\delta(S))\ge2r(S)$ (Ch. 6.1), becomes a master row $\sum_r(\text{number of times }r\text{ crosses }\delta(S))\,y_r\ge2r(S)$; its dual is moved onto the arcs of $\delta(S)$ in pricing, so the pricing problem keeps its structure. Such robust cuts are the "TSP-based valid inequalities" that Lecture 14 mentions. On Kaveri's root LP the capacity cut for $S=\{5,6,7\}$ ($d(S)=11$, $r(S)=2$) asks for $x(\delta(S))\ge4$, while the half routes cross $\delta(S)$ only $3$ times in total: violated.

    Lab 7: two root bounds

    Lab 7 takes the first $15$ customers of the benchmark instance X-n101-k25 (capacity $206$; distances rounded to integers) and compares two LP bounds. The link (arc) formulation with MTZ load constraints gives $2923.73$. The path formulation, solved by column generation with an RCSP pricing problem, gives $5441$; it equals the set-partitioning LP over all $1558$ feasible customer sets. The optimum is $5553$ with four routes. Root gaps: $47.3\%$ against $2.0\%$. (All three values recomputed for this site by enumerating the feasible sets.)

    In Kaveri's root LP, routes $0\text{-}5\text{-}6\text{-}0$ and $0\text{-}5\text{-}7\text{-}0$ each have weight $\tfrac12$ and no other route visits customer $5$. What is the flow on edge $0\text{–}5$?

    Add the weights of the routes that use the edge.

    $\tfrac12+\tfrac12=1$: integral, so it is no use for branching.

    Lab 7: optimum $5553$, MTZ link LP $2923.73$, path LP $5441$. Give both root gaps $(z^*-\text{bound})/z^*$ in percent (one decimal).

    $2629.27/5553$ and $112/5553$.

    $47.3\%$ and $2.0\%$.

    In the root LP, compute $x(\delta(S))$ for $S=\{5,6,7\}$: routes $0\text{-}5\text{-}6\text{-}0$, $0\text{-}5\text{-}7\text{-}0$, $0\text{-}6\text{-}7\text{-}0$ at $\tfrac12$ each, and no other route touches $S$.

    Each of these routes enters and leaves $S$ once, crossing $\delta(S)$ twice.

    $3\cdot\tfrac12\cdot2=3\lt4=2r(S)$: the rounded capacity cut is violated by $1$.

    • Branch on arc flows and impose the decision in the pricing graph.
    • Add cuts in arc form so that their duals fit into the pricing arc costs.
    • Branching $y_r=0$ on a route variable.
    • Calling price and branch exact: columns generated at the root may not contain the optimal plan.
    1. Branch and price runs column generation at every node; branching on arcs ($x_{ij}=0$ or $1$) keeps the pricing problem a shortest path.
    2. On Kaveri's day the tree has five nodes: root $97.37$, children $98.47$ and $99.04$, and the optimum $98.71$ under $x_{56}=0$, $x_{34}=1$.
    3. Lab 7 shows why: the route LP is within $2\%$ of the optimum, the compact MTZ LP $47\%$ below; robust cuts on arcs strengthen it further (branch, cut and price).

    Why is branching on $y_r=0$ a poor rule?

    It cuts off integer solutions.
    Both branches together keep every solution.
    It barely changes the master and the pricing problem may generate the same route again.
    The tree becomes very unbalanced.
    It makes the LP infeasible.
    Other routes remain.

    On branch $x_{ij}=0$, what changes in pricing?

    Arc $(i,j)$ is removed from the pricing graph.
    The problem stays a resource-constrained shortest path.
    The duals of $i$ and $j$ are set to zero.
    Duals come from the master.
    Customers $i$ and $j$ are removed.
    They must still be served.

    What is "price and branch"?

    An exact method that prices at every node.
    That is branch and price.
    Generate columns at the root only, then solve the integer master on them: a heuristic.
    It may miss the optimum.
    Branching on the duals.
    Duals are not branched on.

    The reduced cost of route $0\text{-}a\text{-}b\text{-}0$ with duals $\pi_a,\pi_b$ and no fleet row is:

    $c_{0a}+c_{ab}+c_{b0}$
    Duals must be subtracted.
    $c_{0a}+c_{ab}+c_{b0}-\pi_a-\pi_b$
    Equivalently the sum of $\bar c_{ij}=c_{ij}-\pi_j$ along the route.
    $\pi_a+\pi_b-c_{ab}$
    Signs and terms are off.

    Label $p=(-4,5,\{1\})$ and $q=(-6,5,\{1,3\})$ at the same node. Which statement is right?

    $p$ dominates $q$.
    $p$ is more expensive.
    $q$ dominates $p$.
    $q$'s visited set is not a subset of $p$'s.
    Neither dominates; keep both.
    Cost favours $q$, the visited set favours $p$.

    In the tree for Kaveri's day, why is the node with LP $99.04$ never branched on?

    It is infeasible.
    It has an integral solution.
    Its bound is not below the incumbent $98.71$.
    Pruned by bound.
    Its LP is fractional.
    It is integral.

    Which inequality on route variables removes Kaveri's root LP point without branching?

    $y_{56}+y_{57}+y_{67}\le1$
    The three routes pairwise share a customer: a clique in the conflict graph.
    $y_{56}\le\tfrac12$
    The point satisfies it.
    $\sum_ry_r\ge4$
    The point uses $4.5$ vans.

    The route master is the Dantzig–Wolfe master of which compact model?

    The two-index model.
    It has no vehicle blocks.
    The three-index model, with one block per vehicle.
    Each block's integer points are feasible routes.
    The MTZ model.
    Load variables are not decomposed by vehicle.

    The last class of the course looked at practical case studies, led by the 2024 paper of Mehrotra and co-authors on how Walmart plans its grocery supply chain (INFORMS Journal on Applied Analytics 54(1), an Edelman Award paper). It connects three tools: a facility-location model for where grocery distribution centres should be, a daily routing-and-loading engine (Load Planner) for the trucks, and a simulation platform that runs the daily engine to test strategic ideas. This short part maps each tool onto the models of the course, with small examples of our own; the figures quoted are the paper's.

    You need: Part 3 (facility location, Ch. 3.3), Part 6 (VRP with time windows, heuristics and local search, Ch. 6.3–6.4) and Part 4 (why exact MIPs stop scaling).

    Network design at scale: where the grocery DCs should be

    Walmart's network-design question is uncapacitated-style facility location with many options per site: where to put grocery distribution centres (GDCs), of which type and size, and which stores each one serves, at least total cost of running the DCs, handling cases and trucking to stores.

    The model is the one of Lab 1 and Ch. 3.3; what changes is the size, and the paper's answer to size is a heuristic loop around an exact MIP. That pattern (solve exactly on a well-chosen subset, then refine the subset) is worth recognising in any large project.

    It is like choosing a flat: you cannot view every flat in the city, so you shortlist a few, find the best area among them, and then look more closely around that area.

    The setting, in the paper's numbers

    The paper concerns groceries moving from Walmart's $47$ grocery DCs to about $4{,}700$ Walmart stores and $600$ Sam's Clubs. Groceries are the hardest freight: frozen, chilled and dry goods need different temperatures, and demand changed quickly with online orders. New automation, especially for cold goods, made it worth redesigning the network, and a multi-year plan was needed to get from today's network to the new one without leaving stores unsupplied.

    Why the exact model is too big

    A new DC could in principle go anywhere; even restricted to zip codes there are more than $30{,}000$ candidate locations, each with about $31$ to $78$ type and size options, and any DC could serve any store. The paper states that a commercial MIP solver cannot solve this model in reasonable time. In course terms: binary $y_{s,o}$ for site $s$ with option $o$, assignment $x_{ij}$ of stores to DCs, forcing constraints $x_{ij}\le\sum_oy_{i,o}$, capacity by option, and the number of binaries alone runs into the millions.

    1. Group store demand by type (freezer, fresh, dry) to shrink the data.
    2. Choose candidate sites: a random sample of zip codes plus the existing DCs.
    3. Solve the facility-location MIP on these candidates.
    4. If the answer changed from the last iteration (or this is the first), replace the candidates by new ones near the chosen sites and return to step 3.
    5. Once the network is stable, fix the DCs and assign stores to them optimally.

    Step 4 is a neighbourhood search (Ch. 6.4) whose moves are "look near the sites the MIP liked"; each step 3 is exact on its subset.

    Try it

    This facility-location widget from Ch. 3.3 shows why the model itself matters even before size: switch between the weak and strong formulations and watch the LP bound. A network-design MIP with millions of binaries is only solvable on subsets if its LP is strong.

    A toy version of the loop. Four candidate sites with fixed costs $A{:}\,50$, $B{:}\,40$, $C{:}\,45$, $D{:}\,35$ serve four store groups; the cost of serving group $j$ from site $i$ (already multiplied by demand) is: $A$: $10,30,40,60$; $B$: $35,12,25,45$; $C$: $50,28,10,20$; $D$: $60,45,30,8$. Start from the sample $\{A,D\}$; "near" means $B$ is near $A$ and $C$ is near $D$ and $B$.

    1. Iteration 1, candidates $\{A,D\}$: $\{A\}$ alone costs $50+140=190$, $\{D\}$ alone $35+143=178$, both $85+(10+30+30+8)=163$. Best: open $\{A,D\}$ at $163$.

      With both open, group 2 goes to $A$ (30) and group 3 to $D$ (30).

    2. Iteration 2, candidates near $A$ and $D$ added: $\{A,B,C,D\}$. Enumerating the $15$ non-empty subsets, the best is $\{C\}$ alone: $45+(50+28+10+20)=153$.

      One central site beats two good corner sites once it is in the candidate list.

    3. Iteration 3, candidates near $C$: $\{B,C,D\}$. Best again $\{C\}$ at $153$ ($\{B,D\}$ costs $155$). The network did not change: stop and assign stores.

      The stopping rule of the paper: two consecutive answers are close enough.

    The transformation roadmap

    Knowing the target network is not enough: building or retrofitting a DC takes years in stages (land, construction, equipment, testing), contractors can run only so many big projects at once, and stores must be served throughout. A second MIP schedules when each DC starts each stage, linked to a store-assignment problem in every period (the paper's Appendix A). It is solved hierarchically, with coarse time steps first.

    In the toy, what does opening $\{B,D\}$ cost?

    Fixed $40+35$; each group goes to the cheaper of $B$ and $D$.

    $75+(35+12+25+8)=155$.

    Two DCs, P and Q, are to be retrofitted. Each retrofit takes $2$ years; at most one retrofit may start per year. A finished P saves $30$ per year, a finished Q $20$ per year. Over years $1$ to $5$, with savings counted in every full year after completion, what is the largest total saving?

    Compare "P in year 1, Q in year 2" with the reverse order.

    P first: P done after year 2, saves years 3–5: $90$; Q starts year 2, done after year 3, saves years 4–5: $40$. Total $130$. Q first: $60+60=120$. So $130$.

    With $4$ candidate sites, how many non-empty sets of open sites must an enumeration check?

    $2^4-1$.

    $15$. With $30{,}000$ sites the count is $2^{30000}-1$, which is why the paper samples.

    • Recognise the base model (facility location) under the business vocabulary.
    • When the model is too large, solve exactly on a subset and improve the subset.
    • Assuming an exact solver scales because a toy instance solves instantly.
    • Planning the target network without a feasible path from today's network.
    1. Walmart's network design is facility location with type and size options: over $30{,}000$ candidate sites and $31$–$78$ options each, too large for a MIP solver directly.
    2. The paper samples candidate sites, solves the MIP exactly on them, moves the sample towards the chosen sites, and stops when the answer is stable.
    3. A second, multi-period MIP schedules the stages of each DC's build or retrofit under contractor capacity while keeping every store served.

    Which course model is Walmart's network design built on?

    The travelling salesman problem.
    Routing is the daily layer.
    Facility location (open sites, assign stores), as in Lab 1.
    With type and size options per site.
    Cutting stock.
    Nothing is cut into patterns.

    What is exact in the paper's network-design loop?

    Nothing; it is a pure heuristic.
    Each inner step solves a MIP.
    The MIP on the current candidate sites; the choice of candidates is heuristic.
    Optimal on the subset, not proven optimal overall.
    The whole problem, by branch and price.
    The paper does not claim global optimality.

    Why is a separate roadmap model needed?

    The network-design model has no stores.
    It assigns stores.
    To compute truck routes.
    That is Load Planner.
    Building and retrofitting take years in stages, with limited contractors, and stores must stay served meanwhile.
    It is a multi-period scheduling and assignment MIP.

    Load Planner: routing, loading and the simulation loop

    Every day, for each DC, Load Planner decides which stores go on which truck, in what order, and where each pallet sits in the trailer. It is a vehicle routing problem with time windows (Ch. 6.3) joined to a packing problem, with legal limits on driving hours.

    The paper reports what this daily engine saved in one year, and explains why it is a metaheuristic, not an exact code: it must answer within minutes for a DC and within milliseconds for each feasibility check.

    It is like packing a removal van for several houses on one trip: the order of the houses decides which boxes must go in first, and the boxes decide whether the order is possible at all.

    What a feasible truck must satisfy

    The paper's Table 1 lists the rules. In course terms:

    • Routing: each store's delivery window (VRPTW); route start and end times; US Department of Transportation hours-of-service (HOS) rules: an $11$-hour driving limit, a $14$-hour limit and a $30$-minute driving break; backhaul pickups with their own windows (Ch. 6.3); some stores must be the last stop (drop-and-hook).
    • Loading: pallets for different stores, or at different temperatures, may not be stacked; stacks must fit the trailer's height, weight and volume; tri-temperature trailers have movable walls between compartments; reloads (unloading another store's pallets to reach your own) are not allowed for dry goods and must be minimised for perishables.

    Loading couples with routing through the order of stops: in a trailer unloaded from the back, the last store's pallets must go in first, at the nose.

    1. Construct initial routes, as a VRP or by assigning pallet groups to route templates.
    2. Improve them by tabu search with the moves one-zero exchange (move a stop to another route, which can remove a route), one-one exchange (swap two stops), two-opt and large-neighbourhood search; tabu search accepts some worsening moves and forbids recently reversed ones (Ch. 6.4).
    3. At every move, ask the Feasible Loading module (build stacks by a greedy method improved with simulated annealing, assign stacks to compartments, place them on floor spots using predesigned patterns) and the HOS module whether the new route is legal. These checks must answer in milliseconds.

    Time budgets in the paper: at most $15$ minutes to plan routes for a DC, about $1$ second to plan or adjust one truck load.

    Try it

    This time-window widget from Ch. 6.3 is the routing half of a feasibility check. Build an order of the stops and see where it fails. Load Planner runs a check like this, plus loading and driving-hour checks, for every move its tabu search considers.

    An hours-of-service check, with the rules of our example: at most $11$ hours of driving, at most $14$ hours on duty from the start, and a $30$-minute break once $8$ hours of driving have been reached before more driving. A truck leaves the DC and drives $2.5$ h to store 1, unloads $1$ h, drives $3$ h to store 2, unloads $1$ h, drives $2$ h to store 3, unloads $1$ h, and drives $3$ h back. Is the route legal? Can a fourth store with $0.5$ h extra driving and $1$ h unloading be added?

    1. Driving: $2.5+3+2+3=10.5\le11$ h.

      The driving limit counts wheel time only.

    2. Break: after the third leg the driver has driven $7.5$ h; the last leg would take driving to $10.5$ h, past $8$ h, so a $30$-minute break is taken before (or during) it.

      The break is forced by the cumulative driving, not by the clock.

    3. On duty: $10.5$ h driving $+3$ h unloading $+0.5$ h break $=14$ h: exactly at the limit. Legal.

      Unloading and breaks count towards the duty window.

    4. A fourth store adds $0.5$ h driving and $1$ h unloading: driving $11$ h (still legal) but duty $15.5\gt14$ h. Illegal: the stop must go on another truck, or the route must be re-ordered.

      This is why the HOS module is called inside every routing move.

    The simulation loop and the results

    Strategic models usually use rough average transport costs, but the true cost of a network depends on how well its trucks can be routed and packed. Because Load Planner is fast, Walmart runs it on many what-if scenarios (other store-to-DC alignments, trailer types, delivery frequencies such as five instead of seven days a week) and feeds the results back into network design. Better networks make daily operations cheaper; a faster daily engine allows more scenarios: the paper calls this loop the link between strategy and execution.

    The paper reports that in fiscal year 2023 the optimisation eliminated $108{,}000$ truck routes covering $33$ million miles, saved $91.5 million and avoided $98.6$ million pounds of CO₂ emissions.

    With the example's rules, a route has driving legs of $3$, $2.5$, $2$ and $2$ hours and three unloading stops of $1$ hour each. How many hours is the driver on duty (including any required break)?

    Total driving is $9.5$ h; does it pass $8$ h before the last leg?

    Driving $9.5$ h, which passes $8$ h during the last leg ($7.5$ h before it), so a $0.5$ h break is needed. Duty $9.5+3+0.5=13$ h.

    From the paper's FY23 figures ($108{,}000$ routes eliminated, $33$ million miles), how many miles did an eliminated route cover on average? Round to whole miles.

    $33{,}000{,}000/108{,}000$.

    $\approx305.6$, about $306$ miles.

    A trailer unloaded from the back visits stores $1$, $2$, $3$ in that order. To avoid reloads, whose pallets are loaded first, at the nose of the trailer?

    First in, last out.

    Store 3, the last stop: its pallets must not block anyone else's.

    • Name the course model behind each business rule: windows (VRPTW), backhauls, packing (bin packing), driver hours (a resource on the route).
    • Keep feasibility checks fast when they sit inside a local search.
    • Planning routes and loads separately when the loading order depends on the route.
    • Reading the paper's savings as a guarantee of optimality; Load Planner is a metaheuristic.
    1. Load Planner solves a VRP with time windows, backhauls and hours-of-service limits jointly with pallet stacking and trailer loading, by construction plus tabu search with fast feasibility modules.
    2. Hours-of-service rules are route resources: driving time, duty time and breaks are checked as the route is built, exactly like load or time in a labelling algorithm.
    3. Running the fast daily engine on what-if scenarios links network strategy and execution; the paper reports $108{,}000$ fewer routes, $33$ million fewer miles and $91.5 million saved in FY23.

    Why is Load Planner a metaheuristic rather than branch and price?

    Branch and price cannot handle time windows.
    It can (Part 11).
    It must plan a DC's routes within minutes and check loads in milliseconds, with complex loading rules; tabu search with fast checks fits this.
    The paper names the time limits as a design constraint.
    The problem has no integer variables.
    Routes and loads are discrete.

    Which tabu-search move is mainly used to reduce the number of routes?

    One-zero exchange (moving a stop to another route).
    Emptying a route removes a truck.
    Two-opt.
    It shortens one route; it does not empty routes.
    One-one exchange.
    A swap keeps the number of stops per route.

    What does the simulation platform add?

    Real-time traffic data.
    It evaluates scenarios, not live traffic.
    An exact lower bound.
    It runs a heuristic engine.
    Daily-operation costs for strategic what-if scenarios, fed back into network design.
    The loop between strategy and execution.

    In the toy network-design loop, why did the first iteration miss the optimum $\{C\}$?

    The MIP was solved badly.
    It was exact on its candidates.
    Site $C$ was not among the sampled candidates.
    Sampling, not solving, limited the answer.
    Facility location has no optimum.
    It always has one.

    A driver has driven $7.5$ h and the next leg is $2$ h. Under the example's rules:

    No break is needed; $9.5\le11$.
    The break rule depends on passing $8$ h of driving.
    A $30$-minute break is needed before driving past $8$ h.
    It also adds $0.5$ h to the duty time.
    The leg is illegal.
    $9.5$ h of driving is within $11$.

    Walmart's backhaul pickups correspond to which VRP variant of Part 6?

    Two-echelon VRP.
    That uses satellites.
    VRP with backhauls (deliveries, then pickups).
    With pickup windows, as in the paper.
    Location routing.
    Depots are fixed in the daily problem.

    For a facility-location MIP to be solvable on large subsets, which formulation choice matters?

    Aggregated forcing rows $\sum_jx_{ij}\le my_i$.
    They give a weak LP.
    Disaggregated forcing rows $x_{ij}\le y_i$.
    A strong LP prunes far more of the tree.
    Big-M with $M=10^6$.
    Large $M$ weakens the LP.

    This part is for the last weeks before the paper. It shows how to read an exam question, drills thirty true/false statements of the kind that catch careful students, gives a timed mock paper of ten new problems, then shows how to answer a design-a-question paper (theme, model, small solved instance, method at scale) and drills the later material of Parts 7 to 12, and ends with a cumulative quiz. Every problem here is new: none is taken from the slides, past papers or the problem set.

    You need: the main course, Parts 1 to 12, as the material to be examined (Part D for big-M and Part B for LP drawing). Come back to this part after each lecture and again in the week before the exam.

    How to attack an exam question: six types and a first move for each

    Almost every question in this course is one of six types. Naming the type in the first ten seconds tells you which tool to pick up and where the marks are.

    Marks reward visible method: defined variables, a stated objective sense, a labelled bound, a clear reason. A wrong final number with all of these still earns most of the marks; a bare correct number can earn very few.

    It is like a pilot's checklist: the checklist does not fly the plane, but it stops you from forgetting the one step that causes the accident.

    A five-step habit that works for every type

    1. Read the command word and the marks. "Formulate", "branch", "dual", "show that", "state with reason", "interpret the log". Marks tell you how much working is expected: 2 marks means one or two lines, 12 marks means a full method.
    2. Name the type using the table below.
    3. Write the set-up before any arithmetic. Variables with meaning, the objective with its sense (min or max), or the dual with its sign rules, or the node set $S$. The set-up is where most marks are, and it protects you if the arithmetic goes wrong.
    4. Calculate with a check built in. Primal and dual values equal; degrees add to $2$; bound below the incumbent for a minimisation.
    5. Finish with a sentence that answers the question in words, with units: "the cheapest plan costs 98 and opens sites 3 and 4".
    TypeSignal wordsFirst moveWhere the marks areTypical slip
    Formulate an IPformulate, model, write the constraintsSay what each variable means and its domain; fix min or maxvariables, objective, one constraint per sentence of the story, integralitywrong sense (bin packing and lot sizing are minimisations); a forcing row $x\le My$ missing
    Solve or prune a branch and bound treebranch, incumbent, bound, prune, nodeSolve the root LP; draw the tree; label each node with its LP valueLP value at each node, a reason on every closed node, the final proofbranching to $x\ge\lfloor v\rfloor$ instead of $\lceil v\rceil$; pruning on the wrong side of the incumbent
    LP duality and sensitivitydual, shadow price, reduced cost, rangeWrite the dual with the sign rules, or take $B^{-1}$ from the optimal basiscorrect dual, equal objective values, the range of validityequality row given a non-negative dual variable; a price used outside its range
    TSP or VRP model, cut or heuristicsubtour, MTZ, cut, capacity, savingsName the node set $S$ and compute $x(\delta(S))$ or $x(E(S))$ against the right-hand sidethe right $S$, the direction of the inequality, $r(S)$ for capacitymixing $x(\delta(S))\ge2$ with $x(E(S))\le|S|-1$; $\lceil d(S)/C\rceil$ instead of $r(S)$
    True / false and short reasoningtrue or false, justify, explain whyHunt for the smallest counterexamplea one-line reason; the verdict alone earns littlea reason that is true but does not decide the statement
    Read a solver loglog, incumbent, BestBd, gapRead the three numbers: Incumbent, BestBd, Gapthe gap formula; rounding the bound when costs are integersdividing by the bound instead of the incumbent; swapping the two for a minimisation
    Try it

    Read each stem and press the type you think it is. A first-try score is kept at the bottom. Notice that the command word (write, branch, show, state, read) decides the type much more often than the topic does: two stems about the same big-M can be a formulation and a true/false.

    Running example for the formulation type

    The dispatcher at Kaveri Courier plans tomorrow's deliveries to six zones A to F. Binary $y_Z=1$ means "zone $Z$ is served". The statement of a formulation question is usually a list of such sentences, and every sentence becomes one constraint. The skill is translating sentence by sentence.

    Write each rule about the six zones as a linear constraint on $y_A,\dots,y_F\in\{0,1\}$. (1) At most 3 zones are served. (2) If C is served then B is served. (3) Exactly one of D and E is served. (4) A and F are never served together. (5) The amount $x_C$ sent to C is at most 50 units, and only if C is served.

    1. (1) $y_A+y_B+y_C+y_D+y_E+y_F\le 3$.

      Each served zone contributes $1$ to the sum, so "at most 3" is a bound on the sum.

    2. (2) $y_C\le y_B$.

      If $y_C=1$ the row forces $y_B=1$; if $y_C=0$ the row says nothing. That is exactly "if C then B".

    3. (3) $y_D+y_E=1$.

      One of them is $1$ and the other $0$; "exactly one" is an equality.

    4. (4) $y_A+y_F\le 1$.

      The pair $(1,1)$ would give $2$, which the row forbids; the other three pairs are allowed.

    5. (5) $x_C\le 50\,y_C$ with $x_C\ge0$.

      If $y_C=0$ it forces $x_C=0$; if $y_C=1$ it allows up to $50$. The number $50$ is the smallest valid big-$M$, because $x_C$ can never exceed $50$ (Part D).

    Careful: read the sense of the objective before anything else. Bin packing minimises the number of bins used, and lot sizing minimises total cost, even though some slides write a maximisation. A formulation with the wrong sense scores no objective marks, whatever else is right.

    Six jobs are assigned to three machines. Variables: $x_{ij}\in\{0,1\}$ ($1$ if job $i$ runs on machine $j$) and $y_j\in\{0,1\}$ ($1$ if machine $j$ is used). The constraints are $\sum_j x_{ij}=1$ for each job and $\sum_i d_ix_{ij}\le q_jy_j$ for each machine. How many binary variables and how many constraints (not counting the $0$–$1$ bounds) does the model have?

    Count the pairs $(i,j)$, add the machines, then count one row per job and one per machine.

    Variables: $6\cdot3=18$ for $x$ plus $3$ for $y$, so $21$. Constraints: $6$ assignment rows plus $3$ capacity rows, so $9$. Note that the capacity row with $q_jy_j$ also links $x$ to $y$ (it forces $x_{ij}=0$ when $y_j=0$), so no separate linking rows are needed.

    A minimisation problem has integer variables and integer cost coefficients. A node of the branch and bound tree has LP value $17.4$. What is the smallest value the best integer solution inside that node can have?

    With integer variables and integer costs, every integer solution has an integer cost. The LP value is a lower bound.

    Every integer solution in the node costs at least $17.4$ and is an integer, so at least $18$. The node can therefore be closed as soon as the incumbent is $18$ or lower.

    A primal LP $\min c^\top x$ with $Ax\ge b$, $x\ge0$ has $4$ constraints and $6$ variables. How many variables and how many constraints does its dual have?

    Each primal constraint gets a dual variable; each primal variable gets a dual constraint.

    The dual $\max b^\top y$, $A^\top y\le c$, $y\ge0$ has one variable per primal row, so $4$, and one constraint per primal column, so $6$.

    A minimisation log shows Incumbent $250$ and BestBd $240$. What gap, in percent, does the solver print?

    The gap is the difference divided by the incumbent.

    $(250-240)/250=0.04$, that is $4\%$. Dividing by the bound would give $4.17\%$, which is not what the solver prints.

    • Underline the command word and the marks before you start.
    • Define every variable and state min or max first.
    • Put a one-sentence answer, with units, at the end.
    • Starting arithmetic before the set-up is written.
    • Giving a true/false verdict without a reason.
    • Leaving a question blank: a correct set-up earns marks on its own.
    1. Almost every question is one of six types: formulate, branch and bound, duality or sensitivity, TSP or VRP model or cut, true/false reasoning, and reading a log; name the type first.
    2. Marks sit in the set-up: variables with meaning, the objective sense, the dual's signs, the node set $S$, the stated reason on a closed node.
    3. Build a check into every calculation: equal primal and dual values, degrees adding up, a bound on the correct side of the incumbent.

    A 12-mark question says "Formulate". Which of these earns marks even if every constraint turns out wrong?

    The final numerical optimum.
    A formulation question has no numerical answer to give; the marks are for the model.
    Defining the variables and stating the objective with the right sense.
    These are the first marks on the scheme, and a reader can only follow the constraints if the variables are defined.
    Copying the constraints from the slides.
    Marks go to constraints that fit this story, not to remembered ones.

    A log for a minimisation shows Incumbent $1342$ and BestBd $1301.6$. Which statement about the printed gap is right?

    It is $(1342-1301.6)/1301.6$.
    That divides by the bound. Check which of the two numbers the formula in Part 4 uses.
    It is $1301.6/1342$.
    That is a ratio of the two numbers, not a gap.
    It is $(1342-1301.6)/1342\approx3.01\%$.
    The gap divides by the incumbent.

    The statement says "If C is served then B must be served". Which constraint is correct?

    $y_C\le y_B$
    If $y_C=1$ it forces $y_B=1$; if $y_C=0$ it is silent.
    $y_B\le y_C$
    This says "if B then C", the reverse implication.
    $y_B+y_C=1$
    This says exactly one of them is served.

    True/false drill: thirty statements with traps

    A true/false question with a reason tests one precise fact. The traps are always the same few: min against max, which way an inequality points, "always" and "never", and weak against strong formulations.

    The score on a drill like this tells you exactly which facts are still shaky. Each statement below has a hint and a reason; the reason is the part that earns marks in the exam.

    It is like a spot-the-difference puzzle: the two versions look alike, and one changed word flips the answer.

    Method: counterexample first

    To show a statement false you need only one example where it fails. To show it true you need a rule. So test the statement on the smallest case you can imagine (one variable, two cities, one constraint) before reaching for theory. Pay special attention to words such as always, never, any, only, exactly.

    TrapThe fact to remember
    Direction of boundsMinimisation: LP relaxation value is a lower bound, an incumbent is an upper bound. Maximisation: the reverse.
    Dual signsMinimisation, $\ge$ row: dual variable $\ge0$. An equality row: dual variable free. A free primal variable: an equality dual row.
    Weak against strongA formulation is stronger when its LP region lies inside the other's and has the same integer points. Larger big-$M$ means a weaker bound.
    Children in branch and boundEach child adds a constraint, so its LP value is never better than the parent's.
    MTZ against DFJDFJ LP is at least as strong as MTZ LP; MTZ is compact, DFJ needs cuts.
    Sense of the objectiveBin packing minimises bins used; lot sizing minimises cost.
    Try it

    A single fixed-charge row $x\le My$ with demand $x=40$. Slide the big-$M$ and read the LP bound against the integer optimum. Notice that the bound is best when $M$ equals the demand and falls steadily as $M$ grows: this is the fact behind several statements below.

    Decide: "The dual variable of an equality constraint in a minimisation LP must be non-negative." Use the counterexample method on $\min\ 3x_1+4x_2$ subject to $x_1-x_2=-2$, $x_1,x_2\ge0$.

    1. Solve the primal. The equality gives $x_1=x_2-2$, and $x_1\ge0$ forces $x_2\ge2$. The cost is $3(x_2-2)+4x_2=7x_2-6$, smallest at $x_2=2$, $x_1=0$, cost $8$.

      A counterexample needs an actual optimum to compare against.

    2. Write the dual with one variable $y$ for the equality: maximise $-2y$ subject to $y\le3$ (from $x_1$) and $-y\le4$ (from $x_2$).

      Each primal column gives one dual inequality; the right-hand side $-2$ of the equality is the dual objective coefficient.

    3. The dual constraints say $-4\le y\le3$, and $-2y$ is largest at $y=-4$, with value $8$.

      Strong duality: the dual optimum $8$ equals the primal optimum $8$.

    4. The optimal dual variable is negative, so it cannot be restricted to $y\ge0$. The statement is false: the dual variable of an equality is free.

      If we had forced $y\ge0$ the best dual value would be $0$, which is below the true optimum $8$.

    Group A: LP and duality

    1. In the dual of a minimisation LP, the variable of an equality constraint of the primal must be non-negative.

    What does a dual variable multiply, and may an equality be multiplied by a negative number?

    False. An equality can be multiplied by any real number, so its dual variable is free. Only the variable of a $\ge$ row (in a minimisation) is restricted to $y\ge0$.

    2. If a constraint is not tight at an optimal solution of an LP, its shadow price is zero.

    Complementary slackness: price times slack.

    True. At an optimal pair, $y_i\cdot(\text{slack}_i)=0$. A positive slack forces $y_i=0$: extra room in a constraint that is not binding has no value.

    3. If the primal LP is unbounded, the dual LP is also unbounded.

    Weak duality: a dual feasible point bounds the primal objective.

    False. If the dual had a feasible point it would bound the primal value, so an unbounded primal forces the dual to be infeasible.

    4. Adding a new constraint to a minimisation LP can lower the optimal value.

    What happens to the feasible region?

    False. The feasible region can only shrink, so the minimum stays the same or rises. (If the new constraint is violated at the old optimum, the dual simplex repairs it, and the value rises or stays equal.)

    5. In a minimisation LP, a basic feasible solution with all non-basic reduced costs $\ge0$ is optimal.

    Every neighbouring corner changes the objective by (step) times (reduced cost).

    True. Each move from the corner has a non-negative reduced cost times a non-negative step, so no neighbour improves, and for a convex problem a local optimum is global.

    6. A shadow price stays valid for every change of the right-hand side.

    Think of the basic solution $B^{-1}b$ as $b$ changes.

    False. The price holds only while the basis stays feasible, that is while $B^{-1}b+t\,B^{-1}e_i\ge0$. Beyond the range some basic variable would become negative and the basis changes. For the LP $\max 6x_1+4x_2$ with $2x_1+x_2\le b_1$ in the mock paper below, the price $2$ holds only for $19\le b_1\le28$.

    Group B: modelling and formulation strength

    7. For a minimisation IP, the optimal value of the LP relaxation is an upper bound on the IP optimum.

    The relaxation has more feasible points than the IP.

    False. A larger feasible set can only give a smaller (or equal) minimum, so the relaxation value is a lower bound.

    8. Rounding the LP optimum of a pure integer programme to the nearest integers always gives a feasible solution.

    Try two binaries with $2x_1+2x_2\le3$.

    False. For $2x_1+2x_2\le3$ the point $(0.75,0.75)$ is LP-feasible, but rounding gives $(1,1)$ with left side $4>3$.

    9. If polyhedron $P_1\subseteq P_2$ and both have the same integer points, the LP over $P_1$ gives a bound at least as good as the LP over $P_2$.

    Compare the two feasible sets.

    True. For a minimisation the smaller region has the larger (or equal) minimum, so a higher lower bound: $P_1$ is the stronger formulation.

    10. Replacing $M=60$ by $M=1000$ in $x\le My$ (where $x\le60$ always) improves the LP bound.

    The LP sets $y=x/M$ and pays the fixed cost on that fraction.

    False. With $M=1000$ the LP pays only $1/1000$ of the fixed cost per unit, so the bound is weaker. The smallest valid $M$ is the best choice.

    11. In facility location, the $mn$ rows $x_{ij}\le y_j$ give an LP bound at least as strong as the $n$ rows $\sum_i x_{ij}\le m\,y_j$ ($m$ customers).

    Add the individual rows over $i$.

    True. Summing $x_{ij}\le y_j$ over $i$ gives $\sum_i x_{ij}\le m\,y_j$, so the individual rows imply the aggregated ones and cut away at least as much.

    12. Bin packing is a maximisation problem: the aim is to use as many bins as possible.

    What would a warehouse manager want?

    False. The aim is to pack all items using the fewest bins: the objective is $\min\sum_j y_j$. (Some slides write $\max$; that is a slip.)

    13. Adding a valid inequality to an IP never removes a feasible integer point.

    What does "valid" mean?

    True. A valid inequality holds for every feasible integer point by definition; it only cuts off fractional points of the relaxation.

    14. For binary $x,y$, the constraint $x\le y$ forbids the pair $x=y=1$.

    Check the four pairs one by one.

    False. The pairs $(0,0)$, $(0,1)$, $(1,1)$ are allowed; only $x=1,y=0$ is forbidden. The row means "if $x$ then $y$".

    15. Items of weights $5,6,7$ do not fit together in a knapsack of capacity $15$. Then $x_1+x_2+x_3\le2$ is a valid inequality.

    Total weight is $18$.

    True. The three items weigh $18>15$, so they form a cover; no feasible 0–1 point takes all three, hence $x_1+x_2+x_3\le|C|-1=2$. For example the LP point $(1,1,4/7)$ satisfies $5+6+4=15$ but has left side $2.57$, so the cut removes it.

    Group C: branch and bound

    16. In a minimisation, a node whose LP value is at least the incumbent value can be discarded.

    Can a child be better than its parent?

    True. Every solution inside the node costs at least the LP value, so none beats the incumbent.

    17. In a minimisation, a child node's LP value can be lower than its parent's.

    What does branching add to the parent's LP?

    False. A child has one more constraint, so its feasible set is smaller and its minimum cannot be lower.

    18. Depth-first and best-first search can end with different optimal values.

    What does the search order change, and what does it not change?

    False. The order changes the number of nodes, not the answer: both end with an incumbent proved optimal.

    19. A minimisation has integer variables and integer costs. A node has LP value $41.3$ and the incumbent is $42$. The node can be pruned.

    Round the node's bound up.

    True. Any integer solution in the node costs at least $\lceil41.3\rceil=42$, which does not beat $42$.

    20. Branching on $x_3=3.4$ creates the two children $x_3\le3$ and $x_3\ge3$.

    Does the second child cut off $3.4$?

    False. The children are $x_3\le3$ and $x_3\ge4$. With $x_3\ge3$ the point $3.4$ would stay feasible in the second child.

    21. When the printed gap is $0\%$, the incumbent is proved optimal.

    What do the incumbent and the BestBd sandwich?

    True. The incumbent is an upper bound and BestBd a lower bound for the optimum; a zero gap makes them equal.

    Group D: TSP and VRP

    22. The LP relaxation of the MTZ formulation is at least as strong as the LP relaxation of the DFJ formulation.

    MTZ allows $(1-\tfrac1{n-1})|C|$ on a cycle $C$; DFJ allows $|C|-1$.

    False. MTZ allows more on short cycles, so its LP region is larger and its bound weaker. It is compact, DFJ is strong.

    23. A violated subtour constraint of the symmetric TSP can be found in polynomial time.

    Treat $x^*_e$ as capacities.

    True. A violated cut $x^*(\delta(S))\lt2$ is a minimum cut of the support graph with capacities $x^*_e$, found by max-flow computations.

    24. For the ATSP, the assignment problem (degree constraints only) always returns a single tour.

    Two disjoint cycles also give every city one arc in and one out.

    False. Its solutions are cycle covers: a set of cycles that together visit every city. Only the subtour constraints force a single cycle.

    25. For a symmetric TSP with non-negative costs, the minimum spanning tree cost is a lower bound on the optimal tour cost.

    Delete one edge of an optimal tour.

    True. A tour minus one edge is a spanning tree, so the cheapest tree is no more expensive than the tour minus an edge, and that is no more than the tour.

    26. The 2-opt heuristic always ends at a globally optimal tour.

    What does "local optimum" mean?

    False. It stops when no single swap of two edges improves the tour, a local optimum that can be far from the global one.

    27. A symmetric TSP on $7$ cities has $360$ distinct tours.

    Fix the first city, then divide by two for direction.

    True. $(7-1)!/2=720/2=360$.

    28. Three customers with demands $4,4,4$ and van capacity $6$ can be served by $\lceil12/6\rceil=2$ vans.

    Can two demands of $4$ share a van?

    False. Two demands weigh $8>6$, so each customer needs its own van: $r(S)=3$, while $\lceil12/6\rceil=2$ is only a lower bound.

    29. The savings value $s_{ij}=c_{0i}+c_{0j}-c_{ij}$ is the cost saved by visiting $i$ and $j$ on one route instead of two separate out-and-back trips.

    Compare the two trips with the merged one: $0\to i\to j\to0$.

    True. Two separate trips cost $2c_{0i}+2c_{0j}$ (symmetric costs); the merged route $0\to i\to j\to0$ costs $c_{0i}+c_{ij}+c_{0j}$. The difference is $c_{0i}+c_{0j}-c_{ij}$.

    30. The set-partitioning formulation of the CVRP has a polynomial number of columns.

    How many different routes can be made from $n$ customers?

    False. Every feasible route is a column, and their number grows exponentially with $n$. That is why column generation prices routes with the dual values instead of listing them.

    • Test the smallest case first; one counterexample settles a "false".
    • Write the reason as a rule: "the feasible set shrinks, so the minimum cannot fall".
    • Check min or max, and the direction of the inequality, before the verdict.
    • Answering from the topic ("this is about MTZ") instead of the exact words.
    • Giving a verdict with no reason.
    • Trusting a slide's objective sense without checking it.
    1. Use the counterexample method: one tiny case disproves a statement, and a rule proves it.
    2. The same traps recur: direction of bounds, sign of dual variables, weak against strong big-$M$ and MTZ against DFJ, and children never being better.
    3. A good reason is one line that names the rule: complementary slackness, weak duality, "the feasible set shrinks", "valid means no integer point is lost".

    "A larger big-$M$ never changes the LP bound of a fixed-charge model." What is the best verdict with reason?

    True: big-$M$ is only a technical constant.
    Try the widget: moving $M$ moves the bound.
    False: the LP sets $y=x/M$, so a larger $M$ lowers the fixed cost paid and weakens the bound.
    The integer optimum is unchanged, but the relaxation gets weaker.
    False: a larger $M$ makes the problem infeasible.
    A larger valid $M$ keeps every integer point feasible.

    For $\min x_1+x_2$ with $x_1+x_2\ge4$ and $x_1-x_2=0$, the dual variable $y_2$ of the equality can be:

    Only non-negative.
    An equality row gives a free dual variable.
    Only non-positive.
    The sign is not fixed in either direction.
    Any real number; here the dual optimum has $y_2=0$ but its sign is not restricted.
    Dual: $\max4y_1$ with $y_1+y_2\le1$ and $y_1-y_2\le1$, $y_1\ge0$; the optimum is $y=(1,0)$ with value $4$.

    Which of these is a valid reason for "a child node's LP value is never lower than its parent's" (minimisation)?

    Child nodes use better solvers.
    The reason is about the feasible set, not the solver.
    The incumbent only improves.
    The incumbent concerns integer solutions, not the LP of the child.
    The child has one more constraint, so its feasible set is a subset of the parent's.
    A minimum over a subset cannot be smaller.

    Timed mock paper: ten new problems, 100 marks

    A mock paper trains something the chapters cannot: choosing what to do next with the clock running. Every problem below is new and has the same style and level as the exam.

    Do it with pencil and paper first. Type your final numbers into the boxes only when you have them; the page checks the answer, gives a hint after one wrong try and the full solution after two. Marks are printed so that you can mark yourself honestly.

    It is like a driving test: knowing the rules helps, but you only find out whether you can drive by driving with someone watching the clock.

    Rules of the mock

    • Choose the paper length (the real exam length is on your timetable; 120 min is a good default) and press Start. Do not use the notes tabs or the earlier parts.
    • The timer never submits, locks or marks anything. It only shows time and the pace.
    • Read all ten problems first. Do the ones you can finish quickly before the long ones.
    • If a problem has taken one and a half times its share of minutes, leave it and move on; come back with the time left over.
    Try it

    Pick the paper length, press Start and begin Problem 1 below. Use Pause only for a real interruption. Notice how the pace line tells you how many of the 100 marks should be written up by now; if you are behind it, skip to a shorter problem.

    Plan a 120-minute paper of 100 marks. The marks per problem are 14, 12, 10, 12, 10, 8, 8, 8, 10, 8. How do you split the time, and which problems do you start with?

    1. Reserve $10$ minutes at the start to read and $10$ at the end to check. That leaves $120-20=100$ minutes of working time.

      Reading first lets you choose an order; checking last catches sign slips that cost marks.

    2. Working time per mark: $100/100=1$ minute. A 14-mark problem gets about $14$ minutes, an 8-mark one gets about $8$.

      Marks are the price list; time should follow price.

    3. Start with the three 8-mark problems that need one idea each (problems 6, 7 and 10): about $24$ minutes for $24$ marks.

      Short, self-contained problems bank marks early and make the long ones less frightening.

    4. Set a stop-loss of one and a half times the share: $21$ minutes for problem 1, $18$ minutes for problem 2. At that point move on.

      A single stuck problem is the most common way to lose a paper.

    The paper

    Problem 1 [14 marks] Siting depots. The owner of Kaveri Courier chooses among five candidate depot sites to open (opening costs $f_j$ below). Each of four customers is served from exactly one open site at cost $c_{ij}$. Rules: at most $3$ sites are open; site 2 may open only if site 1 is open; sites 4 and 5 are never both open.

    Customer \ site12345
    Opening cost $f_j$3012261824
    Customer 11227213624
    Customer 2339241827
    Customer 3213062715
    Customer 4361827930

    (a) Write the model with $y_j$ (site $j$ open) and $x_{ij}$ (customer $i$ served from $j$); how many binary variables does it have? (b) Find the minimum total cost (opening plus service).

    For (b) choose which sites are open; then every customer simply takes the cheapest open site. List the allowed site sets and compare.

    (a) $\min\sum_jf_jy_j+\sum_{i,j}c_{ij}x_{ij}$ subject to $\sum_jx_{ij}=1$ for each customer, $x_{ij}\le y_j$, $\sum_jy_j\le3$, $y_2\le y_1$, $y_4+y_5\le1$, all binary. Variables: $4\cdot5+5=25$.

    (b) For a fixed set of open sites each customer takes its cheapest open site. Without the rule on site 2 the best set is $\{2,3\}$ with cost $12+26+(21+9+6+18)=92$, but it opens 2 without 1 and is forbidden. Among allowed sets: $\{3,4\}$ costs $26+18+(21+18+6+9)=98$; $\{1,2\}$ costs $30+12+(12+9+21+18)=102$; $\{3\}$ alone costs $26+(21+24+6+27)=104$. The minimum is 98, opening sites 3 and 4.

    Problem 2 [12 marks] LP and sensitivity. $\max\ 6x_1+4x_2$ subject to $2x_1+x_2\le b_1$ (with $b_1=20$), $x_1+x_2\le14$, $x_1+3x_2\le32$, $x_1,x_2\ge0$. Give (a) the optimal value, (b) the shadow price of the first constraint, (c) the smallest $b_1$ for which that shadow price stays valid.

    At the optimum the first two constraints are tight. The shadow prices solve $2y_1+y_2=6$, $y_1+y_2=4$. For (c) express $x$ in terms of $b_1$ and keep the third constraint satisfied.

    (a) The first two constraints give $x_1=6$, $x_2=8$; the third reads $6+24=30\le32$, so it is slack. Value $36+32=68$.

    (b) $y_1+y_2=4$ and $2y_1+y_2=6$ give $y_1=2$, $y_2=2$, $y_3=0$ (slack). Check: $20\cdot2+14\cdot2=68$.

    (c) With $b_1$ free: $x_1=b_1-14$, $x_2=28-b_1$. Need $x_1\ge0$: $b_1\ge14$; $x_2\ge0$: $b_1\le28$; third constraint $x_1+3x_2=70-2b_1\le32$: $b_1\ge19$. The binding lower limit is 19 (range $19\le b_1\le28$).

    Problem 3 [10 marks] Dual with an equality and a free variable. $\min\ 3x_1+2x_2+2x_3$ subject to $x_1+x_2+x_3=10$, $2x_1+x_3\ge8$, with $x_1,x_2\ge0$ and $x_3$ free. Write the dual and give its optimal value and the optimal $y_1$ of the equality row.

    A free primal variable gives an equality in the dual: for $x_3$ the dual row reads $y_1+y_2=2$. The equality row gives $y_1$ free; the $\ge$ row gives $y_2\ge0$.

    Dual: $\max\ 10y_1+8y_2$ subject to $y_1+2y_2\le3$ (for $x_1$), $y_1\le2$ (for $x_2$), $y_1+y_2=2$ (for $x_3$, free), $y_1$ free, $y_2\ge0$.

    Substitute $y_2=2-y_1\ge0$, so $y_1\le2$. The first row gives $y_1+4-2y_1\le3$, so $y_1\ge1$. The objective is $10y_1+16-8y_1=16+2y_1$, largest at $y_1=2$, $y_2=0$: value 20, $y_1=$ 2.

    Check with the primal: $x=(0,2,8)$ is feasible ($0+2+8=10$, $2\cdot0+8=8$) with cost $4+16=20$. Equal values prove both optimal.

    Problem 4 [12 marks] Branch and bound. $\max\ 29x_1+20x_2+13x_3+8x_4+18x_5$ subject to $4x_1+3x_2+4x_3+10x_4+7x_5\le24$, $x\in\{0,1\}^5$. Solve by branch and bound with the LP bound from the best value-to-weight order. Explore depth first, always the branch $x_j=1$ before $x_j=0$. Close a node if its LP is infeasible, its LP solution is integer, or its LP value is not above the incumbent. Give the root LP value, the number of nodes created (including the root), and the optimal value.

    Ratios value/weight: $7.25,\ 6.67,\ 3.25,\ 0.8,\ 2.57$ for items 1 to 5. Fill items in decreasing ratio order; the last item may be fractional. The only fractional variable at the root is $x_4$.

    Order of ratios: items 1, 2, 3, 5, 4. Root: items 1, 2, 3, 5 weigh $18$, leaving $6$ for item 4: $x_4=0.6$, value $29+20+13+18+4.8=\mathbf{84.8}$. Branch on $x_4$.

    $x_4=1$: uses $10$, leaving $14$. Take items 1, 2, 3 (weight $11$), leaving $3$ for item 5: $x_5=3/7$; value $8+29+20+13+\tfrac{54}{7}=77.71$. Branch on $x_5$.

    $x_4=1,x_5=1$: uses $17$, leaving $7$: items 1 and 2 fit exactly: integer, value $8+18+29+20=75$. Incumbent $75$.

    $x_4=1,x_5=0$: items 1, 2, 3 fit: integer, value $8+29+20+13=70\le75$: closed.

    $x_4=0$: items 1, 2, 3, 5 fit (weight $18$): integer, value $80>75$: new incumbent. Five nodes in all, optimum 80 (items 1, 2, 3, 5).

    Had we explored $x_4=0$ first the incumbent $80$ would appear at once, and the node $x_4=1$ (value $77.71\le80$) would be closed unexplored: only $3$ nodes. The order does not change the answer, only the work.

    Problem 5 [10 marks] Weak and strong big-M. Three periods with demands $20,30,10$. Production in period $t$ costs $2$ per unit, holding costs $1$ per unit per period, and each period with production has a set-up cost of $60$ ($y_t=1$). Production $x_t\le M_ty_t$. No stock at start or end. (a) The LP bound with $M_t=60$ in all periods; (b) the LP bound with the tight values $M_t=$ demand still to come $=(60,40,10)$; (c) the integer optimum.

    In the LP, $y_t=x_t/M_t$, so a unit produced in period $t$ pays $60/M_t$ of set-up. Compare for each unit the cost of producing it in its own period against producing it earlier.

    (a) With $M=60$ every unit pays set-up $60/60=1$ wherever it is produced, and holding only adds cost, so produce just in time: $2\cdot60+60\cdot\tfrac{60}{60}=120+60=\mathbf{180}$.

    (b) Set-up per unit is $1$, $1.5$, $6$ in periods 1, 2, 3. Demand 1 (20 units) is made in period 1: $20(2+1)=60$. Demand 2 (30 units): own period costs $2+1.5=3.5$ per unit, period 1 costs $2+1+1=4$; choose own, $105$. Demand 3 (10 units): own period $2+6=8$, period 2 costs $2+1.5+1=4.5$; choose period 2, $45$. Total $60+105+45=\mathbf{210}$ (period 2 produces $40$, with $y_2=1$).

    (c) In the IP set-ups are whole. Plans: $y=(1,0,0)$: set-up $60$, production $120$, holding $30\cdot1+10\cdot2=50$: 230. $y=(1,1,0)$: $120+120+10=250$. $y=(1,0,1)$: $120+120+30=270$. $y=(1,1,1)$: $180+120=300$. The minimum is $230$. The gaps are $21.7\%$ for $M=60$ and $8.7\%$ for the tight $M$.

    Problem 6 [8 marks] Finding a violated subtour cut. A fractional point of a six-city symmetric TSP has $x^*_{12}=x^*_{23}=x^*_{45}=x^*_{56}=1$ and $x^*_{13}=x^*_{46}=x^*_{14}=x^*_{36}=\tfrac12$; all other edges are $0$. Every city has degree $2$. For $S=\{1,2,3\}$ compute $x^*(\delta(S))$ and $x^*(E(S))$, and say which subtour constraint is violated.

    $\delta(S)$ are edges with exactly one end in $S$; $E(S)$ are edges with both ends in $S$.

    $\delta(S)=\{14,36\}$ with values $\tfrac12+\tfrac12=\mathbf{1}$. $E(S)=\{12,23,13\}$ with values $1+1+\tfrac12=\mathbf{2.5}$.

    The cut form needs $x(\delta(S))\ge2$ but it is $1$: violated. The edge form needs $x(E(S))\le|S|-1=2$ but it is $2.5$: violated. These agree through $\sum_{u\in S}x(\delta(u))=2x(E(S))+x(\delta(S))$: $6=2\cdot2.5+1$. Adding either constraint cuts off this point.

    Problem 7 [8 marks] MTZ against DFJ. A directed TSP has $n=8$ cities including the depot. A cycle $C$ of $5$ customers avoids the depot. How large can $x(C)$ (the sum of $x$ over the arcs of $C$) be in the MTZ LP, and how large in the DFJ LP?

    Write the MTZ row as $u_i-u_j+(n-1)x_{ij}\le n-2$ and add it around the cycle; the labels cancel.

    Adding the rows over the $|C|=5$ arcs: $(n-1)x(C)\le(n-2)|C|$, so $x(C)\le\tfrac{6}{7}\cdot5=\tfrac{30}{7}\approx\mathbf{4.2857}$. DFJ gives $x(C)\le|C|-1=\mathbf{4}$. MTZ allows a fractional $0.2857$ more on this cycle, so its LP bound is weaker.

    Problem 8 [8 marks] Capacity cut. Four customers have demands $7,6,6,5$ and each van carries $C=10$. For $S$ the set of all four, give (a) $\lceil d(S)/C\rceil$, (b) $r(S)$, the minimum number of vans, and (c) the right-hand side of the two-index capacity cut $x(\delta(S))\ge2r(S)$.

    $r(S)$ is a bin-packing number. Which pairs of demands fit in one van?

    (a) $d(S)=24$ and $\lceil24/10\rceil=\mathbf{3}$.

    (b) Pairs: $7+6=13$, $7+5=12$, $6+6=12$, $6+5=11$ all exceed $10$, so every customer needs a van of its own: $r(S)=\mathbf{4}$, one more than the cheap bound.

    (c) The cut reads $x(\delta(S))\ge2\cdot4=\mathbf{8}$: four vans, each entering and leaving the depot side once. Using the weaker $\lceil24/10\rceil$ would give only $6$.

    Problem 9 [10 marks] Savings. Kaveri Courier has its depot 0 and five customers with demands $d=(4,5,3,6,3)$ for customers $1,\dots,5$ and van capacity $C=12$. Travel costs (symmetric) are below. Run the parallel Clarke–Wright savings algorithm and give the number of routes and the total cost of the result.

    Cost12345
    from depot 07791113
    customer 1–4646
    customer 2–1066
    customer 3–48
    customer 4–4

    Compute $s_{ij}=c_{0i}+c_{0j}-c_{ij}$ for the ten pairs and go through them from the largest. Merge only if both customers are route ends of two different routes and the combined load is at most $12$.

    Savings in decreasing order: $s_{45}=11+13-4=20$, $s_{34}=9+11-4=16$, then $14$ for the pairs $(3,5),(2,5),(1,5),(1,4)$, $s_{24}=12$, $s_{13}=s_{12}=10$, $s_{23}=6$.

    Go through the list. $(4,5)$: loads $6+3=9\le12$, merge into $[4,5]$. $(3,4)$: customer 4 is an end of $[4,5]$, loads $3+9=12\le12$, merge into $[3,4,5]$. $(3,5)$: same route, skip. $(2,5)$: loads $5+12=17>12$, skip. $(1,5)$: $4+12=16>12$, skip. $(1,4)$: customer 4 is now inside the route, not an end, skip. $(2,4)$: same reason, skip. $(1,3)$: $4+12=16>12$, skip. $(1,2)$: both single-customer routes, $4+5=9\le12$, merge into $[1,2]$. $(2,3)$: loads $9+12=21>12$, skip.

    Result: $2$ routes. $[3,4,5]$ costs $9+4+4+13=30$; $[1,2]$ costs $7+4+7=18$. Total 48, a saving of $94-48=46=20+16+10$ over serving each customer separately (cost $94$).

    Problem 10 [8 marks] Reading a log. A minimisation with integer costs prints:

       Node   Incumbent      BestBd     Gap
    H     0   1410.0000   1271.0000   9.86%
    *    40   1368.0000   1288.5000   5.81%
         95   1342.0000   1301.6000      ?

    (a) What gap is printed on the last row, in percent? (b) What is the smallest value the optimum can still take?

    Use the formula that reproduces the first row: $(1410-1271)/1410=9.86\%$. For (b) use that costs are integers.

    (a) $(1342-1301.6)/1342=40.4/1342=0.0301$, so 3.01%.

    (b) The optimum is at least BestBd $=1301.6$ and, with integer costs, an integer, so at least 1302. It is also at most the incumbent $1342$. The true gap to the optimum is therefore at most $40$ units. The row markers: H means a heuristic found the incumbent, * means branching found it.

    • Write the set-up (variables, sense, the dual's signs, the set $S$) before the numbers.
    • Keep to the minutes-per-mark; at one and a half times the share, move on.
    • Spend the last minutes checking signs and the direction of each inequality.
    • Spending half the paper on a single problem.
    • Erasing working instead of crossing it out: partial marks need to be seen.
    • Stopping at a number without a sentence that answers the question.
    1. Plan the paper: read first, bank short problems early, give each problem time in proportion to its marks and move on at one and a half times its share.
    2. Every problem type has a check: equal primal and dual values, degrees summing to the cut identity, a bound on the correct side of the incumbent, the LP gap shrinking with a tighter $M$.
    3. Practise under the clock: the pace line shows whether you are fast enough, which no amount of untimed reading can.

    A 90-minute paper of 100 marks. You reserve 10 minutes for reading and 10 for checking. How many minutes of working time do you have per mark?

    0.9
    That uses all 90 minutes for working; subtract the reading and checking time first.
    0.7
    $(90-20)/100=0.7$, so a 10-mark problem gets about 7 minutes.
    1.1
    That is more than the total time per mark.

    Halfway through a problem the arithmetic goes wrong and you cannot find the slip. What protects most of the marks?

    Rubbing it all out and starting again silently.
    Work that is erased cannot earn marks.
    Writing a final number that looks plausible.
    An unsupported number earns nothing and may lose method marks.
    Leaving the correct set-up and method visible, stating the result you reached, and moving on.
    Method marks are awarded for the set-up and each correct step.

    In the mock, the LP bound with $M=60$ was $180$ and with tight $M$ it was $210$ against an optimum of $230$. What does this show?

    The bound depends on the solver used.
    An LP optimum is the same for every correct solver; the models differ.
    A tighter big-$M$ gives a stronger formulation: a higher lower bound with the same integer optimum.
    Same integer points, smaller LP region, better bound.
    Tight big-$M$ changes the optimal plan.
    Both formulations share the integer solutions, so the optimum is $230$ in each.

    Design-a-question: from a theme to a solved model

    In a design-a-question exam you are given a theme (healthcare, ports, disaster relief, retail) and must invent a logistics problem on it, formulate it, solve a small instance and explain how the method scales.

    Marks go to a model that is new in a specific way, constraints that each say one sentence of the story, a small instance with a verified answer and a reason it is optimal, and a sensible method for large sizes. The course's models are the building blocks; this chapter shows one complete answer.

    It is like a cooking exam with a mystery basket: the techniques are the ones you practised, and the marks are for combining them into one coherent dish and explaining every step.

    1. Story (3–5 lines): who decides what, and the real tension (cost against service, fairness, speed against consolidation).
    2. What is new: name the base model and the one or two twists, and say how they interact.
    3. Sets, parameters with units, variables with type and meaning, in a table.
    4. Objective and constraints, each with a one-line meaning.
    5. Small instance (3–6 nodes) chosen so the answer is not obvious.
    6. Solve and prove: enumeration table, an LP or dual bound that meets the solution, a cut, or a small branch-and-bound tree.
    7. Insight: what is counter-intuitive in the answer.
    8. Method at scale: which constraint family is exponential (branch and cut with which separation), which structure suits column generation (and its pricing problem), which valid inequalities strengthen the LP.
    9. Limitations and extensions: uncertainty, several periods, robustness.
    Phrase in the questionConstraintCourse link
    "only from an open site"$x_{ij}\le y_i$Ch. 3.3 (strong forcing rows)
    "at most $p$ sites"$\sum_iy_i\le p$Part D
    "no one farther than $R$"$x_{ij}=0$ if $d_{ij}\gt R$arc deletion, Ch. 6.3
    "the worst-off as well off as possible"$\min T$, $T\ge\sum_id_{ij}x_{ij}$ for all $j$min–max, Part D
    "if van goes $i\to j$, it arrives after $i$"$w_j\ge w_i+s_i+t_{ij}-M_{ij}(1-x_{ij})$Ch. 6.3
    "cannot both be chosen"$y_a+y_b\le1$, or a clique rowCh. 7.2
    "routes must be connected to the depot"$x(\delta(S))\ge2r(S)$, separated lazilyCh. 6.1, 8.3
    "choose among many routes or patterns"set partitioning + column generationParts 10–11
    Theme: flood relief

    After a flood, a district can station water tankers at two of three depots $A,B,C$. Four villages with populations (in hundreds) $40,20,10,10$ must each be served from the nearest open depot. Road distances in km: from $A$: $5,8,9,9$; from $B$: $7,3,10,2$; from $C$: $10,8,2,4$. Should the district minimise total person-kilometres, or the distance of the worst-served village?

    Formulate both objectives, solve the instance, and say what fairness costs.

    1. Variables: $y_i\in\{0,1\}$ open depot $i$; $x_{ij}\in\{0,1\}$ village $j$ served from $i$. Constraints: $\sum_iy_i=2$; $\sum_ix_{ij}=1$ for every village; $x_{ij}\le y_i$. Efficiency: $\min\sum_{i,j}h_jd_{ij}x_{ij}$ (a $2$-median). Fairness: $\min T$ with $T\ge\sum_id_{ij}x_{ij}$ for every $j$ (a $2$-centre).

      Each sentence of the story is one constraint family; the two objectives share them.

    2. Enumerate the three pairs. $\{A,B\}$: distances $5,3,9,2$, person-km $40\cdot5+20\cdot3+10\cdot9+10\cdot2=370$, worst $9$. $\{A,C\}$: $5,8,2,4$, total $420$, worst $8$. $\{B,C\}$: $7,3,2,2$, total $380$, worst $7$.

      With only $\binom32=3$ options the table is a complete proof of optimality.

    3. Efficiency picks $\{A,B\}$ ($370$); fairness picks $\{B,C\}$ (worst village $7$ km). The fair plan costs $10$ more person-km, $2.7\%$.

      A small price for a $2$ km shorter worst trip: this is the insight to state.

    4. At scale: hundreds of villages and sites make enumeration impossible. The $p$-median is solved by branch and bound on the strong formulation (Ch. 3.3), whose LP is often integral; the $p$-centre by trying radii $R$ in increasing order and solving a set-covering problem "every village within $R$ of an open depot, at most $p$ depots", strengthened with clique and cover cuts (Part 7).

      Name the method, the hard part and the cut families.

    Flood relief: total person-km of the plan $\{B,C\}$?

    Distances to the nearest open depot are $7,3,2,2$.

    $40\cdot7+20\cdot3+10\cdot2+10\cdot2=280+60+20+20=380$.

    By how many percent does the fair plan exceed the efficient plan in person-km?

    $(380-370)/370$.

    $10/370\approx2.7\%$.

    Which constraint says "no village may be farther than $R$ km from the depot that serves it"?

    Forbid the assignments that are too long.

    Fix $x_{ij}=0$ for every pair with $d_{ij}\gt R$ (or delete those variables). The other two mix units or count depots.

    • Keep the instance small enough that a table proves the answer.
    • State the scaling method precisely: what is exponential, what is separated or priced, which cuts help.
    • Inventing a twist that does not interact with the base model ("also minimise emissions" with no new decision).
    • Giving a number without a reason it is optimal.
    1. A full answer has a story, a named base model with interacting twists, a tidy model, a small solved instance with a proof, an insight, and a method at scale.
    2. Phrases translate into standard constraints: forcing rows, cardinality, arc deletion, min–max, time propagation, clique rows, capacity cuts, set partitioning.
    3. On the flood-relief instance efficiency opens $\{A,B\}$ ($370$ person-km), fairness opens $\{B,C\}$ (worst $7$ km) at $2.7\%$ more.

    What best proves optimality for a three-option instance?

    Saying the solver found it.
    In a written exam there is no solver.
    A table listing all three options and their values.
    Complete enumeration is a proof.
    A heuristic with a good gap.
    A gap is not a proof when enumeration is possible.

    Which scaling method fits "many possible van routes, each with complicated rules"?

    MTZ constraints in a compact model.
    Weak LP, and route rules become big-M rows.
    Set partitioning with column generation, the rules inside the pricing problem.
    Branch and price for an exact answer.
    Enumerating all routes.
    Too many at scale.

    Which twist is coupled to the base model?

    "Also report the CO₂ of each route."
    A report changes no decision.
    "Customers are in a city."
    That is setting, not structure.
    "A van's load decides its speed, and speed decides whether time windows can be met."
    Load, time and routing now interact.

    Drill: cuts, columns and the case study

    Short computations of the kind the later lectures ask for: a rounded cut, a cover, a Gomory cut, a blossom, a reduced cost, a bound, a dominance check.

    Each takes two to five minutes by hand and checks one definition precisely; together they cover Parts 7 to 11.

    It is like scales for a musician: short, exact, and repeated until they need no thought.

    CG cut from $3x_1+5x_2\le17$, $x\in\Z^2_+$, with $\lambda=\tfrac13$: $x_1+x_2\le\,?$

    $x_1+\tfrac53x_2\le\tfrac{17}3$, then round.

    $\lfloor5/3\rfloor=1$ and $\lfloor17/3\rfloor=5$: $x_1+x_2\le5$.

    Knapsack $7x_1+6x_2+4x_3+3x_4\le12$. The LP point $x^*=(1,\tfrac56,0,0)$. Evaluate the left side of the cover inequality for $C=\{1,2\}$.

    $7+6=13\gt12$, so $x_1+x_2\le1$.

    $1+\tfrac56=\tfrac{11}6\gt1$: violated by $\tfrac56$.

    Tableau row $x_1-0.4x_3+1.2x_4=3.6$. Give the Gomory cut $f_3x_3+f_4x_4\ge f_0$.

    $-0.4-\lfloor-0.4\rfloor$.

    $f_3=0.6$, $f_4=0.2$, $f_0=0.6$.

    A blossom with $3$ teeth has left side $x(\delta(H))+\sum x(\delta(T_i))=9.5$ at an LP point. By how much is it violated?

    Right side $3k+1$.

    $10-9.5=0.5$.

    A route serving customers with duals $9,8,6$ costs $25$. The master has a fleet row $\sum y_r\le K$ with dual $\mu=-2$. What is the route's reduced cost?

    $c_r-\sum\pi_i-\mu$.

    $25-23-(-2)=4$. Not attractive.

    Cutting stock: RMP value $50$, best pricing value $\max y^\top a=1.25$. Lower bound on the LP optimum?

    Farley: divide.

    $50/1.25=40$.

    At the same node, does label $(-6,\ 7,\ \{1,3\})$ dominate $(-6,\ 7,\ \{1,3,4\})$?

    Equal cost and load; compare visited sets.

    Yes: $\{1,3\}\subset\{1,3,4\}$, so the first can do everything the second can, at no higher cost.

    • Write the definition first, then substitute numbers.
    • Check signs of duals from the row type and objective sense.
    • Taking fractional parts of negative numbers as absolute values.
    • Comparing labels at different nodes.
    1. CG and Gomory cuts are rounding; covers, cliques and blossoms are counting arguments.
    2. Reduced costs subtract duals of every row the column touches, including fleet and cut rows.
    3. Every column-generation round gives a bound; labels are pruned only by full dominance.

    A cut $x(E(S))\le2$ for a $5$-node set in a matching problem is:

    A cover inequality.
    No knapsack row is involved.
    An odd-set inequality, a CG cut with multipliers $\tfrac12$.
    $\lfloor5/2\rfloor=2$.
    A subtour cut.
    Subtour cuts bound $x(E(S))$ by $|S|-1=4$.

    Column generation stalls: the RMP value is unchanged for three rounds while pricing still finds negative columns. Most likely cause?

    The LP is optimal.
    Negative columns still exist.
    Degeneracy: new columns enter at value zero.
    The value will move again.
    The pricing problem is wrong.
    Stalling is normal under degeneracy.

    Which pair is right?

    Blossoms: lazy constraints; subtours: user cuts.
    The other way round.
    Subtours: lazy constraints; blossoms: user cuts.
    Only subtours are needed for feasibility.
    Both: lazy constraints.
    Tours satisfy every blossom.

    In Walmart's Load Planner, which course concept is the hours-of-service check?

    A clique inequality.
    It is about route feasibility.
    A resource limit on a route, like load or time in labelling.
    Driving and duty hours accumulate along the route.
    A Gomory cut.
    No tableau is involved.

    $\min\ 4x_1+3x_2$ subject to $x_1+x_2\ge6$, $x_1\ge2$, $x\ge0$. What is the optimal value (use the dual)?

    18
    That is the dual value at $y=(3,0)$, which is feasible but not optimal; it uses only one of the two rows.
    20
    Dual: $\max6y_1+2y_2$ with $y_1+y_2\le4$, $y_1\le3$: $y=(3,1)$ gives $20$; primal $x=(2,4)$ costs $8+12=20$.
    24
    That is $6\cdot4$, which breaks the dual row $y_1\le3$.

    $x$ is a quantity with $0\le x\le35$, and $y$ is a binary switch. Which is the best linking row?

    $x\le1000\,y$
    Valid, but the LP bound is far weaker than necessary.
    $x\le35\,y$
    The smallest valid $M$ is the upper bound of $x$, and it gives the strongest relaxation.
    $x\le y$
    This cuts off every feasible value of $x$ above $1$.

    In a maximisation, a node has LP value $12.5$ and the incumbent is $13$. What do you do?

    Branch further, since $12.5$ is fractional.
    A fractional LP does not matter if the node cannot beat the incumbent.
    Close the node: nothing inside it can exceed $12.5$, which is below $13$.
    For a maximisation the LP value is an upper bound on the node.
    Replace the incumbent by $12.5$.
    The incumbent must be a feasible integer plan, and it never gets worse.

    A fractional TSP point has degree $2$ at every city and $x(\delta(S))=1.5$ for a set $S$. Which is right?

    The point is feasible for DFJ.
    DFJ needs $x(\delta(S))\ge2$ for every $S$.
    The cut $x(\delta(S))\ge2$ is violated, and so is $x(E(S))\le|S|-1$.
    The two forms are equal under the degree constraints: $x(E(S))=(2|S|-1.5)/2=|S|-0.75\gt|S|-1$.
    The point violates the degree constraints.
    The statement says every degree is $2$.

    As $n$ grows with the cycle length $|C|=3$ fixed, how do the MTZ and DFJ allowances $x(C)$ behave?

    Both stay at $2$.
    Only DFJ is independent of $n$.
    DFJ stays at $2$, while MTZ rises towards $3$.
    MTZ allows $(1-\tfrac1{n-1})\cdot3$, which tends to $3=|C|$.
    MTZ falls below DFJ.
    The MTZ value $(1-\tfrac1{n-1})|C|$ is never below $|C|-1$.

    Three customers with demands $4,4,4$ and van capacity $6$. How many vans do they need, and what is the rounded capacity cut for their set?

    2 vans, $x(\delta(S))\ge4$
    $\lceil12/6\rceil=2$ is only a lower bound; two demands of $4$ do not fit in a van of capacity $6$.
    3 vans, $x(\delta(S))\ge6$
    Each customer needs its own van, so $r(S)=3$ and the right-hand side is $2r(S)=6$.
    3 vans, $x(\delta(S))\ge3$
    The cut is $2r(S)$, because each van enters and leaves $S$ once.
    Every question, answered right

    You made it all the way down.

    You worked through every quiz and every practice problem in Logistics and Freight Modelling. That took real effort, and the understanding is yours to keep. Add your name to make a certificate.