doc5.5

advertisement
First of all, let’s give two examples of Traveling Salesman
problems:
Example 1 (page201): A Tale of Five Cities
Willy Loman, a travel salesman, has 5 customers in 5
cities: A, B, C, D and E, and he is planning an upcoming sales
trip to visit each of them. Willy
needs to start and end the trip at
his hometown A. The graph
shows the cost of a one-way
airline ticket between each pair
of cities. Willy wants to know
what is the cheapest possible
sequence in which to visit the 5
cities.
Example 2 (page202): A small trip in our Solar System
We want to start an expedition from Earth to explore
those 5 moons presented in the figure from below: collect rock
samples at each, and then
return to Earth with the
loot. The figure also shows
the mission time (in years)
between any two moons.
What is the best way to
route the spaceship so that,
the entire trip takes the
least amount of time?
As we see, all these traveling salesman problems ask to
find a the cheapest Hamilton circuit (or path) from a graph
whose edges have numbers attached to them.
DEFINITIONS: Any graph whose edges have numbers
attached to them is called a weighted graph and the
numbers are called the weights of the edges.
DEFINITIONS:
The graphs from previous two
examples are called completed weighted graphs (since
these graphs are clearly weighted and also complete).
OBS:
In each example, the weights of a graph represent
different variables; they can represent cost, time, distance etc.
OBS: Most important of all, in each example, the problem we
want to solve is the same: to find an optimal Hamilton circuit
(or path) – that is, a Hamilton circuit (or path) with least total
weight – for the complete weighted graph.
The Brute-Force Algorithm
Step 1:
Make a list of all the possible Hamilton circuits of the
graph.
Step 2:
For each Hamilton circuit calculate its total weight by
adding the weights of all the edges in the circuit.
Step 3:
Find the circuits (there is always more than one) with the
least total weight. Any one of these can be chosen as an optimal
Hamilton circuit for the graph.
The Nearest-Neighbor Algorithm
Step 1:
Pick a vertex as a starting point.
Step 2:
From the starting vertex go to the vertex for which the
corresponding edge has the smallest weight. We call this vertex
the nearest neighbor. If there is more than one, choose one of
them at random.
Step 3:
Continue building the circuit, one vertex at a time, by
always going from a vertex to the nearest neighbor of that
vertex from among the vertices that have not been visited yet.
(Whenever there is a tie, choose at random.) Keep doing this
until all the vertices have been visited.
Step 4:
From the last vertex return to the starting point.
Example (page201):
1)
A Tale of Five Cities
Using the Brute-Force algorithm we get:
So, the cheapest Hamilton circuit is A, E, C, B, D, A with the
total weight of $676.
2)
Using the Nearest-Neighbor algorithm (starting at A)
we get the circuit A, C, E, D, B, A with the total cost of
$773.
CONCLUSION!!!!:
The Brute-Force algorithm is an inefficient since the
amount of work required to carry out the algorithm increases by
a factor that is equal to the number of vertices in the graph. For
example, it takes 5 times as much work to go from 5 vertices to
6, 10 times more work to go from 10 vertices to 11, 100 times as
much work to go from 100 vertices to 101.
So, the Brute-Force algorithm is inefficient, but it gives
always the cheapest Hamilton circuit.
The Nearest-Neighbor algorithm is clearly an efficient
one, but it does not give us what we are asking for – an optimal
Hamilton circuit.
Unfortunately, nobody knows an algorithm which is
efficient and which gives also the optimal Hamilton circuit.
DEFINITIONS: From now on, we will use the term
approximate algorithm to describe any algorithm that
produces solutions that are, most of the time, reasonable
close to the optimal solution.
The Repetitive Nearest-Neighbor Algorithm
i)
Let X be any vertex. Apply the Nearest-Neighbor
algorithm using X as a starting vertex and calculate the total
cost of the circuit obtained.
ii) Repeat the process using each of the other vertices of the
graph as starting vertex.
iii) Of the Hamilton circuits obtained, keep the best one. If
there is a designated starting vertex, rewrite the circuit with
that vertex as the reference point.
Example (page201):
A Tale of Five Cities
Using the Repetitive Nearest-Neighbor algorithm we get:
the circuit (starting with A) A, C, E, D, B, A total cost $773;
the circuit (starting with B) B, C, A, E, D, B total cost $722;
the circuit (starting with C) C, A, E, D, B, C total cost $722;
the circuit (starting with D) D, B, C, A, E, D total cost $722;
the circuit (starting with E) E, C, A, D, B, E total cost $741.
So, the best solution the Repetitive Nearest algorithm gives is the
circuit B, C, A, E, D, B with the total cost of $722. If we want A to be the
starting point, then we can rewrite the previous circuit as: A, E, D, B, C,
A (these two circuits are the same).
The Cheapest-Link Algorithm
Step 1:
Pick the link with the smallest weight first (in case of a tie,
pick one at random). Mark the corresponding edge (say in
red).
Step 2:
Pick the next cheapest link and mark the corresponding
edge in red.
Step 3:
Continue picking the cheapest link available. Mark the
corresponding edge in red except when:
 it closes a circuit;
 it results in three edges coming out of a single vertex.
Step 4:
When there are no more vertices to link, close the red
circuit.
Example (page201):
A Tale of Five Cities
Using the Cheapest-Link algorithm, we get:
Hence, the Hamilton circuit obtained is A, C, E, B, D, A ($741).
CONCLUSION!!!!:
Neither of the Nearest-Neighbor algorithm nor the
Cheapest-Link algorithm can claim to be superior to the other
one. Sometimes one of them gives better results, the other time
it happens the other way around.
Unfortunately, nobody knows an algorithm which is
efficient and which gives also the optimal Hamilton circuit.
At present, the best approximate algorithms known give
solutions guaranteed to be 1% of the optimal solution for
problems with up to 100,000 vertices. Constant refinements of
these algorithms and improvements in technology guarantee that
such levels of performance will get even better.
On a theoretical level, the fundamental question for TPSs
remains unsolved: Is there an algorithm that is both efficient and
optimal, or is such an algorithm a mathematical impossibility?
This problem is still waiting for the next EULER (or
HAMILTON maybe) to come along.
Download