0% found this document useful (0 votes)
14 views

Daa Unit III

Uploaded by

maredu vyshnavi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Daa Unit III

Uploaded by

maredu vyshnavi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 82

Design and Analysis of Algorithms

CSE III year II sem (R18)


UNIT III

Shumama Ansa
Dynamic Programming:
General Method
• Dynamic programming is a name, coined by Richard Bellman in
1955.
• Dynamic programming, is a powerful algorithm design technique
that can be used when the solution to the problem can be viewed
as the result of a sequence of decisions.
• In the greedy method we make irrevocable decisions one at a time,
using a greedy criterion.
• However, in dynamic programming we examine the decision
sequence to see whether an optimal decision sequence contains
optimal decision subsequence.
• When optimal decision sequences contain optimal
decision sub sequences, we can establish recurrence
equations, called dynamic-programming recurrence
equations that enable us to solve the problem in an
efficient way.
• Dynamic programming is based on the principle of
optimality (also coined by Bellman).
• The principle of optimality states that no matter
whatever the initial state and initial decision are, the
remaining decision sequence must constitute an optimal
decision sequence with regard to the state resulting from
the first decision.
• The principle implies that an optimal decision
sequence is comprised of optimal decision
subsequences.
• Since the principle of optimality may not hold
for some formulations of some problems, it is
necessary to verify that it does hold for the
problem being solved.
• Dynamic programming cannot be applied
when this principle does not hold.
The steps in a dynamic programming solution are:
• Verify that the principle of optimality holds. Set up the
dynamic- programming recurrence equations. Solve the
dynamic- programming recurrence equations for the
value of the optimal solution. Perform a trace back step
in which the solution itself is constructed.

• Optimal solutions to sub-problems are retained
in a table, thereby avoiding the work of re
computing the answer every time a sub-
problem is encountered
All pairs shortest path problem

• In the all pairs shortest path problem, we should


