0% found this document useful (0 votes)
229 views14 pages

Branch and Bound

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 14

Branch and Bound

15 Puzzle Problem

Random Arrangement Desired Arrangement

1 2 15 5 1 2 3 4

4 3 6 5 6 7 8

14 13 12 9 9 10 11 12

10 11 7 8 13 14 15

Empty slot can move Goal is to have desired


Left/right/top/bottom a arrangement in
number of times to get the minimum number of
desired arrangement moves
Possible Moves
Total permutation= 16! 1 2 15 5
State space tree will be huge! 4 3 6
14 13 12 9 left
bottom
10 11 7 8 1 2 15 5
1 2 15 5
4 3 6
4 13 3 6
top 14 13 12 9
14 12 9 right
10 11 7 8
10 11 7 8
1 2 15 5 1 15 5
4 3 6 4 2 3 6
14 13 12 9 14 13 12 9
10 11 7 8 10 11 7 8
Possible Moves
1 2 15 5
4 3 6
14 13 12 9
bottom 10 11 7 8

1 2 15 5
4 13 3 6
14 12 9
10 11 7 8
Possible Moves
1 2 15 5
4 3 6
14 13 12 9
bottom 10 11 7 8

1 2 15 5
Can’t move TOP, it will result back
4 13 3 6 into previous state
14 12 9
10 11 7 8
left
right bottom
1 2 15 5 1 2 15 5
1 2 15 5
4 13 3 6 4 13 3 6
4 13 3 6
14 12 9 14 11 12 9
14 12 9
10 11 7 8 10 7 8
10 11 7 8
Problem Solving
• Cannot try all possible solutions!
• Cannot build state space tree
– Branch for each move…. Very large…
• Need some heuristics to simplify the search
• Heuristics decide the fate of state space tree
– decides which sub-child to selected for branching
– and which should be pruned (bounded)
Heuristic for 15 puzzle
• For a state node ‘x’ in state space tree let its cost be
defined as:
𝑐 (𝑥) = 𝑓 𝑥 + 𝑔(𝑥)
• 𝑐 (𝑥) =estimated min cost to reach the goal node
• 𝑓 𝑥 length of path from root to node ‘x’
• 𝑔(𝑥) =estimate of length of shortest path from node
‘x’ to a goal node in subtree with root ‘x’

• Here 𝑔(𝑥) =number of non blank tiles not in


their goal position.
state space tree 1 1 2 3 4
5 6 8
9 10 7 11
13 14 15 12
B L 5
2 T R
1 2 4 3 1 2 3 4 4 1 2 3 4 1 2 3 4
5 6 3 8 5 6 7 8 5 6 8
5 6 8
9 10 7 11 9 10 11 9 10 7 11
9 10 7 11
13 14 15 12 13 14 15 12 13 14 15 12
13 14 15 12

• Four board arrangements possible..


• Need to find which may be best arrangement
closest to desired arrangement
state space tree 1 1 2 3 4
5 6 8
9 10 7 11
13 14 15 12 f 𝑥 =1
f 𝑥 =1 5
2 T f 𝑥 =1 R f 𝑥 =1 B L
1 2 4 3 1 2 3 4 4 1 2 3 4 1 2 3 4
5 6 3 8 5 6 7 8 5 6 8
5 6 8
9 10 7 11 9 10 11 9 10 7 11
9 10 7 11
13 14 15 12 13 14 15 12 13 14 15 12
13 14 15 12
𝑔(𝑥) = 4
𝑔(𝑥) = 4 𝑔(𝑥) = 4 𝑔(𝑥) = 2

Select the branch from where we can reach the


desired arrangement in min number of moves…
state space tree 1 1 2 3 4
5 6 8
9 10 7 11
13 14 15 12 f 𝑥 =1
f 𝑥 =1 5
2 T f 𝑥 =1 R f 𝑥 =1 B L
1 2 4 3 1 2 3 4 4 1 2 3 4 1 2 3 4
5 6 3 8 5 6 7 8 5 6 8
5 6 8
9 10 7 11 9 10 11 9 10 7 11
9 10 7 11
13 14 15 12 13 14 15 12 13 14 15 12
13 14 15 12
𝑔(𝑥) = 4
𝑔(𝑥) = 4 𝑔(𝑥) = 4 𝑔(𝑥) = 2
bound bound branch bound

Select the branch from where we can reach the


