Download as pdf or txt
Download as pdf or txt
You are on page 1of 18

Chapter 4

Integer programs

Once again, consider the resource constraint problem we modelled in chapter 2. In this problem,
the goal was to determine the optimal number of fractional barrels produced of each type of oil,
given limited quantities of the input crude oils. However, it isn’t practical to produce a fractional
barrel of oil, since customers come to expect full barrels of oil. Integer programming allows us
to incorporate the constraint that any feasible solution can only produce an integer number of
barrels of each oil type. In this section, we will review integer programming formulations and
some modelling tricks that can be achieved with integer programs. Furthermore, we will discuss
solving integer programs and some properties that make the solving process much easier.
An integer program is obtained from a linear program by adding the condition that a nonempty
subset of variables must take on integer values. When all variables are restricted to take integer
values, we call the corresponding program a pure integer program. Otherwise, it is called a mixed
integer program.

4.1 Assignment problems


One of the most common appearances of integer variables is when an assignment must be made.
Assignment problems arise in assigning employees to tasks, students to schools, and many other
problems. In our first example, we will discuss a problem which requires variables take on integer
values since we cannot hire a fraction of a person.
Example 4.1 Hiring
We are given a set of tasks I and a set J of employee types. For each task i 2 I, we require
bi employees to be hired that are capable of completing that task. For each employee j 2 J,
Sj is the set of tasks an employee of type j can complete, and cj denotes the cost of hiring one
employee of type j. It is important to note that employees need not be assigned to complete a
single, specific task. How many employees of each type should we hire so that we are able to
satisfy the required number of employees capable of each task, at the lowest cost possible? For
example, suppose I = {1, 2, 3} and bi = 1 for each task i. If there was an employee type j such
that Sj = {1, 2, 3}, then a feasible solution would be to hire just one employee of type j.

IP Formulation
Naturally, this problem can be modelled as an integer program.

39
40 CHAPTER 4. INTEGER PROGRAMS

Variables. As stated in the question, we need to decide the number of employees of each type
to hire. Therefore, for each employee type j 2 J, we need an integer variable xj to denote the
number of employees of type j hired.

Constraints. For each task i 2 I, we need to hire at least bi employees. Thus, we have the
system of constraints X
xj bi 8 i 2 I.
j2J:
i2Sj

Objective. The goal is to minimize the cost of hiring the employees, which is given by
X
c j xj .
j2J

Formulation. With the addition of non-negativity constraints we obtain the following integer
program.
X
min c j xj (4.1)
j2J
X
s.t. xj bi 8i2I
j2J:
i2Sj

xj 0 8j2J
xj 2 Z 8 j 2 J

In an assignment problem, we use binary variables to indicate choices. We will illustrate the
use of binary variables in assigning numbers to empty squares on a Sudoku puzzle. In an n ⇥ n
p p p
Sudoku puzzle, where n must be an integer, the grid is partitioned into n ⇥ n blocks. Given
a set of numbers already placed on the grid, the goal is to fill the remainder of the board with
numbers 1 to n such that each row, column, and block contains each number from 1 to n. For
ease of notation, we introduce [n] to indicate the set {1, 2, ..., n}. See figure 4.1 for an example
of a 4 ⇥ 4 Sudoku puzzle.

1
4
2
3 1

Figure 4.1: 4 ⇥ 4 Sudoku puzzle

Example 4.2 Sudoku


p
Let n be a number such that n 2 Z. We are given an n ⇥ n matrix G where Gij 2 {1, . . . n, •}
4.1. ASSIGNMENT PROBLEMS 41

and • indicates that the square ij is currently blank. How can we write an IP to fill in missing
numbers?

Variables. What are we deciding? For each cell ij where i 2 [n] and j 2 [n], we would like
to know which value from 1 to n is chosen for that cell. We will use binary variables xijk for all
i, j, k 2 [n] where xijk = 1 if value k is placed in cell i, j and xijk = 0 otherwise.

Constraints. First, we cannot change the numbers already place on the grid. Thus we have
the constraint
xijk = 1 8 i, j, k 2 [n] : Gij = k.

In row i, we only want one of each value. So, for all i 2 [n] and k 2 [n] , k must occur precisely
once in row i. Let Ri denote all positions in row i. That is, Ri = {(i, j) : j 2 [n]}. Then we have
the set of row constraints,
X
xijk = 1 8 i, k 2 [n].
(i,j)2Ri

Similarly, we want each value to occur precisely once in each column j. Let Cj = {(i, j) : i 2 [n]}.
Then we have the set of column constraints,
X
xijk = 1 8 j, k 2 [n].
(i,j)2Cj

