6 views

Uploaded by Satria Surya Wijaya

save

- Goodrich 6e Ch12 DivideAndConquer
- 44 Dynamic Programming
- Economic operation of power system august 14 2014 lecture
- Dynamic Programming
- millepunti-algoritmo
- lpiii-2.pdf
- DAA Lecture DynProg
- Demo Merge
- Update 1.3 to Elements of Programming Interviews
- Design & Analysis of Algorithms Jan 2014
- Simpson - DynamicProgramminginExcelVer1.0Withabstract
- 0270_PDF_C03.pdf
- 90d0aa9e63eff0b8544fb07abca1fd8c 03 Divide and Conquer Problems 20161023
- chap10
- lec4
- spectogram hata.pdf
- RASA Profile
- The_Impact_of_Charging_Plug-In_Hybrid_Electric_Vehicles_on_a_Residential_Distribution_Grid-d55.pdf
- Problem 8-8 Bm 181
- cs-2008.docx
- Cognitive tics Project Report
- NR-220502- Design and Analysis of Algorithms
- review 6
- B.Mergesort.pdf
- CSFacultyResearchInterests[1]
- m6-game-pub
- ETCS 254 Algorithm Analysis and Design Lab
- English Resume
- serena paul resume 2 pdf
- 14-apsp
- 01 Agung Analisis
- referensi kutipan
- Analisis Perang Dunia II
- Melanesia.doc
- 3-1-PB
- SEGMENTASI_CITRA_DIGITAL_DENGAN_MENGGUNA.pdf
- Proposal Pp
- Praktikum Multimedia 2015
- 846
- 45-90-1-SM
- 00-Sampul
- penulisan-kutipan
- Data Hotspot Di Perkebunan Sawit Di Kalteng 1 14 Oktober 2014
- Multimedia
- Table
- Chapter 11. GUI
- LAPORAN HASIL PRAKTIKUM BD1 MOD4.docx
- Rangkuman Materi Algoritma Divide and Conquer
- Modul 1 Basis Data
- Percent Rank
- Percent Rank
- 6 Pengalamatan Ip
- Daftar Isi
- Penetapan Hari Efektif
- Modul 11 Pkn
- Modul 10 Pkn
- Laporan Akhir Praktikum Modul 2
- 10_stream Dan File
- Makala h

You are on page 1of 36

Chapter 15: Dynamic Programming

Dynamic Programming

**Well known algorithm design techniques:
**

Brute-Force (iterative) algorithms Divide-and-conquer algorithms

**Another strategy for designing algorithms is dynamic programming.
**

Used when problem breaks down into recurring small subproblems

Dynamic programming is typically applied to optimization problems. In such problem there can be many solutions. Each solution has a value, and we wish to find a solution with the optimal value.

**Divide-and-conquer
**

Divide-and-conquer method for algorithm design: Divide: If the input size is too large to deal with in a straightforward manner, divide the problem into two or more disjoint subproblems Conquer: conquer recursively to solve the subproblems

Combine: Take the solutions to the subproblems and “merge” these solutions into a solution for the original problem

Divide-and-conquer .Example .

If same subproblem is solved several times. we can use table to store result of a subproblem the first time it is computed and thus never have to recompute it again. we mean that the same recursive call is made over and over. when subproblems share subsubproblems. Dynamic programming is applicable when the subproblems are dependent. “Programming” refers to a tabular method . that is. By “inefficient”.Dynamic programming Dynamic programming is a way of improving on inefficient divideand-conquer algorithms.

Difference between DP and Divide-andConquer Using Divide-and-Conquer to solve these problems is inefficient because the same common subproblems have to be solved many times. DP will solve each of them once and their answers are stored in a table for future use. .

Elements of Dynamic Programming (DP) DP is used to solve problems with the following characteristics: Simple subproblems We should be able to break the original problem to smaller subproblems that have the same structure Optimal substructure of the problems The optimal solution to the problem contains within optimal solutions to its subproblems. . Overlapping sub-problems there exist some places where we solve the same subproblem more than once.

Characterize optimal substructure 2. Recursively define the value of an optimal solution 3. (if needed) Construct an optimal solution .Steps to Designing a Dynamic Programming Algorithm 1. Compute the value bottom up 4.

5. 8. 21. 2. 3. 1. F1 =1 0. 13. … Straightforward recursive procedure is slow! Let’s draw the recursion tree .Fibonacci Numbers Fn= Fn-1+ Fn-2 n≥2 F0 =0. 55. 1. 34.

