You are on page 1of 31

PEMROGRAMAN 

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) 

Allows a difficult problem to be  A problem is not divided into 


broken down into a sequence of  sub‐problems.
easier sub‐problems, which are then 
evaluated by stages. 
Could determine the optimal  A method that gives single‐
solution over a one‐year time  stage (i.e., one‐time period) 
horizon by breaking the problem into  solutions. 
12 smaller one‐month horizon 
problems and to solve each of these 
optimally
Karakter Masalah Pemrograman
Dinamis
1. Stages
2. States
3. Recursive Optimisation
Karakter Masalah Pemrograman Dinamis
1. Stages
• The optimization problems are structured into multiple stages, 
• The problems are solved sequentially one stage at a time.
• Although each one‐stage problem is solved as an ordinary 
optimization problem, its solution helps to define the 
characteristics of the next one‐stage problem in the sequence.
2. States
3. Recursive Optimisation
Karakter Masalah Pemrograman Dinamis
1. Stages
2. States
• Associated with each stage of the optimization problem are the 
states of the process. 
• The states reflect the information required to fully assess the 
consequences that the current decision has upon future actions.
• The essential properties:
i)   The states should convey enough information to make future 
decisions without regard to how the process reached the current 
state; and
ii)  The number of state variables should be small, since the 
computational effort associated with the dynamic programming 
approach is prohibitively expensive.
3. Recursive Optimisation
Karakter Masalah Pemrograman Dinamis
1. Stages
2. States
3. Recursive Optimisation
• Recursive optimization procedure: builds to a solution of the 
overall N‐stage problem by first solving a one‐stage problem and 
sequentially including one stage at a time and solving one‐stage 
problems until the overall optimum has been found. 
• This procedure can be based on a backward induction process.
• Alternatively, the recursive procedure can be based on a forward 
induction process.
Multistage Decision Process
Four Steps in Dynamic Programming
1. Divide the original problem into subproblems called stages.
2. Solve the last stage of the problem for all possible 
conditions or states.
3. Working backward from that last stage, solve each 
intermediate stage.
4. Obtain the optimal solution for the original problem by 
solving all stages sequentially.
Types of Dynamic Programming 
Problems

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

Stage 3 Stage 2 Stage 1


STAGE ARC DISTANCE
1 5‐7 14
6‐7 2
2 4‐5 10
3‐5 12
3‐6 6
2‐5 4
2‐6 10
3 1‐4 4
1‐3 5
1‐2 2
Step 2: Solve The Last Stage – Stage 1

• 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.

You might also like