communication engineering
communication engineering
UNIT – V
Branch And Bound: Least Cost search – 15 puzzle – control abstractions for LC search – bounding –
FIFO Branch and bound – LC branch and Bound - Knapsack problem: LC branch and bound – FIFO
branch and bound solutions – Traveling salesman problem – assignment problem
The design technique known as branch and bound is very similar to backtracking(seen in unit 4) in that it
searches a tree model of the solution space and is applicable to a wide variety of discrete combinatorial
problems.
Each node in the combinatorial tree generated in the last Unit defines a problem state. All paths from the
root to other nodes define the state space of the problem.
Solution states are those problem states 's' for which the path from the root to 's' defines a tuple in the
solution space. The leaf nodes in the combinatorial tree are the solution states.
Answer states are those solution states 's' for which the path from the root to 's' defines a tuple that is a
member of the set of solutions (i.e.,it satisfies the implicit constraints) of the problem.
The tree organization of the solution space is referred to as the state space tree.
A node which has been generated and all of whose children have not yet been generated is called a live node.
The live node whose children are currently being generated is called the E-node (node being expanded).
A dead node is a generated node, which is not to be expanded further or all of whose children have been
generated.
Bounding functions are used to kill live nodes without generating all their children.
Depth first node generation with bounding function is called backtracking. State generation methods in
which the E-node remains the E-node until it is dead lead to branch-and-bound method.
The term branch-and-bound refers to all state space search methods in which all children of the E-node are
generated before any other live node can become the E-node.
In branch-and-bound terminology breadth first search(BFS)- like state space search will be called FIFO
(First In First Output) search as the list of live nodes is a first -in-first -out list(or queue).
A D-search (depth search) state space search will be called LIFO(Last In First Out)search, as the list of live
nodes is a list-in-first-out list (or stack).
Bounding functions are used to help avoid the generation of subtrees that do not contain an answer node.
The branch-and-bound algorithms search a tree model of the solution space to get the solution. However,
this type of algorithms is oriented more toward optimization. An algorithm of this type specifies a real -valued
cost function for each of the nodes that appear in the search tree.
Usually, the goal here is to find a configuration for which the cost function is minimized. the branch-and-
bound algorithms are rarely simple. they tend to be quite complicated in many cases.
Example 8.1[4-queens] Let us see how a FIFO branch-and-bound algorithm would search the state space tree
(figure 7.2) for the 4-queens problem.
1 Department of IT
DESIGN AND ANALYIS OF ALGORITHM
Initially, there is only one live node, node1. This represents the case in which no queen has been placed on the
chessboard. This node becomes the E-node.
These nodes represent a chessboard with queen1 in row 1and columns 1, 2, 3, and 4 respectively.
The only live nodes 2, 18, 34, and 50.If the nodes are generated in this order, then the next E-node is node 2.
It is expanded and the nodes 3,8, and 13 are generated. Node 3 is immediately killed using the bounding
function. Nodes 8 and 13 are added to the queue of live nodes.
Node 18 becomes the next E-node. nodes 19,24, and 29 are generated. Nodes 19 and 24 are killed as a result
of the bounding functions. Node 29 is added to the queue of live nodes.
Now the E-node is node 34.Figure 8.1 shows the portion of the tree of Figure 7.2 that is generated by a FIFO
branch-and-bound search. Nodes that are killed as a result of the bounding functions are a "B" under them.
Numbers inside the nodes correspond to the numbers in Figure 7.2.Numbers outside the nodes give the order
in which the nodes are generated by FIFO branch-and-bound.
At the time the answer node, node 31, is reached, the only live nodes remaining are nodes 38 and 54.
2 Department of IT
DESIGN AND ANALYIS OF ALGORITHM
In both LIFO and FIFO branch-and-bound the selection rule for the next E-node is rather rigid and in a
sense blind. The selection rule for the next E-node does not give any preference to a node that has a very good
chance of getting the search to an answer node quickly.
Thus, in Example 8.1, when node 30 is generated, it should have become obvious to the search algorithm
that this node will lead to answer node in one move. However, the rigid FIFO rule first requires the expansion
of all live nodes generated before node 30 was expanded.
The search for an answer node can often be speeded by using an "intelligent" ranking function (.) for live
nodes. The next E-node is selected on the basis of this ranking function.
If in the 4-queens example we use a ranking function that assigns node 30 a better rank than all other live
nodes, then node 30 will become E-node following node 29.The remaining live nodes will never become E-
nodes as the expansion of node 30 results in the generation of an answer node (node 31).
The ideal way to assign ranks would be on the basis of the additional computational effort (or cost) needed
to reach an answer node from the live node.For any node x, this cost could be
(1) The number of nodes on the sub-tree x that need to be generated before any answer node is generated
or, more simply,
(2) The number of levels the nearest answer node (in the sub-tree x) is from x
Using cost measure (2), the cost of the root of the tree of Figure 8.1 is 4 (node 31 is four levels from node
1).The costs of nodes 18 and 34,29 and 35,and 30 and 38 are respectively 3, 2, and 1.The costs of all remaining
nodes on levels 2, 3, and 4 are respectively greater than 3, 2, and 1.
Using these costs as a basis to select the next E-node, the E-nodes are nodes 1, 18, 29, and 30 (in that
order).The only other nodes to get generated are nodes 2, 34, 50, 19, 24, 32, and 31.
The difficulty of using the ideal cost function is that computing the cost of a node usually involves a search
of the sub-tree x for an answer node. Hence, by the time the cost of a node is determined, that sub-tree has been
searched and there is no need to explore x again. For this reason, search algorithms usually rank nodes only on
the basis of an estimate (.) of their cost.
Let (x) be an estimate of the additional effort needed to reach an answer node from x. node x is assigned a
rank using a function (.) such that (x)=f(h(x))+ (x),where h(x) is the cost of reaching x from the root and f(.)
is any non-decreasing function.
A search strategy that uses a cost function (x)=f(h(x))+ (x), to select the next e-node would always choose
for its next e-node a live node with least (.).Hence, such a strategy is called an LC-search(least cost search).
Cost function c(.) is defined as,if x is an answer node ,then c(x) is the cost (level, computational difficulty,etc.)
of reaching x from the root of the state space tree . If x is not an answer node, then c(x)=infinity, providing the
sub-tree x contains no answer node; otherwise c(x) is equals the cost of a minimum cost answer node in the
3 Department of IT
DESIGN AND ANALYIS OF ALGORITHM
sub-tree x.
It should be easy to see that (.) with f(h(x))=h(x) is an approximation to c(.). From nou on (x) is referred to
as the cost of x.
Bounding :
A branch -and-bound searches the state space tree using any search mechanism in which all the children
of the E-node are generated before another node becomes the E-node .
We assume that each answer node x has a cost c(x) associated with it and that a minimum-cost answer
node is to be found. Three common search strategies are FIFO,LIFO,and LC.
A cost function (.) such that (x)<=c(x) is used to provide lower bounds on solutions obtainable from
any node x.If upper is an upper bound on the cost of a minimum-cost solution, then all live nodes x with
(x)>upper may be killed as all answer nodes reachable from x have cost c(x)>= (x)>upper. The starting value
for upper can be set to infinity.
Clearly, so long as the initial value for upper is no less than the cost of a minimum-cost answer node, the
above rule to kill live nodes will not result in the killing of a live node that can reach a minimum-cost answer
node .Each time a new answer is found ,the value of upper can be updated.
As an example optimization problem, consider the problem of job scheduling with deadlines. We
generalize this problem to allow jobs with different processing times. We are given n jobs and one processor.
Each job i has associated with it a three tuple
( ).job i requires units of processing time .if it's processing is not completed by the deadline , then
a penalty is incurred.
The objective is to select a subset j of the n jobs such that all jobs in j can be completed by their deadlines.
Hence, a penalty can be incurred only on those jobs not in j.The subset j should be such that the penalty incurred
is minimum among all possible subsets j. such a j is optimal.
Consider the following instances: n=4,( , , )=(5,1,1),( , , )=(10,3,2),( , , )=(6,2,1),and(
, , )=(3,1,1).The solution space for this instances consists of all possible subsets of the job index
set{1,2,3,4}. The solution space can be organized into a tree by means of either of the two formulations used
for the sum of subsets problem.
4 Department of IT
DESIGN AND ANALYIS OF ALGORITHM
Figure 8.6 corresponds to the variable tuple size formulations while figure 8.7 corresponds to the fixed tuple
size formulation. In both figures square nodes represent infeasible subsets. In figure 8.6 all non-square nodes
are answer nodes. Node 9 represents an optimal solution and is the only minimum-cost answer node .For this
node j={2,3} and the penalty (cost) is 8. In figure 8.7 only non-square leaf nodes are answer nodes. Node 25
represents the optimal solution and is also a minimum-cost answer node. This node corresponds to j={2,3} and
a penalty of 8. The costs of the answer nodes of figure 8.7 are given below the nodes.
In LIFO Method, the selection (generation) of next E-node is a rigid one. The next E-node is selected in
terms of level by level.
The nodes in current level are expanded first and then go to the next level.
This process is repeated until the nearest answer node is found
5 Department of IT
DESIGN AND ANALYIS OF ALGORITHM
In FIFO, it takes more time to search the nearest answer node, because of expansion of all nodes in each
level
Because of FIFO takes more time to search the nearest answer node we go for Least cost search(LC)
method
In LC search method, we can speed up the searching by ranking (cost) function.
A search strategy that uses a cost function
C’(x)=f(h(x)+g’(x))
to select the next E-node (current live node is chosen as next E-node) with least Cost. Hence such a
strategy is called LC search
h(x) – cost of reaching x from root (no of levels form root to any node x)
g(x)-cost of reaching a nearest answer node(answer node with minimum cost) from any node
x(no of levels form any node x to a nearest answer node)
listnode = record
{
listnode *next,
*parent; Float cost;
}
Algorithm LC Search(t)
\\ Search t for an answer node
{
If *t is an answer node then output *t and return;
E = t ; \\ E-node
Initialize the list of live nodes to be
empty; Repeat
{
For each child x of E do
{
If x is an answer node the output the
path from x to t and return
6 Department of IT
DESIGN AND ANALYIS OF ALGORITHM
Algorithm explanation:-
Example
15 Puzzle Problems
the 15 puzzle consists of 15 numbered tiles on a square frame with a capacity of 16 tiles
Initial arrangement of the tiles are given, the objective of the problem is to transform this arrangement
into the goal arrangement through a series of legal moves.
The legal moves are ones in which a tile adjacent to the empty spot is moved to Empty Spot
1 2 3 4
7 Department of IT
DESIGN AND ANALYIS OF ALGORITHM
5 6 7 8
9 10 11 12
13 14 15
1 2 3 4
5 6 7 8
9 10 12
13 14 15 11
C’(2)=1+4 = 5
C’(3)=1+4 = 5
C’(4)=1+2 = 3 (least cost node)
C’(5)=1+4 = 5
The live node with least C’ is node 4, which becomes the next E-node. It generates all its children
10,11 and becomes dead node
The live nodes are 2,3,5,10,11 and 12
To determine the next E-node, C’(x) is computed for all live nodes and the live node with least C’(x)is
selected as next E-node
C’(x)=f(x)+g’(x)
8 Department of IT
DESIGN AND ANALYIS OF ALGORITHM
C’(2)=1+4 = 5
C’(3)=1+4 = 5
C’(5)=1+4 = 5
C’(10)=2+1 = 3 (least cost node)
C’(11)=2+3 = 5
The live node with least C’ is node10, which becomes the next E-node. It generates all its
children 22 and 23 and becomes dead node
The node 23 is determined as goal node and the search terminates
In this case LC search is as efficient as using exact function C’ ()
The LC search will be far more selective than any other search methods
KNAPSACK PROBLEM
To use branch and bound technique to solve any problem, it is first necessary to conceive of a state
space tree for the problem.
Branch and bound technique is used to solve minimization problem(eg 15 puzzle, 4 queen, node with
minimum cost is selection criteria)
The branch and bound technique can not be applied directly in the knapsack problem , because the
knapsack problem is a maximization problem(eg maximum profit is the selection criteria)
This difficulty is easily overcome by replacing the objective function ∑PiXi by the function -∑PiXi
The modified knapsack problem is stated as
n
Minimize - ∑pixi
i=1
n
subject to ∑wixi<=m
i=1
xi=0 or 1, 1<=I<=n
Every leaf node in the state space tree representing an assignment for which
9 Department of IT
DESIGN AND ANALYIS OF ALGORITHM
Example
Consider the knapsack instance n=4,(p1,p2,p3,p4)=(10,20,12,18),(w1,w2,w3,w4)=2,4,6,9), and
m=15
there are two methods to solve the knapsack problem
Algorithm Ubound(cp,cw,k,m)
// cp is the current profit total ,cw is the current weight total; k is the index of the last removed item; and m is
the knapsack size//
{
b=cp; c=cw;
for I=k+1 to n do
{
if((c+w[I])<=m) then
{
c=c+w[I]; b=b-p[I];
}
}
return b;
}
b=0; c=0;
for i= 1 to 4
i=1;
if ((c+w[1])<=m} (c=0 and w[1]=2 and 0+2=>2<=15) true
c=0+2= 2
b=0-10= -10
i=2
if ((c+w[2])<=m} (c=2 and w[2]=4 and 2+4=6<=15) true
c=2+4=6
b=-10-10= -20
i=3
if ((6+w[3])<=m} (c=6 and w[2]=6 and 6+6=12<=15) true
c=6+6=12
b=-20-12= -32
i=4
if ((15+w[4])<=m} (c=12 and w[2]=9 and 12+9=21<=15) False
10 Department of IT
DESIGN AND ANALYIS OF ALGORITHM
for any node x in the state space tree, we compute c’(x) and u(x) and upper
for any node x , if c’(x)>upper the node x is killed immediately
initially the upper =u(1) and then the upper is updated by the node with minimum u(x) value in current
level
u() for root node is calculated using the algorithm Ubound or (-∑ fully included objects
u(1)=b(return value of UBound algorithm)=-32 (objects1, 2 and 3 are fully includes so -∑ p1+p2+p3 =-
(10+10+12)=-32)
Node 1
Initially, first 3 whole objects and part of 4 th object are included in the knapsack, that is (1,1,1,3/9)
c’(1)= -
1*10+1*10+1*12+3/9*18 =
-32
upper=u(1)=-32(-∑ fully(not a part of object) included objects (that is1, 2 and 3 ) -∑p1+ p2+p3 =-
(10+10+12)=-32)
E-node node 1 generates all its children 2,3 and becomes dead node. Now node 2 and 3 are live nodes.
To determine the next E-node compute c’(x),u(x) and upper for live nodes 2 and 3
2 3
Node 2
If first object is included (already the first object is included in node 1 so same value is obtained for c’(2)
) status of Included objects; (1,1,1,3/9)
c’(2)= -
1*10+1*10+1*12+3/9*18 =
-38
u(1)=-32(-∑ fully included objects (tat is1, 2 and 3 ) -∑p1+ p2+p3 =-(10+10+12)=-32)
Node 3
If first object is not included , status of Included( objects;
(0,1,1,5/9) c’(3)= - 0*10+1*10+1*12+5/9*18
= -32
u(3)=-22(-∑ fully included objects (tat is 2 and 3 ) -∑ p2+p3 =-(10+12)=-22)
upper=min{u(2),u(3)}
=min{-32,-
22}
upper=-32
if c’(2) and c’(3) < upper, so node 2 and 3 are not killed and are live nodes
The node 3 becomes the next E-node because c’(2)=-38<c’(3)=-32
Node 3 generates all its children 4, 5
11 Department of IT
DESIGN AND ANALYIS OF ALGORITHM
2 3
4 5
Node 4
If second object is included (already the third object is included in node 1, 2 so same value is obtained
for c’(4) ) status of Included( objects; (1,1,1,3/9)
c’(4)= - 1*10+1*10+1*12+3/9*18
= -38
u(4)=-32(-∑ fully included objects (tat is1, 2 and 3 ) -∑p1+ p2+p3 =-(10+10+12)=-32)
Node 5
If second object is not included, status of Included objects; (1,,
0,1,7/9) c’(5)= - 1*10+0*10+1*12+7/9*18
= -36
u(5)=-22(-∑ fully included objects (that is 1 and 3 ) -∑ p1+p3 =-(10+12)=-22)
upper=min{u(4),u(5)}
=min{-32,-22}
upper=-32
if c’(4) and c’(5) < upper, so node 4 and 5 are not killed and are live nodes
Within the live nodes 4 and 5,the node 4 becomes the next E-node because c’(4)=-38<c’(5)=-36
Node 4 generates all its children 6,7
1
2 3
4 5
12 Department of IT
DESIGN AND ANALYIS OF ALGORITHM
6 7
Node 6
If third object is included (already the third object is included in node 1, 2, 4, so same value is obtained for
c’(6) ) status of Included objects; (1,1,1,3/9)
c’(6)= - 1*10+1*10+1*12+3/9*18
= -38
u(6)=-32(-∑ fully included objects (tat is1, 2 and 3 ) -∑p1+ p2+p3 =-(10+10+12)=-32)
Node 7
upper=min{u(6),u(7)}
=min{-32,-
38} upper=-38
if c’(6) and c’(7) = upper, so node 4 and 5 are not killed and are live nodes
Within the live nodes 6 and 7,the node 7 becomes the next E-node because u(7)=-38<u(6)=-32
(c’(6)=-38 is equal to c’(7)=-36 so compare u(x)))
Node 7 generates all its children 8,9
2 3
4 5
6
7
8
9
13 Department of IT
DESIGN AND ANALYIS OF ALGORITHM
Node 8
If fourth object is included status of Included objects;
(1,1,0,1) c’(6)= - 1*10+1*10+0*12+1*18
= -38
u(8)=-38(-∑ fully included objects (tat is1, 2 and 4 ) -∑p1+ p2+p4 =-(10+10+18)=-38)
Node 9
If fourth object is not included ,status of Included objects; (1,1,0,0)
c’(7)= - 1*10+1*10+0*12+0*18= -20
u(7)=-20(-∑ fully included objects (tat is 1 and 2 ) -∑ p1+p2 =-(10+10)=-20)
upper=min{u(8),u(9)}
=min{-38,-20}
upper=-38
if c’(9)=-20 > upper, so node and 9 is killed
Nodes 6 and 8 are live nodes with least costs. Regardless of which becomes the next
E-node ,c’(E)>=upper and the search terminates with node 8, the answer node
At this time the value of upper –38 together with the path 8,7,4,2,1 is printed
As output
FIFO Branch and Bound
for any node x in the state space tree, we compute c’(x) and u(x) and upper
for any node x , if c’(x)>upper the node x is killed immediately
initially the upper =u(1) and then the upper is updated by the node with minimum u(x) value in current level
u() for root node is calculated using the algorithm Ubound or (-∑ fully included objects
u(1)=b(return value of UBound algorithm)=-32 (objects1, 2 and 3 are fully includes so -∑ p1+p2+p3 =-
(10+10+12)=-32)
Initially the root node, node1 is the E-node and queue of live nodes are empty
Since this is not a solution node, upper is initialize to u(1)
Assume that, the children of a node are generated left to right. Node 2 and 3 are generated and added to
the queue
2
3
4 5 7
6
8 9
14 Department of IT
DESIGN AND ANALYIS OF ALGORITHM
10 11 12 13
15 Department of IT
DESIGN AND ANALYIS OF ALGORITHM
INTRODUCTION :
It is algorithmic procedure similar to backtracking in which a new branch is chosen
and is there (bound there) till new branch is choosing for advancing.
This technique is implemented in the traveling salesman problem [TSP]
which are asymmetric (Cij <>Cij) where this technique is an effective procedure.
16
DESIGN AND ANALYIS OF ALGORITHM
22 5
27 1 25
9 19
25
5 8 2
1
50
10 31 17 15
6 40
30
7 3
4
6
24
Step 0:Generate Cost Matrix
1 2 3 4 5
25 40 31 27
1
5 17 30 25
2
19 15 6 1
3
9 50 24 6
4
22 8 7 10
5
Phase 1:
Step1: Row Reduction in C.
In R1,an edge <1,2> = 25
In R2,an edge <2,1> = 5
In R3,an edge <3,5> = 1
In R4,an edge <4,5> = 6
In R5,an edge <5,3> = 7
Subtract these elements from other elements.
1 2 3 4 5
0 15 6 2
1
0 12 25 20
2
18 14 5 0
3
3 44 18 0
4
15 1 0 3
5
17
DESIGN AND ANALYIS OF ALGORITHM
1 2 3 4 5
0 15 3 2
1
0 12 25 20
2
18 14 2 0
3
3 44 18 0
4
15 1 0 3
5
Step 5:
Preserve the above in C1,
1 2 3 4 5
0 15 3 2
1
0 12 22 20
2
18 14 2 0
3
3 44 18 0
4
5 15 1 0 3
18
DESIGN AND ANALYIS OF ALGORITHM
Step 10: The order of reduced Cost matrix 2 x 2 .Therefore goto step 1.
Phase 2:
Step 1 : Do RR
2 3 4 5
1 13 1 0
3 14 2 0
4 44 18 0
5 1 0 0
Step 3: Do CR
2 3 4 5
1 13 1 0
3 13 2 0
4 43 18 0
5 0 0 0
19
DESIGN AND ANALYIS OF ALGORITHM
C2 = 2 3 4 5
1 13 1 0
3 13 2 0
4 43 18 0
5 0 0 0
Step 10: The order of cost matrix 2x2 hence goto step 1
Phase 3:
Step 1: Do RR
2 3 4
1
12 0
3 11 0
5 0 0
Step 3: Do CR
20
DESIGN AND ANALYIS OF ALGORITHM
2 3 4
1
12 0
3
5
11 0
0 0
Step 5: Preserve the above in C3
2 3 4
1
12 0
11 0
0 0
Step 6: L={(1,4), (3,4), (5,2), (5,3)}
Step 7: Calculation of E.C
EC of edge (1,4)=12+0=12
EC of edge (3,4)=11+0=11
EC of edge (5,2)=0+11=11
EC of edge (5,3)=0+12=12
Step 8: Here we are having two edges (1,4) and (5,3) with cost = 12. Hence arbitrarily
choose (1,4)
Step 9: Delete (1,4).Change (4,1) = if exists.
Now cost matrix is
2 3
2 11
3 0 0
3 0
5 0 0
Do CR:
2 3
3 0
5 0 0
Therefore C4 =
2 3
3 0
5 0 0
21
DESIGN AND ANALYIS OF ALGORITHM
C4 : 2 3
3
5
0
0 0
C3: 2 3 4
1
12 0
3
5
11 0
0 0
C2 :
2 3 4 5
1 13 1 0
3
13 2 0
4
5 43 18 0
0 0 0
C1:
1 2 3 4 5
1 0 15 3 2
2
0 12 22 20
3
4 18 14 2 0
5 3 44 18 0
15 1 0 0
Step 12:
Use C4 = 2 3
3 0
5 0 0
Use C3 = 2 3 4
1
12 0
3
5
11 0
0 0
22
DESIGN AND ANALYIS OF ALGORITHM
Use C2=
2 3 4 5
1 13 1 0
3 13 2 0
43 18 0
4
0 0 0
5
Pick up an edge (i, j) with least cost index. Here (1,5) → not possible. B’coz city1 has
already choosen. Then (3,5) → not possible as already chosen index.
Next choose (4,5) →0
Hence, T (3,2), (1,4), (4,5)
Use C1 =
1 2 3 4 5
1 0 15 3 2
2
0 12 22 20
3
4 18 14 2 0
5 3 44 18 0
15 1 0 0
Pick up an edge (i, j) with least index.
(1,2) → Not possible
(2,1) → Choose it
Hence T (3,2), (1,4), (4,5), (2,1)
Solution:
From the above list
3—>2—>1—>4—>5
Now this results , Travelling Salesperson started his tour from city3 and visited
city2,city1,city4 ,city 5 and returned to the starting city3.
Final result:
3—>2—>1—>4—>5—>3
Cost is 15+15+31+6+7=64
A branch -and-bound searches the state space tree using any search mechanism in
which all the children of the E-node are generated before another node becomes
the E-node.
We assume that each answer node x has a cost c(x) associated with it and that a
minimum-cost answer node is to be found. Three common search strategies are
FIFO, LIFO, and LC.
23
DESIGN AND ANALYIS OF ALGORITHM
A cost function (.) such that (x) <=c(x) is used to provide lower bounds on
solutions obtainable from any node x.
If upper is an upper bound, then all live nodes x with (x)>upper may be killed
as all answer nodes reachable from x have cost c(x)>=c’(x)>upper6
The starting value for upper can be set to infinity.
Each time a new answer node is found, the value of upper can be updated
C’(x) and upper and c(x) can be computed using formulas
Example
Job Sequencing Problem
Given n jobs and one processor
Each job i is
defined as 3
tuples(Pi,di,ti) ti -
processing time in
units
di - deadline
Pi - penalty, if the job I is not completed within the deadline, then penalty
Pi is incurred
Let us assume that n=4 (P1,d1,t1) = (5,1,1) (P2,d2,t2) = (10,3,2) (P3,d3,t3) = (6,2,1)
(P4,d5,t4) = (3,1,1)
solution space for this instance consist of all possible subsets of the
job index set (1,2,3,4) job index : 1,2,3,4
solution space : all
possible subset of job
index ie {1,2,3} {2,3}
{1,4} {1,3,4} ,……..
Compute c(x)
using the
following rule if x
is a leaf node,
24
DESIGN AND ANALYIS OF ALGORITHM
c(x) – summation of penalty of the jobs which are not in the path from root node to any
node x
if x is a root node
c(x) - minimum penalty corresponding to any node in the subtree within root x
(or)
c(x)=min{c(child-1),c(child-2),….c(child-n) ,where x is node in subtree
This problem begins with upper = ∝ as an upper bound on the cost of minimum-
cost answer node.
Whenever the node is generated in the tree, C’(x) and u(x) are computed.
Each time a new answer node is found, the value of upper can be updated by the
value of u(x)
For any node, if c’(x)>upper then the node will be killed
Start with node1 as E-node and generate all its children 2, 3, 4 and 5. So compute
C(2),C’(3),C’(4),C’(x) and u(2),u(3),u(4),u(5
2 3
4 5
25
DESIGN AND ANALYIS OF ALGORITHM
S4={3}
Refer Sx and determine P=1,2,4
(which are not exist in S4)
u(4)=P1+P2+P4=5+10+3=18
u(x) for node 5
S5={4}
Refer Sx and determine P=1,2,3
(which are not exist in S5)
u(5)=P1+P2+P3=5+10+6=21
2 3
4 5
6 7 8
Computation of c’(x)
27
DESIGN AND ANALYIS OF ALGORITHM
Computation of u(x)
2 5
3 4
6 7 8
9 10
Computation of c’(x)
28
DESIGN AND ANALYIS OF ALGORITHM
2
3 4 5
6 7 8 9 10
11 12 13 14
29
DESIGN AND ANALYIS OF ALGORITHM
c(x) – summation of penalty of the jobs which are not in the path from root node to
any node x
x=4, 5,6,7,8,9,10
C(4)( Jobs 1,2 and 4 are not chosen from root node 1 to leaf node 6)
= P1+P2+P4=5+6+3=14 C(5)( Jobs 1,2 and 3 are not chosen from
root node 1 to leaf node 6)
=P1+ P2+P3=5+10+6=19
C(6)( Jobs 3 and 4 are not chosen from root node 1 to leaf node
6) = P3+P4=6+3=9 C(7)( Jobs 2 and 4 are not chosen from
root node 1 to leaf node 6) = P2+P4=10+3=13 C(8)( Jobs 2
and3 are not chosen from root node 1 to leaf node 6) =
P2+P3=10+6=16 C(9)( Jobs 1 and 4 are not chosen from root
node 1 to leaf node 6) = P1+P4=5+3=8 C(10)( Jobs 1 and 3 are
not chosen from root node 1 to leaf node 6) = P1+P3=5+6=11
if x is a root node
c(x) - minimum penalty corresponding to any node in the subtree within root x
(or)
c(x)=min{c(child-1),c(child-2),….c(child-n) ,where x is any root node in subtree
x=2,3 (4,5 are killed so it does not have any child) and 1
C(2) = min{ C(6),C(7),C(8)}
= min {9,13,16}
=9
C(3) = min{ C(9),C(10)}
= min {8,11}
=8
C(1) =min{C(2),C(3),C(4),C(5)}
= min{9,8,14,19}
=8
30