SlideShare a Scribd company logo
Start with the name of ALLAH the
Most merciful and the most
beneficial
Dynamic Programming
Prepared by :-
Contents:
 Meaning
 Defination
 What is dynamic programming used for
 Technique used in it
 Divide and Conquer Strategy
 General Divide and Conquer recurrence
 Common example
 Approaches of dynamic programming
 Elements of Dynamic Programming
 Dynamic Programming and Chain Matrix Multiplication
 Fibonacci Numbers
 Steps for problem solving
 Advantages and Disadvantages
 Good bye :p :p
What does Dynamic Mean ??
Characterized by continuous change activity
Characterized by much activity and vigor, especially
in bringing about change energetic and forceful
The designing, scheduling, or planning of a program
Ref http://www.thefreedictionary.com
So Combine Meaning Of Dynamic Programming is :
Change and Schedule a Solution for a problem
Defination :
 Dynamic Programming refers to a
very large class of algorithms. The
idea is to break a large problem
down (if possible) into incremental
steps so that, at any given stage,
optimal solutions are known to sub-
problems.
Ref :- Monash University
DEFINATION :
Use of dynamic programming
 Dynamic programming is used for problems requiring a sequence of interrelated
decision. This means that to take another decision we have to depend on the
previous decision or solution formed.
Technique used in dynamic programming
The Divide and Conquer Algorithm
• Divide_Conquer(problem P)
• {
• if Small(P) return S(P);
• else {
• divide P into smaller instances P1, P2, …, P k , k1;
• Apply Divide_Conquer to each of these sub problems;
• return Combine(Divide_Conquer(P1),
Divide_Conquer(P2),…, Divide Conquer(P k));
• }
• }
Divide Conquer recurrence relation
 The computing time of Divide Conquer is
 T(n) is the time for Divide Conquer on any input size n.
 g(n) is the time to compute the answer directly (for small inputs)
 f(n) is the time for dividing P and combining the solutions.
14





)()(...)()(
)(
)(
21 nfnTnTnT
ng
nT
k
n small
otherwise
15
General Divide and Conquer recurrence
The Master Theorem
T(n) = aT(n/b) + f (n), where f (n) ∈ Θ(n k)
1. a < bk T(n) ∈ Θ(n k)
2. a = bk T(n) ∈ Θ(n k lg n )
3. a > bk T(n) ∈ Θ(n log b a)
the time spent on solving a sub problem of size n/b.
the time spent on dividing the problem
into smaller ones and combining their solutions.
Difference between DP and Divide-and-
Conquer
 Using Divide-and-Conquer to solve these problems is inefficient because
the same common sub problems have to be solved many times.
 DP will solve each of them once and their answers are stored in a table
for future use.
i) Backward Recursion
ii) Forward Recursion
Two Approach of Dynamic Programming
It Contains Sequence of “n” decisions.
Each “n” corresponding to one of the decision.
Each stage of analysis is described by a set of elements
decision, input state, output state and return.
Then symbolic representation of n stages of analysis using
backward recursion so we can formalize the notation
Backward recursion
Cumulative return = Direct return + Cumulative return
through stage from stage through stage i-1
 We use sb to denote the previous state
 Tb determines the state that came before s when the decision made to reach state s is d
 Db(s) is the set of decisions that can be used to enter state s
sb = Tb(s, d), //where d belongs to Db(s)
Backward recursion formula
 Approach takes a problem
 Decomposed into a sequence of n stages
 Analyzes the problem starting with the first stage
in the sequence
 Working forward to the last stage
 it is also known as deterministic probability
approach
Forward recursion
Example
Elements of Dynamic Programming
i) Optimal substructure
ii) Overlapping sub problem
iii) Memoization
 a problem is said to have optimal substructure if an optimal solution can be
constructed efficiently from optimal solutions of its sub problems. This property is
used to determine the usefulness of dynamic programming
ref : wikipedia
Optimal Substructure
 This is the necessary property , if this property is not present we cant use
dynamic programming.
 a problem p , with sub problems p1,p2.
Solution of problem p is s , and s1 is the optimum solution of sub problem p1,and
s2 is the optimum solution of sub problem p2.
 Claim “s” is the optimal solution ,if both solution of the sub problems are