Fibonacci Numbers .

only two values need to be remembered at any time .Fibonacci Numbers We can calculate Fn in linear time by remembering solutions to the solved subproblems – dynamic programming Compute solution in a bottom-up fashion In this case.

We denote the jth station on line i (where i is 1 or 2) by Si.j) . The time required at each station varies. Each line has the same number “n” of stations.j )... The jth station on line 1 (S1.j) performs the same function as the jth station on line 2 (S2.. even between stations at the same position on the two different lines. . time required at station Si. . There is also an entry time (ei) for the chassis to enter assembly line i and an exit time (xi) for the completed auto to exit assembly line i.j is (ai. 2. as each assembly line has different technology. Numbered j = 1. n.Ex1:Assembly-line scheduling Automobiles factory with two assembly lines.j .

j to S3-i.j.j+1 transfer cost from Si. or q transfer to other line next station is S3-i.j ( j = 1.n.n 13 .j+1 is ti.Ex1:Assembly-line scheduling After going through station Si. can either q stay on same line next station is Si.j+1 no transfer cost . because the assembly line is complete after Si. n–1) No ti. … .

.Ex1:Assembly-line scheduling •(Time between adjacent stations are nearly 0).

what stations should be chosen from line 1 and from line 2 for minimizing the total time for car assembly.Problem Definition Problem: Given all these costs. “Brute force” is to try all possibilities. Simple example : 2 stations (2n) possibilities =4 . requires to examine Ω(2n) possibilities Trying all 2n subsets is infeasible when n is large.

1 (i = 1.Step 1: Optimal Solution Structure optimal substructure : choosing the best path to Sij. 2) Only one way: from entry starting point to Si. The structure of the fastest way through the factory (from the starting point) The fastest possible way to get through Si.1 take time is entry time (ei) .

j Same as above . Two choices: Stay in the same line: Si.j-1 + ai.j (i = 1.j-1 Si.j-1 + ai.j If the fastest way through Si..j-1 + t3-i.j-1 Si..Step 1: Optimal Solution Structure The fastest possible way to get through Si.j-1.j Time is T3-i.j Time is Ti. n). 2) (j = 2.j-1 Transfer to other line: S3-i. it must have taken a fastest way through Si. .. 3.j is through Si.

j-1 then a transfer from line 3-i to line i and finally to Si.j The fastest way from starting point to S3-i.j-1 or S3-i.j-1 and then directly from Si. .j or Optimal Substructure.Step 1: Optimal Solution Structure An optimal solution to a problem finding the fastest way to get through Si.j-1 contains within it an optimal solution to sub-problems Fastest way from starting point to Si.j is either: The fastest way from starting point to Si.j finding the fastest way to get through either Si.j-1 to Si.

Example .

.

.

2) Let fi [j] be the fastest possible time to go from starting point through Si.j The fastest time to go all the way through the factory: f* x1 and x2 are the exit times from lines 1 and 2. respectively .Step 2: Recursive Solution Define the value of an optimal solution recursively in terms of the optimal solution to sub-problems Sub-problem here finding the fastest way through station j on both lines (i=1.

j e1 and e2 are the entry times for lines 1 and 2 .Step 2: Recursive Solution The fastest time to go through Si.

Example .

Example .

Step 2: Recursive Solution To help us keep track of how to construct an optimal solution. and j = 2.. 2. 3. let us define li[j ]: line # whose station j-1 is used in a fastest way through Si... n) we avoid defining li[1] because no station precedes station 1 on either lines.j (i = 1.. We also define l*: the line whose station n is used in a fastest way through the entire factory .

& 6 Line 2: 2. 4. 3. & 5 .Step 2: Recursive Solution Using the values of l* and li[j] shown in Figure (b) in next slide. we would trace a fastest way through the factory shown in part (a) as follows The fastest total time comes from choosing stations Line 1: 1.

Step 2: Recursive Solution .

Step 3: Optimal Solution Value .

Step 3: Optimal Solution Value 2 .

Step 3: Optimal Solution Value 2 .

Step 3: Optimal Solution Value Use substitution method to solve it O(2n) exponential .

Step 3: Optimal Solution Value .

Step 3: Optimal Solution Value .

Step 3: Optimal Solution Value .

Step 4: Optimal Solution Constructing the fastest way through the factory .

- Goodrich 6e Ch12 DivideAndConquerUploaded bySteven Galford
- 44 Dynamic ProgrammingUploaded byrosev15
- Economic operation of power system august 14 2014 lectureUploaded byAshok Saini
- Dynamic ProgrammingUploaded bynkapre
- millepunti-algoritmoUploaded byShubham Mishra
- lpiii-2.pdfUploaded bySoumodip Chakraborty
- DAA Lecture DynProgUploaded byraunak .com
- Demo MergeUploaded bycfdcfcf
- Update 1.3 to Elements of Programming InterviewsUploaded bytungdnguyen
- Design & Analysis of Algorithms Jan 2014Uploaded byPrasad C M
- Simpson - DynamicProgramminginExcelVer1.0WithabstractUploaded byTarig Gibreel
- 0270_PDF_C03.pdfUploaded byBao Tram Nguyen
- 90d0aa9e63eff0b8544fb07abca1fd8c 03 Divide and Conquer Problems 20161023Uploaded bykriti
- chap10Uploaded bymamudu francis
- lec4Uploaded byRawal Khirodkar
- spectogram hata.pdfUploaded byahmetygt
- RASA ProfileUploaded bybiotecnika
- The_Impact_of_Charging_Plug-In_Hybrid_Electric_Vehicles_on_a_Residential_Distribution_Grid-d55.pdfUploaded byBvijaya krishna
- Problem 8-8 Bm 181Uploaded byTrisha Luna
- cs-2008.docxUploaded byidlenbusy
- Cognitive tics Project ReportUploaded byNeha Arora
- NR-220502- Design and Analysis of AlgorithmsUploaded bySrinivasa Rao G
- review 6Uploaded byapi-253006610
- B.Mergesort.pdfUploaded byManuel Pérez
- CSFacultyResearchInterests[1]Uploaded bypraths1979
- m6-game-pubUploaded bychakravarthyashok
- ETCS 254 Algorithm Analysis and Design LabUploaded byGS Insititute
- English ResumeUploaded byMinh Le
- serena paul resume 2 pdfUploaded byapi-357794569
- 14-apspUploaded byshubhamagarwal2010

- 01 Agung AnalisisUploaded bySatria Surya Wijaya
- referensi kutipanUploaded bySatria Surya Wijaya
- Analisis Perang Dunia IIUploaded bySatria Surya Wijaya
- Melanesia.docUploaded bySatria Surya Wijaya
- 3-1-PBUploaded bySatria Surya Wijaya
- SEGMENTASI_CITRA_DIGITAL_DENGAN_MENGGUNA.pdfUploaded bySatria Surya Wijaya
- Proposal PpUploaded bySatria Surya Wijaya
- Praktikum Multimedia 2015Uploaded bySatria Surya Wijaya
- 846Uploaded bySatria Surya Wijaya
- 45-90-1-SMUploaded bySatria Surya Wijaya
- 00-SampulUploaded bySatria Surya Wijaya
- penulisan-kutipanUploaded bySatria Surya Wijaya
- Data Hotspot Di Perkebunan Sawit Di Kalteng 1 14 Oktober 2014Uploaded bySatria Surya Wijaya
- MultimediaUploaded bySatria Surya Wijaya
- TableUploaded bySatria Surya Wijaya
- Chapter 11. GUIUploaded bySatria Surya Wijaya
- LAPORAN HASIL PRAKTIKUM BD1 MOD4.docxUploaded bySatria Surya Wijaya
- Rangkuman Materi Algoritma Divide and ConquerUploaded bySatria Surya Wijaya
- Modul 1 Basis DataUploaded bySatria Surya Wijaya
- Percent RankUploaded bySatria Surya Wijaya
- Percent RankUploaded bySatria Surya Wijaya
- 6 Pengalamatan IpUploaded bySatria Surya Wijaya
- Daftar IsiUploaded bySatria Surya Wijaya
- Penetapan Hari EfektifUploaded bySatria Surya Wijaya
- Modul 11 PknUploaded bySatria Surya Wijaya
- Modul 10 PknUploaded bySatria Surya Wijaya
- Laporan Akhir Praktikum Modul 2Uploaded bySatria Surya Wijaya
- 10_stream Dan FileUploaded bySatria Surya Wijaya
- Makala hUploaded bySatria Surya Wijaya