You are on page 1of 22

Graduate Studies Program

Term: Fall 2022/2023

Computing

Lecture 7
Branch & Bound Strategy
(Draft)

This lecture notes have been compiled from different resources,


I’d like to thank all authors who make them available to use.

1
Lecture Outline
◼ Branch-and-Bound Strategy.

◼ Traveling Salesman Problem (TSP)

◼ TSP using Branch-and-Bound Strategy.

◼ TSP using Brute Force Strategy.

◼ Hamiltonian Circuits Problem.

2
The Branch-and-Bound Strategy (B&B)
◼ This strategy can be used to solve optimization problems
without an exhaustive search in the average case.
◼ Using B&B to avoid n! exhaustive search technique on the
average case. (O(n!)>O(2n)).
◼ 2 mechanisms:
◼ A mechanism to generate branches when searching the
solution space
◼ A mechanism to generate a bound so that many branches
can be terminated
◼ It is efficient in the average case because many branches can
be terminated very early.
◼ Although it is usually very efficient, a very large tree may be
generated in the worst case.

3
The Basic Idea of B&B

◼ There is a way to split the solution space (branch)


◼ There is a way to predict a lower bound for a class of
solutions.
◼ There is also a way to find an upper bound of an
optimal solution.
◼ If the lower bound of a solution exceeds the upper
bound, this solution cannot be optimal and thus we
should terminate the branching associated with this
solution.

4
Traveling Salesman Problem (TSP)

• Given a graph, the TSP Optimization problem is to find a tour, starting from
any vertex, visiting every other vertex and returning to the starting vertex,
with minimal cost.

TSP Applications:

❑ Transportation routing.

❑ Robotic welding in the car industry.

❑ Printed circuit board drilling and laser cutting of integrated circuits.

❑ Job processing: Chemical plants – cost of setup to produce chemicals.


Real-Life Applications

◼ It’s not likely anyone would want to plan a bike trip to 25 cities
◼ But the solution of several important “real world” problems is the
same as finding a tour of a large number of cities

◼ transportation: school bus routes,


service calls, delivering meals, ...
◼ manufacturing: an industrial robot
that drills holes in printed circuit
boards
◼ VLSI (microchip) layout
◼ communication: planning new
telecommunication networks

For many of these problems n


(the number of “cities”) can be
1,000 or more
Example: Traveling salesman problem

• Given n cities and a network of connections and distances


between cities dij R
• Goal: Find shortest round trip
Nearest-Neighbour Algorithm: Start with initial city, and then
choose always the closest city next that you have not visited yet.
1
Starting city: 2
4 5 3 1 3
Next closest city: 4 16
Next closest city: 5 f(x) = 1 + 2 + 2 + 16 + 12 = 33 12 4 5
Next closest city: 3 8 2
1 2
Next closest city: 1 4
5
2
15 3
Traveling salesman -
Example: Traveling salesman problem
Greedy
◼ A salesman must visit every city (starting from city A), and
wants to cover the least possible distance
◼ He can revisit a city (and reuse a road) if necessary

◼ He does this by using a greedy algorithm: He goes to the next


nearest city from wherever he is

◼ From A he goes to B
A 2 B 4 C ◼ From B he goes to D
◼ This is not going to result in a
shortest path!
3 3
4 4 ◼ The best result he can get now
will be ABDBCE, at a cost of 16
◼ An actual least-cost path from A
D is ADBCE, at a cost of 14
E
8
TSP Optimization Problem

◼ E.g. A Cost Matrix for a Traveling Salesperson Problem.

j 1 2 3 4 5 6 7
i
1 ∞ 3 93 13 33 9 57
2 4 ∞ 77 42 21 16 34
3 45 17 ∞ 36 16 28 25
4 39 90 80 ∞ 56 7 91
5 28 46 88 33 ∞ 25 57
6 3 88 18 46 92 ∞ 7
7 44 26 33 27 84 39 ∞

9
Traveling Salesperson Optimization Problem

◼ The Cost Matrix for a Traveling Salesperson Problem.

Step 1 to reduce: Search each row for the smallest value

j 1 2 3 4 5 6 7 to j
i
1 ∞ 3 93 13 33 9 57
2 4 ∞ 77 42 21 16 34
3 45 17 ∞ 36 16 28 25
4 39 90 80 ∞ 56 7 91
from i
5 28 46 88 33 ∞ 25 57
6 3 88 18 46 92 ∞ 7
7 44 26 33 27 84 39 ∞

10
Traveling Salesperson Optimization Problem

Step 2 to reduce: Search each column for the smallest value