Finally, we need a set of constraints for the blocks. Define S to be a set of blocks, where
each block is represented by the set of cells in that block. i.e. for a 4 ⇥ 4 puzzle, S =
{{(1, 1), (1, 2), (2, 1), (2, 2)}, ...}. Then we have the set of block constraints,
X
xijk = 1 8 S 2 S, 8 k 2 [n].
(i,j)2S

Integer program. Since we desire any feasible solution, we set the objective function to be
max 0, and obtain the following integer program.

max 0 (4.2)
X
s.t. xijk = 1 8 i, k 2 [n]
(i,j)2Ri
X
xijk = 1 8 j, k 2 [n]
(i,j)2Cj
X
xijk = 1 8 S 2 S, k 2 [n]
(i,j)2S

xijk 2 {0, 1} 8 i, j, k 2 [n]


42 CHAPTER 4. INTEGER PROGRAMS

4.2 Modelling tricks


4.2.1 Forcing a variable to take fixed values
Consider the condition, x 2 {a1 , . . . , am }. With the help of integer variables, this condition can
expressed as the set of solutions to a system of constraints. Essentially we are choosing one
item out of a set of m options, and this arises frequently in optimization problems. For each
i 2 {1, . . . , m} we require a binary variable yi . Recall that a binary variable takes the values of 0
and 1. Since we are choosing one out of a set of m options, we would like precisely one of the m
y-variables to be 1, say yi , indicating that the ith item is chosen. This can be expressed as the
set of solutions to the following system.

y1 + y2 + . . . + ym = 1, and
yi 2 {0, 1} 8 i 2 {1, 2, . . . , m}

We would like to enforce that if the ith item is chosen, then x is equal to ai . Writing

x = a 1 y1 + a 2 y2 + . . . + a m y m

achieves this result, since precisely one y-variable will be 1, and so all other terms in the sum are
equal to zero.

4.2.2 Piecewise linear functions


In section 2.4, we looked at how to model the problem of minimizing a convex piecewise linear
function as a linear programming problem. In this section, we will look at how we can optimize
over more general piecewise linear functions.
Let f : R ! R be a continuous piecewise linear function and consider the portion of f (x)
between two points, x = a and x = b, where a < b. Then f is defined as the “linear interpolation”
of the breakpoints from a to b: (a1 , f1 ), (a2 , f2 ), . . . , (ak , fk ), with a = a1 < a2 < . . . < ak = b and
fi = f (ai ) for each 1  i  k. For an example, see figure 4.2.

fi+1 f

fi

a1 ai ai+1 ak

Figure 4.2: f specified by breakpoints

Since the points (ai , fi ) for 1  i  k are chosen as the set of breakpoints from a to b, we have
that if (x, f (x)) is a point with x 2 [ai , ai+1 ], then it can be expressed as a convex combination
4.2. MODELLING TRICKS 43

of the two endpoints (ai , fi ) and (ai+1 , fi+1 ). That is,

8 1  i  k, x 2 [ai , ai+1 ] ) 9 i, i+1 2 [0, 1] : (4.3)


i + i+1 = 1,
x= i ai + i+1 ai+1 , and
f (x) = i f (ai ) + i+1 f (ai+1 ).

How can we write an integer program that maximizes f (x) given x 2 [a, b], such that the
feasible values of x and y in the program are precisely the set of all points (x, f (x)) where
x 2 [a, b]?

Variables. Notice that between any two breakpoints, the function f is linear and it is not too
hard to express the set of feasible points in the interval. Thus, we would like to have a binary
variable zi for each interval [ai , ai+1 ], where zi = 1 indicates that x is in the ith interval. We also
introduce variables si and ei for each interval i so that x = si ai + ei ai+1 for some si and ei if
and only if x is in [ai , ai+1 ]. We can think of si and ei as measurements of where x lies relative
to the start and end of the interval.

Constraints. Similar to in section 4.2.1, we are choosing one interval out of k 1 options, so
we require the constraints:

z1 + z2 + . . . + zk 1 = 1, and
zi 2 {0, 1} 8 i 2 {1, 2, . . . , k 1}.

Since the function is only linear between breakpoints, we also require that si and ei are positive
only if x is in the ith interval. Furthermore, we need si ai + ei ai+1 to describe precisely the
interval [ai , ai+1 ]. This is accomplished by

s e
i + i = zi 8 i 2 [k 1], and
s e
i, i 0 8 i 2 [k 1].

Finally, we have

k 1
X k 1
X
s e
x= i ai + i ai+1 .
i=1 i=1

Since only one pair of s and e will be positive, x is a point in the interval [ai , ai+1 ].
i i

Objective. The value of f (x) is completely determined by the positive values of s and e,
i i
and therefore we have the objective function

k 1
X k 1
X
s e
i fi + i fi+1 .
i=1 i=1
44 CHAPTER 4. INTEGER PROGRAMS