desired arrangement in min number of moves…
state space tree 1 1 2 3 4
5 6 8
9 10 7 11
13 14 15 12 f 𝑥 =1
f 𝑥 =1 5
2 T f 𝑥 =1 R f 𝑥 =1 B L
1 2 4 3 1 2 3 4 4 1 2 3 4 1 2 3 4
5 6 3 8 5 6 7 8 5 6 8
5 6 8
9 10 7 11 9 10 11 9 10 7 11
9 10 7 11
13 14 15 12 13 14 15 12 13 14 15 12
13 14 15 12
𝑔(𝑥) = 2 𝑔(𝑥) = 4
𝑔(𝑥) = 4 𝑔(𝑥) = 4
R
B L
1 2 3 4 1 2 3 4 1 2 3 4
5 6 7 8 5 6 7 8 5 6 7 8
9 10 11 9 10 15 11 9 10 11
13 14 15 12 13 14 12 𝑔(𝑥) = 3
13 14 15 12
𝑔(𝑥) = 1
𝑔(𝑥) = 3
state space tree 1 1 2 3 4
5 6 8
9 10 7 11
13 14 15 12 f 𝑥 =1
f 𝑥 =1 5
2 T f 𝑥 =1 R f 𝑥 =1 B L
1 2 4 3 1 2 3 4 4 1 2 3 4 1 2 3 4
5 6 3 8 5 6 7 8 5 6 8
5 6 8
9 10 7 11 9 10 11 9 10 7 11
9 10 7 11
13 14 15 12 13 14 15 12 13 14 15 12
13 14 15 12
𝑔(𝑥) = 2 𝑔(𝑥) = 4
𝑔(𝑥) = 4 𝑔(𝑥) = 4
R
B L
1 2 3 4 1 2 3 4 1 2 3 4
5 6 7 8 5 6 7 8 5 6 7 8
9 10 11 9 10 15 11 9 10 11
13 14 15 12 13 14 12 13 14 15 12
𝑔(𝑥) = 1
𝑔(𝑥) = 3 𝑔(𝑥) = 3
branch
bound bound
state space tree 1 1 2 3 4
5 6 8
9 10 7 11
13 14 15 12 f 𝑥 =1
f 𝑥 =1 5
2 T f 𝑥 =1 R f 𝑥 =1 B L
1 2 4 3 1 2 3 4 4 1 2 3 4 1 2 3 4
5 6 3 8 5 6 7 8 5 6 8
5 6 8
9 10 7 11 9 10 11 9 10 7 11
9 10 7 11
13 14 15 12 13 14 15 12 13 14 15 12
13 14 15 12
𝑔(𝑥) = 2 𝑔(𝑥) = 4
𝑔(𝑥) = 4 𝑔(𝑥) = 4
R 𝑔(𝑥) = 3 B L
1 2 3 4 1 2 3 4 1 2 3 4
5 6 7 8 5 6 7 8 5 6 7 8
9 10 11 9 10 15 11 9 10 11
13 14 15 12 13 14 12 13 14 15 12
𝑔(𝑥) = 1
𝑔(𝑥) = 3
1 2 3 4
B 1 2 3 4
5 6 7 8 5 6 7
T
9 10 11 12 9 10 11 8
13 14 15 13 14 15 12
state space tree 1 1 2 3 4
5 6 8
9 10 7 11
13 14 15 12 f 𝑥 =1
f 𝑥 =1 5
2 T f 𝑥 =1 R f 𝑥 =1 B L
1 2 4 3 1 2 3 4 4 1 2 3 4 1 2 3 4
5 6 3 8 5 6 7 8 5 6 8
5 6 8
9 10 7 11 9 10 11 9 10 7 11
9 10 7 11
13 14 15 12 13 14 15 12 13 14 15 12
13 14 15 12
𝑔(𝑥) = 2 𝑔(𝑥) = 4
𝑔(𝑥) = 4 𝑔(𝑥) = 4
R 𝑔(𝑥) = 3 B L
1 2 3 4 1 2 3 4 1 2 3 4
5 6 7 8 5 6 7 8 5 6 7 8
9 10 11 9 10 15 11 9 10 11
13 14 15 12 13 14 12 13 14 15 12
𝑔(𝑥) = 1
𝑔(𝑥) = 3
1 2 3 4
B 1 2 3 4
5 6 7 8 5 6 7
T
9 10 11 12 9 10 11 8
13 14 15 13 14 15 12

You might also like