Alg Unit-4
Alg Unit-4
BOUND
• Backtracking: nQueens problem (L3) - Hamiltonian
Circuit Problem (L3) - Subset Sum Problem (L3) -
Branch and Bound: Solving 15 Puzzle problem (L3) -
Assignment problem (L3) - Knapsack Problem (L3) -
Travelling Salesman Problem (TSP) (L3).
Construct the state space tree for the given subset sum
problem
A = {1, 2, 5, 6, 8} and d = 9
BRANCH AND BOUND
Possible
arrangements
Solving 15-Puzzle problem
7
Solving 15-Puzzle problem
Solving 15-Puzzle problem
Solving 15-Puzzle problem
Solving 15-Puzzle problem
Solving 15-Puzzle problem
Assignment
6
Problem
ASSIGNMENT
7
PROBLEM
There are n people who need to be assigned to
execute n jobs, one person per job. (That is, each
person is assigned to exactly one job and each job
is assigned to exactly one person.)
The cost that would accrue if the ith person is
Machine I 10 5 12 8
Machine II 12 10 14 15
Machine III 19 7 13 11
Machine IV 11 8 11 9
19
Knapsack
Problem
Knapsack
Problem
20
= 0+10(10)
w=0 v= 0
= 100
UB = 100
Node 1: Node 2:
UB = v+(W-w)(v2/w2) UB = v+(W-w)(v2/w2)
= 40+(10-4) (6) = 0+(10) (6)
= 40+36 = 0+60
=76 =60
24
Node 4:
UB = v+(W-w)(v3/w3)
= 40+(10-4) (5)
= 40+30
25
= 70
Node 5:
UB = v+(W-w)(v4/w4)
= 65+(10-9) (4)
= 65+4
= 69
Node 6:
UB = v+(W-w)(v4/w4)
= 40+(10-4) (4)
= 40+ 24
26
= 64
Node 8:
UB = v+(W-w)(v5/w5)
= 65+(10-9) (0)
= 65+0
= 65
27
The remaining live nodes 2
and
6 have smaller upper-bound
values than the value of the
solution represented by node
8.
LBat Node 1:
Lb=[(1+ 3) + (3 + 6) + (1+ 2) + (3 + 4) + (2 + 3)]/2 = 28/2=14
LBat Node 3:
Lb=[(1+
34 5) + (3 + 6) + (1+ 2) + (5 + 3) + (2 + 3)]/2 = 31/2 =16
Node 4
LBat Node 4:
Lb=[(1+ 8) + (3 + 6) + (1+ 2) + (3 + 4) + (2 + 8)]/2 = 38/2=19
35
•There are three live nodes namely 1, 3 and 4.
•Among whichnode 1 has the most promising
node. We can explore the node 1.
•At level 2, there are three options for the
salesman, he can visit c or d or e.
•36So there are three children for node 1.
LBat Node 5:
Lb=[(1+
37 3) + (3 + 6) + (1+ 6) + (3 + 4) + (2 + 3)]/2 = 32/2=16
LBat Node 6:
Lb=[(1+
38 3) + (3 + 7) + (1+ 2) + (3 + 7) + (2 + 3)]/2 = 32/2=16
LBat Node 7:
Lb=[(1+
39 3) + (3 + 9) + (1+ 2) + (3 + 4) + (2 + 9)]/2 = 37/2=19
✓ Live nodes : 3, 4, 5, 6 and 7.
✓ In which Nodes 3, 5 and 6 are most promising nodes. We
will explore node 5.
✓ Node five represents the path a → b → c. Now salesman
have two options either he can visit d or e.
✓ In addition, after visiting n − 1= 4 cities, a tour has no
choice but to visit the remaining unvisited city and return
to the starting
LBat Node 8:
Lb=[(8+
41 3) + (3 + 6) + (6+ 4) + (3 + 4) + (3 + 8)]/2 = 48/2= 24
LBat Node 9:
Lb=[(5+
42 3) + (3 + 6) + (6+ 2) + (3 + 5) + (3 + 2)]/2 = 38/2= 19
❖ Node 8 and 9 represents solution with the cost of 24 and 19 respectively.
❖ Node 9 ( Tour : a → b → c → e → d → a) has better solution (cost : 19) compared
to Node 8 (Tour : a → b → c → d → e → a) with cost 24.
❖ Live Nodes: 3, 4, 6 and 7
❖ Live nodes 3 and 6 has lower bound than solution represented by node 9.
❖ Now we are exploring the node 6 (Path : a → b → d)
43
❖ Now salesman have two options either he can visit c or e.
LBat Node 10:
Lb=[(8+
44 3) + (3 + 7) + (4+ 2) + (4 + 7) + (8 + 2)]/2 = 48/2= 24
LBat Node 11:
Lb=[(1+
45 3) + (3 + 7) + (1+ 2) + (3 + 7) + (3 + 2)]/2 = 32/2= 16
Optimal
Solution
46
Node 11:
🞑 Tour : a → b → d → c → e → a
🞑 Cost : 16