A task-scheduling probelm as a matroid
A task-scheduling probelm as a matroid
Exercises
16.4-1
Show that .S; k / is a matroid, where S is any finite set and k is the set of all
subsets of S of size at most k, where k jSj.
16.4-2 ?
Given an m n matrix T over some field (such as the reals), show that .S; / is a
matroid, where S is the set of columns of T and A 2 if and only if the columns
in A are linearly independent.
16.4-3 ?
Show that if .S; / is a matroid, then .S; 0 / is a matroid, where
0 D fA0 W S A0 contains some maximal A 2 g :
That is, the maximal independent sets of .S; 0 / are just the complements of the
maximal independent sets of .S; /.
16.4-4 ?
Let S be a finite set and let S1 ; S2 ; : : : ; Sk be a partition of S into nonempty disjoint
subsets. Define the structure .S; / by the condition that D fA W jA \ Si j 1
for i D 1; 2; : : : ; kg. Show that .S; / is a matroid. That is, the set of all sets A
that contain at most one member of each subset in the partition determines the
independent sets of a matroid.
16.4-5
Show how to transform the weight function of a weighted matroid problem, where
the desired optimal solution is a minimum-weight maximal independent subset, to
make it a standard weighted-matroid problem. Argue carefully that your transfor-
mation is correct.
An interesting problem that we can solve using matroids is the problem of op-
timally scheduling unit-time tasks on a single processor, where each task has a
deadline, along with a penalty paid if the task misses its deadline. The problem
looks complicated, but we can solve it in a surprisingly simple manner by casting
it as a matroid and using a greedy algorithm.
A unit-time task is a job, such as a program to be run on a computer, that requires
exactly one unit of time to complete. Given a finite set S of unit-time tasks, a
444 Chapter 16 Greedy Algorithms
Lemma 16.12
For any set of tasks A, the following statements are equivalent.
1. The set A is independent.
2. For t D 0; 1; 2; : : : ; n, we have N t .A/ t.
3. If the tasks in A are scheduled in order of monotonically increasing deadlines,
then no task is late.
Proof To show that (1) implies (2), we prove the contrapositive: if N t .A/ > t for
some t, then there is no way to make a schedule with no late tasks for set A, because
more than t tasks must finish before time t. Therefore, (1) implies (2). If (2) holds,
then (3) must follow: there is no way to “get stuck” when scheduling the tasks in
order of monotonically increasing deadlines, since (2) implies that the ith largest
deadline is at least i. Finally, (3) trivially implies (1).
Using property 2 of Lemma 16.12, we can easily compute whether or not a given
set of tasks is independent (see Exercise 16.5-2).
The problem of minimizing the sum of the penalties of the late tasks is the same
as the problem of maximizing the sum of the penalties of the early tasks. The
following theorem thus ensures that we can use the greedy algorithm to find an
independent set A of tasks with the maximum total penalty.
Theorem 16.13
If S is a set of unit-time tasks with deadlines, and is the set of all independent
sets of tasks, then the corresponding system .S; / is a matroid.
Task
ai 1 2 3 4 5 6 7
di 4 2 4 3 1 4 6
wi 70 60 50 40 30 20 10
Figure 16.7 An instance of the problem of scheduling unit-time tasks with deadlines and penalties
for a single processor.
unit-time tasks with deadlines and penalties for a single processor. The running
time is O.n2 / using G REEDY, since each of the O.n/ independence checks made
by that algorithm takes time O.n/ (see Exercise 16.5-2). Problem 16-4 gives a
faster implementation.
Figure 16.7 demonstrates an example of the problem of scheduling unit-time
tasks with deadlines and penalties for a single processor. In this example, the
greedy algorithm selects, in order, tasks a1 , a2 , a3 , and a4 , then rejects a5 (because
N4 .fa1 ; a2 ; a3 ; a4 ; a5 g/ D 5) and a6 (because N4 .fa1 ; a2 ; a3 ; a4 ; a6 g/ D 5), and
finally accepts a7 . The final optimal schedule is
ha2 ; a4 ; a1 ; a3 ; a7 ; a5 ; a6 i ;
which has a total penalty incurred of w5 C w6 D 50.
Exercises
16.5-1
Solve the instance of the scheduling problem given in Figure 16.7, but with each
penalty wi replaced by 80 wi .
16.5-2
Show how to use property 2 of Lemma 16.12 to determine in time O.jAj/ whether
or not a given set A of tasks is independent.
Problems