algorithms for network optimization problems this handout: minimum spanning tree problem...

18
Algorithms for Network Optimization Problems This handout: • Minimum Spanning Tree Problem • Approximation Algorithms • Traveling Salesman Problem

Upload: robyn-eaton

Post on 27-Dec-2015

234 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Algorithms for Network Optimization Problems This handout: Minimum Spanning Tree Problem Approximation Algorithms Traveling Salesman Problem

Algorithms for Network Optimization Problems

This handout:

• Minimum Spanning Tree Problem

• Approximation Algorithms

• Traveling Salesman Problem

Page 2: Algorithms for Network Optimization Problems This handout: Minimum Spanning Tree Problem Approximation Algorithms Traveling Salesman Problem

Terminology of Graphs• A graph (or network) consists of

– a set of points

– a set of lines connecting certain pairs of the points.

The points are called nodes (or vertices).

The lines are called arcs (or edges or links).

• Example:

Page 3: Algorithms for Network Optimization Problems This handout: Minimum Spanning Tree Problem Approximation Algorithms Traveling Salesman Problem

Terminology of Graphs: Paths

• A path between two nodes is a sequence of distinct nodes and edges connecting these nodes.

Example:

a

b

Page 4: Algorithms for Network Optimization Problems This handout: Minimum Spanning Tree Problem Approximation Algorithms Traveling Salesman Problem

Terminology of Graphs:

Cycles, Connectivity and Trees

• A path that begins and ends at the same node is called a cycle.Example:

• Two nodes are connected if there is a path between them.• A graph is connected if every pair of its nodes is connected. • A graph is acyclic if it doesn’t have any cycle.• A graph is called a tree if it is connected and acyclic.

Example:

Page 5: Algorithms for Network Optimization Problems This handout: Minimum Spanning Tree Problem Approximation Algorithms Traveling Salesman Problem

Minimum Spanning Tree Problem

• Given: Graph G=(V, E), |V|=n

Cost function c: E R .• Goal: Find a minimum-cost spanning tree for V

i.e., find a subset of arcs E* E which

connects any two nodes of V

with minimum possible cost.• Example:

2

3

3

44

5

7

8

e

b

c

d

a

23

3

44

5

7

8

e

b

c

d

a

G=(V,E) Min. span. tree: G*=(V,E*)

Red bold arcs are in E*

Page 6: Algorithms for Network Optimization Problems This handout: Minimum Spanning Tree Problem Approximation Algorithms Traveling Salesman Problem

Algorithm for solving the Minimum Spanning Tree

Problem• Initialization: Select any node arbitrarily,

connect to its nearest node.

• Repeat– Identify the unconnected node

which is closest to a connected node

– Connect these two nodes

Until all nodes are connected

Note: Ties for the closest node are broken arbitrarily.

Page 7: Algorithms for Network Optimization Problems This handout: Minimum Spanning Tree Problem Approximation Algorithms Traveling Salesman Problem

The algorithm applied to our example

• Initialization: Select node a to start. Its closest node is node b. Connect nodes a and

b.

• Iteration 1: There are two unconnected node closest to a connected node: nodes c and d

(both are 3 units far from node b).

Break the tie arbitrarily by

connecting node c to node b.

2

3

3

44

5

7

8

e

b

c

d

a

23

3

44

5

7

8

e

b

c

d

a

Red bold arcs are in E*;

thin arcs represent potential links.

Page 8: Algorithms for Network Optimization Problems This handout: Minimum Spanning Tree Problem Approximation Algorithms Traveling Salesman Problem

The algorithm applied to our example

• Iteration 2: The unconnected node closest to a connected node is node d (3 far from node b). Connect nodes b and d.

• Iteration 3: The only unconnected node left is node e. Its closest connected node is node c

(distance between c and e is 4).

Connect node e to node c.• All nodes are connected. The bold

arcs give a min. spanning tree.

2

3

3

44

5

7

8

e

b

c

d

a

23

3

44

5

7

8

e

b

c

d

a

Page 9: Algorithms for Network Optimization Problems This handout: Minimum Spanning Tree Problem Approximation Algorithms Traveling Salesman Problem

Recall Classes of discrete optimization problems:Class 1 problems have polynomial-time algorithms

for solving the problems optimally.

Ex.: Min. Spanning Tree problem

Assignment ProblemFor Class 2 problems (NP-hard problems)

• No polynomial-time algorithm is known;

• And more likely there is no one.

Ex.: Traveling Salesman Problem

Coloring problem

Page 10: Algorithms for Network Optimization Problems This handout: Minimum Spanning Tree Problem Approximation Algorithms Traveling Salesman Problem

Three main directions to solve

NP-hard discrete optimization problems:

• Integer programming techniques

• Heuristics

• Approximation algorithms

• We gave examples of the first two methods for TSP.