optimal only then the final solution is optimal.
Dynamic
Programming
Chain
Matrix
Multiplication
Dynamic Programming and
Chain Matrix Multiplication
In mathematics or computer science, Dynamic
Programming is a method for solving complex problems
by breaking them down into simpler sub-problems. So,
Matrix chain multiplication is an ideal example that
demonstrates utility of dynamic programming.
Engineering applications often have to multiply a large
chain of matrices with large dimensions, for example: 100
matrices of dimension 100×100. We can multiply this chain
of matrices in many different ways, but we will go for that
way which takes lower computations.
Dynamic Programming of Chain Matrix
Multiplication
For example, we are going to multiply 4 matrices:
M1 = 2 x 3
M2 = 3 x 4
M3 = 4 x 5
M4 = 5 x 7
And we have conditions for multiplying matrices:
• We can multiply only two matrices at a time.
• When we go to multiply 2 matrices, the number of columns of 1st matrix should
be same as the number of rows of 2nd matrix.
M1 = 2 x 3
M2 = 3 x 4
M3 = 4 x 5
M4 = 5 x 7
( M1 M2 )( M3 M4 ) = 220
(( M1 M2 ) M3 ) M4 = 134
M1 ( M2 ( M3 M4 ) = 266
( M1 ( M2 M3 ) M4 = 160
M1 (( M2 M3 ) M4 ) = 207
We can multiply the chain of matrices by following those
conditions in these ways:
Numbers of the rightmost side is number of total scalar
multiplication. So we have realized that we can reduce
the number of total multiplication and this reduced
time is a fact for a large chain of matrices.
Algorithm and Mechanism
Renaming matrices as Mi and dimensions as Pi - 1 x Pi , we have got:
M1 = P0 x P1
M2 = P1 x P2
M3 = P2 x P3
M4 = P3 x P4
| | |
Mi = Pi – 1 x Pi
We will use a formula:
Where C i, j means Mi to Mj .
i.e.: C 1, 4 means M1 to M4 .
And we will use a variable 'k' as follows:
M1 |k=1 M2 M3 M4
M1 M2 |k=2 M3 M4
M1 M2 M3 |k=3 M4
The thing we’re going to do is to apply above formula for every 'k' in the range 'i' to
'j' and pick the lowest value every step.
C 1 , 4 = min ( C1 , 1 + C2 , 4 + P0 * P1 * P4 , C1 , 2 + C3 , 4 + P0 * P2 * P4 , C1 , 3 + C4 , 4 + P0 *
P3 * P4 ) = min ( 207, 220, 134 ) = 134
C 2, 4 = min ( C2 , 2 + C3 , 4 + P1 * P2 * P4 , C2 , 3 + C4 , 4 + P1 * P3 * P4 ) = min ( 224, 165 )
= 165
C 1, 3 = min ( C1 , 1 + C2 , 3 + P0 * P1 * P3 , C1 , 2 + C3 , 3 + P0 * P2 * P3 ) = min ( 90, 64 ) =
64
C 1, 2 = P0 * P1 * P2 = 24
C 2, 3 = P1 * P2 * P3 = 60
C 3, 4 = P2 * P3 * P4 = 140
Pseudocode
1. int Chain( int i, int j )
2. {
3. int min = 10000, value, k;
4. if( i == j ){
5. return 0;
6. }
7. else{
8. for( k = i; k < j; k++ ){
9. value = (Chain(i, k) + Chain(k + 1, j) + (dimensions[i-1] *
dimensions[k] * dimensions[j]));
10. if( min > value ){
11. min = value;
12. mat[i][j] = k;
13. }
14. }
15. }
16. return min;
1. int main(void)
2. {
3. int result, i;
4. printf("Enter number of matrices: ");
5. scanf("%d", &n);
6. printf("Enter dimensions : ");
7. for( i = 0; i <= n; i++ ){
8. scanf("%d", &dimensions[i]);
9. }
10. result = Chain(1, n);
11. printf("nTotal number of multiplications: %d andn", result);
12. printf("Multiplication order is: ");
13. PrintOrder( 1, n );
14. printf("n");
15. }
Input and Output in Console App
Fibonacci Numbers
Fibonacci Numbers
 Fn= Fn-1+ Fn-2 n ≥ 2
 F0 =0, F1 =1
 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, …
 Straightforward recursive procedure is slow!
 Let’s draw the recursion tree
Fibonacci Numbers
Fibonacci Numbers
 How many summations are there? Using Golden Ratio
 As you go farther and farther to the right in this sequence, the ratio of a term to the one
before it will get closer and closer to the Golden Ratio.
 Our recursion tree has only 0s and 1s as leaves, thus we have 1.6n summations
 Running time is exponential!
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, only two values need to be remembered at any time
Steps for problem solving
 There are four steps of problem solving
 Optimal Solution Structure
 Recursive Solution
 Optimal Solution Value
 Optimal Solution
Problem Definition
 Problem: Given all these costs, what stations should be chosen from line 1
and from line 2 for minimizing the total time for car assembly.
 “Brute force” is to try all possibilities.
 requires to examine Omega(2n) possibilities
 Trying all 2n subsets is infeasible when n is large.
 Simple example : 2 station  (2n) possibilities =4
start end
Step 1: Optimal Solution Structure
optimal substructure : choosing the best path to Sij.
 The structure of the fastest way through the factory (from
the starting point)
 The fastest possible way to get through Si,1 (i = 1, 2)
 Only one way: from entry starting point to Si,1
 take time is entry time (ei)
Step 1: Optimal Solution Structure
 The fastest possible way to get through Si,j (i = 1, 2) (j = 2, 3, ..., n).
Two choices:
 Stay in the same line: Si,j-1  Si,j
 Time is Ti,j-1 + ai,j
 If the fastest way through Si,j is through Si,j-1, it must have taken a fastest way through Si,j-1
 Transfer to other line: S3-i,j-1  Si,j
 Time is T3-i,j-1 + t3-i,j-1 + ai,j
 Same as above
Step 1: Optimal Solution Structure
 An optimal solution to a problem
 finding the fastest way to get through Si,j
 contains within it an optimal solution to sub-problems
 finding the fastest way to get through either Si,j-1 or S3-i,j-1
 Fastest way from starting point to Si,j is either:
 The fastest way from starting point to Si,j-1 and then directly from Si,j-1 to
Si,j
or
 The fastest way from starting point to S3-i,j-1 then a transfer from line 3-i to
line i and finally to Si,j
 Optimal Substructure.
Example
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,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
 The fastest time to go through Si,j
 e1 and e2 are the entry times for lines 1 and 2
Example
Example
Step 2: Recursive Solution
 To help us keep track of how to construct an optimal solution, let us define
 li[j ]: line # whose station j-1 is used in a fastest way through Si,j (i = 1, 2, and j =
2, 3,..., n)
 we avoid defining li[1] because no station precedes station 1 on either lines.
 We also define
 l*: the line whose station n is used in a fastest way through the entire factory
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, 3, & 6 Line 2: 2, 4, & 5
Step 3: Optimal Solution Value
Step 3: Optimal Solution Value
Step 3: Optimal Solution Value
Step 3: Optimal Solution Value
Step 3: Optimal Solution Value
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
1)`the process of breaking down a complex problem into
a series of interrelated sub problems often provides
insight into the nature of problem
2) Because dynamic programming is an approach to
optimization rather than a technique it has flexibility
that allows application to other types of mathematical
programming problems
3) The computational procedure in dynamic programming
allows for a built in form of sensitivity analysis based
on state variables and on variables represented by
stages
4)Dynamic programming achieves computational savings
over complete enumeration.
1.)more expertise is required in solving dynamic programming problem then
using other methods
2.)lack of general algorithm like the simplex method. It restricts computer
codes necessary for inexpensive and widespread use
3.)the biggest problem is dimensionality. This problems occurs when a
particular application is characterized by multiple states. It creates lot of
problem for computers capabilities & is time consuming
Di
dynamic programming complete by Mumtaz Ali (03154103173)

More Related Content

What's hot

Design and analysis of computer algorithms
Design and analysis of computer algorithmsDesign and analysis of computer algorithms
Design and analysis of computer algorithms Krishna Chaytaniah
 
Flowshop scheduling
Flowshop schedulingFlowshop scheduling
Flowshop scheduling
Kunal Goswami
 
Dynamic programming class 16
Dynamic programming class 16Dynamic programming class 16
Dynamic programming class 16Kumar
 
Dynamic Programming
Dynamic ProgrammingDynamic Programming
Dynamic ProgrammingNilam Kabra
 
Algorithms, Union Find
Algorithms, Union FindAlgorithms, Union Find
Algorithms, Union Find
Nikita Shpilevoy
 
Analysis and Design of Algorithms
Analysis and Design of AlgorithmsAnalysis and Design of Algorithms
Analysis and Design of Algorithms
Bulbul Agrawal
 
Sum of subset problem.pptx
Sum of subset problem.pptxSum of subset problem.pptx
Sum of subset problem.pptx
V.V.Vanniaperumal College for Women
 
Recursive algorithms
Recursive algorithmsRecursive algorithms
Recursive algorithms
subhashchandra197
 
Travelling Salesman Problem
Travelling Salesman ProblemTravelling Salesman Problem
Travelling Salesman ProblemDaniel Raditya
 
implementation of travelling salesman problem with complexity ppt
implementation of travelling salesman problem with complexity pptimplementation of travelling salesman problem with complexity ppt
implementation of travelling salesman problem with complexity ppt
AntaraBhattacharya12
 
Assignment problem
Assignment problemAssignment problem
Assignment problem
Anggy Herny Anggraeni
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
Melaku Bayih Demessie
 
Randomized Algorithm- Advanced Algorithm
Randomized Algorithm- Advanced AlgorithmRandomized Algorithm- Advanced Algorithm
Randomized Algorithm- Advanced Algorithm
Mahbubur Rahman
 
Logic programming in python
Logic programming in pythonLogic programming in python
Logic programming in python
Pierre Carbonnelle
 
Computational Complexity: Complexity Classes
Computational Complexity: Complexity ClassesComputational Complexity: Complexity Classes
Computational Complexity: Complexity Classes
Antonis Antonopoulos
 
Traveling salesman problem
Traveling salesman problemTraveling salesman problem
Traveling salesman problem
Jayesh Chauhan
 
Tsp branch and-bound
Tsp branch and-boundTsp branch and-bound
Tsp branch and-bound
Saravanan Natarajan
 

What's hot (20)

Chap8 new
Chap8 newChap8 new
Chap8 new
 
Design and analysis of computer algorithms
Design and analysis of computer algorithmsDesign and analysis of computer algorithms
Design and analysis of computer algorithms
 
Flowshop scheduling
Flowshop schedulingFlowshop scheduling
Flowshop scheduling
 
Knapsack Problem
Knapsack ProblemKnapsack Problem
Knapsack Problem
 
Dynamic programming class 16
Dynamic programming class 16Dynamic programming class 16
Dynamic programming class 16
 
Dynamic Programming
Dynamic ProgrammingDynamic Programming
Dynamic Programming
 
Algorithms, Union Find
Algorithms, Union FindAlgorithms, Union Find
Algorithms, Union Find
 
Analysis and Design of Algorithms
Analysis and Design of AlgorithmsAnalysis and Design of Algorithms
Analysis and Design of Algorithms
 
Sum of subset problem.pptx
Sum of subset problem.pptxSum of subset problem.pptx
Sum of subset problem.pptx
 
Recursive algorithms
Recursive algorithmsRecursive algorithms
Recursive algorithms
 
Travelling Salesman Problem
Travelling Salesman ProblemTravelling Salesman Problem
Travelling Salesman Problem
 
implementation of travelling salesman problem with complexity ppt
implementation of travelling salesman problem with complexity pptimplementation of travelling salesman problem with complexity ppt
implementation of travelling salesman problem with complexity ppt
 
Assignment problem
Assignment problemAssignment problem
Assignment problem
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 
Randomized Algorithm- Advanced Algorithm
Randomized Algorithm- Advanced AlgorithmRandomized Algorithm- Advanced Algorithm
Randomized Algorithm- Advanced Algorithm
 
Logic programming in python
Logic programming in pythonLogic programming in python
Logic programming in python
 
Dynamic pgmming
Dynamic pgmmingDynamic pgmming
Dynamic pgmming
 
Computational Complexity: Complexity Classes
Computational Complexity: Complexity ClassesComputational Complexity: Complexity Classes
Computational Complexity: Complexity Classes
 
Traveling salesman problem
Traveling salesman problemTraveling salesman problem
Traveling salesman problem
 
Tsp branch and-bound
Tsp branch and-boundTsp branch and-bound
Tsp branch and-bound
 

Viewers also liked

Dynamic Programming
Dynamic ProgrammingDynamic Programming
Dynamic Programming
Sahil Kumar
 
7 New California DMV Laws You Need to Know
7 New California DMV Laws You Need to Know7 New California DMV Laws You Need to Know
7 New California DMV Laws You Need to KnowCost U Less Direct
 
Tellurian | Customized Corporate Diaries, Calendars, Flexible and Elastic Not...
Tellurian | Customized Corporate Diaries, Calendars, Flexible and Elastic Not...Tellurian | Customized Corporate Diaries, Calendars, Flexible and Elastic Not...
Tellurian | Customized Corporate Diaries, Calendars, Flexible and Elastic Not...
Tellurian Book Production
 
6 ways to save your hearing
6 ways to save your hearing6 ways to save your hearing
6 ways to save your hearing
Maico Audiological Services
 
Normas de auditoria
Normas de auditoria Normas de auditoria
Normas de auditoria
Alfredo Hernandez
 
The top 5 hearing aid myths exposed maicoaudio.com
The top 5 hearing aid myths exposed   maicoaudio.comThe top 5 hearing aid myths exposed   maicoaudio.com
The top 5 hearing aid myths exposed maicoaudio.comMaico Audiological Services
 
Wijkbijeenkomst
WijkbijeenkomstWijkbijeenkomst
Wijkbijeenkomst
Herman Van Schie
 
Capitulo 3
Capitulo 3Capitulo 3
Capitulo 3
Alfredo Hernandez
 
Eqpo 10 exposicion
Eqpo 10 exposicionEqpo 10 exposicion
Eqpo 10 exposicion
Alfredo Hernandez
 
BreeCS Example Report - All Deliveries
BreeCS Example Report - All DeliveriesBreeCS Example Report - All Deliveries
BreeCS Example Report - All Deliveries
Daniel Raines Communications / BreeCS Software
 
задачі на відсотки
задачі на відсоткизадачі на відсотки
задачі на відсотки
Viktoria Mikolaenko
 
hell vissor
hell vissorhell vissor
hell vissor
darieflor
 
квіти – діти землі
квіти – діти земліквіти – діти землі
квіти – діти земліlarionova123
 
What God Sees in You - 2/2/2014
What God Sees in You - 2/2/2014What God Sees in You - 2/2/2014
What God Sees in You - 2/2/2014
HaynesStreet
 
Reclaiming the Future: Lessons from Cuba and the 11th International Permacult...
Reclaiming the Future: Lessons from Cuba and the 11th International Permacult...Reclaiming the Future: Lessons from Cuba and the 11th International Permacult...
Reclaiming the Future: Lessons from Cuba and the 11th International Permacult...
Adam Brock
 

Viewers also liked (20)

Dynamic Programming
Dynamic ProgrammingDynamic Programming
Dynamic Programming
 
7 New California DMV Laws You Need to Know
7 New California DMV Laws You Need to Know7 New California DMV Laws You Need to Know
7 New California DMV Laws You Need to Know
 
я обираю
я обираюя обираю
я обираю
 
Ion druâă4
Ion druâă4Ion druâă4
Ion druâă4
 
Tellurian | Customized Corporate Diaries, Calendars, Flexible and Elastic Not...
Tellurian | Customized Corporate Diaries, Calendars, Flexible and Elastic Not...Tellurian | Customized Corporate Diaries, Calendars, Flexible and Elastic Not...
Tellurian | Customized Corporate Diaries, Calendars, Flexible and Elastic Not...
 
Maths project
Maths projectMaths project
Maths project
 
10 ways to instantly become more attractive
10 ways to instantly become more attractive10 ways to instantly become more attractive
10 ways to instantly become more attractive
 
6 ways to save your hearing
6 ways to save your hearing6 ways to save your hearing
6 ways to save your hearing
 
Normas de auditoria
Normas de auditoria Normas de auditoria
Normas de auditoria
 
The top 5 hearing aid myths exposed maicoaudio.com
The top 5 hearing aid myths exposed   maicoaudio.comThe top 5 hearing aid myths exposed   maicoaudio.com
The top 5 hearing aid myths exposed maicoaudio.com
 
Wijkbijeenkomst
WijkbijeenkomstWijkbijeenkomst
Wijkbijeenkomst
 
Expocion 2 equipo
Expocion 2 equipoExpocion 2 equipo
Expocion 2 equipo
 
Capitulo 3
Capitulo 3Capitulo 3
Capitulo 3
 
Eqpo 10 exposicion
Eqpo 10 exposicionEqpo 10 exposicion
Eqpo 10 exposicion
 
BreeCS Example Report - All Deliveries
BreeCS Example Report - All DeliveriesBreeCS Example Report - All Deliveries
BreeCS Example Report - All Deliveries
 
задачі на відсотки
задачі на відсоткизадачі на відсотки
задачі на відсотки
 
hell vissor
hell vissorhell vissor
hell vissor
 
квіти – діти землі
квіти – діти земліквіти – діти землі
квіти – діти землі
 
What God Sees in You - 2/2/2014
What God Sees in You - 2/2/2014What God Sees in You - 2/2/2014
What God Sees in You - 2/2/2014
 
Reclaiming the Future: Lessons from Cuba and the 11th International Permacult...
Reclaiming the Future: Lessons from Cuba and the 11th International Permacult...Reclaiming the Future: Lessons from Cuba and the 11th International Permacult...
Reclaiming the Future: Lessons from Cuba and the 11th International Permacult...
 

Similar to dynamic programming complete by Mumtaz Ali (03154103173)

Dynamic programming prasintation eaisy
Dynamic programming prasintation eaisyDynamic programming prasintation eaisy
Dynamic programming prasintation eaisy
ahmed51236
 
01 - DAA - PPT.pptx
01 - DAA - PPT.pptx01 - DAA - PPT.pptx
01 - DAA - PPT.pptx
KokilaK25
 
Daa chapter 3
Daa chapter 3Daa chapter 3
Daa chapter 3
B.Kirron Reddi
 
Lecture 8 dynamic programming
Lecture 8 dynamic programmingLecture 8 dynamic programming
Lecture 8 dynamic programmingOye Tu
 
Lecture11
Lecture11Lecture11
Lecture11
Nv Thejaswini
 
Matrix Multiplication(An example of concurrent programming)
Matrix Multiplication(An example of concurrent programming)Matrix Multiplication(An example of concurrent programming)
Matrix Multiplication(An example of concurrent programming)
Pramit Kumar
 
Data Structure & Algorithms - Mathematical
Data Structure & Algorithms - MathematicalData Structure & Algorithms - Mathematical
Data Structure & Algorithms - Mathematical
babuk110
 
Dynamic Programming - Part 1
Dynamic Programming - Part 1Dynamic Programming - Part 1
Dynamic Programming - Part 1
Amrinder Arora
 
Big Oh.ppt
Big Oh.pptBig Oh.ppt
Big Oh.ppt
Senthil Vit
 
Workshop03.docx lap trinh C cho người mới bắt đầu
Workshop03.docx  lap trinh C cho người mới bắt đầuWorkshop03.docx  lap trinh C cho người mới bắt đầu
Workshop03.docx lap trinh C cho người mới bắt đầu
linhtran111111111111
 
Computer algorithm(Dynamic Programming).pdf
Computer algorithm(Dynamic Programming).pdfComputer algorithm(Dynamic Programming).pdf
Computer algorithm(Dynamic Programming).pdf
jannatulferdousmaish
 
Ch3(1).pptxbbbbbbbbbbbbbbbbbbbhhhhhhhhhh
Ch3(1).pptxbbbbbbbbbbbbbbbbbbbhhhhhhhhhhCh3(1).pptxbbbbbbbbbbbbbbbbbbbhhhhhhhhhh
Ch3(1).pptxbbbbbbbbbbbbbbbbbbbhhhhhhhhhh
danielgetachew0922
 
Introduction to computing Processing and performance.pdf
Introduction to computing Processing and performance.pdfIntroduction to computing Processing and performance.pdf
Introduction to computing Processing and performance.pdf
TulasiramKandula1
 
Divide and Conquer - Part 1
Divide and Conquer - Part 1Divide and Conquer - Part 1
Divide and Conquer - Part 1
Amrinder Arora
 
dynamic programming Rod cutting class
dynamic programming Rod cutting classdynamic programming Rod cutting class
dynamic programming Rod cutting class
giridaroori
 
Ch-2 final exam documet compler design elements
Ch-2 final exam documet compler design elementsCh-2 final exam documet compler design elements
Ch-2 final exam documet compler design elements
MAHERMOHAMED27
 
Daa chapter 2
Daa chapter 2Daa chapter 2
Daa chapter 2
B.Kirron Reddi
 
Daa notes 2
Daa notes 2Daa notes 2
Daa notes 2
smruti sarangi
 
Time and space complexity
Time and space complexityTime and space complexity
Time and space complexityAnkit Katiyar
 
Dynamic Programming - Matrix Chain Multiplication
Dynamic Programming - Matrix Chain MultiplicationDynamic Programming - Matrix Chain Multiplication
Dynamic Programming - Matrix Chain Multiplication
Pecha Inc.
 

Similar to dynamic programming complete by Mumtaz Ali (03154103173) (20)

Dynamic programming prasintation eaisy
Dynamic programming prasintation eaisyDynamic programming prasintation eaisy
Dynamic programming prasintation eaisy
 
01 - DAA - PPT.pptx
01 - DAA - PPT.pptx01 - DAA - PPT.pptx
01 - DAA - PPT.pptx
 
Daa chapter 3
Daa chapter 3Daa chapter 3
Daa chapter 3
 
Lecture 8 dynamic programming
Lecture 8 dynamic programmingLecture 8 dynamic programming
Lecture 8 dynamic programming
 
Lecture11
Lecture11Lecture11
Lecture11
 
Matrix Multiplication(An example of concurrent programming)
Matrix Multiplication(An example of concurrent programming)Matrix Multiplication(An example of concurrent programming)
Matrix Multiplication(An example of concurrent programming)
 
Data Structure & Algorithms - Mathematical
Data Structure & Algorithms - MathematicalData Structure & Algorithms - Mathematical
Data Structure & Algorithms - Mathematical
 
Dynamic Programming - Part 1
Dynamic Programming - Part 1Dynamic Programming - Part 1
Dynamic Programming - Part 1
 
Big Oh.ppt
Big Oh.pptBig Oh.ppt
Big Oh.ppt
 
Workshop03.docx lap trinh C cho người mới bắt đầu
Workshop03.docx  lap trinh C cho người mới bắt đầuWorkshop03.docx  lap trinh C cho người mới bắt đầu
Workshop03.docx lap trinh C cho người mới bắt đầu
 
Computer algorithm(Dynamic Programming).pdf
Computer algorithm(Dynamic Programming).pdfComputer algorithm(Dynamic Programming).pdf
Computer algorithm(Dynamic Programming).pdf
 
Ch3(1).pptxbbbbbbbbbbbbbbbbbbbhhhhhhhhhh
Ch3(1).pptxbbbbbbbbbbbbbbbbbbbhhhhhhhhhhCh3(1).pptxbbbbbbbbbbbbbbbbbbbhhhhhhhhhh
Ch3(1).pptxbbbbbbbbbbbbbbbbbbbhhhhhhhhhh
 
Introduction to computing Processing and performance.pdf
Introduction to computing Processing and performance.pdfIntroduction to computing Processing and performance.pdf
Introduction to computing Processing and performance.pdf
 
Divide and Conquer - Part 1
Divide and Conquer - Part 1Divide and Conquer - Part 1
Divide and Conquer - Part 1
 
dynamic programming Rod cutting class
dynamic programming Rod cutting classdynamic programming Rod cutting class
dynamic programming Rod cutting class
 
Ch-2 final exam documet compler design elements
Ch-2 final exam documet compler design elementsCh-2 final exam documet compler design elements
Ch-2 final exam documet compler design elements
 
Daa chapter 2
Daa chapter 2Daa chapter 2
Daa chapter 2
 
Daa notes 2
Daa notes 2Daa notes 2
Daa notes 2
 
Time and space complexity
Time and space complexityTime and space complexity
Time and space complexity
 
Dynamic Programming - Matrix Chain Multiplication
Dynamic Programming - Matrix Chain MultiplicationDynamic Programming - Matrix Chain Multiplication
Dynamic Programming - Matrix Chain Multiplication
 

Recently uploaded

一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
FluxPrime1
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
ydteq
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
Jayaprasanna4
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
ongomchris
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
Kamal Acharya
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
Jayaprasanna4
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
Vijay Dialani, PhD
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
AafreenAbuthahir2
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Dr.Costas Sachpazis
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
BrazilAccount1
 

Recently uploaded (20)

一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
 

dynamic programming complete by Mumtaz Ali (03154103173)

  • 1. Start with the name of ALLAH the Most merciful and the most beneficial
  • 3. Contents:  Meaning  Defination  What is dynamic programming used for  Technique used in it  Divide and Conquer Strategy  General Divide and Conquer recurrence  Common example  Approaches of dynamic programming  Elements of Dynamic Programming  Dynamic Programming and Chain Matrix Multiplication  Fibonacci Numbers  Steps for problem solving  Advantages and Disadvantages  Good bye :p :p
  • 5. Characterized by continuous change activity Characterized by much activity and vigor, especially in bringing about change energetic and forceful
  • 6.
  • 7. The designing, scheduling, or planning of a program Ref http://www.thefreedictionary.com
  • 8. So Combine Meaning Of Dynamic Programming is : Change and Schedule a Solution for a problem
  • 9. Defination :  Dynamic Programming refers to a very large class of algorithms. The idea is to break a large problem down (if possible) into incremental steps so that, at any given stage, optimal solutions are known to sub- problems. Ref :- Monash University DEFINATION :
  • 10. Use of dynamic programming  Dynamic programming is used for problems requiring a sequence of interrelated decision. This means that to take another decision we have to depend on the previous decision or solution formed.
  • 11. Technique used in dynamic programming
  • 12.
  • 13. The Divide and Conquer Algorithm • Divide_Conquer(problem P) • { • if Small(P) return S(P); • else { • divide P into smaller instances P1, P2, …, P k , k1; • Apply Divide_Conquer to each of these sub problems; • return Combine(Divide_Conquer(P1), Divide_Conquer(P2),…, Divide Conquer(P k)); • } • }
  • 14. Divide Conquer recurrence relation  The computing time of Divide Conquer is  T(n) is the time for Divide Conquer on any input size n.  g(n) is the time to compute the answer directly (for small inputs)  f(n) is the time for dividing P and combining the solutions. 14      )()(...)()( )( )( 21 nfnTnTnT ng nT k n small otherwise
  • 15. 15 General Divide and Conquer recurrence The Master Theorem T(n) = aT(n/b) + f (n), where f (n) ∈ Θ(n k) 1. a < bk T(n) ∈ Θ(n k) 2. a = bk T(n) ∈ Θ(n k lg n ) 3. a > bk T(n) ∈ Θ(n log b a) the time spent on solving a sub problem of size n/b. the time spent on dividing the problem into smaller ones and combining their solutions.
  • 16. Difference between DP and Divide-and- Conquer  Using Divide-and-Conquer to solve these problems is inefficient because the same common sub problems have to be solved many times.  DP will solve each of them once and their answers are stored in a table for future use.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25. i) Backward Recursion ii) Forward Recursion Two Approach of Dynamic Programming
  • 26.
  • 27. It Contains Sequence of “n” decisions. Each “n” corresponding to one of the decision. Each stage of analysis is described by a set of elements decision, input state, output state and return. Then symbolic representation of n stages of analysis using backward recursion so we can formalize the notation Backward recursion Cumulative return = Direct return + Cumulative return through stage from stage through stage i-1
  • 28.  We use sb to denote the previous state  Tb determines the state that came before s when the decision made to reach state s is d  Db(s) is the set of decisions that can be used to enter state s sb = Tb(s, d), //where d belongs to Db(s) Backward recursion formula
  • 29.
  • 30.  Approach takes a problem  Decomposed into a sequence of n stages  Analyzes the problem starting with the first stage in the sequence  Working forward to the last stage  it is also known as deterministic probability approach Forward recursion
  • 32.
  • 33. Elements of Dynamic Programming i) Optimal substructure ii) Overlapping sub problem iii) Memoization
  • 34.  a problem is said to have optimal substructure if an optimal solution can be constructed efficiently from optimal solutions of its sub problems. This property is used to determine the usefulness of dynamic programming ref : wikipedia
  • 35.
  • 36. Optimal Substructure  This is the necessary property , if this property is not present we cant use dynamic programming.  a problem p , with sub problems p1,p2. Solution of problem p is s , and s1 is the optimum solution of sub problem p1,and s2 is the optimum solution of sub problem p2.  Claim “s” is the optimal solution ,if both solution of the sub problems are optimal only then the final solution is optimal.
  • 37.
  • 38.
  • 39.
  • 40.
  • 42. Dynamic Programming and Chain Matrix Multiplication In mathematics or computer science, Dynamic Programming is a method for solving complex problems by breaking them down into simpler sub-problems. So, Matrix chain multiplication is an ideal example that demonstrates utility of dynamic programming. Engineering applications often have to multiply a large chain of matrices with large dimensions, for example: 100 matrices of dimension 100×100. We can multiply this chain of matrices in many different ways, but we will go for that way which takes lower computations.
  • 43. Dynamic Programming of Chain Matrix Multiplication For example, we are going to multiply 4 matrices: M1 = 2 x 3 M2 = 3 x 4 M3 = 4 x 5 M4 = 5 x 7 And we have conditions for multiplying matrices: • We can multiply only two matrices at a time. • When we go to multiply 2 matrices, the number of columns of 1st matrix should be same as the number of rows of 2nd matrix.
  • 44. M1 = 2 x 3 M2 = 3 x 4 M3 = 4 x 5 M4 = 5 x 7 ( M1 M2 )( M3 M4 ) = 220 (( M1 M2 ) M3 ) M4 = 134 M1 ( M2 ( M3 M4 ) = 266 ( M1 ( M2 M3 ) M4 = 160 M1 (( M2 M3 ) M4 ) = 207 We can multiply the chain of matrices by following those conditions in these ways: Numbers of the rightmost side is number of total scalar multiplication. So we have realized that we can reduce the number of total multiplication and this reduced time is a fact for a large chain of matrices.
  • 45. Algorithm and Mechanism Renaming matrices as Mi and dimensions as Pi - 1 x Pi , we have got: M1 = P0 x P1 M2 = P1 x P2 M3 = P2 x P3 M4 = P3 x P4 | | | Mi = Pi – 1 x Pi
  • 46. We will use a formula: Where C i, j means Mi to Mj . i.e.: C 1, 4 means M1 to M4 . And we will use a variable 'k' as follows: M1 |k=1 M2 M3 M4 M1 M2 |k=2 M3 M4 M1 M2 M3 |k=3 M4
  • 47. The thing we’re going to do is to apply above formula for every 'k' in the range 'i' to 'j' and pick the lowest value every step. C 1 , 4 = min ( C1 , 1 + C2 , 4 + P0 * P1 * P4 , C1 , 2 + C3 , 4 + P0 * P2 * P4 , C1 , 3 + C4 , 4 + P0 * P3 * P4 ) = min ( 207, 220, 134 ) = 134 C 2, 4 = min ( C2 , 2 + C3 , 4 + P1 * P2 * P4 , C2 , 3 + C4 , 4 + P1 * P3 * P4 ) = min ( 224, 165 ) = 165 C 1, 3 = min ( C1 , 1 + C2 , 3 + P0 * P1 * P3 , C1 , 2 + C3 , 3 + P0 * P2 * P3 ) = min ( 90, 64 ) = 64 C 1, 2 = P0 * P1 * P2 = 24 C 2, 3 = P1 * P2 * P3 = 60 C 3, 4 = P2 * P3 * P4 = 140
  • 48. Pseudocode 1. int Chain( int i, int j ) 2. { 3. int min = 10000, value, k; 4. if( i == j ){ 5. return 0; 6. } 7. else{ 8. for( k = i; k < j; k++ ){ 9. value = (Chain(i, k) + Chain(k + 1, j) + (dimensions[i-1] * dimensions[k] * dimensions[j])); 10. if( min > value ){ 11. min = value; 12. mat[i][j] = k; 13. } 14. } 15. } 16. return min;
  • 49. 1. int main(void) 2. { 3. int result, i; 4. printf("Enter number of matrices: "); 5. scanf("%d", &n); 6. printf("Enter dimensions : "); 7. for( i = 0; i <= n; i++ ){ 8. scanf("%d", &dimensions[i]); 9. } 10. result = Chain(1, n); 11. printf("nTotal number of multiplications: %d andn", result); 12. printf("Multiplication order is: "); 13. PrintOrder( 1, n ); 14. printf("n"); 15. }
  • 50. Input and Output in Console App
  • 52. Fibonacci Numbers  Fn= Fn-1+ Fn-2 n ≥ 2  F0 =0, F1 =1  0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, …  Straightforward recursive procedure is slow!  Let’s draw the recursion tree
  • 54. Fibonacci Numbers  How many summations are there? Using Golden Ratio  As you go farther and farther to the right in this sequence, the ratio of a term to the one before it will get closer and closer to the Golden Ratio.  Our recursion tree has only 0s and 1s as leaves, thus we have 1.6n summations  Running time is exponential!
  • 55. 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, only two values need to be remembered at any time
  • 56.
  • 57. Steps for problem solving  There are four steps of problem solving  Optimal Solution Structure  Recursive Solution  Optimal Solution Value  Optimal Solution
  • 58. Problem Definition  Problem: Given all these costs, what stations should be chosen from line 1 and from line 2 for minimizing the total time for car assembly.  “Brute force” is to try all possibilities.  requires to examine Omega(2n) possibilities  Trying all 2n subsets is infeasible when n is large.  Simple example : 2 station  (2n) possibilities =4 start end
  • 59. Step 1: Optimal Solution Structure optimal substructure : choosing the best path to Sij.  The structure of the fastest way through the factory (from the starting point)  The fastest possible way to get through Si,1 (i = 1, 2)  Only one way: from entry starting point to Si,1  take time is entry time (ei)
  • 60. Step 1: Optimal Solution Structure  The fastest possible way to get through Si,j (i = 1, 2) (j = 2, 3, ..., n). Two choices:  Stay in the same line: Si,j-1  Si,j  Time is Ti,j-1 + ai,j  If the fastest way through Si,j is through Si,j-1, it must have taken a fastest way through Si,j-1  Transfer to other line: S3-i,j-1  Si,j  Time is T3-i,j-1 + t3-i,j-1 + ai,j  Same as above
  • 61. Step 1: Optimal Solution Structure  An optimal solution to a problem  finding the fastest way to get through Si,j  contains within it an optimal solution to sub-problems  finding the fastest way to get through either Si,j-1 or S3-i,j-1  Fastest way from starting point to Si,j is either:  The fastest way from starting point to Si,j-1 and then directly from Si,j-1 to Si,j or  The fastest way from starting point to S3-i,j-1 then a transfer from line 3-i to line i and finally to Si,j  Optimal Substructure.
  • 63.
  • 64.
  • 65. 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,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
  • 66. Step 2: Recursive Solution  The fastest time to go through Si,j  e1 and e2 are the entry times for lines 1 and 2
  • 69. Step 2: Recursive Solution  To help us keep track of how to construct an optimal solution, let us define  li[j ]: line # whose station j-1 is used in a fastest way through Si,j (i = 1, 2, and j = 2, 3,..., n)  we avoid defining li[1] because no station precedes station 1 on either lines.  We also define  l*: the line whose station n is used in a fastest way through the entire factory
  • 70. 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, 3, & 6 Line 2: 2, 4, & 5
  • 71.
  • 72. Step 3: Optimal Solution Value
  • 73. Step 3: Optimal Solution Value
  • 74. Step 3: Optimal Solution Value
  • 75. Step 3: Optimal Solution Value
  • 76. Step 3: Optimal Solution Value
  • 77. Step 3: Optimal Solution Value
  • 78. Step 3: Optimal Solution Value
  • 79. Step 3: Optimal Solution Value
  • 80. Step 4: Optimal Solution  Constructing the fastest way through the factory
  • 81.
  • 82. 1)`the process of breaking down a complex problem into a series of interrelated sub problems often provides insight into the nature of problem 2) Because dynamic programming is an approach to optimization rather than a technique it has flexibility that allows application to other types of mathematical programming problems 3) The computational procedure in dynamic programming allows for a built in form of sensitivity analysis based on state variables and on variables represented by stages 4)Dynamic programming achieves computational savings over complete enumeration.
  • 83. 1.)more expertise is required in solving dynamic programming problem then using other methods 2.)lack of general algorithm like the simplex method. It restricts computer codes necessary for inexpensive and widespread use 3.)the biggest problem is dimensionality. This problems occurs when a particular application is characterized by multiple states. It creates lot of problem for computers capabilities & is time consuming Di