◼ Reduced cost matrix:
j 1 2 3 4 5 6 7
i
1 ∞ 0 90 10 30 6 54 (-3)
2 0 ∞ 73 38 17 12 30 (-4)
3 29 1 ∞ 20 0 12 9 (-16)
4 32 83 73 ∞ 49 0 84 (-7)
5 3 21 63 8 ∞ 0 32 (-25)
6 0 85 15 43 89 ∞ 4 (-3)
7 18 0 7 1 58 13 ∞ (-26)
A Reduced Cost Matrix. reduced: 84

11
TSP Optimization Problem

j 1 2 3 4 5 6 7
i
1 ∞ 0 83 9 30 6 50
2 0 ∞ 66 37 17 12 26
3 29 1 ∞ 19 0 12 5
4 32 83 66 ∞ 49 0 80
5 3 21 56 7 ∞ 0 28
6 0 85 8 42 89 ∞ 0
7 18 0 0 0 58 13 ∞
(-7) (-1) (-4)
◼ Lower bound: The total cost of 84+12=96 is subtracted.
◼ Thus, we know the lower bound of feasible solutions to this TSP
problem is 96.
12
TSP Example (B&B Strategy)

13
TSP Example (Brute Force Strategy)

14
Hamiltonian Circuits Problem
A Hamiltonian circuit or tour of a graph is a path that starts at a given vertex, visits
each vertex in the graph exactly once, and ends at the starting vertex.
A route returning to the beginning is known as a Hamiltonian Circuit
Some graphs do not contain Hamiltonian circuits.
A route not returning to the beginning is known as a Hamiltonian Path

v1 v2 v3 v1 v2 v3

v4 v5 v6 v4 v5 v6
A state space tree for this problem is as follows:
Put the starting vertex at level 0 in the tree, call this the zero'th vertex on the path.
At level 1, consider each vertex other than the starting vertex as the first vertex after the
starting one.
At level 2, consider each of these vertices as the second vertex, and so on. You may now
backtrack in this state space tree.
State Space Tree

v1 v2 v3 v4 1 state space tree

2 5
v5 v6 v7 v8

graph
5 7 2 6

6 7 3

3 4 8 :
:
3 8 4

:
:
Example: Identifying Hamilton Circuits
Refer to the graph below. Which of the following are Hamilton circuits?
a) A → B → E → D → C → F → A
b) A → B → C → D → E → F → C →
E→B→F→A B C D

c) B → C → D → E → F → B
Solution A F E
a) It is a Hamilton circuit for the graph.
b) It is not a Hamilton circuit since it visits B more than once.
c) It is not a Hamilton circuit since it does not visit all the vertices.
• Any complete graph with three of more vertices has a Hamilton circuit.
• A complete graph with n vertices has (n – 1)! Hamilton circuits.
• The Hamilton circuits that differ only in their starting points will be considered
to be the same circuit.
• In a weighted graph, a minimum Hamilton circuit is a Hamilton circuit with
the smallest possible weight.
Brute Force Algorithm

Step 1: Choose a starting point.


Step 2: List all the Hamilton circuits with that starting point.
Step 3: Find the total weight of each circuit.
Step 4: Choose a Hamilton circuit with the smallest total weight.
Example: Brute Force Algorithm

• Find a minimum Hamilton circuit for the complete, A 3 B


weighted graph:
1 1 5 7

D C
3
Solution: Weight of circuit
1. A →B→C→D→A 14
2. A→B→D→C→A 12 Min.
3. A→C→B→D→A 14
4. A→C→D→B→A 12 (opposite of 2)
5. A→D→B→C→A 14 (opposite of 3)
6. A→D→C→B→A 14 (opposite of 1)
Nearest Neighbor Algorithm
Step 1: Choose a starting point, call this vertex A.

Step 2: Check all the edges joined to A,


and choose one that has the smallest weight.
Proceed along this edge to the next vertex.

Step 3: At each vertex you reach, check the edges from there to
vertices not yet visited.
Choose the smallest weight.
Proceed along this edge to the next vertex.

Step 4: Repeat Step 3 until you have visited all the vertices.

Step 5: Return to the starting vertex.


Example: Nearest Neighbor

• The time it takes to travel between points (in minutes) is


shown on the graph below.
• Use the nearest neighbor algorithm to approximate the least
time to visit each location.
A
20
9 13 9
B 3 E
8 8
10 5

C D
7
Solution:
A
20
• Note that A → B → E → C → D → A 9 13 9
3 E
has a total weight of 36 minutes. All B
we can expect from the nearest 8 8
neighbor algorithm is a reasonably 10 5
good solution. C D
7

Start Circuit Weight


A A→D→E →B→C→A 40
B B→E →D→C→A →B 37
C C→D→E →B→A →C 37
D D→E →B→A →C→D 37
E E →B→D→C→A →E 51

You might also like