Integer program.
k 1
X k 1
X
s e
max i fi + i fi+1 (4.4)
i=1 i=1
k 1
X k 1
X
s e
s.t. x = i ai + i ai+1
i=1 i=1
z 1 + z2 + . . . + z k 1 =1
zi 2 {0, 1} 8 i 2 {1, 2, . . . , k 1}
s e
i + i = zi 8 i 2 [k 1]
s e
i, i 0 8 i 2 [k 1]

4.2.3 Optimizing over the union of polyhedra


Suppose we have two linear programs with di↵erent feasible regions, but the same objective
function c> x. One may want to create a new program which optimizes over the intersection or
the union of the two polyhedra. For example, consider the polyhedra, P1 and P2 in figure 4.3.

Figure 4.3: P1 and P2

A polyhedron is the feasible region of a linear program, or equivalently the intersection of a


finite number of halfspaces. As such, P1 = {x : A1 x  b1 } and P2 = {x : A2 x  b2 } for some A1 ,
A2 , b1 and b2 . Consider the mathematical programs resulting from taking the intersection and
the union of the feasible regions respectively.

max c> x (4.5) max c> x (4.6)


s.t. x 2 P1 \ P2 s.t. x 2 P1 [ P2
We can express the intersection of two polyhedra as another polyhedron. That is, we can
express (4.5) as a linear program. Specifically, (4.5) is equivalent to
max c> x (4.7)
s.t. A1 x  b1
A2 x  b 2 .
Clearly, the union of two polyhedra may be non-convex. Since the feasible region of a linear
program is always convex, it is not possible to express (4.6) as a linear program in general.
4.3. PERFECT FORMULATIONS 45

However, it is possible to express (4.6) as an integer program. We will demonstrate this property
for the case where 0  x  u. This process is not quite as straightforward as the intersection
case and we will need to introduce additional variables. In this case, we are choosing from a set
of two items, where the items are P1 and P2 . Let y1 and y2 be binary variables satisfying

y1 + y2 = 1, and
y1 , y2 2 {0, 1}.

Similar to in section 4.2.1, we would like yi = 1 to imply that x 2 Pi . Note that this does not
prevent x from being in both P1 and P2 , but at all times only a single y-variable will be equal to
1. Since x is in at least one of P1 and P2 , it is equal to some vector x1 in P1 or some vector x2
in P2 .

Integer program. Continuing with this logic, we claim that (4.6), with the additional con-
straint that 0  x  u is equivalent to the following integer program.

max c> x (4.8)


s.t. y1 , y2 2 {0, 1} (4.9)
y1 + y 2 = 1 (4.10)
1 2
x=x +x (4.11)
A1 x 1  y 1 b 1 (4.12)
2 2 2
A x  y2 b (4.13)
1
0  x  y1 u (4.14)
2
0  x  y2 u (4.15)

Proof. To prove the two programs are equivalent, it suffices to show that the feasible regions are
the same. Firstly, suppose x̄, x̄1 , x̄2 , ȳ1 , and ȳ2 is a feasible solution to (4.8). We must show that
x̄ is a feasible solution to (4.6). We may assume that ȳ1 = 1 and ȳ2 = 0 due to constraints (4.9)
and (4.10). Since ȳ2 = 0, constraint (4.15) implies that x̄2 = 0, and so x̄ = x̄1 . Since x̄1 satisfies
constraint (4.12), x̄1 = x̄ is in P1 . Therefore x̄ is a solution to (4.6).
Conversely, suppose x̄ 2 P1 [P2 and 0  x̄  u. We would like to construct a solution to (4.8)
with x̄ given. We may assume that x̄ 2 P1 and so we assign ȳ1 = 1 and ȳ2 = 0, which satisfies
constraints (4.9) and (4.10). Letting x̄1 = x̄ and x̄2 = 0 clearly satisfies constraints (4.11), (4.14),
and (4.15). Observe that A2 x̄2 = 0 = 0b2 = y2 b2 , and so (4.13) is satisfied. Finally, (4.12) is
satisfied since A1 x̄1 = A1 x̄  b1 = y1 b1 , where the inequality holds since we assumed that x̄ was
in P1 .

4.3 Perfect formulations


At this point, it would be helpful to review the definitions of basis and basic solution in chapter
3. For an integer program (IP), we obtain the linear relaxation of (IP) by removing or “relaxing”
the condition that some variables have to take integer values. Let x̄ be an optimal solution
to (IP). Then x̄ is a feasible solution to the linear relaxation, but it may not be the optimal
solution. However, if we find an optimal solution to the linear relaxation that happens to satisfy
46 CHAPTER 4. INTEGER PROGRAMS

the integrality constraints of (IP), then the optimal value of (IP) and the optimal value of its
linear relaxation are equal.
An integer program admits a perfect formulation if all of the basic feasible solutions to the
linear relaxation satisfy the integrality constraints of the integer program. For an alternative
definition of perfect formulation, see section 5.7. By our previous argument, if an integer program
admits a perfect formulation, then we can solve the linear relaxation to find an optimal solution
to (IP) and bypass the challenge of solving an integer program. In this section, we will look at
how to identify if an integer program admits a perfect formulation, and we will see that various
nice classes of problems have perfect formulations.
A linear program is written in standard equality form (SEF) if it is of the form
max c> x (4.16)
s.t. Ax = b
x 0.
We may assume that the matrix A has full row rank, or equivalently, A has linearly independent
rows. In this section, when we would like to solve an integer program, we will assume the linear
relaxation is expressed in standard equality form. Recall from CO 250 [6] that if (4.16) has
an optimal solution, then it has an optimal basic solution, which we can find by applying the
Simplex method.
First, we introduce some notation. Consider a matrix A 2 Rm⇥n , a vector b 2 Rm , and the
system Ax = b. We define A j b as the matrix obtained by replacing the jth column of A by
the vector b.
Example 4.3
  
3 4 1 1 4
If A = ,b = , then A 1 b= .
1 1 2 2 1

Theorem 4.1. (Cramer’s rule)


If A is square and non-singular matrix, and x̄ is a vector such that Ax̄ = b, then,
det (A j b)
x̄j = (4.17)
det(A)
At this point it would be beneficial to review how to calculate determinants, especially via
the method of cofactor expansion.
Example 4.4
Suppose x̄ is a solution to  
3 4 1
x= .
1 1 2
Then x̄1 and x̄2 are given by:
✓ ◆ ◆ ✓
1 4 3 1
det det
2 1 1 2
x̄1 = ✓ ◆ = 9, and x̄2 = ✓ ◆ = 7.
3 4 3 4
det det
1 1 1 1
4.3. PERFECT FORMULATIONS 47

Proposition 4.1. Let M be a square matrix with all integer entries. If det(M ) 2 {±1} and b is
an integer vector, then any solution x̄ to the system M x = b is integer.

Proof. The proof follows directly from Cramer’s rule since M is non-singular if det(M ) 2 {±1}.
Therefore, if x̄ is a solution to M x = b, then we can find each entry using equation (4.17).
Futhermore, the denominator of (4.17) will be -1 or 1, and the numerator will be an integer since
all entries of M and b are integer. Thus, x̄j is integer for each entry j.

4.3.1 Totally unimodular matrices


We would like to develop properties of matrices so that when solving for a basic feasible solution,
we will always obtain a solution with all integer values. When we are solving for the basic feasible
solution for a given basis B, we are not considering the entire matrix A, but rather the square
submatrix AB . A submatrix of a matrix A is any matrix that is obtained from A by deleting a
series of rows and columns from A. Note that any matrix is its own submatrix.

Definition 4.1. (Totally unimodular matrix)


A matrix M is totally unimodular (TU) if for any square submatrix N of M , det(N ) 2 {±1, 0}.

Example 4.5
Which of the following matrices is TU?
2 3
2 3 2 3 2 3 1 0 1 0
1 1 0 1 1 1 0 1 60 1 0 17
A=4 1 0 25 , B = 4 1 1 5 , C = 4 0 1 0 5 , and D = 6
41
7.
1 0 15
1 1 1 0 1 1 0 1
0 0 1 0

1. Matrix A is not TU since the entry 2 is a 1 ⇥ 1 submatrix, with determinant 2.

2. Matrix B is not TU, because the square submatrix obtained by removing the third row has
determinant equal to 2.

3. Matrix C is not TU, because the square submatrix obtained by removing the second row
and second column has determinant equal to -2.

4. Matrix D is TU. Observe that there is at most one +1 and one -1 in each column. The
significance of this property will be discussed in section 4.3.2.

How can we use the fact that a matrix is TU to our advantage?

Proposition 4.2. Consider Ax = b where A is TU and b is integer. Then every basic solution
is integer.

Proof. Let x̄ be a basic solution of Ax = b for basis B. By definition, x̄j = 0 8j 2


/ B. Additionally,
AB x̄B = b, so x̄B is integer by proposition 4.1.

If a linear program in SEF has an optimal solution, then it has an optimal basic solution.
Thus, we obtain the following corollary of proposition 4.2.
48 CHAPTER 4. INTEGER PROGRAMS

Corollary 4.1. Suppose we are given some LP (P) in SEF form.

max c> x
s.t. Ax = b
x 0.

Suppose A is TU and b is integer. Then if (P) has an optimal feasible solution it has an integer
one.

Thus, if an integer program has a linear relaxation that satisfies Corollary 4.1, then the integer
program can be solved by solving the linear relaxation. One thing to note is that Corollary 4.1
is not an if and only if statement. In fact, we only need that AB has determinant 1 or -1 to get
an integer basic feasible solution.
While Corollary 4.1 is mathematically interesting, it is only useful if we can find optimization
problems that have an associated TU matrix. We will show that there are actually a large number
of problems with this property. But first, we need to be able to recognize TU matrices when we
encounter them out in the wild.

4.3.2 Constructing TU matrices


There are a few important take-aways from example 4.5. Firstly, we know that any entry of a
TU matrix must be 0, -1, or +1. Secondly, it is easier to certify that a matrix is not TU, than
prove that it is. We would like a way to prove that a matrix is TU, without listing all its square
submatrices and computing determinants. We will see that for some class of TU matrices, we
can bypass this tedious process. A basic class, which includes matrix D from example 4.5, is
given in the following proposition.

Proposition 4.3. If A is a {±1, 0}-matrix with at most one +1 and at most one -1 in each
column, then it is totally unimodular.

Proof. What do we need to show? We need to show that for any k ⇥k submatrix M of A, det(M )
2 {0, ±1}. We will proceed by induction on k. For k = 1, M is a single entry, which must be 0
or ±1, and so det(M ) 2 {0, ±1}.
Suppose the claim holds for some k 1 and consider k + 1. If there are no (k + 1) ⇥ (k + 1)
square submatrices, then the property trivially holds, so suppose such a submatrix M exists. We
consider three cases:

1. M has a column of zeros;

2. M has exactly one +1 and one -1 in each column;

3. M has a column with exactly one non-zero entry.

If M has a column of zeros, then it has determinant zero. Similarly, if M has exactly one
+1 and one -1 in each column, then the sum of the rows is the zero vector, meaning that the
rows are linearly dependent and the determinant is zero. Thus, we may assume that M has a
column with exactly one non-zero entry, Mij . Then by applying cofactor expansion, det(M ) =
Mij ( 1)i+j det(Mij0 ) where Mij0 is the square submatrix of M obtained by deleting row i and
column j. By induction, det(Mij0 ) is 0, +1, or -1, and so det(M ) must also be 0, +1, or -1.
4.3. PERFECT FORMULATIONS 49

There are also a few nice methods to obtain additional TU matrices. Let A1 2 Rm⇥n and
A2 2 Rm⇥s . We define A1 |A2 to be the matrix obtained by concatenating A1 and A2 , i.e. listing
the columns of A1 and then the columns of A2 in one matrix. In the following proposition, I
denotes the identity matrix of the appropriate size.
Proposition 4.4. Let A be a TU matrix. Then the following matrices are also TU:
1. A|I;
2. A> ;
3. any submatrix M of A;
4. A|A.
We leave the proof of Proposition 4.4 as an exercise. Notice that in the proposition A is an
arbitrary TU matrix and we cannot assume it satisfies the properties of proposition 4.3.
Example 4.6
Consider the matrix 2 3
1 1 0
A= 4 1 0 05 .
0 1 1
Since A has at most one +1 and at most one -1 in each column, it is TU by Proposition 4.3. By
proposition 4.4, the following matrices are all TU:
2 3 2 3
1 1 0 1 0 0 1 1 0 
4 5 > 4 5 1 1
A|I = 1 0 0 0 1 0 ,A = 1 0 1 , and M = .
0 1
0 1 1 0 0 1 0 0 1

It is useful to consider why we might want matrix types (1) (4) to be TU if A is TU. Suppose
we are given a formulation with a TU matrix, but it is not yet in SEF. Since A|I is also TU, this
implies that even if we add slack variables, the resulting problem in SEF will have a TU matrix.
Proposition 4.5. Consider the following LP:
max c> x (4.18)
s.t. Ax = b
0  x  u.
Suppose A is TU, and b and u are integer vectors. If (4.18) has an optimal solution then there
exists an optimal integer solution.
Proof. Notice that Proposition 4.5 is almost identical to Corollary 4.1, except the variables x
have an upper bound given by u. That is, the given LP is not in standard equality form. In
order to apply Corollary 4.1, we add slack variables s and obtain the following LP:
max c> x (4.19)
✓ ◆✓ ◆ ✓ ◆
A 0 x b
s.t. =
I I s u
✓ ◆
x
0.
s
50 CHAPTER 4. INTEGER PROGRAMS

By
✓ ◆applying Proposition 4.4, it is not hard to show that the resulting matrix is TU. The vector
b
is also integer and therefore by Corollary 4.1, if (4.19) has an optimal solution, then it has
u
an optimal solution that is integral.

4.3.3 Application to flows


Recall that for a min cost flow problem, we are given a digraph G = (V, E), with net flow demand
bv for each v 2 V , and edge cost ce for each e 2 E. This problem can be expressed as the min
cost flow LP.
Min cost flow LP
P
min e2E ce xe (4.20)
s.t. fx (v) = bv , 8 v 2 V
0  x  u.
In section 2.5, we applied the max st-flow integrality and the min cost flow integrality theo-
rems, theorems 2.1 and 2.2 respectively, without proving them. We will prove Theorem 2.2 and
leave the proof of Theorem 2.1 as an exercise. In order to prove the min cost flow integrality
theorem, we need to introduce the vertex-arc incidence matrix of a given directed graph.
Definition 4.2. (Vertex-arc incidence matrix)
The vertex-arc incidence matrix of digraph G = (V, E) is a {±1, 0}-matrix M with one row for
each vertex u 2 V and one column for each arc (u, v) 2 E. The entries of the matrix are such
that: 8
>
<+1 u = v
Mu,vw = 1 u=w
>
:
0 otherwise.

Example 4.7
For the directed graph given in figure 4.4, M is the following matrix.

v2111111

e1 11 e5 11

e1 e2 e3 e4 e5 e6 11111 11111

0 0 1 e4
v1 1 1 0 0 0 v11111111
e3 11
11
v4
1111111

v B 1 0 1 1 1 0 C
11111
11111

M = 2@ A
v3 0 1 1 1 0 1 e2 11 e6 11

11111 11111

v4 0 0 0 0 1 1
v3

Figure 4.4: Digraph G

It is important to notice that the matrix M is TU. In fact, it is not hard to see that the vertex-
arc incidence matrix of a digraph is always totally unimodular. This observation motivates the
proof of the min cost flow integrality theorem, which we restate here for convenience.
4.3. PERFECT FORMULATIONS 51

Theorem 4.2. (Min cost flow integrality theorem)


If the edge capacities, u, and node demands, b, are all integers and (4.20) has an optimal solution,
then there exists an integer optimal solution.

Proof.
P Consider theP net flow condition for a vertex v. The constraint fx (v) = bv can be expressed
as e2 + (v) xe e2 (v) xe = bv . In this expanded form, we see that fx (v) is equal to Mv x,
where Mv is the row vector corresponding to vertex v of vertex-arc incidence matrix. Therefore,
the min-cost flow LP can be rewritten in terms of M as follows:

min c> x (4.21)


s.t. M x = b
0xu

Suppose u and b are integer and there exists an optimal solution to (4.21). Since M is totally
unimodular and b and u are integer, by proposition 4.5 there is an optimal solution that is
integer.

4.3.4 A characterization of TU matrices


We know that not all totally unimodular matrices will have at most one +1 and at most one -1
in each column. In this section, we will fully characterize all TU matrices. That is, we will find
a condition such that a matrix satisfies the condition if and only if it is totally unimodular. In
order to do this, we introduce the idea of an equitable 2-colouring.

Definition 4.3. (Equitable 2-colouring)


An m ⇥ n matrix A has an equitable 2-colouring if there is a partition of the row indices [m] =
{1, 2, ..., m} into sets R1 and R2 such that
X X
Aij Aij 2 {±1, 0} 8 j 2 [n].
i2R1 i2R2

Example 4.8
From example 4.6, we know that the following matrix A is totally unimodular.
2 3
1 1 0
A = 41 0 15
0 0 1

In fact, it admits an equitable 2-colouring with R1 = {1} and R2 = {2, 3}. Notice that this was
the only possible split (up to relabeling R1 and R2 ). The first column indicates that rows 1 and
2 cannot both be in the same set. Similarly, column 3 indicates that rows 2 and 3 must be in
the same set.
We can now state a characterization of TU matrices. In the following theorem, R is a set of
row indices and rowR (A) denotes the submatrix of A induced by the row indices in R.

Theorem 4.3. (Ghouila, Houri)


An m⇥n matrix A is T U if and only if rowR (A) admits an equitable 2-colouring for all R ✓ [m].
52 CHAPTER 4. INTEGER PROGRAMS

Example 4.9
Continuing with the matrix A from example 4.8, we would like to show that A is TU using
Theorem 4.3. That is, for any R ✓ [m], we must be able to find an equitable 2-colouring of
rowR (A).
If |R| = 1, then we trivially have an equitable 2-colouring with R1 = R and R2 = ;, since all
entries are ±1 and 0. If |R| = 2, then we have the following three cases: R = {1, 2}, R = {2, 3},
and R = {1, 3}. An equitable 2-colouring for each case is given below.

  
1 1 0 1 0 1 1 1 0
row{1,2} (A) = row{2,3} (A) = row{1,3} (A) =
1 0 1 0 0 1 0 0 1

R1 = {1}, R2 = {2} R1 = {2, 3}, R2 = ; R1 = {1}, R2 = {3}

Finally, we need to show that there is an equitable 2-colouring when R = {1, 2, 3}. This case
was completed in example 8. Therefore by Theorem 4.3, A is TU.

In this course, we will prove the “if” direction of the Ghouila-Houri Theorem. That is, we will
prove that given an m ⇥ n matrix A, if rowR (A) admits an equitable 2-colouring for all R ✓ [m],
then A is TU.

Proof. Suppose rowR (A) has an equitable 2-colouring for all R ✓ [m]. Let B be a k ⇥k submatrix
of A and we will prove that det(B) 2 {±1, 0} by induction on k. We may assume that B is non-
singular, as otherwise the determinant is zero and we are done. Suppose k = 1. Since there is an
equitable 2-colouring when |R| = 1, each entry of A must be 0, +1, or -1.
Now consider k > 1 and suppose the hypothesis holds for all k 0 < k. We would like to find
the determinant of B and we currently have some information on the entries of B. Recall that
Cramer’s rule relates solution indices to determinants. If we want to solve for B 1 such that
BB 1 = I, we can solve for a single column of B 1 , say j at a time: BBj 1 = ej . By Cramer’s
rule since B is non-singular,

det (B i ej )
Bij 1 = . (4.22)
det(B)

Let B̄ be the matrix obtained by deleting the ith column and jth row of B i ej . B̄ is a
smaller square submatrix of A, so by induction det(B̄) 2 {±1, 0}. By applying cofactor expansion
along column i we see that det(B i ej ) 2 {±1, 0}.
Let B ⇤ be the matrix obtained by scaling the entries of B 1 by det(B). Recall from intro-
ductory linear algebra that B ⇤ is the adjugate matrix. Since det(B i ej ) 2 {±1, 0}, all entries
of B ⇤ are in {0, ±1}. Let R = {j : B1j
⇤ 6= 0}. Since B is non-singular, it cannot have a row with

all zero entries, so R 6= ;.


Let row1 (B ⇤ ) denote the ith row of B ⇤ . Then row1 (B ⇤ )B = det(B)e> 1 , a row vector with
entry det(B) in the first coordinate
P and all other entries 0. Thus, for any j 2 {2, ..., k}, 0 =

(row1 (B ⇤ )B)j = row1 (B ⇤ )Bj = B1i Bij , which is the sum of values in {0, ±1}. Since
i2R |{z} |{z}
2{±1} 2{0,±1}
the sum is equal to 0, there must be an equal number of +1 values and -1 values. Therefore,
|{i 2 R : Bij 6= 0}| is even for any j 2 {2, ..., k}.
4.3. PERFECT FORMULATIONS 53

˙ 2 = R such that
By the assumption, there exists a partition R1 [R
X X
Bij Bij 2 {±1, 0} 8 j 2 [k].
i2R1 i2R2
P P
For j 2 {2, ..., k} we must have that i2R1 BijP ij = 0 since |{i 2 R : Bij 6= 0}|
i2R2 BP
indicates that the result must be even. Therefore, i2R1 Bi1 i2R2 Bi1 2 ±1 as otherwise the
matrix would be singular.
In summary, y > B 2 {e> >
1 , e1 } where
8
>
<1 i 2 R1
yi = 1 i 2 R2
>
:
0 otherwise.

Recall that row1 (B ⇤ )B = det(B)e> > >


1 . Since B is non-singular, x B = det(B)e1 has a unique

solution x̄ = row1 (B ). By our previous argument, we have shown that either det(B)y or
det(B)y is the unique solution. Thus, row1 (B ⇤ ) 2 {(det(B))y, (det(B))y}. Since row1 (B ⇤ )
and y have entries 2 {0, ±1}, it must be that det(B) = ±1.

For a proof of the reverse direction, please refer to [7]. The following demonstrates how to
apply Theorem 4.3 to a combinatorial problem.
Example 4.10
Suppose we are given a set E = {e1 , ..., ek }, an integer parameter B, and for each element ei we
are given a cost cei 0. The goal is to pick a minimum cost subset S ✓ E such that |S| = B.
This is not hard to express as an integer program. For each i 2 [k], we need a decision variable
xi which is 1 when ei is in S, and 0 otherwise. The linear relaxation is
X
min c ei xei
i2[k]
X
s.t. xe i = B
i2[k]

0  x  1.

Equivalently, we can express this as the following LP:

max c> x
✓ > ◆✓ ◆ ✓ ◆
1 0 x B
s.t. =
I I s 1
✓ ◆
x
0.
s

For example, if E = {e1 , e2 , e3 }, then


0 1
✓ ◆ 1 1 1 0 0 0
1> 0> B1 0 0 1 0 0C
A= =B
@0
C.
I I 1 0 0 1 0A
0 0 1 0 0 1
54 CHAPTER 4. INTEGER PROGRAMS

We >
✓ would
◆ like to prove that A is TU. By proposition 4.4, it is equivalent to show that A =
1 I
is TU. Note that A> is a 2k ⇥ (k + 1) matrix. When |E| = 3,
0 I
0 1
1 1 0 0
B1 0 1 0C
B C
B1 0 0 1C
>
A =B B C.
C
B0 1 0 0C
@0 0 1 0A
0 0 0 1
We will prove that A> is TU by applying the Ghouila-Houri Theorem. Let R be a subset of row
indices. We need to show that rowR (A> ) has an equitable 2-colouring. First, we know that in
the first column, there is a 1 in the first k rows and a 0 in the remaining rows. We now split
the row indices into upper and lower sections. That is, U = [k] and L = [2k]\[k]. Suppose
R = {i1 , ..., iq , ..., it } ordered by increasing row index in R, and iq is the largest index in R that
is in U .
We know that for the upper indices, we need the number of upper indices in R1 and R2 to
di↵er by at most 1. One way to achieve this is to assign the rows in R to R1 and R2 in an
alternating fashion. Our partition of of rows in U \ R is
R1U = {ij : j  q and j is even}, and
R2U = {ij : j  q and j is odd}.
It is important to notice that this assignment is done based on the index in set R, and not on
the corresponding row index in A> .
We now consider the rows in L \ R. Notice that in column l, for l 2 {2, ..., k + 1}, there are
1s in row l 1 and row l 1 + k. Therefore, if both of these rows appeared in R, then we must
assign one row to R1 and the other to R2 . That is,
R1L = {r = l 1+k 2L\R:l 1 2 R2U }, and
R2L = (L \ R)\R1L .
Finally, R1 = R1U [ R1L and R2 = R2U [ R2L . We have found a method that creates an equitable
2-colouring for any row subset R, and so by the Ghouila-Houri theorem, A> is TU.
For example, if R = {1, 3, 6},
0 1
1 1 0 0
A>R =
@1 0 0 1A .
0 0 0 1
The rows in R are ordered as {i1 , i2 , i3 }. j = 2 is the largest number such that row ij in R is
in the upper portion of A. Therefore row i1 = 1 is assigned to R2 and row i2 = 3 is assigned to
R1 . We see that i3 = 6, and row 6 = l 1 + k = 1 l + 3 implies that l = 4. Row l 1 = 3
was assigned to R1 , so we assign row i3 = 6 to R2 . Therefore we obtain the partition R1 = {3},
R2 = {1, 6}.

The following corollary to the Ghouila-Houri Theorem can be proven by a similar method, and
we leave the proof as an exercise.
4.4. EXERCISES 55

Corollary 4.2. Let A be a {0, 1}-matrix such that in every column, the 1-entries are consecutive.
Then A is TU.

4.4 Exercises
Exercise 4.1. Permutation matrices
A {0, 1} square matrix is a permutation matrix if in each row and each column, there is precisely
one entry that is 1, and all other entries are zero. Without applying Proposition 4.3, prove that
any permutation matrix is totally unimodular.

Exercise 4.2. TU matrices and row conditions


Prove that if A is a {±1, 0}-matrix with at most one +1 and at most one -1 in each row, then it
is totally unimodular.

Exercise 4.3. Max st-flow integrality theorem


Prove the max st-flow integrality theorem (Theorem 2.1).

Exercise 4.4. LP formulations and TU matrices


Consider the following LP:
max c> x (4.23)
s.t. Ax  b
x 0.
Suppose A is TU and b is an integer vector. Prove that if (4.23) has an optimal solution then
there exists an optimal integer solution.

Exercise 4.5. Max matching in bipartite graphs


(a) Prove that if A is a TU matrix, it remains TU under the following operations:
(i) Multiplying a row or column by -1;
(ii) Permuting rows or columns;
(iii) Deleting or duplicating a row or column.
(b) Given an undirected graph G, we define the (undirected) incidence matrix M to be the
matrix with a row for each vertex and a column for each edge such that for all v 2 V and
e 2 E, the entry Mv,e is equal to 1 if vertex v and edge e are incident, and 0 otherwise. By
multiplying some rows by -1, prove that the incidence matrix of a bipartite graph is TU.
(c) Let G be a bipartite graph. Prove that the linear relaxation of the maximum matching IP is
of the form (4.23), with the constraint matrix given by the incidence matrix. Additionally,
prove that the maximum matching of a bipartite graph admits a perfect formulation.

Exercise 4.6. Equitable 2-colourings


Suppose A has at most one +1 and at most one -1 in each column. Without applying the
Ghouila-Houri Theorem, prove that rowR (A) has an equitable 2-colouring for all R ✓ [m].
56 CHAPTER 4. INTEGER PROGRAMS

You might also like