find a shortest path between every pair of
vertices in a directed graph G.
• That is, for every pair of vertices (i, j), we are to
find a shortest path from i to j as well as one
from j to i. These two paths are the same when G
is undirected.
• When no edge has a negative length, the all-pairs
shortest path problem may be solved by using
Dijkstra’s greedy single source algorithm n times,
once with each of the n vertices as the source vertex.
• The all pairs shortest path problem is to determine a
matrix A such that A (i, j) is the length of a shortest
path from i to j.
• The matrix A can be obtained by solving n single-
source problems using the algorithm shortest Paths.
Since each application of this procedure requires O
(n2) time, the matrix A can be obtained in O (n3)time.
• The shortest i to j path in G, i ≠ j originates at vertex i
and goes through some intermediate vertices (possibly
none) and terminates at vertex j.
• If k is an intermediate vertex on this shortest path, then
the subpaths from i to k and from k to j must be shortest
paths from i to k and k to j, respectively.
• Otherwise, the i to j path is not of minimum length.
• So, the principle of optimality holds.
• Let Ak (i, j) represent the length of a shortest path from i
to j going through no vertex of index greater than k, we
obtain:
• Ak (i, j) = {min {min 1<k<n {Ak-1 (i, k) + Ak-1 (k, j)}, cost (i,j)}
Example graph
Initial matrix A0

A0 1 2 3

1 0 4 11

2 6 0 2

3 3 ∞ 0
• Considering vertex 1 as intermediate vertex
• So 1st row and 1st column do not change
• A1 (2, 3) = min {(A0 (2, 3)),A0(2,1)+A0(1,3))
=min(2,6+11)
=min(2,17)=2
• A1 (3, 2) = min {(A0 (3,2)),A0(3,1)+A0(1,2))
=min(∞,3+4) A0 1 2 3
=min(∞,7) 1 0 4 11
=7 2 6 0 2
3 3 ∞ 0
A0 1 2 3
1 0 4 11
2 6 0 2 A1 1 2 3
3 3 ∞ 0 1 0 4 11

2 6 0 2

3 3 7 0
• Considering vertex 2 as intermediate vertex
• So 2nd row and 2nd column do not change
• A2 (1, 3) = min {(A1 (1, 3)),A1(1,2)+A1(2,3))
=min(11,4+2)
=min(11,6)=6
• A2 (3, 1) = min {(A1 (3,1)),A1(3,2)+A1(2,3))
=min(3,7+2) A1 1 2 3
=min(3,9) 1 0 4 11
=3 2 6 0 2
3 3 7 0
A1 1 2 3

1 0 4 11

2 6 0 2

3 3 7 0 A2 1 2 3

1 0 4 6

2 6 0 2

3 3 7 0
• Considering vertex 3 as intermediate vertex
• So 3rd row and 3rd column do not change
• A3 (1, 2) = min {(A2 (1, 2)),A2(1,3)+A2(3,2))
=min(4,6+7)
=min(4,13)=4
• A3 (2, 1) = min {(A2 (2,1)),A2(2,3)+A2(3,1))
=min(6,2+3) A2 1 2 3
=min(6,5) 1 0 4 6
=5 2 6 0 2
3 3 7 0
A2 1 2 3

1 0 4 6

2 6 0 2

3 3 7 0
A3 1 2 3

1 0 4 6

2 5 0 2

3 3 7 0
A0 1 2 3 A1 1 2 3

1 0 4 11 1 0 4 11

2 6 0 2 2 6 0 2

3 3 ∞ 0 3 3 7 0

A2 1 2 3 A3 1 2 3

1 0 4 6 1 0 4 6

2 6 0 2 2 5 0 2

3 3 7 0 3 3 7 0
Optimal binary search trees
• A binary search tree (BST), also called an ordered or
sorted binary tree, is a rooted binary tree whose
internal nodes store a key greater than all the keys in
the node's left sub tree and less than those in its right
sub tree.
• Time taken to search is O(log n)
BST with 3 nodes
• Number of binary search trees with 3 nodes =
5
• Number of binary search trees with 4 nodes =
14
• Number of binary search trees with n nodes =
(2ncn)/(n+1)
• Given a fixed set of identifiers, we wish to
create a binary search tree.
• Different binary search trees may exist for the
same identifier set to have different
performance characteristics
• The tree of figure5.12(a) in the worst case,
requires four comparisons to find an identifier,
where as the tree of figure5.12(b) requires only
three.
• On the average two trees need12/5and
11/5comparisons respectively.
• for example in the case of tree(a), it
takes1,2,2,3,and 4 comparisons respectively, to
find the identifiers for, do, while, int, and if.
• Thus the average number of comparisons is
(1+2+2+3+4)/5 = 12/5.
• This calculation assumes that each identifier is
searched for with equal probability and that no
unsuccessful searches(i.e., searches for identifiers
not in the tree) are made.
• Let us assume that the given set of identifiers
is {a1, . . . , an} with a1 < a2 < . . . . < an.
• Let p (i) be the probability with which we
search for ai.
• Let q (i) be the probability that the identifier x
being searched for is such that ai < x < ai+1, 0 <i
<n. (assume a0 = -∞ and an+1 = +∞ ).
• Then,∑o≤i≤nq(i) is the probability of an unsuccessful
search.
• ∑1 ≤ i ≤ nP(i)+ ∑0 ≤ i ≤ nq(i ) = 1
• Given this data, we wish to construct an optimal binary
search Tree.
• In obtaining a cost function for binary search trees, it is
useful to add a fictitious node in place of every empty
sub tree in the search tree.
• Such nodes, called external nodes, are drawn square in
figure5.13
• All other nodes are internal nodes.
• If a binary search tree represents n identifiers,
then there will be exactly n internal nodes and
n +1(fictitious) external nodes.
• Every internal node represents a point where
a successful search may terminate.
• Every external node represents a point where
an unsuccessful search may terminate.
• If a successful search terminates at an
internal node at level I, then the expected cost
contribution from the internal node for ai is
p(i) * level(ai).
• The identifiers not in the binary search tree
can be partitioned into n + 1 equivalence
classes Ei, 0 ≤ i ≤ n.
• If the failure node for Ei is at level l, then the cost
contribution of this node is q(i) * (level(Ei)-1).
• The preceding discussion leads to the following
formula for the expected cost of a binary search
tree:
∑1 ≤ i ≤ n p(i) * level(ai)+ ∑0 ≤ i ≤ n q{i)* (level(Ei)-1)
• We define an optimal binary search tree for the
identifier set {a1,a2,.,.an} to be a binary search
tree for which the given formula is minimum.
• Example1:
Let n = 4, and (a1, a2, a3, a4) = (do, if, int, while)
Let P (1: 4) = (3, 3, 1, 1) and Q (0: 4) = (2, 3, 1,
1,1)
Initially w(i,i) = q[i] , c(i,i) = 0 and r(i,i) = 0
• W(0,0) = 2, w(1,1) =3, w(2,2) = 1, w(3,3) = 1,
w(4,4) = 1
• c(0,0) = 0, c(1,1) =0, c(2,2) = 0, c(3,3) = 0, c(4,4)
=0
• r(0,0) = 0, r(1,1) =0, r(2,2) = 0, r(3,3) = 0, r(4,4) = 0
• c (i, j) = min i<k<j {c (i, k-1) + c (k, j)} +w (i,j)
• Where w (i, j) = P (j) + Q (j) +w (i,j-1)
• And r(i, j) = k
• first, computing all C (i, j) such that |j – i| = 1; j = i + 1
and as 0 <i < 4; i = 0, 1, 2 and 3; i < k ≤ J.
• Start with i = 0; so j = 1; as i < k ≤ j, so the possible
value for k =1
W (0, 1) = P (1) + Q (1) + W (0, 0) = 3 + 3 + 2 =8
C (0, 1) = W (0, 1) + min {C (0, 0) + C (1, 1)} =8
R (0, 1) = 1 (value of 'K' that is minimum in the above
equation).
• Next with i = 1; so j = 2; as i < k ≤ j, so the possible value for
k =2
W (1, 2) = P (2) + Q (2) + W (1, 1) = 3 + 1 + 3 =7
C (1, 2) = W (1, 2) + min {C (1, 1) + C (2, 2)} =7
R (1, 2) =2
• Next with i = 2; so j = 3; as i < k ≤ j, so the possible
value for k =3
W (2, 3) = P (3) + Q (3) + W (2, 2) = 1 + 1 + 1 =3
C (2, 3) = W (2, 3) + min {C (2, 2) + C (3, 3)} =3
R (2, 3) =3

• Next with i = 3; so j = 4; as i < k ≤ j, so the possible


value for k =4
W(3, 4) = P (4) + Q (4) + W (3, 3) = 1 + 1 + 1 =3
C (3, 4) = W (3, 4) + min {[C (3, 3) + C (4, 4)]} = 3
R (3, 4) =4
• Second, Computing all C (i, j) such that j - i = 2; j
= i + 2 and as 0 <i < 3; i = 0, 1, 2; i < k ≤ J.
• Start with i = 0; so j = 2; as i < k ≤ J, so the possible
values for k = 1 and2.

W (0, 2) = P (2) + Q (2) + W (0, 1) = 3 + 1 + 8 =12


C (0, 2) = W (0, 2) + min {(C (0, 0) + C (1, 2)),
(C (0, 1) + C (2,2))}
= 12 + min {(0 + 7, 8 + 0)}
=19
R (0, 2) =1
• Next, with i = 1; so j = 3; as i < k ≤ j, so the possible value for k = 2 and3.
W (1, 3) = P (3) + Q (3) + W (1, 2) = 1 + 1+ 7 =9
C (1, 3) = W (1, 3) + min {[C (1, 1) + C (2, 3)],
[C (1, 2) + C (3,3)]}
= W (1, 3) + min {(0 + 3), (7 + 0)} = 9 + 3 =12
R (1, 3) =2

• Next, with i = 2; so j = 4; as i < k ≤ j, so the possible value for k = 3 and 4.


W (2, 4) = P (4) + Q (4) + W (2, 3) = 1 + 1 + 3 =5
C (2, 4) = W (2, 4) + min {[C (2, 2) + C (3, 4)],
[C (2, 3) + C (4,4)]}
= 5 + min {(0 + 3), (3 + 0)} = 5 + 3 =8
R (2, 4) =3 or 4
• Third, Computing all C (i, j) such that J - i = 3; j = i + 3 and as 0 <i < 2; i
= 0,1; i < k ≤ J.
• Start with i = 0; so j = 3; as i < k ≤ j, so the possible values for k =1, 2 and3.
W (0, 3) = P (3) + Q (3) + W (0, 2) = 1 + 1 + 12 =14
C (0, 3) = W (0, 3) + min {[C (0, 0) + C (1, 3)],
[C (0, 1) + C (2,3)],
[C (0, 2) + C (3,3)]}
= 14 + min {(0 + 12), (8 + 3), (19 + 0)} = 14 + 11 =25
R (0, 3) =2
• Start with i = 1; so j = 4; as i < k ≤ j, so the possible values for k = 2, 3and4.
W (1, 4) = P (4) + Q (4) + W (1, 3) = 1 + 1 + 9 =11
C (1, 4) = W (1, 4) + min {[C (1, 1) + C (2, 4)],
[C (1, 2) + C (3,4)],
[C (1, 3) + C (4,4)]}
= 11 + min {(0 + 8), (7 + 3), (12 + 0)} = 11 + 8 =19
R (1, 4) =2
• fourth, Computing all C (i, j) such that j - i = 4; j = i + 4
and as 0 <i < 1; i = 0; i < k≤J.
• Start with i = 0; so j = 4; as i < k ≤ j, so the possible values
for k = 1, 2, 3 and 4.
W (0, 4) = P (4) + Q (4) + W (0, 3) = 1 + 1 + 14 =16
C (0, 4) = W (0, 4) + min {[C (0, 0) + C (1, 4)],
[C (0, 1) + C (2,4)],
[C (0, 2) + C (3, 4)],
[C (0, 3) + C (4,4)]}
= 16 + min [0 + 19, 8 + 8, 19+3, 25+0]
= 16 + 16 =32
R (0, 4) =2
• from the table we see that C (0, 4) = 32 is the
minimum cost of a binary search tree for (a1, a2,
a3, a4). The root of the tree 'T04' is'a2'.
• Hence the left sub tree is 'T01' and right sub tree is
T24. The root of 'T01' is 'a1' and the root of 'T24' is a3.
• The left and right sub trees for 'T01' are 'T00' and 'T11‘
respectively. The root of T01 is 'a1'
• The left and right sub trees for T24 are T22 and T34
respectively.
• The root of T24 is'a3'.
• The root of T22 is null
• The root of T34 is a4.
0/1 KNAPSACK PROBLEM
• This problem is similar to ordinary knapsack problem but we
may not take a fraction of an object.
• We are given n objects and a knapsack. Each object i has a
positive weight wi and a positive value profit pi. The knapsack
can carry a weight not exceeding m.
• fill the knapsack so that the profit of objects in the knapsack is
optimized.
• A solution to the knapsack problem can be obtained by making
a sequence of decisions on the variables x1, x2, . . . . , xn.
• A decision on variable xi involves determining which of the
values 0 or 1 is to be assigned to it.
0/1 KNAPSACK PROBLEM
• Let us assume that decisions on the xi are made in the order
xn, xn-1, . . . .x1.
• following a decision on xn, we may be in one of two possible
states:
 the capacity remaining is m – wn and no profit has accrued.
 the capacity remaining in m – wn and a profit of pn has
accrued.
• It is clear that the remaining decisions xn-1, . . . , x1 must be
optimal with respect to the problem state resulting from the
decision on xn. Otherwise, xn,. . . . , x1 will not be optimal.
• Hence, the principal of optimality holds.
0/1 KNAPSACK PROBLEM
• Let fj (y) be the value of an optimal solution to
knap(1,j,y). Since the principle of optimality holds we
obtain
– fn (m) = max {fn-1 (m), fn-1 (m-wn)+pn} -- 1
• for arbitrary fi (y), i > 0, this equation generalizes to:
– fi (y) = max {fi-1 (y), fi-1 (y-wi)+pi} -- 2

Equation 2 can be solved for fn (m) by beginning with the


knowledge f0 (y) = 0 for all y and fi (y) = - ∞, y < 0. Then
f1, f2, . . . fn can be successively computed using
equation–2.
0/1 KNAPSACK PROBLEM
• To solve the problem by dynamic programming we
update a table T[1…N, 0…M] (ic) the size is N.
where ‘N’ is the no. of objects and column starts with
‘O’ to capacity (ic) ‘M’.
• In the table T[i,j] will be the maximum valve of the
objects i varies from 1 to n and j varies from O to M.
RULES TO FILL THE TABLE:-

• If i=l and j < w(i) then T(i,j) =o,


• If i=l and j  w (i) then T (i,j) = p(i), the cell is filled with the
profit p[i], since only one object can be selected to the
maximum.
• If i>l and j < w(i) then T(i,j) = T (i-l,j) the cell is filled the
profit of previous object since it is not possible with the
current object.
• If i>l and j  w(i) then T (i,j) = max{p(i) +T(i-l,j-w(i)), T(i-1,j).
• After the table is generated, it will give details the profit.
Example:
• M=8, n=4, p={1,2,5,6} and w = {2,3,4,5}
w
0 1 2 3 4 5 6 7 8
Pi Wi 0 0 0 0 0 0 0 0 0 0
1 2 1
2 3 2
5 4 3
6 5 4

For i=0, no object is included, hence row 0 will have


all zeroes
Example:
• M=8, n=4, p={1,2,5,6} and w = {2,3,4,5}
w
0 1 2 3 4 5 6 7 8
Pi Wi 0 0 0 0 0 0 0 0 0 0
1 2 1 0 0 1 1 1 1 1 1 1
2 3 2
5 4 3
6 5 4

For i=1, object 1 is included, hence [1,2] will have


value as 2(profit of object 1)
Example:
• M=8, n=4, p={1,2,5,6} and w = {2,3,4,5}
w

0 1 2 3 4 5 6 7 8
Pi Wi 0 0 0 0 0 0 0 0 0 0
1 2 1 0 0 1 1 1 1 1 1 1
2 3 2 0 0 1 2 2 3 3 3 3
5 4 3
6 5 4

For i=2, object 2 is included, hence cell [1,2] will have


value as 2(profit of object 1)
When object 1 and 2 both are included weight becomes
5 and profit becomes 3
Example:
• M=8, n=4, p={1,2,5,6} and w = {2,3,4,5}
w

0 1 2 3 4 5 6 7 8
Pi Wi 0 0 0 0 0 0 0 0 0 0
1 2 1 0 0 1 1 1 1 1 1 1
2 3 2 0 0 1 2 2 3 3 3 3
5 4 3 0 0 1 2 5 5 6 7 7
6 5 4

For i=3, object 3 is included, hence cell [3,4] = 5


If we take object 3 and 1 weight =6 and profit =6
If we take object 3 and 2 weight =7 and profit =7
Example:
• M=8, n=4, p={1,2,5,6} and w = {2,3,4,5}
w

0 1 2 3 4 5 6 7 8
Pi Wi 0 0 0 0 0 0 0 0 0 0
1 2 1 0 0 1 1 1 1 1 1 1
2 3 2 0 0 1 2 2 3 3 3 3
5 4 3 0 0 1 2 5 5 6 7 7
6 5 4 0 0 1 2 5 6 6 7 8

For i=4, object 4 is included, hence cell [4,5] = 6


If we take object 4 and 1 weight =7 and profit =7
If we take object 4 and 2 weight =8 and profit =8
0 1 2 3 4 5 6 7 8
0 0 0 0 0 0 0 0 0 0
1 0 0 1 1 1 1 1 1 1
2 0 0 1 2 2 3 3 3 3
3 0 0 1 2 5 5 6 7 7
4 0 0 1 2 5 6 6 7 8

Or values can be calculated as


T (i,j) = max{p(i) +T(i-l,j-w(i)), T(i-1,j)}
Let us calculate for i=4
T(4,1)=max{p(4) +T(4-l,1-5), T(3,1)}
T(3,-4) is not defined
Hence till j=4 we will have T(4,j) as T(3,j)
For j=5, T(4,5) = max{p(4) +T(3,0), T(3,5)}
= max{6,5}=6
For j=6,
T(4,6) = max{p(4) +T(3,1), T(3,6)} 0 1 2 3 4 5 6 7 8

= max{6,6}=6 0 0 0 0 0 0 0 0 0 0

1 0 0 1 1 1 1 1 1 1
For j=7, 2 0 0 1 2 2 3 3 3 3
T(4,7) = max{p(4) +T(3,2), T(3,7)}
3 0 0 1 2 5 5 6 7 7
= max{7,7}=7
4 0 0 1 2 5 6 6 7 8
For j=8,
T(4,8) = max{p(4) +T(3,3), T(3,8)}
= max{8,7}=8
0 1 2 3 4 5 6 7 8
0 0 0 0 0 0 0 0 0 0
1 0 0 1 1 1 1 1 1 1
2 0 0 1 2 2 3 3 3 3
3 0 0 1 2 5 5 6 7 7
4 0 0 1 2 5 6 6 7 8

• For solution we see here that t(4,8) = 8 which is max


and it is only in 4th row, hence object 4 is included
• 8-p4 = 8-6 = 2 is in 3rd row as well as in 2nd so do not
include object 3.
• 2 is in 2nd row but not in 1st . So include object 2.
• Now 2-p2 = 2- 2= 0
• 0 is in 1st as well as 0th row. So do not include object 1
• Hence the solution is 0 1 0 1.
Sets method
• Ordered set si can be used to represent t(i,j)
• Each member of si is a pair (p,w)
• s0 = {(0,0)}
• We can compute si+1 from si by first computing
si1 ={(p,w)|(p-pi,W-wi)€si}
• si+1 can be computed by merging the pairs in si
and si1
For the given data we have:
S0={(0,0)}; (S0 no object included yet)
S01 1st object is included add (p1,w1) to S0
S01 = {(1,2)}
Set 1 S1 is obtained by merging S0 and S01
S1 = (S0 U S01) = {(0, 0), (1,2)}
S11 = {(2,3),(3,5)} add p2, w2 to S1
So s2 = {(0, 0), (1,2), (2,3),(3,5)}
s2 = {(0, 0), (1,2), (2,3),(3,5)}
Consider object 3
S21 = {{(5, 4), (6,6), (7,7),(8,9)}
S3 is obtained by merging S2 and S21
S3 = (S2 U S21) = {(0, 0), (1,2), (2,3),(3,5),(5, 4), (6,6),(7,7),(8,9)}
discard (8,9) so
S3 = (S2 U S21) = {(0, 0), (1,2), (2,3),(5, 4), (6,6),(7,7)}
S31 = {(6,5),(7,7),(8,8),(11,9),(12,11),(13,12)}
So s4 = {(0, 0), (1,2), (2,3), (5, 4), (6,6),(7,7),
(6,5),(7,7),(8,8),(11,9),(12,11),(13,12)}
Using dominance rule
s4 = {(0, 0), (1,2), (2,3), (5, 4), (6,5),(7,7),(8,8)}
Max in
s4 = {(0, 0), (1,2), (2,3), (5, 4), (6,5),(7,7),(8,8)}
Is (8,8) and it does not belong to s3
X4=1
(8,8)-(p4,w4) = (8,8) – (6,5) = (2,3) belongs to s3 and s2
So X3=0
(2,3) belongs to s2 and does not belong to s1
So X2=1
(2,3) – (2,3) =(0,0) which belongs to s1 and s0
So X1=0
Hence solution is {0 1 0 1}
TRAVELLING SALESMAN PROBLEM

• Let G(V,E) be a directed graph with edge cost cij is defined


such that cij >0 for all i and j and cij = ,if <i,j> E.
• Let |V| =n and assume n>1.
• The traveling salesman problem is to find a tour of minimum
cost.
• A tour of G is a directed cycle that include every vertex in V.
• The cost of the tour is the sum of cost of the edges on the tour.
• The tour is the shortest path that starts and ends at the same
vertex (ie) 1.
• Every tour consists of an edge <1,k> for some k  V-{1} and
a path from vertex k to vertex 1.
• the path from vertex k to vertex 1 goes through each vertex
in V-{1,k} exactly once.
• g(i,s) be the length of a shortest path starting at vertex i,
going through all vertices in S, and terminating at vertex 1.
• the function g(1,v-{1}) is the length of an optimal tour.
• The function which is used to find the path is
g(1,V-{1}) = min2≤k ≤n{ c1k + g(k,v-{1,k})}
Generalizing we obtain
g(i,s)= minj€S { cij + g(j,s-{j})}
example
• |s| = 0
• g(1,) = c11 => 0
• g(2,) = c21 => 5
• g(3,) = c31 => 6
• g(4,) = c41 => 8
• |s| = 1 i =2 to 4
• g(2,{3}) = c23 + g(3,) = 9+6 =15
• g(2,{4}) = c24 + g(4,)= 10+8 =18
• g(3,{2}) = c32 + g(2,)= 13+5 =18
• g(3,{4}) = c34 + g(4,)= 12+8 =20
• g(4,{2}) = c42 + g(2,)= 8+5 =13
• g(4,{3}) = c43 + g(3,)= 9+6 =15
|s| = 2
• g(2,{3,4}) = min{c23+g(3{4}),c24+g(4,{3})}
=min{9+20,10+15}
=min{29,25}
=25
• g(3,{2,4}) = min{c32+g(2{4}),c34+g(4,{2})}
= min{13+18,12+13}
= min{31,25}
=25
• g(4,{2,3}) = min{c42+g(2{3}),c43+g(3,{2})}
= min{8+15,9+18}
= min{23,27}
=23
|s|= 3
• g(1,{2,3,4})=min{c12+g(2{3,4}),
c13+g(3,{2,4}),
c14+g(4,{2,3})}
= min{10+25,15+25,20+23}
= min{35,35,43}
=35
• optimal cost is 35
the shortest path is,
• g(1,{2,3,4}) = c12 + g(2,{3,4}) => 1->2

g(2,{3,4}) = c24 + g(4,{3}) => 1->2->4

g(4,{3}) = c43 + g(3{}) => 1->2->4->3->1

• so the optimal tour is 1  2  4 3  1


Reliability Design
• The problem is to design a system that is composed of
several devices connected in series.
• Let ri be the reliability of device Di (that is ri is the
probability that device i will function properly) then
the reliability of the entire system is ∏ri.
• Even if the individual devices are very reliable (the ri’s
are very close to one), the reliability of the system may
not be very good.
• For example, if n = 10 and ri = 0.99, i <i <10, then ∏ri =
.904. Hence, it is desirable to duplicate devices.
• Multiply copies of the same device type are connected
in parallel.
• If stage i contains mi copies of device Di, then
the probability that all mi have a malfunction
is (1 - ri) ^mi. Hence the reliability of stage i
becomes 1 –(1 - ri) ^mi
• The reliability of stage ‘i’ is given by a function
∏1≤i ≤ nØi(mi).
• Devices connected in series
• Multiple devices connected in parallel in each
stage
• Our problem is to use device duplication. This
maximization is to be carried out under a cost
constraint.
• Let ci be the cost of each unit of device i and
let c be the maximum allowable cost of the
system being designed.
Example:
We are to design a three stage system with
device types D1, D2 and D3. The costs are
$30,$15,and $20 respectively. The cost of the
system is to be no more than $105. The
reliability of each device type is .9, .8 and .5
respectively.
• M
• M
• M

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy