Documente Academic
Documente Profesional
Documente Cultură
Cover Page
Title Page
Preface
CLASSES OF PROBLEMS
Introduction
Computational Problems
The classes P and NP
An NP-complete Set
More NP-Complete Problems
Historical Notes and References
Problems
INTEGER PROGRAMMING
Introduction
Linear Programming
Transition to Integer Solutions
Cutting Planes
Upper Bounds for Integer Programs
Historical Notes and References
Problems
ENUMERATION TECHNIQUES
Introduction
Enumerating 0-1 Integer Programs
Intellegent Solution Space Enumeration
General Branch and Bound Algorithms
http://www.cs.uky.edu/~lewis/cs-heuristic/text/contents.html (1 of 3)12/2/2015 10:06:28 AM
DYNAMIC PROGRAMMING
Introduction
A Shortest Path Problem
Characteristics and Approaches
More Examples
Historical Notes and References
Problems
APPROXIMATE SOLUTIONS
Introduction
Bounds for Hueristics
Performance Analysis
Terminating Exact Solutions
Historical Notes and References
Problems
LOCAL OPTIMIZATION
Introduction
The Greedy Method
Divide and Conquer
Local Improvement
General Techniques for Local Search
Gradient Methods
Historical Notes and References
Problems
NATURAL MODELS
Introduction
Force Directed Optimization
http://www.cs.uky.edu/~lewis/cs-heuristic/text/contents.html (2 of 3)12/2/2015 10:06:28 AM
Simulated Annealing
Neural Networks
Genetic Algorithms
DNA Computing (Slides)
Historical Notes and References
Problems
Copyright by F. D. Lewis.
All rights reserved.
No part of this publication may be reproduced, stored in a retrieval system, or
transmitted, in any form or by any means, electronic, mechanical, photocopying,
recording, or otherwise, without prior written permission.
http://www.cs.uky.edu/~lewis/cs-heuristic/text/front/title.html12/2/2015 10:06:33 AM
Classes of Problems
Computational problems can be described in many ways. Almost every discipline has
their own special or favorite way on defining and grouping the problems that they
compute. In this section we shall characterize several classes of problems using
methods familiar to mathematicians and computer scientists. Then we shall
concentrate upon one very prevalent class of problems: those whose solutions can be
verified easily but seem to require vast amounts of time to solve optimally.
The sections are:
Computational Problems
The classes P and NP
An NP-complete Set
More NP-Complete Problems
Historical Notes and References
Problems
http://www.cs.uky.edu/~lewis/cs-heuristic/text/class/clasintr.html12/2/2015 10:06:38 AM
Computational Problems
Computational Problems
When asked to characterize computation and to describe all of the problems that are
solved through computation, a computer scientist will usually begin by describing a
programming language in which to do the computation. Most would present an
imperative language such as C++, but some might mention functional languages or
logic programming languages. All however, would probably then discuss computation
in terms of the resources required to perform the required task.
There is another way, namely mathematical programming. This is where a problem is
defined as the solution to a system of simultaneous equations. In fact, every one of
the problems which we compute using programs written in our favorite languages can
also be described in terms of mathematical programming. An example of such a
problem is finding values for the triple of variables: <x, y, z> which satisfy the
constraints specified in following two equations.
6x2 + y + 4z4 178
7x + 8y3 + z2 11
The triples <1, 1, 1> and <2, 2, 1> are among the many solutions to this particular
problem.
Instead of computational resources, the standard method used to classify
mathematical programming problems is by the largest exponent found in any of the
constraint equations. This provides a hierarchy which contains the classes of linear
programming problems, quadratic programming problems, third power problems,
and so forth. Our above example is a fourth power mathematical programming
problem. In graphics and geometric modeling problems with higher powers abound,
but in most areas of computer science and operations research one concentrates
primarily upon linear programming problems.
A practical example is the following truck packing problem. Suppose we have a truck
with a capacity of 2000 pounds and wish to load it with packages. We are allowed to
make up the load from a collection of three kinds of packages which weigh 540, 1270,
and 303 pounds each. To make things a little more difficult, we find that the
packages are worth $770, $1900, and $400 respectively and that our load must be
worth at least $2670. Setting x, y, and z as the numbers of each type of package that
we place on the truck, we now easily describe possible solutions to this problem with
http://www.cs.uky.edu/~lewis/cs-heuristic/text/class/comprob.html (1 of 5)12/2/2015 10:06:42 AM
Computational Problems
the equations:
540x + 1270y + 303z 2000
770x + 1900y + 400z 2670
The feasible solution space or collection of correct solutions to a mathematical
programming problem can be represented geometrically by a polytope in n-space
where n is the number of variables found in the constraint equations. Consider the
two linear equations:
3x + 5y 15
x - 2y 2
Pairs of values <x, y> that satisfy both equations must lie below the line defined by 3x
+ 5y = 15 and above that defined by x - 2y = 2. These two lines are shown in figure 1.
Computational Problems
Computational Problems
Note that not all of the linear integer programming problems are convex. The convex
integer linear programming problems are of great interest to computer scientists
since they are exactly the set of graph problems solvable in polynomial time.
We are interested in two styles of computational problems. The first group we shall
examine are decision problems. These are all of the problems with true or false as
solutions. Several examples are:
a. Is x a prime number?
b. Are there any solutions to the first mathematical programming
problem presented above?
c. Can the truck mentioned above be packed with a cargo worth at
least $2700?
We are often interested in finding not only finding solutions, but optimum solutions
to problems. To do this, a problem must be stated in such a way that an optimum
solution is requested. This is done by either maximizing or minimizing a relationship
between the variables called an objective function. Below is an example stated in the
general format for optimization problems.
maximize:
w = 3x - y + 4z
subject to the constraints:
x + 5y + z 75
17x - y - 3z 45
5x - y + z 38
where x, y, and z 0
In an optimization problem we must find a solution which provides either a minimum
or maximum value for the objective function. This is depicted geometrically by
selecting the point on the surface of the feasible solution polytope which provides an
optimum value for the objective function. With convex problems this appears
straightforward if we hop on the surface and go uphill until we reach the top.
With nonconvex problems things are not so simple. Consider the curve shown in
Figure 4. There are two places on the curve with values larger than the points
adjacent to them, one at point a and one at point b. The greatest of these (that at
point b) is called the global maximum while any other point at which there is a
maximum relative to immediately adjacent points is called a local maximum. The
solution space on the right in figure 2 also contains local and global maxima.
Computational Problems
P and NP
P and NP
the semester.
One might wonder if the above analysis was needed, because after all, who would
look at all of the schedules? You only need to check a few of the obvious ones. Or do
you? Think back over all of the examination schedules you have seen. Were there any,
which were optimal? No! So, there must be a small problem somewhere. We shall see
more on this problem later.
Let us think a little more about examination schedules. While it might be very difficult
to find a good one, it is easy to check a schedule to see how near perfect it is. This
process is called verification and allows us to know quickly if we stumble upon a
good schedule.
Consider another problem that of finding a minimal length tour of n cities where we
begin and end at the same place. (This is called the closed tour problem.) Again, there
are many solutions, in fact n factorial different tours are possible. And, once more, if
we have a tour, we can easily check to see how long it is. Thus if we want a tour of
less than some fixed length, we can quickly check candidates to see if they qualify.
This is interesting and provides some hope of solving problems of this kind. If we can
determine the worth of an answer, then maybe we can investigate promising solutions
and keep the best one.
Let us consider a class of problems, which all seem very complex, but have solutions,
which are easily checked. Here is a class, which contains the problems for which
solutions can be verified in polynomial time.
Definition. The class of nondeterministic polynomially acceptable
problems, NP, contains all sets in which membership can be verified in
polynomial time.
This may seem to be quite a bizarre collection of problems. But think for a moment.
The examination scheduling problem does fit here. If we were to find a solution, it
could be checked out very quickly. Lots of other problems fall into this category.
Another instance is closed tours of groups of cities. Many graph problems used in
CAD algorithms for computer chip design fit in here also. Also, most scheduling
problems. This is a very interesting collection of problems.
One might wonder about the time actually involved in solving membership in this
class. The only known relationship between NP and deterministic time is the
following result.
P and NP
P and NP
P and NP
In closing, here is a small list of some of the many problems that are members of NP,
and are in fact, NP-complete.
0-1 Integer Programming (0-1 INT). Given a matrix A and a vector b, is
there a vector x with values from {0, 1} such that Ax b?
CLIQUE. Given a graph and an integer k, are there k vertices in the
graph which are all adjacent to each other?
Vertex Cover (VC). Given a graph and an integer k, is there a collection
of k vertices such that each edge is connected to one of the vertices in
the collection?
Chromatic Number (COLOR). Given a graph and an integer k, is there a
way to color the vertices with k colors such that adjacent vertices are
colored differently?
Examination Scheduling (EXAM). Given a list of courses, a list of
conflicts between them, and an integer k; is there an exam schedule
consisting of k dates such that there are no conflicts between courses
which have examinations on the same date?
Closed Tour (TOUR). Given n cities and an integer k, is there a tour, of
length less than k, of the cities which begins and ends at the same city?
Rectilinear Steiner Spanning Tree (STEINER). Given n points in
Euclidean space and an integer k, is there a collection of vertical and
horizontal lines of total length less than k, which spans the points?
Knapsack. Given n items, each with a weight and a value, and two
integers k and m, is there a collection of items with total weight less
than k, which has a total value greater than m?
An NP-complete Set
An NP-complete Set
The definitions and discussion about P and NP were very interesting. But, of course for
any of this discussion to be worthwhile we need to see an NP-complete set. Or at least
prove that there is one. The following definitions from the propositional calculus lead to
our first NP-complete problem.
Definition. A clause is a finite collection of literals, which in turn are
Boolean variables or their complements.
Definition. A clause is satisfiable if and only if at least one literal in the
clause is true.
Suppose we examine the clauses below which are made up of literals from the set of
Boolean variables {v1, ..., vn}.
The first clause is satisfiable if either v1 or v3 are true or v2 is false. Now let us consider at
the entire collection of clauses. All three are true (at once) when all three variables are
true. Thus we shall say that a collection of clauses is satisfiable if and only if there is
some assignment of truth values to the variables which makes all of the clauses true
simultaneously. The collection:
is not satisfiable because at least one of the three clauses will be false no matter how the
truth values are assigned to the variables. Now for the first decision problem which is
NP-complete. It is central to theorem proving procedures and the propositional calculus.
The Satisfiability Problem (SAT). Given a set of clauses, is there an
assignment of truth values to the variables such that the collection of
clauses is satisfiable?
Since some collections are satisfiable and some are not, this is obviously a nontrivial
http://www.cs.uky.edu/~lewis/cs-heuristic/text/class/np-compl.html (1 of 7)12/2/2015 10:06:53 AM
An NP-complete Set
decision problem. And it just happens to be NP-complete! By the way, it is not the
general satisfiability problem for propositional calculus, but the conjunctive normal
form satisfiability problem. Here is the theorem and its proof.
Theorem 5. The satisfiability problem is NP-complete.
Proof Sketch. The first part of the proof is to show that the satisfiability
problem is in NP. This is simple. A machine which checks this merely jots
down a truth value for each Boolean variable in a nondeterministic manner,
plugs these into each clause, and then checks to see if one literal per clause
is true. A Turing machine can do this as quickly as it can read the clauses.
The hard part is showing that every set in NP is reducible to the
satisfiability problem. Let's start. First of all, if a set is in NP then there is
some one tape Turing machine Mi with alphabet = {0, 1, b} which recognizes
members (i.e., verifies membership) of the set within time p(n) for a
polynomial p(n). What we wish is to design a polynomial time computable
recursive function gi(x) such that:
Mi recognizes x if and only if gi(x) SAT.
For gi(x) to be a member of SAT, it must be some collection of clauses which
contain at least one true literal per clause under some assignment of truth
values. This means that gi must produce a logical expression which states
that Mi accepts x. Let us recall what we know about computations and
arithmetization. Now examine the following collections of assertions.
a) When Mi begins computation:
#x is on the tape,
the tape head is on square one, and
instruction I1 is about to be executed.
An NP-complete Set
An NP-complete Set
for each instruction pair i and j (where i < j) and each time t. These clauses
state that no pair of instructions can be executed at once and there are about
p(n) m2 literals in them.
An NP-complete Set
Clauses which mandate the tape head to be on one and only one square at
each step are very much the same. So are the clauses which state that exactly
one symbol is written upon each tape square at each step of the
computation. The number of literals in these clauses is on the order of p(n)2.
(So, we still have a polynomial number of literals in our clauses to date.)
Now we must describe the action of Mi when it changes from configuration to
configuration during computation. Consider the Turing machine instruction:
Note that the second line of instruction 27 contains a halt. In this case we
switch to instruction 0 and place the tape head on a bogus tape square
(square number 0). This would be something like:
(These clauses are not very intuitive, but they do mean exactly the same as
the if-then way of saying it. And besides, we've got it in clauses just like we
needed to. This was quite convenient.)
An NP-complete Set
In general, we need trios of clauses like the above for every line of each
instruction, at every time, for all of the tape squares. Again, O(p(n)2) literals
are involved in this.
To make sure that the rest of the symbols (those not changed by the
instruction) remain on the tape for the next step, we need to state things like:
These must be jotted down for each tape square and each symbol, for every
single time unit. Again, we have O(p(n)2) literals.
When Mi halts we pretend that it goes to instruction 0 and place the head on
square 0. Since the machine should stay in that configuration for the rest of
the computation, we need to state for all times t:
(this was another if-then statement) and note that there are O(p(n)) literals
here.
One more assertion and we are done. Before p(n) steps, Mi must halt if it is
going to accept. This is an easy one since the machine goes to instruction 0
only if it halts. This is merely the clause
(INSTR[0, p(n)]).
Of course this one must be true if the entire collection of clauses is to be
satisfiable.
That is the construction of gi(x). We need to show that it can be done in
polynomial time. Let us think about it. Given the machine and the time
bound p(n), it is easy (long and tedious, but easy) to read the description of
the Turing machine and generate the above clauses. In fact we could write
them down in a steady stream as we counted to p(n) in loops such as
An NP-complete Set
So, computing gi(x) takes about as much time to compute as it does to write
it down. Thus its complexity is O(|gi(x)|). The same as the length of all of the
literals in the clauses. Since there are O(p(n)2) of these and the length of a
literal will not exceed log2(p(n)) we arrive at polynomial time complexity for the
computation of gi(x).
The remainder of the proof is to show that
Mi accepts x if and only if gi(x) SAT.
While not completely trivial, it does follow from an examination of the
definitions of how Turing machines operate compared to the satisfiability of
the clauses in the above construction. The first part of the proof is to argue
that if Mi accepts x, then there is a sequence of configurations which Mi
progresses through. Setting the HEAD, CHAR, and INSTR variables so that
they describe these configurations makes the set of clauses computed by gi(x)
satisfiable. The remainder of the proof is to argue that if gi(x) can be satisfied
then there is an accepting computation for Mi(x).
That was our first NP -complete problem. It may not be quite everyone's favorite, but at
least we have shown that one does indeed exist. And now we are able to state a result
having to do with the question about whether P = NP in very explicit terms. In fact the
satisfiability problem has become central to that question. And by the second corollary,
this problem can aid in proving NP-completeness.
Corollary. SAT is in P if and only if P = NP.
Corollary. If A NP and SAT A then A is NP -complete.
p
So, all we need to do is determine the complexity of the satisfiability problem and we
have discovered whether P and NP are the same. Unfortunately this seems much easier
said than done!
NP. (That is, we can verify that a truth assignment satisfies all of the clauses as
fast as we can read the clauses.)
To show that it 3-SAT hard for NP, we will reduce SAT to it by transforming
any instance of the satisfiability problem to an instance of 3-SAT. This means
we must demonstrate how to convert clauses which do not contain exactly three
literals into ones which do. It is easy if a clause contains two literals. Let us take
(x1, x2) as an example. This is equivalent to the pair:
where u is a new variable. Note that each clause of the pair contains exactly
three literals and that.
So far, so good. Now we will transform clauses such as (x) which contain one
literal. This will require two steps. We begin by converting it to the pair of two
literal clauses:
much as before. Then we change each of these just as before and get:
This was easy. (But youd better plug in all possible truth values for the literals
and fully check it out.)
One case remains. We might have a clause such as (x1, ... , xk) which contains
more than three literals. We shall arrange these literals as a cascade of three
literal clauses. Consider the sequence of clauses:
Let us look at this. If the original clause were satisfiable then one of the xi's had
to be true. Let us set all of the ui's to true up to the point in the sequence where
xi was encountered and false thereafter. A little thought convinces us that this
works just fine since it provides a truth assignment which satisfies the
collection of clauses. So, if the original clause was satisfiable, this collection is
satisfiable too.
http://www.cs.uky.edu/~lewis/cs-heuristic/text/class/more-np.html (2 of 12)12/2/2015 10:06:59 AM
Now for the other part of the proof. Suppose the original clause is not
satisfiable. This means that all of the xi's are false. We claim that in this case the
collection of clauses we constructed is unsatisfiable also. Assume that there is
some way to satisfy the sequence of clauses. For it to be satisfiable, the last
clause must be satisfiable. For the last clause to be satified, uk-3 must be false
since xk-1 and xk are false. This in turn forces uk-4 to be false. Thus all of the ui's all
the way down the line have got to be false. And when we reach the first clause
we are in big trouble since u1 is false. So, if the xi's are all false there is nothing
we can do with the truth values for the ui's that satisfies all of the clauses.
Note that the above transformation is indeed a polynomial time mapping. Thus
SAT 3-SAT and we are done.
p
One of the reasons that showing that 3-SAT is NP-complete is not too difficult is that
it is a restricted version of the satisfiability problem. This allowed us to merely
modify a group of clauses when we did the reduction. In the future we shall use 3SAT in reductions and be very pleased with the fact that having only three literals per
clause makes our proofs less cumbersome.
Of course having only two literals per clause would be better yet. But attempting to
change clauses with three literals into equivalent two literal clauses is very difficult.
Try this. I'll bet you cannot do it. One reason is because 2-SAT is in P. In fact, if you
could reduce 3-SAT to 2-SAT by translating clauses with three literals into clauses
with two literals, you would have shown that P = NP.
Let us return to introducing more NP-complete problems. We immediately use 3-SAT
for the reduction to our next NP-complete problem which comes from the field of
mathematical programming and operations research. It is a variant of integer
programming.
0-1 Integer Programming (0-1 INT). Given a matrix A and a vector b, is there
a vector x with values from {0, 1} such that Ax b?
If we did not require the vector x to have integer values, then this is the linear
programming problem and is solvable in polynomial time. This one is more difficult.
Theorem 2. 0-1 INT is NP-complete.
Proof. As usual it is easy to show that 0-1 INT is in NP. Just guess the values in
http://www.cs.uky.edu/~lewis/cs-heuristic/text/class/more-np.html (3 of 12)12/2/2015 10:06:59 AM
x and multiply it out. (The exact degree of the polynomial in the time bound is
left as an exercise.)
A reduction from 3-SAT finishes the proof. In order to develop the mapping
from clauses to a matrix we must change a problem in logic into an exercise in
arithmetic. Examine the following chart. It is just a spreadsheet with values for
the variables x1, x2, and x3 and values for some expressions formed from them.
Expressions
Values
X1
X2
X3
+ X1 + X2 + X3
+ X1 + X2 - X3
-1
+ X1 - X2 - X3
-1
-1
-2
-1
- X 1 - X2 - X3
-1
-1
-2
-1
-2
-2
-3
Above is a table of values for arithmetic expressions. Now we shall interpret the
expressions in a logical framework. Let the plus signs mean true and the minus
signs mean false. Place or's between the variables. So, +x1 + x2 - x3 now means that
x1 is true, or x2 is true, or x3 is false.
If 1 denotes true and 0 means false, then we could read the expression as x1=1 or
x2=1 or x3=0.
Now note that in each row headed by an arithmetic expression there is a
minimum value and it occurs exactly once. Find exactly which column contains
this minimum value. The first expression row has a zero in the column where
http://www.cs.uky.edu/~lewis/cs-heuristic/text/class/more-np.html (4 of 12)12/2/2015 10:06:59 AM
each xi is also zero. Look at the expression. Recall that +x1 + x2 + x3 means that at
least one of the xi should have the value 1. So, the minimum value occurs when
the expression is not satisfied.
Look at the row headed by +x1 - x2 - x3 . This expression means that x1 should be a
1 or one of the others should be 0. In the column containing the minimum value
this is again not the case.
The points to remember now for each expression row are:
a) Each has exactly one column of minimum value.
b) This column corresponds to a nonsatisfying truth assignment.
c) Every other column satisfies the expression.
d) All other columnms have higher values.
Here is how we build a matrix from a set of clauses. First let the columns of the
matrix correspond to the variables from the clauses. The rows of the matrix
represent the clauses - one row for each one. For each clause, put a 1 under
each variable which is not complemented and a -1 under those that are. Fill in
the rest of the row with zeros. Or we could say:
The vector b is merely made up of the appropriate minimum values plus one
from the above chart. In other words:
bi = 1 - (the number of complemented variables in clause i).
The above chart provides the needed ammunition for the proof that our
construction is correct. The proper vector x is merely the truth assignment to
the variables which satisfies all of the clauses. If there is such a truth
assignment then each value in the vector Ax will indeed be greater than the
minimum value in the appropriate chart column.
If a 0-1 valued vector x does exist such that Ax b, then it from the chart we
can easily see that it is a truth assignment for the variables which satisfies each
and every clause. If not, then one of the values of the Ax vector will always be
less than the corresponding value in b. This means that the that at least one
http://www.cs.uky.edu/~lewis/cs-heuristic/text/class/more-np.html (5 of 12)12/2/2015 10:06:59 AM
Note that everything comes out fine if the proper values for the xi are put in place. If
x3 is 0 then the first entry of Ax cannot come out less than 0 nor can the second ever
be below -1. And if either x2 or x1 is 1 then the third entry will be at least 1.
Problems in graph theory are always interesting, and seem to pop up in lots of
application areas in computing. So let us move to graph theory for our next problem.
CLIQUE. Given a graph and an integer k, are there k vertices in the
graph which are all adjacent to each other?
This does not sound like a very practical problem, does it? Interesting, yes, but
practical? Consider this. Suppose that you had a graph whose nodes were wires on a
silicon chip. And there was an edge between any two nodes whose wires might
overlap if placed on the same horizontal coordinate of the chip. Finding the cliques
tells the designer how much horizontal room is needed to route all of the wires.
Theorem 3. CLIQUE is NP-complete.
Proof. Again, it is easy to verify that a graph has a clique of size k if we
guess the vertices forming the clique. We merely examine the edges. This
can be done in polynomial time.
We shall now reduce 3-SAT to CLIQUE. We are given a set of k clauses and
must build a graph which has a clique if and only if the clauses are
satisfiable. The literals from the clauses become the graphs vertices. And
collections of true literals shall make up the clique in the graph we build.
http://www.cs.uky.edu/~lewis/cs-heuristic/text/class/more-np.html (6 of 12)12/2/2015 10:06:59 AM
Then a truth assignment which makes at least one literal true per clause
will force a clique of size k to appear in the graph. And, if no truth
assignment satisfies all of the clauses, there will not be a clique of size k
in the graph.
To do this, let every literal in every clause be a vertex of the graph we are
building. We wish to be able to connect true literals, but not two from the
same clause. And two which are complements cannot both be true at
once. So, connect all of the literals which are not in the same clause and
are not complements of each other. We are building the graph G = (V, E)
where:
V = {<x, i> | x is in the i-th clause}
E = {(<x, i>,<y, j>) | x
and i j}
Now we shall claim that if there were k clauses and there is some truth
assignment to the variables which satisfies them, then there is a clique of
size k in our graph. If the clauses are satisfiable then one literal from each
clause is true. That is the clique. Why? Because a collection of literals (one
from each clause) which are all true cannot contain a literal and its
complement. And they are all connected by edges because we connected
literals not in the same clause (except for complements).
On the other hand, suppose that there is a clique of size k in the graph.
These k vertices must have come from different clauses since no two
literals from the same clause are connected. And, no literal and its
complement are in the clique, so setting the truth assignment to make the
literals in the clique true provides satisfaction.
A small inspection reveals that the above transformation can indeed be
carried out in polynomial time. (The degree will again be left as an
exercise.) Thus the CLIQUE problem has been shown to be NP-hard just
as we wished.
One of the neat things about graph problems is that asking a question about a graph
is often equivalent to asking quite a different one about the graph's complement.
Such is the case for the clique problem. Consider the next problem which inquires as
to how many vertices must be in any set which is connected to or covers all of the
edges.
Vertex Cover (VC). Given a graph and an integer k, is there a collection
http://www.cs.uky.edu/~lewis/cs-heuristic/text/class/more-np.html (7 of 12)12/2/2015 10:06:59 AM
Proof. To show that COLOR is in NP, again just guess the method of
coloring vertices and check it out.
We shall reduce 3-SAT to COLOR. Suppose that we have r clauses which
contain n 3 variables. We need to construct a graph which can be
colored with n+1 colors if and only if the clauses are satisfiable.
Begin by making all of the variables {v1, ... , vn} and their complements
vertices of the graph. Then connect each variable to its complement. They
must be colored differently, so color one of each pair false and the other
true.
Now we will force the true colors to be different from each other.
Introduce a new collection of vertices {x1, ... , xn} and connect them all
together. The n xi's now form a clique. Connect each xi to all of the vj and
their complements except when i = j. Thus if we have n different true
colors (call them t1, , tn) we may color the xi's with these. And, since
neither vj or its complement is connected to xi one of these may also be
colored with ti. So far we have colored:
a. each xi with ti,
b. either vi or its complement with ti, and the other false.
An example for three variables is depicted in figure 2. Since shades of
gray are difficult to see, we have used three for the true colors and have
drawn as squares all of the vertices to be colored with the false color.
Note that v1 and v2 are true while v3 is false.
Here's a recap. One of each variable and complement pair must be false
and the other, one of the true colors. These true's must be different
because the xi's form a clique. Then, the clauses (the ci's) are connected to
all of the literals not in the clause.
Suppose that there is a truth assignment to the variables which satisfies
http://www.cs.uky.edu/~lewis/cs-heuristic/text/class/more-np.html (10 of 12)12/2/2015 10:06:59 AM
all of the clauses. Color each true literal with the appropriate ti and color
its complement false. Examine one of the clauses (say, ci). One of its
literals must have been colored with one of the true colors since the
clause is satisfied. The vertex ci can be colored that way too since it is not
connected to that literal. That makes exactly n+1 colors for all the vertices
of the graph.
If there is no truth assignment which satisfies all of the clauses, then for
each of these assignments there must be a clause (again, say ci) which has
all its literals colored with the false or (n+1)-st color. (Because otherwise
we would have a satisfying truth assignment and one of each literal pair
must be colored false if n+1 colors are to suffice.) This means that ci is
connected to vertices of every true color since it is connected to all those
it does not contain. And since it is connected to all but three of the literal
vertices, it must be connected to a vertex colored false also since there
are at least three variables. Thus the graph cannot be colored with only n
+1 colors.
Since constructing the graph takes polynomial time, we have shown that 3SAT COLOR and thus COLOR is NP-complete.
p
Integer Programming
At the core of the problems we shall be considering, lies the class of integer
programming problems. From our earlier discussion of optimization and decision
problems, we know that these problems can either be convex and linear or NP complete. Thus they span the space from very simple computing tasks to extremely
complex optimization problems. Now we shall examine standard methods for solving
these problems in the framework of mathematical programming.
The sections are entitled:
Linear Programming
Transition to Integer Solutions
Cutting Planes
Upper Bounds for Integer Programs
Historical Notes and References
Problems
http://www.cs.uky.edu/~lewis/cs-heuristic/text/integer/intintro.html12/2/2015 10:07:07 AM
Linear Programming.
Linear Programming
The intersection of integer programming and linear programming seems the logical
place to begin our discussion of integer programming. We know that these are exactly
the convex problems which can stated in integer programming terms. Thus if we can
find a minimum (or maximum) solution we know that that is a global minimum (or
maximum). And, since these are included in the realm of linear programming, we are
guaranteed an optimal solution in polynomial time. These problems not only can be
solved in polynomial time, but comprise a major portion of the algorithms
encountered in computer science. Even though very few are solved in a linear
programming context ordinarily, all can be stated in linear programming terms.
For example, consider bipartite graph matching. An example of a bipartite graph (one
whose vertices can be partitioned into two nonconnected sets) appears in figure 1b.
The bipartite graph matching problem is to find a set of unconnected edges which
cover as many of the vertices as possible. If we select the set of edges:
{<a, b>, <c, f>, <e, d>}
then we have covered all of the vertices of the graph. This is a maximal matching for
the graph.
Now we shall state the problem in linear programming terms. For each edge <u, v> of
the graph we introduce the variable xuv. If the variable is set to 1 then the edge is part
of the matching, and if set to 0, the edge is not in the matching set.
First, we would like to cover as many vertices as possible. This means including as
many edges as we are able. We can accomplish this by maximizing the objective
function:
z = xab + xad + xcd + xcf + xed.
Next we must make sure that no connected edges occur in the matching. Since two
edges leave vertex a, we add the constraint:
Linear Programming.
xab + xad 1
in order to insure that only one of the two edges ends up in the matching. We add
similar constraints for vertices c and d. The complete linear program appears as
figure 1a.
(a)
(b)
(a)
(b)
(c)
Linear Programming.
Linear Programming.
A quick glance at the picture in figure 3 tells us that the best solution to the above
optimization problem occurs at vertex d, where x1 takes the value 5 and x2 is 3.
Now we are ready for two definitions which formally describe this particular class of
optimization problems.
Definition. A general linear programming problem may be stated as
follows: Given real numbers b1 , b2 , ... , bm , c1 , c2 , ... , cn and aij (for i =
1, ... , m and j = 1, ... , n), minimize (or maximize) the objective function:
z(x1 , x2 , ... , xn) = c1 x1 + c2 x2 + ... + cnxn
subject to the conditions
Linear Programming.
x2
y1
y2
y3
bj
-z
-1
y1
19
y2
Linear Programming.
-1
12
y3
to the equations above. The columns are assigned to the original, slack, and surplus
variables. The first row holds the objective function and for each equation, there is a
row holding its coefficients (the aij and the bj's).
Now for some linear algebra. If we can find m independent columns, (one for each
constraint or row) then we have a basic solution to our problem. This basic solution
comes from expressing the vector b as a linear combination of these columns (which
we call a basis). At the moment our problem can be expressed:
Ax + Iy = b
(where I is an m by m identity matrix) and a basic feasible solution for our problem
can be found by setting the xi = 0 and yj = bj. This is:
x1
x2
y1
y2
y3
19
12
Consult the picture in figure 3 and note that <0, 0> was indeed a feasible solution of
the original problem. Now look again at the tableau above and note that the basis
variables are indicated on the right.
At this point we would like to move along toward the optimum solution for our
problem. Making column one into a unit vector (one 1 and the rest 0's) would mean
that we could express b as a linear combination of x1 and two of the yj. This is a step
forward.
Look in column one. We would like to set the column one entry of one of the rows to
1 and then pivot on it. (By pivoting we mean add or subtract that row from the rest to
get 0's in the first column.) We cannot do that in the first row without making the
value of b1 negative (which is not allowed in our definition of standard problem).
Using row two would set b2 to 19/2. This is legal but not the value of x1 in any feasible
solution. So, we are forced to use row three as our pivot.
Linear Programming.
x2
y1
y2
y3
bj
4/3
-1/3
-4
-z
2/3
1/3
y1
11/3
-2/3
11
y2
-1/3
1/3
x1
By doing this, we have added x1 to the basis and removed y3 from it. The feasible
solution is now:
x1
x2
y1
y2
y3
11
which corresponds to the lower right corner of the polygon in figure 3. In the same
manner, we select column two to pivot on next (so that x2 joins the basis). There is a
choice between rows one and two. We select row two and produce the tableau:
x1
x2
y1
y2
y3
bj
-4/11
-1/11
-8
-z
-2/11
5/11
y1
3/11
-2/11
x2
1/11
3/11
x1
Linear Programming.
x1
x2
y1
y2
y3
Here we halt with the optimum (maximum) feasible solution <5, 3> to our original
linear programming problem.
(A note in passing on a topic which we shall return to later. As we pivoted and
modified our tableaux until we found an optimal solution, we were traversing the
vertices of the polygon in figure 3. In fact, we began at vertex a and went through
vertex e so that we could end at vertex d. This geometric interpretation of this
method of solving linear programming problems will be examined in a little more
detail at the end of this section.)
Several topics need some explanation. The first one concerns just exactly how we
choose pivots. The top row of the tableau helps with this since it indicates how much
the objective function would change if we added that column to the basis. For
example, in the first tableau of the above example we note that if either x1 or x2 is
added to the basis, then the objective function would increase by the new value of x1
or x2. We added x1 = 4 to the basis and the objective function went from 0 to 4. (Note
that there is a -4 at the top right.) In the second tableau, the top row informs us that
placing x2 in the tableau will increase the objective function by 4/3 of x2s new value.
This happened, as it went from 4 to 8 as we went from <4, 0> to a solution of <5, 3>.
Thus selecting a pivot which will increase the value of the objective function is
preferable. The way to do this, however, is controversial. A method named steepest
descent calls for pivoting on the column with the largest positive entry in the top row.
Another method (this one called greatest increment) tells us to pivot on the column
which will increase the objective function by the greatest amount. The first is of
course the easier in terms of computational time, but the second might just get us
our optimal answer sooner. Both methods have devotees.
Now that we have selected a column, what row do we pick? It is easy to find out what
row not to pick. First of all, do not select a row that has a nonpositive entry at the
selected column. Since all bj must remain positive, pivoting on a negative entry would
ruin this. (If none of the entries in the column are positive, then there is a problem
since the top row entry tells us that the solution can be improved and the other
entries claim that it cannot. This inconsistency means that the solution is unbounded
and thus no optimum exists. Next, do not select a row which will lead to a unfeasible
solution. An example here is column 1 row 2 of the first tableau in our last example.
http://www.cs.uky.edu/~lewis/cs-heuristic/text/integer/linprog.html (8 of 14)12/2/2015 10:07:12 AM
Linear Programming.
Pivoting on it will set x2 to 19/2 which is not feasible. Another problem occurs when
pivoting on some row will make one of the bj entries negative. (And would happen to
b3 if we pivoted on row 2 column 1 in the first tableau.) This is forbidden also in our
standard form problem
There is one other subtlety in pivoting. It is possible to cycle if one is unlucky. There
are methods for keeping this from taking place, but we shall not investigate them
here.
Our last problem concerns the place we start when solving the equations. If we are
fortunate and have with a problem in the standard form: Ax + Iy = b then we merely
set each x FACE="Arial" SIZE=5>i = 0 and yj = bj and take that as our first basic feasible solution.
Otherwise we have to do some extra work. We must find a basic feasible solution
before we can begin to solve our optimization problem.
Consider our very first example, that of figure 2. After putting it in standard form
with slack and surplus variables we have:
maximize z(x1 , x2) = 2x1 + x2
subject to the constraints:
2x1 + x2 - y1 = 6
2x1 - x2 - y2 = 2
x1 + 3x2 + y3 = 15
x1 - x2 + y4 = 3
where all xi, yj 0.
This looks good. But, what do we use as our first basic feasible solution? Looking
merely at the equations, there are values for the yj which satisfy them. In fact,
something like:
x1
x2
y1
y2
y3
y4
-6
-2
15
ought to be a solution to the problem. But, this of course is not a basic feasible
solution because the yj are negative and this is not allowed in a standard linear
programming problem.
Linear Programming.
x2
y1
y2
y3
y4
s1
s2
15
Minimizing s1 + s2 means bringing them down to zero. If we are lucky and can get
both of the sj to be zero and toss them out of the equations. This will be a basic
feasible solution to our related standard problem.
Since minimization is just reversing signs and maximizing, we begin with a tableau
like that below with -1's on the top row over the sj for our new objective function.
x1
x2
y1
y2
y3
y4
s1
s2
bj
-1
-1
-z
-1
s1
Linear Programming.
-1
-1
s2
15
y3
-1
y4
The tableau is not in proper form though. We want to have zeros, not negative
numbers in the top row over the basis columns. To do this we merely add the first
two rows (those in which s1 and s2 appear) to the top row. This sets -z = 8 as our
beginning point and we now have :
x1
x2
y1
y2
y3
y4
s1
s2
bj
-1
-1
-z
-1
s1
-1
-1
s2
15
y3
-1
y4
We wish to get rid of the sis so the first step is to pivot on first column (which looks
very promising since there is a 4 in the top row), and second row to add x1 to the
basis and get:
x1
x2
y1
y2
y3
y4
s1
s2
bj
-1
-2
-z
-1
-1
s1
-1/2
-1/2
1/2
x1
Linear Programming.
7/2
1/2
-1/2
14
y3
-1/2
1/2
-1/2
y4
The second column now looks very attractive and so we select it for our next pivot.
After pivoting on the second column, first row we have:
x1
x2
y1
y2
y3
y4
s1
s2
bj
-1
-1
-z
-1/2
1/2
1/2
-1/2
x2
1/4
-1/4
1/4
1/4
x1
7/4
-5/4
-7/4
5/4
y3
1/4
1/4
-1/4
-1/4
y4
At last the sj are zero and we know that we have a basic feasible solution to our
related standard problem. It is
x1
x2
y1
y2
y3
y4
and the xi pair <2, 2> is indeed a feasible solution to the original.
Thus linear programming itself provides the method which is used to discover the
basic feasible solution needed in order to start solving the related standard problem.
It also informs us as to whether or not there are feasible solutions. The algorithm we
went through above is named the simplex method and is the standard method for
solving linear programming problems.
With the simplex method in hand we can either solve linear programming problems,
or detect situations where optimal solutions cannot be found. The procedure is
http://www.cs.uky.edu/~lewis/cs-heuristic/text/integer/linprog.html (12 of 14)12/2/2015 10:07:12 AM
Linear Programming.
outlined in figure 4.
place the problem in standard form
if there is no basis then [PHASE I]
add an artificial basis of sj variables
solve problem to minimize sum sj
if unsuccessful then no solution exists
otherwise discard the sj variables and restore original objective function
solve problem [PHASE II]
if unable to pivot then problem is unbounded
Linear Programming.
a convex polytope.
Adding a dimension to the polygon featured in figure 3 shall provide us with a three
dimensional polytope. Figure 5 contains it and the halfspaces whose intersection
form it.
The first constraint of figure 1b calls for two edges in the tree and the others require
the variables to take values between zero and one. (In other words, no more than two
edges may be in the tree and each edge can be in it at most once.)
The shaded region of Figure 1c is the polytope formed by the intersection of all of the
constraints. The constraints that limit the variables to values between zero and one
define a unit cube and the first constraint slices the cube on a diagonal. This shaded
triangular plane contains all of the feasible solutions to the problem. Note that some
of the solutions call for portions of the edges to be in the spanning tree. (For
example, two-thirds of each edge is a feasible solution!) And especially note that the
vertices of this region are the three integer solutions to our problem. This means that
when we minimize the sum of the variables times the weight of their edges, we will
indeed get the proper solution since the vertices of the polytope defined by the
constraints are basic feasible solutions.
After placing the constraints in standard form we find that the complete linear
programming problem statement for the minimum spanning tree of the small graph
in figure 1a is:
minimize z = 2xab + 7xac + 3 xbc
subject to the constraints:
xab + xac + xbc = 2
xab + y1 = 1
xac + y2 = 1
xbc + y3 = 1
where xab, xac, xbc 0
Since there is no feasible solution at the origin, we of course would have to apply the
two-phase process to extract a solution. (We must also note that Gaussian elimination
is far more time consuming than any of the standard methods for building a
minimum spanning tree.)
Going on to larger problems, we must do a bit more than require that two of three
edges be in the spanning tree. Figure 2 contains a slightly larger graph whose
minimum spanning tree is:
{<a, c>, <a, e>, <b, c>, <b, d>, <c, f>}
Let us develop the constraints for this problem. As before, we assign a variable to
each edge of the graph, and, if the variable xuv is 1 then the edge from node u to node
v is in the tree. To find the minimum spanning tree we again minimize the sum of the
variable-weight products. And, once more, we require the variables to have values
between zero and one.
[vertex a]
[vertex b]
[vertex c]
[vertex d]
[vertex e]
[vertex f]
Keeping cycles from appearing is done by taking all subgraphs in which it is possible
to have a cycle and bounding the edges, which may be included in the spanning tree.
For example, the subgraph containing the nodes {a, b, c} might have a cycle of length
three, so we write:
xab + xac + xbc 2
and for the subgraph containing {a, b, c, d} we include:
xab + xac + xbc + xbd + xcd 3
Completing the collection of anti-cycle conditions such as those above completes the
description of the minimum spanning tree.
As before, we get an integer valued answer when we apply the simplex method. This
is again because the vertices of the polytope defined by the constraints have values of
zero and one for all variables.
There is one problem though. There are about 26 constraints needed for cycle
prevention in the last graph and it was not a very large graph. And, since it was
planar, it did not have many edges. To find the minimum spanning tree for an
arbitrary graph we might need a great many constraints. In fact, it is possible in some
problems to have an exponential number of constraints. This is why we do not solve
these problems with linear programming methods.
A much easier problem to define in linear programming terms is the NP-complete
knapsack problem. Recall that in this problem we have n objects, and the i-th one
weighs wi and has a value of vi. We wish to pack a knapsack of capacity K with a
valuable collection of objects. Our variable set shall be {x1, x2, , xn}, and we set the
variable xi to 1 when the i-th object is in the knapsack. Maximizing the value held in
the knapsack is done by the following objective function.
We also require that all variables are greater than zero (xi 0) and bound the knapsack
weight with the constraint:
This seems to work quite well and is easy to express. And, in fact, we may easily look
at a small example example. Let us consider a problem with only two objects so that
we can draw the polytope of feasible solutions. Let one object weigh 5 pounds and
the other weigh 8 pounds. Also, let them have values of 1 and 2. If we wish to pack a
knapsack of capacity 23, the problem can be very simply stated in linear
programming terms as indicated in figure 3.
for every proper subset of cities S. This does take care of the regional tour problem,
http://www.cs.uky.edu/~lewis/cs-heuristic/text/integer/transit.html (6 of 12)12/2/2015 10:07:21 AM
Setting all of the xi 1 completes the development of the linear program. In order to
solve the problem we execute phase one of the linear programming algorithm, and
immediately find a feasible solution. In the case above, we get a solution that contains
values of zero and one for all of the variables. This is exactly as we wished! But, we
are not always so fortunate. In Figure 6 is a very simple satisfiability problem with the
first basic feasible solution at <0.5, 0.5, 0.5>.
But sometimes one is fortunate, and often a linear programming solution to an
integer programming problem leads to a reasonable approximation to the original
problem. For this reason we shall explore techniques for defining problems in terms
of propositional calculus.
where each merely states that either u or v must not be color k. Each of these
translates into the constraint:
xuk + xvk 1
for each edge <u, v> and color k. To make sure that each vertex is colored, we add the
clause:
(xu1 , ... , xun)
which states that u is indeed one of the colors. This is translated into the constraint:
which if we are not careful will allow vertex u to be colored with several colors. We
shall fix this later though.
Let's pause a moment. The constraints which state that adjacent nodes should not be
the same color can be pooled if there are cliques in the graph. Finding cliques is not
often cost effective, except for small ones (size 3 or 4). In the graph of figure 2 we
pool cliques and get the following constraints for each color k:
xak + xbk + xck 1
xak + xck + xek 1
xck + xck + xfk 1
xck + xdk + xfk 1
xbk + xck + xdk 1
Note that each equation merely states that color k is used for at most one of the
vertices in the clique.
The optimization portion of this problem requires some care since we wish to use the
minimum number of colors. If we weight each color, then we can favor the first colors
enough so that new colors are never introduced unless needed. We can think of this
in terms of cost. For example charge $1 for each vertex that is color one, $n for each
color two vertex, $n2 for each that is color three, and so forth. Thus minimum cost
means that we should use lower numbered colors on the vertices of the graph. The
objective function is the following.
Our basic feasible solutions come from a set of m unit vectors which appear as
columns during execution of the simplex algorithm. If we denote the original m
linearly independent columns which make up this basis as the matrix B then we may
state that Bx = b. And, solving for the values of x we get:
adj
in terms of the adjoint of B (B ) and B's determinant. This ties in with the next two
definitions.
Definition. A square, integer matrix is unimodular if its determinant has
the value 1.
Definition. An integer matrix is totally unimodular if all of its square,
nonsingular submatrices are unimodular.
Now at last things fall into place a little. Linear programming problems that can be
stated in totally unimodular form will indeed have integer feasible solutions since the
denominator of the above formula will be one. It conveniently turns out that path
problems, flow problems, and matching problems in networks and graphs have this
property. Therefor, they can be solved with linear programming, but NP-complete
problems cannot. We need some different methods for these.
figure 1a. Cutting the polygon on this line will not destroy any feasible integer
solutions to the problem. In figure 1b we have done this and have a new polygon.
The line we used to shave off part of the polygon is called a cut or a cutting plane
since it pares off some of the noninteger area we do not care about. And, to do the
carving, all we need do is to introduce this cut as an additional constraint. Note that
no feasible integer solutions were omitted by including this new constraining line in
out linear programming problem.
The dot in figure 1b again represents the optimum solution we get from solving the
relaxation. In figure 1c we have added yet another constraint and finally arrive at an
optimum integer solution.
This seems like a good idea. All we need do is solve the relaxation of the integer
programming problem and generate additional constraints until we get an integer
solution. During this process we would like to guarantee that as we add constraints:
a) No feasible integer solutions are excluded.
b) Each constraint reduces the feasible solution region.
c) Each constraint passes through an integer point.
d) An optimum solution is eventually found.
Let's go straight to an example. In figure 2a we have the linear programming problem
specified by
maximize z = x + x
1
5x + 2x 15
1
where all x 0.
i
5/2
and the final tableau after solving for this solution is:
x
-1/10
-3/10
-9/2
-z
1/6
1/6
5/2
-1/15
-1/15
2
1
In the second row of the tableau there is a noninteger value for the variable x . In this
2
Let us leave the fractional portions of our variables on the left hand side of the
equation and move x to the right. If we separate the right side into integer and
2
Let us examine this equation. Suppose that all of the variables were set to their
optimum integer solutions. Since we do not allow negative solutions, the left hand
side of the equation must be greater than zero. This means that the right hand side of
the equation cannot be negative either. Thus:
This in turn forces the quantity (x - 2) to be no more than 1/2. Since the value of x
2
must be a nonnegative integer, x can only be zero, one or two. This means that the
2
left side of the equation above will always have a value of more than 1/2. Putting this
all together we assert that if x is to have an integer value then the following holds.
2
This is a necessary (but not sufficient) condition for optimum integer values for the
variables. Adding this condition to our collection of constraints (along with its
surplus variable y ) at this point in the solution has the same effect as beginning with
3
the additional constraint x 2. This cuts off the area above 2 for x and gives us the
2
polygon in figure 2b and the following tableau for our linear programming problem.
x
-1/10
-3/10
-9/2
-z
1/6
1/6
5/2
-1/15
-1/15
1/6
1/6
-1
1/2
2
1
We are now one column shy of a basis and must remedy that immediately.
Examination of the tableau reveals that y cannot enter the basis, but both y and y
3
might if so desired. We may select either. We choose to pivot on the bottom row and
place y into the basis. This results in the tableau:
1
-1/5
-4/5
21/5
-z
1/5
-2/5
11/5
-6
2
1
Again we have an optimum feasible solution. This one is indicated by the dot on the
picture in figure 2b and corresponds to:
x
11/5
As before, we select the row that provided a noninteger solution, this time involving
x . This gives us the equation:
1
We wish to do as before and end up with positive fractions on the left hand side so
that it will be greater than zero. To do this, we just add y to both sides. Then we
3
by moving the integer portions of x and y to the right. Now we group the integer
1
by moving x and y to the right and group the integer portions of that side. Again we
1
see that the left side must be positive. Thus the right side must be positive and by
employing similar arguments to those used above, we may assert that the following
holds.
Adding this new cutting plane restricts our solution to values of x below two. So, we
1
add the new cutting plane to the collection of constraints and pivot. Again we need
one more variable in the basis and this time we chose y . This leads to the final
2
tableau:
x
-3/5
-1
-4
-z
-1
2
1
-9
-5
1
2
with the optimum integer solution given below and shown in figure 2c.
x
where b is not an integer. We then split b and all of the a into integer and nonnegative
I
fractional parts. (The integer portion of b is written b and its fractional part is b .) Now
the equation is rearranged so that it looks like this:
We now consider the case where all of the variables are set to their optimum integer
values (which must of course be nonnegative), and deduce several things from the
above equation. If the fractional portions of all the a are nonnegative, then we know
i
that both sides of the equation are no less than zero. Thus
since it has an integer value and is not less than -b . This in turn makes
If we add the above fractional equation to the collection of constraints in the tableau,
it is the same as if we began with the previous integer equation as an initial condition.
This is the essence of the cutting plane method of solving integer linear programming
problems. It makes linear programming problems larger and larger as new
constraints are added.
We merely iterate this process and hope for integer solutions to appear quickly. But,
there are several problems. First, the tableaux can become very large indeed. Often
though this is avoided by dropping slack variables introduced with cutting planes
whenever they enter the basis.
A second problem enters because we are using computers to solve our linear
programming equations and computers have finite precision. Thus, noninteger
solutions (such as 5.99999999) might be difficult to detect. Employing algorithms in
which coefficients remain integers does solve this. For example, save the numerator
and denominator of fractions. But, this adds to the execution time.
and due to the above observation, we know that no integer solution can produce a
http://www.cs.uky.edu/~lewis/cs-heuristic/text/integer/bounds.html (1 of 4)12/2/2015 10:07:31 AM
restricted to values no less than 7 and one where x is restricted to values no greater
1
original collection. These subproblems are pictured as the shaded areas of figure 1b.
Note particularly that no feasible integer solutions have been omitted as they are all in
one of the two shaded areas. Only the vertical strip of noninteger space between 6 and
7 has been removed. Relaxing these two new problems and solving for optima provides
us with the solutions for our new problems that appear below.
<6, 6.5> and <7, 6.5>
as solutions to the two subproblems. This is closer to the kind of solution we wish, but
it still is not an integer solution.
Subdividing these two problems results in three new problems that are shown as the
shaded areas of Figure 1c. This time we removed horizontal strips from the solution
space.
Continuing on, we divide the remaining problems as indicated by the tree in Figure 2. It
shows all of the subproblems and the optimum solutions for each.
One more subdivision took place after that shown in Figure 1c. The shaded region to
the right was split into two subproblems. By restricting x to be no greater than 7, we
1
get as a feasible solution space, a line with an x value of 7 and x ranging from 2 to 6.
1
By restricting x to be no less than 8 we end up with an area containing the single point
1
<8, 4.75>.
At this stage in the process three integer solutions have been found and one mixed
solution still remains. The integer solutions all set the objective function to 13 and this
is better than the remaining mixed solution <8, 4.75>. Thus any of the three is the
optimum and we need not pursue the path in the search tree below the mixed solution.
In figure 3 the algorithm for this method is provided.
original problem can be removed if the new bounding constraint supercedes them. For
example, in figure 1a we solved a problem with four constraints, while in figure 1b
there were two problems, each with three constraints. And since we are always
splitting the problem at a vertex of its feasible solution space, at least one constraint
can disappear from the new problem at each stage.
BRANCH
Solving integer programming problems by dividing them into subproblems and using
linear programming methods until integer solutions are found points to a general
method for the exact solution of optimization problems. This method primarily
involves setting up a tree structure in which to consider the entire feasible solution
space for a problem in an organized manner.
First we shall merely enumerate the solution space and then refine our methods. In
an attempt to save computation time and effort we also attempt to cut off our
endeavors when we know that they will not succeed by computing upper and lower
bounds on the possible solutions. This leads to a general method for solving
optimization problems named branch and bound.
The sections are entitled:
Enumerating 0-1 Integer Programs
Intelligent Solution Space Enumeration
General Branch and Bound Algorithms
Historical Notes and References
Problems
http://www.cs.uky.edu/~lewis/cs-heuristic/text/enumerat/enumintr.html12/2/2015 10:07:32 AM
This is often not too difficult to implement. All we do is state the problem in the
language of predicate calculus and then either attempt to satisfy the clauses we
developed or map it into 0-1 integer programming and then solve that problem.
This suggests an intriguing method of finding solutions to problems. All we need do is
to compute the objective function for all combinations of zero and one for all variables
and record the best feasible solution. Since each variable is restricted to values of zero or
one (or, in the case of predicate calculus clauses, true and false), the number of solutions
seems not as large as when we allow arbitrary integer values. This however is misleading
since in mapping arbitrary integer programming problems into 0-1 integer programming
problems there can be a significant variable explosion.
Let us examine this. If we think of 1 as true and 0 as false, then enumerating all
candidates for a feasible integer programming solution is exactly the same as
enumerating all subsets of the set of variables. In this manner we interpret a subset of
the variables such as {x2, x4} as representing the solution where x2 = x4 = 1 and all other
variables have values of zero. Thus any enumeration of subsets of a set of variables
provides all possible candidates for feasible solutions. We even know exactly how many
cases make up the enumeration. It is the same as the size of a truth table for an n
variable formula, namely 2n.
A simple example of an enumeration of the subsets of four variables is pictured as a
graph in figure 1. The subsets are ordered by set inclusion with the empty set at the top
and the set of all variables: {x1 , x2 , x3 , x4} at the bottom.
0000,
1000, 0100, 0010, 0001,
1100, 1010, 1001, 0110, 0101, 0011,
1110, 1101, 1011, 0111,
1111
A quick inspection reveals that this is just examining combinations of no variables, one
variable, two variables, three variables, and four variables. Further examination shows us
the way to do this recursively. All combinations of k variables can be found by setting xi to
one for i from one to n-k+1, fixing x1, ... , xi , and looking at all combinations of k-1 variables from
the sequence xi+1 , ... , xn
The algorithm of figure 4 works provides this sequence when called from a loop which
sets k to zero through n.
a) a feasible solution, or
b) a better objective function value,
then we should not continue on down that portion of the search tree any further.
Another decision which might reduce enumeration time is to carefully select which
branch of the graph (in figure 1) to pursue so that we go directly to the subtree that has
the greatest chance of containing an optimum solution.
Let us examine this with a very simple problem. Consider the problem shown in figure 5.
This is one which was mapped from satisfiability to 0-1 integer programming.
minimize z = 2x1 + 4x2 + x3
subject to the conditions:
(x1 , x2)
x1 + x2 1
(x2 , x3 , x4)
x2 + x3 + x4 1
(x1 , x4)
x1 + x4 1
where all xi {0,1}
x2 = 1
x3 = 1
x4 = 1
Equations Satisfied:
Objective Function:
Action:
Obviously setting x1, x2, or x4 to 1 will improve the values of the constraints the most.
Setting x2 to 1 however, improves the objective function the most. Based upon this, let us
rearrange our depth-first search tree as indicated in figure 6.
x3 = 1
x4 = 1
Equations Satisfied:
Objective Function:
Action:
Again, we have a tie when we consider satisfying the constraints. Setting x1, or x4 to one
both provide feasible solutions. Taking x1 and x2 as one provides us with a feasible
solution with the best objective function value, namely six. We now rearrange the search
tree once more to reflect the priority of setting variables to one and get the tree of figure
7.
x3 = 1
x4 = 1
Equations Satisfied:
Objective Function:
Setting x1, x2, and x3 as one gives us the most improvement in the objective function, so
we shall do that. Continuing in this manner for the entire enumeration provides the
search tree depicted in figure 8.
It should be noted that ordering the variables requires some computation time. Before
implementing a clever search algorithm, one should consider this and compare the
added computation to that of much simpler search techniques.
Figure 1 - A Graph
It is rather obvious that it can be colored with three colors if nodes b and c are the
same color. Let us examine all possible combinations of three colors that can be
applied to the nodes of the graph. Since each node can be any of the three colors,
there are exactly 34 = 81 colorings, but we can easily reduce this to 33 = 27 if we specify
that node a is to be a particular color. Let us set our colors as blue, yellow, and white.
We shall color node a blue. In figure 2 all of the coloring combinations are specified
for three colors and the remaining graph vertices.
A cursory examination reveals that only a few of these are feasible solutions. Those in
the tree on the left (with node b set to blue) are not feasible since node a was set to
that color, node b is adjacent to it, and both cannot be the same color.
a node must not be the same color as any adjacent node that is already
colored, and
a node need only be colored with one of the colors already assigned or the
next color not assigned yet.
Looking back at the original search tree, we now know we need not examine
combinations where node b is blue. This also cuts down the size of the feasible
solution space that we must examine.
Several things should be noted at this point. We could have solved the optimization
problem for the chromatic number problem in graphs by making sure that all
portions of the search tree that contained one and two color solutions were
considered. In addition, we made our decisions of what must be examined based
upon partial solutions. This is often the case and we need not enumerate all of the
full solutions in order to rule out many cases of optimization problems.
This is an example of a very famous algorithmic technique named branch and bound.
Branching takes place since the solution space is modeled as a tree and a search of
the tree is performed. Bounding takes place when a subtree is eliminated because it is
infeasible or none of the solutions in the subtree are better than the best found so
far.
Here, in figure 4, is the branch and bound algorithm for the chromatic number
problem that we have just developed.
If the lower bound is greater than the knapsack capacity, then no feasible
solution exists in the subtree.
If the upper bound is less than the best solution found thus far, then an
optimum solution is not in the subtree.
By traversing the solution space tree, we are BRANCHING to new solutions and we
http://www.cs.uky.edu/~lewis/cs-heuristic/text/enumerat/intsrch.html (6 of 12)12/2/2015 10:07:44 AM
compute a BOUND at each node that helps limit our search. For this reason, these
algorithms have been called branch and bound algorithms.
Let us develop a branch and bound algorithm for the knapsack problem. Let the set W
= {w1, ... , wn} be the weights of objects to be placed in the knapsack and let the set of
variables X = {x1, ... , xn} indicate which objects are to be placed in the knapsack. (That
is, if xi = 1, then the i-th object is in the knapsack.) This algorithm is described in
figure 7.
brings us to <1,0,1,0> and 46 becomes our new best effort. After another overflow at
the leaf <1,0,1,1>, we backtrack and find that the upper bound for <1,0,0,1> will not
be better than 46, so we immediately backtrack all the way to the root. Next we set x1
= 0 and try the subtree rooted at <0,1,0,0>. This brings us a best load of 48.
Insufficient upper bounds prevent examining any more nodes of the subtree.
If we omit the subtrees that the Pack procedure does not visit from our previous
search trees, we find that the algorithm traverses the search tree shown in figure 8.
As before, the nodes where the capacity was exceeded are darker and the subtree
upper bounds (the sum + uk values from the algorithm) have been placed to the left of
each node which is not a leaf.
bc
cd
bd
ac
ab
ad
Length:
10
We initially examine the smallest edge (bc), and place its most central vertex (c) in the
tree. At this point we do a depth-first search on the edges from c: bc, cd, and ac. Note
that we have ordered them by length with the smallest first. The resulting search tree
appears as figure 10.
Problem instances. For the knapsack problem this would consist of two lists,
one for the weights of the items and one for their values. Also we need an
integer for the knapsack capacity. For chromatic numbers (or graph coloring),
Solution tree. This must be an ordered edition of the solution search space,
possibly containing partial and infeasible solution candidates as well as all
feasible solutions as vertices. For knapsack we built a depth-first search tree for
the associated integer programming problem with the objects ordered by
weight. In the chromatic number solution tree we presented partial graph
colorings with the first k nodes colored at level k. These were ordered so that if
a node had a particular color at a vertex, then it remained the same color in the
subtree.
Solution candidates. For knapsack, a list of the items placed in the knapsack will
suffice. Chromatic numbering involves a list of the colors for each vertex in the
graph. But, it is a little more complex since we use partial solutions in our
search, so we must indicate vertices yet to be colored in the list.
An essential rule to be followed in defining solution spaces for branch and bound
algorithms is the following.
If a solution tree vertex is not part of a feasible solution, then the
subtree for which it is the root cannot contain any feasible solutions.
This rule guarantees that if we cut off search at a vertex due to unfeasibility, then we
have not ignored any optimum solutions.
Now, we present the definitions for bounds used in the above algorithm.
Lower bound at a vertex. The smallest value of the objective function for
any node of the subtree rooted at the vertex.
Upper bound at a vertex. The largest value of the objective function for
any node of the subtree rooted at the vertex.
For chromatic number we used the number of colors for the lower bound of a partial
or complete solution. The lower bound for knapsack vertices was the current load,
while the upper bound was the possible weight of the knapsack in the subtree.
Next we must have the following methods (or algorithms) which operate upon and
help us to analyze the objects.
Feasible solution checker. For knapsack, we merely insure that the sum of the
weights of the items in the knapsack is no more than its capacity. Chromatic
numbering involves checking to see if any two adjacent vertices are the same
color.
Objective function. For knapsack, sum the values of the items in the knapsack.
For chromatic numbers, count the colors.
Lower bound function. For knapsack and chromatic number, this is just the
objective function.
Upper bound function. For knapsack this was the lower bound plus the sum of
the weights that could be added. Chromatic numbers did not have a useful
upper bound function since a minimum was optimal.
At this point complexity should be mentioned. Computing these for the knapsack
problem is easy because they all involve summing the weights. A good strategy is to
record the knapsack loads as each vertex in the search tree is visited so that the
objective and upper bound functions require one addition and the feasibility check
utilizes one comparison.
Chromatic numbering involves more work when solution candidates are checked for
feasibility. In the worst case, all of the graph edges must be examined, and this
possibly requires O(n2) steps. One way to reduce this a little is to use partial solutions
where the children of a vertex have one more node colored than their parent.
Let us now turn our attention to two interrelated topics: solution space design and
searching the space. Creative designers build a space that can be searched without
too much complexity - either in the bounding computations or in the space required
to hold the solution candidates under consideration and those about to be
considered. Some helpful techniques are the following.
Design a solution space that contains a subset of the entire solution space that
includes an optimum solution.
Use a depth-first strategy so that only a small portion of the search tree needs
to be stored at any stage.
Make the feasibility checks and bound computations cumulative so that time is
minimized.
Order the children of each vertex so that the most promising solutions are
examined first.
Use a good approximation to the optimum solution as the initial best solution
Our last note involves correctness. Two things must be shown. First, an optimum
solution exists in the solution space tree. And secondly, the optimum solution is
found by the branch and bound search algorithm.
Dynamic Programming
Another exact technique which enumerates the feasible solutions for an optimization
problem is named dynamic programming. Like branch and bound, all feasible
solutions are considered, but in a very different manner. Instead of forming
permutations of the elements found in solutions, we concentrate on combinations.
Also, we shall work backwards from solutions instead of forward as in other
enumeration techniques. Thus dynamic programming is a deductive rather than an
inductive process.
The sections are entitled:
A Shortest Path Problem
Characteristics and Approaches
More Examples
Related Top-Down Techniques
Historical Notes and References
Problems
http://www.cs.uky.edu/~lewis/cs-heuristic/text/dynamic/dynaintr.html12/2/2015 10:07:47 AM
s b e g t
s a d f t
s b d g t
s a d g t
s b d f t
After some computation we would discover that the shortest path was the one that
went through a, c, and f. But we did have to consider all of the possible paths and did
not find the answer until the very end of our search for the shortest path. Also, we
had to do 24 additions in order to find the lengths of each path.
Other methods that involved building paths from s to t were developed by Dijkstra,
Lee, and Moore. All three of these were quite similar and in essence involved
http://www.cs.uky.edu/~lewis/cs-heuristic/text/dynamic/shortest.html (1 of 5)12/2/2015 10:07:53 AM
successively examining the remaining vertex that is closest to s. Thus it is noted that
s a costs 1, s a d costs 2, s a c costs 4, and so forth until the shortest path
to t is found. This computation involves 12 additions to sum all of the path lengths
plus the overhead needed to determine at each stage which remaining node is closest
to s. The method does however have the attractive feature of determining shortest
paths from s to all of the nodes and it is far better than enumerating all of the
possible paths.
The graph in figure 1 is called a layered network because it has five distinct zones of
vertices:
{s}, {a, b}, {c, d, e}, {f, g}, and {t},
and if we wish to find the shortest path from node s to node t we must pass through
one vertex from each zone. But, rather than go from s to t as before, we shall branch
backwards from t going from zone to zone until we reach s.
In order to get to node t we must have come from either f or g. The costs involved are
5 for f t and 2 for the edge g t. Backing up one zone, we find that to reach nodes f
or g, we had to come directly from c, d, or e. In order to go to t from d there is a
choice, namely through f or g. The path through g is shorter, so we select that. The
shortest paths from nodes in these two zones to t are shown in Table 1. The way to
read this chart is to follow the next links. For example, to go from d to t, we go from
d to the next node under d, namely g. Then we look at the next node under g, which is
t. Thus the shortest path from d to t is d g t and its cost is 10.
each edge of the graph once. Compare this to the situation where one might
enumerate and examine all of the paths through the graph. For a complete graph this
means only O(n2) computational steps instead of an exponential number of steps for
complete graphs. And, since we were able to use information again and again, we
saved time.
The other rather famous path problem is the all pairs shortest path problem that is
sometimes called transitive closure. This also is solved by filling in a chart, except
this chare will be of size O(n2) since there are exactly that many paths to find.
We begin by jotting down the distances between all of the pairs of vertices along
paths that do not go through any other nodes. Let us take figure 1 and turn it into an
undirected graph. For this example the shortest paths which go directly from one
node to another and do not pass through other nodes appear in figure 4.
solutions from the subproblems which were just going to and from nodes in the
zones.
Our next step towards solving the problem is to compute values for subproblems and
use them to construct the optimum solution. If
every subsolution of an optimum solution is optimum
then we shall be able to construct optimal solutions from optimal subsolutions. This
statement or rule is named the Principle of Optimality by those in the dynamic
programming field.
The second example from path problems was the dynamic programming solution to
all pairs shortest path problem due to Floyd and Warshall. Here, if we recall that we
defined subsets of the vertices in a graph as
A0 = , A1 = {v1}, , Ai = {v1, , vi}, , An = {v1, , vn}.
and define subproblems involving constrained paths as:
d(Ai, vj, vk) = distance from vj to vk going through only vertices in Ai,
then the recursive relationship between these subproblems is:
d(Ai+1, u, v) = minimum[ d(Ai, vj, vk), d(Ai, vj, vi+1)+d(Ai, vi+1, vk) ].
Let's consider another dramatic example; computing Fibonacci numbers. They are
defined by the recursive relationship:
fn = fn-1 + fn-2
which seems to indicate that we should compute them by a top-down recursive
procedure. But, as everyone knows, this would be a hideous mistake. An exponential
amount of work would be done if we did this since many of the numbers would be
computed over and over again. We instead need to compute them in the order f1 , f2 , ... ,
fn. In other words, we organize the order in which we compute the subproblems, much
the same way that we did with the path problems.
Thus two more steps emerge in our process.
More examples.
Breaking this down into subproblems follows easily. We load a portion of the
knapsack with some of the items. For all values of k n and y b this is defined as:
So, for values of k between 1 and n and values of y from 1 to b, Fk(y) gives us a partial
loaded knapsack. We note that the principle of optimality does indeed apply since an
optimum load consists of several optimum subloads.
The next step is to determine the relationship between the Fk(y) values. This is not too
difficult to do. Suppose we wish to have y pounds of items 1 through k. Either item k
is in the load or not. If not, then the load is the same as the load involving items 1
through k-1, or Fk-1(y). Otherwise we subtract the weight of item k from y and look at
that optimum load. This means that
Fk(y) = maximum[ Fk-1(y), Fk(y - wk)+vk ]
All we need to do now is make a chart of all the Fk(y) values and fill in the chart.
Consider the four items whose weights and values are provided in table 1 below.
More examples.
More examples.
C({k}, k) = a .
1k
For larger sets of cities, we note that some city (say city i) had to precede city k. Thus
to go from city 1 through S to city k, we can go from city 1 to city i through the set S {i} and then go directly to city k. To get the best tour, we simply take the minimum
over all cities in S. This is represented by the formula:
Approximate Solutions
Thus far we have been concentrating on exact solutions to problems which can be
stated as integer programs. A major trouble we encounter is that since the time
n
complexity of these problems is often at least O(2 ), we cannot solve them for large
inputs. Often when it is not feasible to compute an exact solution to a problem, we
revert to approximation because this is better than no solution at all. These
algorithms are often called heuristics since there is usually a rule of thumb at the
core of the algorithm. But before examining heuristics in detail, we shall study several
ways to analyze them.
The sections are:
Bounds for Heuristics
Performance Analysis
Terminating Exact Solutions
Historical Notes and References
Problems
http://www.cs.uky.edu/~lewis/cs-heuristic/text/approx/apprintr.html12/2/2015 10:08:05 AM
The lower bound in the above equation is the least that our optimal solution can
possibly be. Putting this all together we derive that
FF(I) 2 OPT(I).
A rather exotic and long analysis of first fit does provide a tighter bound. In fact, it
can be shown that:
For our next example, let us turn to the Closed Tour problem. It possesses a rather
famous algorithm with a provable optimality bound.
First, one constructs the minimum spanning tree (MST) for the collection of cities.
Then all of the edges in the minimum spanning tree are duplicated. An example
appears as the left portion of figure 2.
Another bounding result due to Hwang that depends upon minimum spanning trees
concerns rectilinear Steiner spanning trees.
Theorem (Hwang). The shortest rectilinear Steiner spanning tree over a
set of points is no less than two-thirds the size of the rectilinear
minimal spanning tree over the points.
Thus if one can show that an algorithm produces a tree no larger than the minimum
spanning tree, then it is no worse than one and a half times the optimum.
Local Optimization
Almost the first scheme thought of when trying to figure out how to solve some
problem by approximation is to try to be as good as possible on as large an area as
possible. In other words, try to be very optimum locally and hope that this carries
over to the rest of the problem. We shall investigate several ways to accomplish this.
The sections are:
The Greedy Method
Divide and Conquer
Local Improvement
General Techniques for Local Search
Gradient Methods
Historical Notes and References
Problems
http://www.cs.uky.edu/~lewis/cs-heuristic/text/local/loclintr.html12/2/2015 10:08:10 AM
Greedy Methods
Greedy Methods
Compulsive algorithm designers adore greedy methods. All that seems to be required
for this is to jump in and do whatever seems best at the time. A great example is the
first fit algorithm for bin packing shown in the section on approximations. In that
algorithm one merely takes items in order and places each in the closest available bin.
The fact that the results are often quite good in practice makes techniques like this
very attractive.
Another greedy method much in the spirit of first fit is the nearest neighbor
algorithm for the closed tour problem. It is very much like the very famous Kruskal
algorithm for minimum spanning trees since we merely keep connecting the cities
that are closest until we have a tour. An example is pictured in figure 1.
which depends on n, the size of the problem. So, the theoretical bound on
performance seems to decrease as the problem instances grow larger.
Greedy Methods
Our next problem comes from the field of CAD algorithms for VSLI design. It is called
channel routing. A routed channel is shown in figure 2 and defined formally as:
Definition. A channel is a sequence of pairs of integers
<t1, b1>,<t2, b2>, ... , <tn, bn>.
Unfortunately the definition, although precise, is not very intuitive and thus does not
help one to understand what a channel actually is. The intuition behind the definition
is that a channel consists of two rows of pins (or terminals), some of which must have
a common electrical connection. The ti represent the pins on the top of the channel,
while the bi are those on the bottom. Examine figure 2.
Greedy Methods
connected, as they are insulated from each other at all other points. The horizontal
wires are routed on tracks. An optimum solution contains the fewest tracks or least
area. Figure 2 illustrates a 5-track routing.
The greedy router we are about to examine makes one pass over the channel the left
to the right. As it progresses along the channel, it brings in wires from pins on the
shores column by column (or pin by pin) into the channel and attaches them to wires
on horizontal tracks until every pin is connected to the rest of those bearing the
identical labels.
Here is an example. First, tracks are assigned to nets, such as net 1, that enter the
channel from the left as shown in figure 3. Then nets 1 and 2 were brought in from
the top and bottom in the first column. Net 2 is assigned to a new track and extended
to the right. Net 1 is attached to the existing net 1 track in both the first and second
columns. Then both tracks are extended to column three.
Greedy Methods
Greedy Methods
net 3 is on the top shore, the extension of net 3's track was made as near the top as
possible. Note also that on the next column we shall be able to consolidate the tracks
for net 2 since no nets enter there.
The process of bringing nets into the channel and either assigning them to new tracks
or attaching them to existing tracks continues column by column until the end of the
channel.
We are ready now to state the entire algorithm, but first we need some terminology. A
net is said to be rising if its next pin further along the channel is on the top shore
and next pin (if any) does not reside on the bottom shore within a pre-defined
distance called the steady net constant. Similarly, a net is falling if its next pin is on
the bottom shore and the following pin is not located on the top shore within the
distance specified by the steady net constant. In our example, net 1 is falling and net
2 is rising after column one. A steady net by default is that which is neither rising nor
falling. Split nets are nets that unfortunately have been placed upon two different
tracks at a column. Net 2 has been split on columns four, five, and six.
The greedy algorithm for channel routing is presented as figure 6 below.
Greedy Methods
Greedy Methods
to see that a vertical jog of one net does not overlap the vertical jog of another net or
of an incoming net unless of course they are the same net. Net 2's two tracks were
reunited in this manner in column 6.
The next step is to narrow down the distance between as many existing split nets as
possible by making nets come closer to each other by the use of vertical wires which
must be the minimum jog length. Also, these wires should not be incompatible with
vertical wires that may have been placed in earlier steps.
This is followed up by locating all single track nets that are rising or falling, and
attempting to move them to higher or lower tracks if possible using vertical wires.
This was done to net 3 at column 5 and net 4 at column 6.
As the algorithm progresses through these steps some bookkeeping is done so that
when:
the list of available tracks is continually updated to reflect the changes in availability
of the tracks made along the way.
Now the routing for this column is over and at this point, the column count is
incremented and routing begins on the new column.
When the end of the channel is reached, all tracks are checked for their availability
and if they are still in use, then there are two possibilities for them. The first is that
the tracks contain split nets that were unable to be collapsed earlier within the
channel area. They may now be collapsed, one at a time if necessary. This might mean
extending the right edge of the channel by some more columns. The second
possibility is that the tracks are continuing with those nets because they comprise the
list of right border nets. These are as they should be and end there.
In order to calculate the time complexity for this routing algorithm, the parameters
are the length of the channel and the number of tracks. The algorithm makes one
pass over a channel having length n. As it processes each column, it checks every
track. This means that the time taken is equal to the channel length multiplied by the
number of tracks. If the number of nets is proportional to n (the length of the
channel), then the time complexity comes out to be O(n2) since n tracks could be
required in the worst case.
In figure 1, shortest closed tours have been found for each quadrant. The last step is
to make connections between quadrants, and omit one of the links in each regional
tour. A possibility is shown in figure 2.
Local search.
Local Improvement
Examining the geometric interpretation of integer programming reveals that a
problems constraints form a polytope. Optimum solutions for the relaxation of the
problem to linear programming can be found on the convex hull of this polytope. But
unfortunately, optimum integer solutions are often found inside the polytope rather
than on the convex hull. This is why linear programming does not solve integer
programming problems.
Consider the two dimensional optimization problem shown in figure 1. The feasible
solution space is the darker area and we wish to maximize the sum of the two
variables. Integer solutions to the problem occur at the intersections of the grid edges.
Local search.
Suppose that we were able somehow to find a feasible solution, perhaps through the
use of a greedy method. Suppose that the solution indicated by the dot labeled a in
figure 1 is such a solution. Let us search the area directly around this solution (which
we call the neighborhood of the solution) to see if there is a better solution which is
not too different than the one we have. If we find a better solution, then we continue
the search for better solutions. This process is illustrated in figure 1. The dots are
feasible solutions and the large circles are neighborhoods. As we find better and
better solutions, we progress upwards and to the right on the path:
a b c d e,
until an optimal solution (in this case found at point e) is encountered.
This method is entitled local search and calls for searching a small area around a
solution and adopting a better solution if found. The process halts when no better
solutions occur. This algorithm is illustrated in figure 2.
Local search.
Local search.
Local search.
Definition. The internal cost or loss I(a) of moving vertex a out of the set
A is the sum of the weights of the edges between a and other vertices in
A.
Definition. The total cost or difference incurred by moving vertex a out
of the set A is: D(a) = E(a) - I(a).
An easy technical lemma follows directly from these definitions.
Lemma. The gain incurred from swapping vertices a A and b B is: g
(a, b) = D(a) + D(b) - 2W[a, b].
Lets look at the values of these items using our last graph and the partition of A = {r,
s, t} and B = {u, v, w}.
Now that we know the external and internal costs incurred by swapping vertices
across the partition, here are the costs when pairs are swapped.
From these numbers we can conclude that swapping r and u seems to be a good idea.
So is swapping t and w. We should probably not wish to swap s and v however. Or at
least not at this time.
Local search.
Let us apply the local search algorithm. We take the graph G = (V, W) and divide the
vertex set V arbitrarily into sets A = {r, s, t} and B = {u, v, w}. Then we examine the
nine neighborhoods that result from exchanging pairs of vertices from A and B.
Figure 5a contains difference values for all of the vertices in the table on the left while
the table on the right indicates all of the gains involved in swapping vertices between
A and B.
Local search.
Local search.
Since no gain took place, we halt and present {u, s, t} and {r, v, w} as our partition.
Figure 8 provides a description of the entire algorithm.
Local search.
Local search.
Proof. The MinCut algorithm swaps vertices. Thus we need to show that
by swapping vertices it is possible to go from any partition to an optimal
one, that is, one with the minimum cut.
Suppose we are given an arbitrary partition P and an optimal one POPT. A
brief examination of P reveals that it either is the same as POPT or it is not.
If not, then there is a vertex in each half of P that does not belong. Swap
them and continue until the desired partition appears.
For this problem, correctness is rather simple. As there are no guarantees, we only
need show that a feasible solution has been found. Thus we may state the following
with very little proof.
Theorem 2. The MinCut algorithm is correct.
Proof. We begin with a feasible solution. Swapping two vertices provides
another feasible solution. Thus at every stage of the algorithm we have a
feasible solution.
With approximation algorithms, correctness is not as much of an issue as with
optimum algorithms. However, the complexity of the procedure is of great
importance to us and must be examined.
Computing the differences D[u] initially is an O(n2) operation since all of the graph
edges need to be examined. Setting the vertices as available requires only linear time.
Inside the for loop, selection of the pair to be swapped can be O(n2). Recalculating
each D[u] takes a constant amount of time for each available u, so this too is O(n).
Empirical results indicate that the repeat loop will be repeated less than four times,
even for very large values of n. These results indicate a time complexity of O(n3) for
the algorithm.
Initial solutions appear in two flavors: random, and the result of a greedy algorithm.
Each has its champions. Possibly the best approach is to try both. That is, add a
greedy initial solution to a collection of randomly generated solutions.
Neighborhood definition is an art form. They can be obvious, but many are clever and
elegant, and some border upon genius. The key to a good neighborhood definition is
primarily ease of manipulation. A good formulation makes all of the manipulation
and computation flow quickly and easily. A clumsy neighborhood adds to the
algorithms complexity.
This brings up the computational methods and data structures, which are part of the
local search algorithm. We must also develop:
Only in a few cases was the best solution in a neighborhood selected, but the
algorithm did find the optimal solution just the same. In fact, it took one more
neighborhood examination than if a full search of each neighborhood took place, but
this is not bad at all if a full search requires O(n2) steps and a restricted search O(n).
This example was of course hypothetical, but it does illustrate the attractiveness of
not searching entire neighborhoods.
The variable depth method is a nice compromise between the first improvement and
steepest descent methods. It begins by searching the entire neighborhood, but
reduces its search area as units become unavailable for manipulation.
Finally, if computing the gain involved by changing to a neighboring solution can be
sped up, lots of time can be saved. The min-cut algorithm accomplishes this by
updating the gain values in linear time during each iteration rather than recomputing
all of them at a cost of quadratic time.
In order to perform proper algorithm analysis, three items must be examined when
presenting a local search algorithm,
correctness,
complexity, and
the possibility of achieving an optimal solution.
Correctness is often rather simple to guarantee since all that needs to be shown is
that a feasible solution is produced. Of course, if the cost can be bounded as some of
the previous examples were, this is better.
Complexity is mainly the size of the neighborhood searched times the number of
solutions in a sequence if the outer loop is executed only a few times. Otherwise, the
algorithm might run for an exponential amount of time. After all, if solutions get
better and better it is possible to examine a large number of feasible solutions before
halting. In practice, most algorithms execute the outer loop less than five times for
large problem instance sizes.
The last consideration, proving that it is possible to go from any initial feasible
solution to an optimal one is a nice touch. It really says that the algorithm has a
chance of achieving optimality if one is very lucky. It also in some sense certifies that
the neighborhood definition and search procedure are reasonable. It is not as trivial
as one might think since there are highly cited algorithms in the literature that can be
shown to never produce an optimal solution with certain inputs.
RANDOMIZED
RANDOMIZED
DNA Computing
DNA Computing
Click here to start
Table of Contents
What Next?
Geographic Tours
Hamiltonian Paths
Solving NP Problems
deoxyribonucleic acid (DNA) molecule
Complementary Bases Attract
PPT Slide
Using DNA as a Computer
Remember Graphs and Paths?
Building Vertices from DNA
Building Edges from DNA
Vertex and Edge Bonding
Operations on Molecules
Encoding Binary Sequences
DNA Operations
http://www.cs.uky.edu/~lewis/cs-heuristic/text/natural/dna-comp/index.htm (1 of 2)12/2/2015 10:08:44 AM
DNA Computing
Advantages
Disadvantages
What Next?
Slide 1 of 17
http://www.cs.uky.edu/~lewis/cs-heuristic/text/natural/dna-comp/sld001.htm12/2/2015 10:08:50 AM
Geographic Tours
Slide 2 of 17
http://www.cs.uky.edu/~lewis/cs-heuristic/text/natural/dna-comp/sld002.htm12/2/2015 10:08:53 AM
Hamiltonian Paths
Slide 3 of 17
http://www.cs.uky.edu/~lewis/cs-heuristic/text/natural/dna-comp/sld003.htm12/2/2015 10:08:54 AM
Solving NP Problems
Slide 4 of 17
http://www.cs.uky.edu/~lewis/cs-heuristic/text/natural/dna-comp/sld004.htm12/2/2015 10:08:56 AM
Slide 5 of 17
http://www.cs.uky.edu/~lewis/cs-heuristic/text/natural/dna-comp/sld005.htm12/2/2015 10:08:58 AM
Slide 6 of 17
http://www.cs.uky.edu/~lewis/cs-heuristic/text/natural/dna-comp/sld006.htm12/2/2015 10:09:00 AM
PPT Slide
Slide 7 of 17
http://www.cs.uky.edu/~lewis/cs-heuristic/text/natural/dna-comp/sld007.htm12/2/2015 10:09:02 AM
Slide 8 of 17
http://www.cs.uky.edu/~lewis/cs-heuristic/text/natural/dna-comp/sld008.htm12/2/2015 10:09:03 AM
Slide 9 of 17
http://www.cs.uky.edu/~lewis/cs-heuristic/text/natural/dna-comp/sld009.htm12/2/2015 10:09:05 AM
Slide 10 of 17
http://www.cs.uky.edu/~lewis/cs-heuristic/text/natural/dna-comp/sld010.htm12/2/2015 10:09:08 AM
Slide 11 of 17
http://www.cs.uky.edu/~lewis/cs-heuristic/text/natural/dna-comp/sld011.htm12/2/2015 10:09:10 AM
Slide 12 of 17
http://www.cs.uky.edu/~lewis/cs-heuristic/text/natural/dna-comp/sld012.htm12/2/2015 10:09:11 AM
Operations on Molecules
Slide 13 of 17
http://www.cs.uky.edu/~lewis/cs-heuristic/text/natural/dna-comp/sld013.htm12/2/2015 10:09:13 AM
Slide 14 of 17
http://www.cs.uky.edu/~lewis/cs-heuristic/text/natural/dna-comp/sld014.htm12/2/2015 10:09:15 AM
DNA Operations
Slide 15 of 17
http://www.cs.uky.edu/~lewis/cs-heuristic/text/natural/dna-comp/sld015.htm12/2/2015 10:09:17 AM
Advantages
Slide 16 of 17
http://www.cs.uky.edu/~lewis/cs-heuristic/text/natural/dna-comp/sld016.htm12/2/2015 10:09:19 AM
Disadvantages
Slide 17 of 17
http://www.cs.uky.edu/~lewis/cs-heuristic/text/natural/dna-comp/sld017.htm12/2/2015 10:09:24 AM