Upload
richmafia21
View
231
Download
1
Embed Size (px)
Citation preview
8/20/2019 T00340020120134065T0034-Pert 15-Dynamic Programming - Multistage Graph
1/14
8/20/2019 T00340020120134065T0034-Pert 15-Dynamic Programming - Multistage Graph
2/14
Session 15
Dynamic Programming:Multistage Graph Problem
Course : T0034 !lgorithm Design " !nalysis
#ear : $013
8/20/2019 T00340020120134065T0034-Pert 15-Dynamic Programming - Multistage Graph
3/14
Bina Nusantara
MULTISTAGE GRAPH
% Multistage Graph is a graph &ith special characteristics:1' Directe( Graph
$' )ach e(ge has &eight
3' *as only 1 source +calle( as s, an( 1 sin- +calle( as t,
4' Path .rom source to sin- consists some stages /1 to /-
5' !ll stages connect no(e in /i to no(e /i01 &here 1 i -
2' There are - stages &here - $
' )ach path .rom s to t is conse6uence o. choice -7$'
% Multistage Graph is a mo(eling that can be use( to sol8esome real problems' )9ample: choosing proect to get ma9imum pro.it; inclu(ing
selecting steps to per.orm each tas-'
8/20/2019 T00340020120134065T0034-Pert 15-Dynamic Programming - Multistage Graph
4/14
Bina Nusantara
MULTISTAGE GRAPH PROBLEM
% Multistage Graph Problem :
Sortest path .in(ing problem .rom source to sin- in Multistage Graph'
The problem is one o. goo( implementation o. Dynamic Programming'
8/20/2019 T00340020120134065T0034-Pert 15-Dynamic Programming - Multistage Graph
5/14
Bina Nusantara
DP IN MULTISTAGE GRAPH PROBLEM
% Sol8ing o. Multistage Graph problem usingDynamic Programming in shortest path .rom ano(e to another is a shortest path o. pre8ious
stage a((e( by (istance o. one o. an e(geconnects to a stage'
%
8/20/2019 T00340020120134065T0034-Pert 15-Dynamic Programming - Multistage Graph
6/14
Bina Nusantara
FORWARD METHOD
% !nalysis by calculating path .rom a node to sink
%
8/20/2019 T00340020120134065T0034-Pert 15-Dynamic Programming - Multistage Graph
7/14Bina Nusantara
FORWARD METHOD
cost(4,I) = c(I,L) = 7
cost(4,J) = c(J,L) = 8
cost(4,K) = c(K,L) = 11
cost(3,F) = min { c(F,I) + cost(4,I) | c(F,J) + cost(4,J) }
cost(3,F) = min { 12 + 7 | 9 + 8 } = 17
cost(3,G) = min { c(G,I) + cost(4,I) | c(G,J) + cost(4,J) }
cost(3,G) = min { 5 + 7 | 7 + 8 } = 12
cost(3,H) = min { c(H,J) + cost(4,J) | c(H,K) + cost(4,K) }
cost(3,H) = min { 1 + 8 | 8 + 11 } = 18
cost(2,!) = min { c(!,F) + cost(3,F) | c(!,G) + cost(3,G) | c(!,H) + cost(3,H) }
cost(2,!) = min { 4 + 17 | 8 + 12 | 11 + 18 } = 2cost(2,") = min { c(",F) + cost(3,F) | c(",G) + cost(3,G) }
cost(2,") = min { 1 + 17 | 3 + 12 } = 15
cost(2,#) = min { c(#,H) + cost(3,H) }
cost(2,#) = min { 9 + 18 } = 27
cost(2,$) = min { c($,G) + cost(3,G) | c($,H) + cost(3,H) }
cost(2,$) = min { % + 12 | 12 + 18 } = 18
cost(1,&) = min { c(&,!) + cost(2,!) | c(&,") + cost(2,") | c(&,#) + cost(2,#) | c(&,$) + cost(2,$) }
cost(1,&) = min { 7 + 2 | % + 15 | 5 + 27 | 9 + 18 } = 21
'ot*st t is &-"-G-I-L .it /istnc* 21
8/20/2019 T00340020120134065T0034-Pert 15-Dynamic Programming - Multistage Graph
8/14Bina Nusantara
BACKWARD METHOD
% !nalysis by calculating path .rom source to a
node
%
8/20/2019 T00340020120134065T0034-Pert 15-Dynamic Programming - Multistage Graph
9/14Bina Nusantara
METODE BACKWARD
0cost(2,!) = c(&,!) = 7
0cost(2,") = c(&,") = %
0cost(2,#) = c(&,#) = 5
0cost(2,$) = c(&,$) = 9
0cost(3,F) = min { c(!,F) + 0cost(2,!) | c(",F) + 0cost(2,") }
0cost(3,F) = min { 4 + 7 | 1 + % } = 11
0cost(3,G) = min { c(!,G) + 0cost(2,!) | c(",G) + 0cost(2,") | c($,G) + 0cost(2,$) }
0cost(3,G) = min { 8 + 7 | 3 + % | % + 9 } = 9
0cost(3,H) = min { c(!,H) + 0cost(2,!) | c(#,H) + 0cost(2,#) | c($,H) + 0cost(2,$) }
0cost(3,H) = min { 11 + 7 | 9 + 5 | 12 + 9 } = 14
0cost(4,I) = min { c(F,I) + 0cost(3,F) | c(G,I) + 0cost(3,G) }
0cost(4,I) = min { 12 + 11 | 5 + 9 } = 14
0cost(4,J) = min { c(F,J) + 0cost(3,F) | c(G,J) + 0cost(3,G) | c(H,J) + 0cost(3,H) }
0cost(4,J) = min { 9 + 11 | 7 + 9 | 1 + 14 } = 1%
0cost(4,K) = min { c(H,K) + cost(3,H) }
0cost(4,K) = min { 8 + 14 } = 22
0cost(5,L) = min { c(I,L) + 0cost(4,I) | c(J,L) + 0cost(4,J) | c(K,L) + 0cost(4,K) }
0cost(5,L) = min { 7 + 14 | 8 + 1% | 11 + 22 } = 21
'ot*st t is &-"-G-I-L .it /istnc* 21
8/20/2019 T00340020120134065T0034-Pert 15-Dynamic Programming - Multistage Graph
10/14Bina Nusantara
SHORTEST PATH IN MULTISTAGE GRAPH
8/20/2019 T00340020120134065T0034-Pert 15-Dynamic Programming - Multistage Graph
11/14Bina Nusantara
EXERCISE
% usingDynamic Programming +.or&ar( metho( an(bac-&ar( metho(, ?
8/20/2019 T00340020120134065T0034-Pert 15-Dynamic Programming - Multistage Graph
12/14Bina Nusantara
REVIEW
% M@>TAST!G) GB!P*
% M@>TAST!G) GB!P* PB=>)M
% DA!MAC PBGB!MMAG A M@>TAST!G)GB!P*
%
8/20/2019 T00340020120134065T0034-Pert 15-Dynamic Programming - Multistage Graph
13/14Bina Nusantara
Books References
% Be.erences:
Computer !lgorithms C
% )llis *oro&itH Sarta Sahni Sanguthe8ar Baase-aran'
% Computer Science Press' +1IIJ,
Antro(uction to !lgorithms
% Thomas * Cormen Charles ) >eiserson Bonal( >'
% 3n( )(ition' The MAT Press' e& #or-' +$00I,
!lgoritma Atu Mu(ah% Bobert Setia(i'
% PT Prima An.osarana Me(ia Felompo- Grame(ia'
% Ka-arta' +$00J,
8/20/2019 T00340020120134065T0034-Pert 15-Dynamic Programming - Multistage Graph
14/14Bina Nusantara
END