ALGORITHM ANALYSIS AND DESIGN
2:15 AM Algorithm Analysis and Design
BRANCH AND BOUND METHOD
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
1
Principle Used
2:15 AM Algorithm Analysis and Design
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
2
Branch And Bound Methods
2:15 AM Algorithm Analysis and Design
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
3
FIFO Branch And Bound Technique
2:15 AM Algorithm Analysis and Design
the list of live nodes is maintained as a FIFO list or queue
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
4
LIFO Branch And Bound Technique
2:15 AM Algorithm Analysis and Design
the list of live nodes is maintained as a LIFO list or stack
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
5
Least Cost Search
2:15 AM Algorithm Analysis and Design
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
6
Computing Cost
2:15 AM Algorithm Analysis and Design
X -Live Node
C(X)- Best cost of solving X
Intelligent function/ approximation function Ĉ to C(X)
Ĉ(X) - Returns a lower bound on the cost of solving through X
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
7
Bounding Function
2:15 AM Algorithm Analysis and Design
U- Upper bound on the cost of a minimum cost solution
U can be a very high cost / the cost of reaching an already found answer state
All live nodes X with Ĉ(X)>U can be killed/ bounded.
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
8
Control Abstraction
Let bound U ← ∞ . //structure min-heap for least-cost search….
Expand from the root and generate children with some estimated cost where children are stored in “live node” L .
While( L is not empty)
{Select and remove the least cost live node as the “expansion node” E, which is the most possible node to the optimal solution.
if( c(E) < U ) then // if (c(E) > U) then E need not be expanded
{ generate children from E.
If child t’s estimated cost c(t) < U, then // if (c(t) > U) then t { Add t to L. //need not be expanded
If t is a solution node and c(t) < U, then U ← c(t) } } }
2:15 AM Algorithm Analysis and Design
9
The node with the last bound U is an optimal solution node.
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
9
More On Least Cost Search
2:15 AM Algorithm Analysis and Design
10
R
x
A
f(x)
g(x)
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
10
Least Cost (LC) Search
2:15 AM Algorithm Analysis and Design
11
Ĉ(x) =f(h(x) )+ĝ(x)
Select an e-node with least Ĉ(x)
– Breadth First Search
where x is parent of y
– Depth First Search
R
x
A
f(h(x))
ĝ(x)
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
11
LC Branch & Bound
2:15 AM Algorithm Analysis and Design
12
x
bound is known as LC branch and bound
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
12
Analysis
2:15 AM Algorithm Analysis and Design
13
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
13
Puzzles
2:15 AM Algorithm Analysis and Design
1 | 3 | 4 | 15 |
2 | | 5 | 12 |
7 | 6 | 11 | 14 |
8 | 9 | 10 | 13 |
1 | 2 | 3 | 4 |
5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 |
13 | 14 | 15 | |
An initial arrangement
Goal arrangement
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
14
8 - Puzzle
2:15 AM Algorithm Analysis and Design
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
15
Solving 8 Puzzle
2:15 AM Algorithm Analysis and Design
5
4
6
8
2
3
1
7
5
4
6
8
2
3
1
7
5
4
6
8
2
3
1
7
5
4
6
8
2
3
1
7
5
4
6
8
2
3
1
7
5
4
6
8
2
3
1
7
5
4
6
8
2
3
1
7
5
4
6
8
2
3
1
7
5
4
6
8
2
3
1
7
5
4
6
8
2
3
1
7
Goal:
↑
←
↓
←
←
→
↓
↓
←
→
↓
↑
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
16
The 15-puzzle: Cost Estimation
2:15 AM Algorithm Analysis and Design
17
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
17
Solving the 15-Puzzle - Steps
2:15 AM Algorithm Analysis and Design
18
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
18
Solving the 15-Puzzle
2:15 AM Algorithm Analysis and Design
1 | 2 | 3 | 4 |
5 | 6 | | 8 |
9 | 10 | 7 | 11 |
13 | 14 | 15 | 12 |
1 | 2 | 3 | 4 |
5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 |
13 | 14 | 15 | |
Initial
Goal
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
19
Solving the 15-Puzzle Contd..
2:15 AM Algorithm Analysis and Design
1 | 2 | 3 | 4 |
5 | 6 | | 8 |
9 | 10 | 7 | 11 |
13 | 14 | 15 | 12 |
1 | 2 | 3 | 4 |
5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 |
13 | 14 | 15 | |
Initial
Goal
ĝ(x)= number of misplaced tiles = 3
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
20
2:15 AM Algorithm Analysis and Design
21
c(2) = 1+4
c(3) = 1+4
c(4) = 1+2
c(5) = 1+4
c(10) = 2+1
c(11) = 2+3
c(12) = 2+3
U ← ∞
U ← 3
c(22) = 3+2
c(23) = 3 = f(23) and g(23) = 0
Because the costs of the remaining live nodes are
c(2) = 5, c(3) = 5, c(5) = 5, c(11) = 5, c(12) = 5, c(22) = 5.
None of the 6 nodes’ costs are less than B = 3,
thus the 6 nodes become dead nodes.
There is no live node, then
node 23 is the goal node.
That is, 3 steps is the minimum
number of steps to the goal.
Solution
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
21
Traveling Salesman Problem
2:15 AM Algorithm Analysis and Design
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
22
Definition
2:15 AM Algorithm Analysis and Design
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
23
Static State Space Tree
2:15 AM Algorithm Analysis and Design
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
i1=2
i1=3
i1=4
i2=3
i2=4
i2=2
i2=4
i2=2
i2=3
i3=4
i3=3
i3=4
i3=2
i3=3
i3=2
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
24
Applying LCBB
2:15 AM Algorithm Analysis and Design
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
25
Obtaining Cost Estimate
2:15 AM Algorithm Analysis and Design
R
x
A
f(h(x))
ĝ(x)
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
26
Principle Used
2:15 AM Algorithm Analysis and Design
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
27
Reduced Matrix
2:15 AM Algorithm Analysis and Design
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
28
Example
2:15 AM Algorithm Analysis and Design
α 20 30 10 11
15 α 16 4 2
3 5 α 2 4
19 6 18 α 3
16 4 7 16 α
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
29
Concept of Reduction
2:15 AM Algorithm Analysis and Design
i
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
30
Reducing Rows
2:15 AM Algorithm Analysis and Design
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
31
Reducing Columns
2:15 AM Algorithm Analysis and Design
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
32
Example for Row Reduction
2:15 AM Algorithm Analysis and Design
α 20 30 10 11
15 α 16 4 2
3 5 α 2 4
19 6 18 α 3
16 4 7 16 α
Cost Matrix
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
33
Reducing Rows
2:15 AM Algorithm Analysis and Design
10
2
2
3
4
α 20 30 10 11
15 α 16 4 2
3 5 α 2 4
19 6 18 α 3
16 4 7 16 α
α 10 20 0 1
13 α 14 2 0
1 3 α 0 2
16 3 15 α 0
12 0 3 12 α
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
34
Example for Column Reduction
2:15 AM Algorithm Analysis and Design
α 20 30 10 11
15 α 16 4 2
3 5 α 2 4
19 6 18 α 3
16 4 7 16 α
Cost Matrix
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
35
Reducing Column
2:15 AM Algorithm Analysis and Design
α 10 20 10 1
13 α 14 2 0
1 3 α 0 2
16 3 15 α 0
12 0 3 12 α
1
0
3
0
0
Minimum Cost
α 10 17 10 1
12 α 11 2 0
0 3 α 0 2
15 3 12 α 0
11 0 0 12 α
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
36
Minimum Cost Path
2:15 AM Algorithm Analysis and Design
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
37
Reduced Matrix
2:15 AM Algorithm Analysis and Design
1
0
3
0
0
=25
Minimum Cost
Min cost for level 2 of state space tree is 25
10
2
2
3
4
α 20 30 10 11
15 α 16 4 2
3 5 α 2 4
19 6 18 α 3
16 4 7 16 α
α 10 17 10 1
12 α 11 2 0
0 3 α 0 2
15 3 12 α 0
11 0 0 12 α
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
38
Reduced Matrix for A Child Node
Reduced matrix for a child node S of R can be obtained as
2:15 AM Algorithm Analysis and Design
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
39
Computing Ĉ (S)
2:15 AM Algorithm Analysis and Design
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
40
Reduced Cost Matrix
2:15 AM Algorithm Analysis and Design
α 10 17 0 1
12 α 11 2 0
0 3 α 0 2
15 3 12 α 0
11 0 0 12 α
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
41
Reduced Matrix – Path 1,2
2:15 AM Algorithm Analysis and Design
α α α α α
α α 11 2 0
0 α α 0 2
15 α 12 α 0
11 α 0 12 α
α 10 17 0 1
12 α 11 2 0
0 3 α 0 2
15 3 12 α 0
11 0 0 12 α
Ĉ (S) = Ĉ(R) + A(i, j) + r= 25+10+0= 35
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
42
Reduced Matrix – Path 1,3
2:15 AM Algorithm Analysis and Design
α α α α α
1 α α 2 0
α 3 α 0 2
4 3 α α 0
0 0 α 12 α
α 10 17 0 1
12 α 11 2 0
0 3 α 0 2
15 3 12 α 0
11 0 0 12 α
Ĉ (S) = Ĉ(R) + A(i, j) + r= 25+17+11= 53
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
43
Reduced Matrix – Path 1,4
2:15 AM Algorithm Analysis and Design
α α α α α
12 α 11 α 0
0 3 α α 2
α 3 12 α 0
11 0 0 α α
α 10 17 0 1
12 α 11 2 0
0 3 α 0 2
15 3 12 α 0
11 0 0 12 α
Ĉ (S) = Ĉ(R) + A(i, j) + r= 25+0+0= 25
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
44
Reduced Matrix – Path 1,5
2:15 AM Algorithm Analysis and Design
α 10 17 0 1
12 α 11 2 0
0 3 α 0 2
15 3 12 α 0
11 0 0 12 α
α α α α α
10 α 9 0 α
0 3 α 0 α
12 0 9 α α
α 0 0 12 α
Ĉ (S) = Ĉ(R) + A(i, j) + r= 25+1+5= 31
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
45
Static State Space Tree
2:15 AM Algorithm Analysis and Design
1
i2=2
6
7
8
i2=3
i2=5
25
2
3
4
i1=2
i1=3
i1=4
5
i1=5
35
53
25
31
28
50
36
52
28
28
9
10
i3=5
i3=3
11
i4=3
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
46
Reduced Matrix–Path 1,4,2 -Node 6
2:15 AM Algorithm Analysis and Design
α α α α α
α α 11 α 0
0 α α α 2
α α α α α
11 α 0 α α
α α α α α
12 α 11 α 0
0 3 α α 2
α 3 12 α 0
11 0 0 α α
Ĉ (S) = Ĉ(R) + A(i, j) + r= 25+3= 28
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
47
Reduced Matrix–Path 1,4,3 -Node 7
2:15 AM Algorithm Analysis and Design
α α α α α
1 α α α 0
α 1 α α 0
α α α α α
0 0 α α α
α α α α α
12 α 11 α 0
0 3 α α 2
α 3 12 α 0
11 0 0 α α
Ĉ (S) = Ĉ(R) + A(i, j) + r= 25+12+2+11= 50
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
48
Reduced Matrix–Path 1,4,5 -Node 8
2:15 AM Algorithm Analysis and Design
α α α α α
1 α 0 α α
0 3 α α α α α α α α
α 0 0 α α
α α α α α
12 α 11 α 0
0 3 α α 2
α 3 12 α 0
11 0 0 α α
Ĉ (S) = Ĉ(R) + A(i, j) + r= 25+0+11= 36
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
49
Reduced Matrix–Path 1,4,2,3 -Node 9
2:15 AM Algorithm Analysis and Design
α α α α α
α α α α α
α α α α 0
α α α α α
0 α α α α
α α α α α
α α 11 α 0
0 α α α 2
α α α α α
11 α 0 α α
Ĉ (S) = Ĉ(R) + A(i, j) + r= 28+11+2+11= 52
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
50
Reduced Matrix-Path 1,4,2,5-Node 10
2:15 AM Algorithm Analysis and Design
α α α α α
α α α α α
0 α α α α
α α α α α
α α 0 α α
α α α α α
α α 11 α 0
0 α α α 2
α α α α α
11 α 0 α α
Ĉ (S) = Ĉ(R) + A(i, j) + r= 28+0+0= 28
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
51
Reduced Matrix-Path 1,4,2,5,3-Node 11
2:15 AM Algorithm Analysis and Design
α α α α α
α α α α α
0 α α α α
α α α α α
α α 0 α α
Ĉ (S) = Ĉ(R) + A(i, j) + r= 28+0+0= 28
α α α α α
α α α α α
α α α α α
α α α α α
α α α α α
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
52
Dynamic Trees�
2:15 AM Algorithm Analysis and Design
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
53
Dynamic Trees
2:15 AM Algorithm Analysis and Design
2
3
Include <i,j>
1
Exclude <i,j>
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
54
Dynamic Trees Contd..
2:15 AM Algorithm Analysis and Design
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
55
Dynamic Trees Contd..
2:15 AM Algorithm Analysis and Design
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
56
Dynamic Trees Contd..
2:15 AM Algorithm Analysis and Design
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
57
Selection of Edge
2:15 AM Algorithm Analysis and Design
Edge | |
<1,4> | 1 |
<2,5> | 2 |
<3,1> | 11 |
<3,4> | 0 |
<4,5> | 3 |
<5,2> | 3 |
<5,3> | 11 |
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
58
Reduced Matrix�Include < 1,2>
2:15 AM Algorithm Analysis and Design
α α α α α
α α 11 2 0
0 α α 0 2
15 α 12 α 0
11 α 0 12 α
α 10 17 0 1
12 α 11 2 0
0 3 α 0 2
15 3 12 α 0
11 0 0 12 α
Ĉ (S) = Ĉ(R) + A(i, j) + r= 25+10+0= 35
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
59
Reduced Matrix�Exclude < 1,2>
2:15 AM Algorithm Analysis and Design
α α 17 0 1
12 α 11 2 0
0 3 α 0 2
15 3 12 α 0
11 0 0 12 α
α 10 17 0 1
12 α 11 2 0
0 3 α 0 2
15 3 12 α 0
11 0 0 12 α
Ĉ (S) = Ĉ(R) = 25
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
60
Reduced Matrix�Exclude < 3,1>
2:15 AM Algorithm Analysis and Design
α 10 17 0 1
12 α 11 2 0
α 3 α 0 2
15 3 12 α 0
11 0 0 12 α
α 10 17 0 1
12 α 11 2 0
0 3 α 0 2
15 3 12 α 0
11 0 0 12 α
Ĉ (S) = Ĉ(R) +r= 25 +11=36
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
61
Dynamic State Space Tree
2:15 AM Algorithm Analysis and Design
2
3
Include <3,1>
1
Exclude <3,1>
4
5
Include <5,3>
Exclude <5,3>
2
3
Include <1,4>
Exclude <1,4>
25
25
36
28
36
28
37
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
62
2:15 AM Algorithm Analysis and Design
Computer Science and Engineering, M.A.College of Engineering, Kothamangalam
63