• In this handout,

an approximation algorithm for TSP.

Page 11: Algorithms for Network Optimization Problems This handout: Minimum Spanning Tree Problem Approximation Algorithms Traveling Salesman Problem

Definition of Approximation Algorithms

• Definition: An α-approximation algorithm is a polynomial-time algorithm which always produces a solution of value within α times the value of an optimal solution.

That is, for any instance of the problem

Zalgo / Zopt α , (for a minimization problem)

where Zalgo is the cost of the algorithm output,

Zopt is the cost of an optimal solution.

• α is called the approximation guarantee (or factor) of the algorithm.

Page 12: Algorithms for Network Optimization Problems This handout: Minimum Spanning Tree Problem Approximation Algorithms Traveling Salesman Problem

Some Characteristics of Approximation Algorithms

• Time-efficient (sometimes not as efficient as heuristics)• Don’t guarantee optimal solution• Guarantee good solution within some factor of the optimum • Rigorous mathematical analysis to prove the approximation

guarantee• Often use algorithms for related problems as subroutines

Next we will give

an approximation algorithm for TSP.

Page 13: Algorithms for Network Optimization Problems This handout: Minimum Spanning Tree Problem Approximation Algorithms Traveling Salesman Problem

An approximation algorithm for TSP

Given an instance for TSP problem,

1. Find a minimum spanning tree (MST) for that instance.

(using the algorithm of the previous handout)

2. To get a tour, start from any node and traverse the arcs of MST by taking shortcuts when necessary.

Example:

Stage 1 Stage 2

start from this node

red bold arcs form a tour

Page 14: Algorithms for Network Optimization Problems This handout: Minimum Spanning Tree Problem Approximation Algorithms Traveling Salesman Problem

Approximation guarantee for the algorithm

• In many situations, it is reasonable to assume that triangle inequality holds for the cost function c: E R defined on the arcs of network G=(V,E) :

cuw cuv + cvw for any u, v, w V

• Theorem:

If the cost function satisfies the triangle ineqality,

then the algorithm for TSP

is a 2-approximation algorithm.

w

v

u

Page 15: Algorithms for Network Optimization Problems This handout: Minimum Spanning Tree Problem Approximation Algorithms Traveling Salesman Problem

Approximation guarantee for the algorithm (proof)

First let’s compare the optimal solutions of MST and TSP for any problem instance G=(V,E), c: E R .

• Idea: Get a tour from Minimum spanning tree without increasing its cost too much (at most twice in our case).

Cost (Opt. TSP sol-n) Cost (of this tree) Cost (Opt. MST sol-n)≥ ≥

Optimal TSP sol-n Optimal MST sol-nA tree obtained from the tour

(*)

Page 16: Algorithms for Network Optimization Problems This handout: Minimum Spanning Tree Problem Approximation Algorithms Traveling Salesman Problem

Approximation guarantee for the algorithm (proof)

The algorithm • takes a minimum spanning tree • starts from any node• traverse the MST arcs

by taking shortcuts when necessary

to get a tour. What is the cost of the tour compared to the cost of MST?• Each tour (bold) arc e is a shortcut

for a set of tree (thin) arcs f1, …, fk

(or simply coincides with a tree arc)

start from this node

red bold arcs form a tour

1

2

3

4

5

6

Page 17: Algorithms for Network Optimization Problems This handout: Minimum Spanning Tree Problem Approximation Algorithms Traveling Salesman Problem

Approximation guarantee for the algorithm (proof)

• Based on triangle inequality,

c(e) c(f1)+…+c(fk)

E.g, c15 c13 + c35

c23 c23

• But each tree (thin) arc

is shortcut exactly twice. (**)

E.g., tree arc 3-5 is shortcut by tour arcs 1-5 and 5-6 . The following chain of inequalities concludes the proof,

by using the facts we obtained so far:

start from this node

red bold arcs form a tour

1

2

3

4

5

6

TSP)alcost(optim2cost(MST)2

c(e)2c(e) our)cost(our t

(*)by

earcsthin

(**)ineq.,Δby

e arcs bold

Page 18: Algorithms for Network Optimization Problems This handout: Minimum Spanning Tree Problem Approximation Algorithms Traveling Salesman Problem

Performance of TSP algorithms in practice

• A more sophisticated algorithm (which again uses the MST algorithm as a subroutine) guarantees a solution within factor of 1.5 of the optimum (Christofides).

• For many discrete optimization problems, there are benchmarks of instances on which algorithms are tested.

• For TSP, such a benchmark is TSPLIB.• On TSPLIB instances, the Christofides’ algorithm outputs

solutions which are on average 1.09 times the optimum.

For comparison, the nearest neighbor algorithm outputs solutions which are on average 1.26 times the optimum.

• A good approximation factor often leads to good performance in practice.