Professional Documents
Culture Documents
2 KIRIM Pemrograman Dinamis
2 KIRIM Pemrograman Dinamis
DINAMIS
D. L. CRISPINA PARDEDE
JULI 2019
Dynamic Programming
Dynamic programming is a quantitative analytic
technique applied to large, complex problems that have
sequences of decisions to be made.
Dynamic programming divides problems into a number
of decision stages; the outcome of a decision at one
stage affects the decision at each of the next stages.
The technique is useful in a large number of multi‐
period business problems, such as smoothing production
employment, allocating capital funds, allocating salespeople to
marketing areas, and evaluating investment opportunities.
Dynamic Programming vs Linear Programming
DYNAMIC LINEAR
No algorithm that can be Algorithm like the simplex
programmed to solve all problems method)
1. NETWORK –
eg. Shortest‐Path Problem
2. NON‐NETWORK –
eg. Knapsack Problem
Shortest Path
• Dynamic‐programming and shortest‐path
problems are very similar
• Types of networks:
i) Acyclic networks. These networks contain no
directed cycles. That is, we cannot start from any
node and follow the arcs in their given directions
to return to the same node.
ii) Networks without negative cycles. These
networks may contain cycles, but the distance
around any cycle (i.e., the sum of the lengths of its
arcs) must be nonnegative.
Contoh Acyclic Network
Contoh Network tanpa negative cycles.
Shortest-path network for minimum-delay problem.
Solving Shortest Route Problems
Example:
George Yates is to travel from Rice (1) to Dixieville (7).
• George wants to find the shortest route. But there are
small towns between Rice and Dixieville.
• The circles (nodes) on the map represent cities such as
Rice (1), Hope (2), Brown (3), Lakecity (4), Athens (5),
Georgetown (6), Dixieville (7).
• The arrows (arcs) represent highways between the
cities.
Solving Shortest Route Problems
• The circles (nodes) on
the map represent
cities such as Rice (1),
Hope (2), Brown (3),
Lakecity (4), Athens (5), Lakecity Athens
Georgetown (6), 10 miles
4 5
Dixieville (7).
• The arrows (arcs)
represent highways Rice Brown
between the cities. 1
5 miles
3 7
2 6
10 miles
Hope Georgetown
Tabel Panah dan Bobot Panah
ARC DISTANCE
Lakecity Athens 5‐7 14
10 miles 6‐7 2
4 5
4‐5 10
Brown 3‐5 12
Rice
5 miles 3‐6 6
1 3 7 2‐5 4
2‐6 10
1‐4 4
2 6
1‐3 5
10 miles 1‐2 2
Hope Georgetown
Lakecity Athens
4 10 miles 5
Rice Brown
5 miles
1 3 7
2 6
10 miles
Hope Georgetown
Step‐1:
First, divide the problem into sub‐problems or stages.
Lakecity Athens
4 10 miles 5
Rice Brown
5 miles
1 3 7
Dixieville
2 6
10 miles
Hope Georgetown
• Next, solve Stage 1, the last part of the network. This
is usually trivial.
• Find the shortest path to the end of the network:
node 7 in this problem.
• The objective is to find the shortest distance to node
7.
Athens
5
Dixieville
n 1 6
Georgetown
1 1
Stage 1
22
Step 2. 14
Athens
n 1 5
1 1
Dixieville
6
Georgetown
2
Stage 1
23
Step 3.
24
n 2 Lakecity
10 miles
Athens
14
4 5
2 2 2
8 Brown
12
2
10 miles
6 2
Hope Georgetown
Stage 2
24
Step 4.
Lakecity 24
n 3 4
3 3 3
Rice Brown
13
5 miles
1 3 8
2 12
Hope
Stage 3
25
Step 5: Final Step
24 14
Minimum
Distance 4 10 miles
5
to Node 7
from Node 1
13 8
5 miles 7
1 3
2 6
10 miles
12 2
Solusi: Jarak terpendek dari Kota Rice (1) to Dixieville (7)
adalah 13 miles, dengan rute Rice(1)‐Brown(3)‐
Georgetown(6)‐Dixieville(7)
24 14
Minimum
Distance 10 miles
4 5
to Node 7
from Node 1
13 8
5 miles 7
1 3
2 6
10 miles
12 2
Shortest Path Problem Transformation Calculation
Distance from the beginning Distance from the beginning of the
of a given stage to the last = previous stage to the last node
node
+
Distance from the given stage to
the previous stage
TUGAS II
1. Tentukan jalur terpendek dari simpul 1
ke simpul 10. Penyelesaian dituliskan
secara bertahap.
7
2 5
1
2 4 3 4
6 8 3
6
4
1 3 2 6 3 10
3 9 4
4
3 1
4
3
4 7
5
2. Selesaikan masalah mencari delay terpendek berikut ini.
Angka pada setiap ruas menunjukkan waktu delay. Penyelesaian
dituliskan secara bertahap.