Dynamic Programming Dynamic Programming Dynamic Programming is a

  • Slides: 18
Download presentation
Dynamic Programming

Dynamic Programming

Dynamic Programming • Dynamic Programming is a general algorithm design technique • It breaks

Dynamic Programming • Dynamic Programming is a general algorithm design technique • It breaks up a problem into a series of overlapping subproblems ( sub-problem whose results can be reused several times) • Main idea: - set up a recurrence relating a solution to a larger instance to solutions of some smaller instances - solve smaller instances once - record solutions in a table - extract solution to the initial instance from that table

Discussed topics • Assembly-line scheduling • Partition of Data Sequence • Route Segmentation and

Discussed topics • Assembly-line scheduling • Partition of Data Sequence • Route Segmentation and Classification for GPS data • Longest Common Subsequence (LCS)

Assembly-line scheduling Recursive equation: where f 1[j] and f 2[j] are the accumulated time

Assembly-line scheduling Recursive equation: where f 1[j] and f 2[j] are the accumulated time cost to reach station S 1, j and S 2, j a 1, j is the time cost for station S 1, j t 2, j-1 is the time cost to change station from S 2, j-1 to S 1, j

Partition of Data Sequence Partition of the sequence X into to K nonoverlapping groups

Partition of Data Sequence Partition of the sequence X into to K nonoverlapping groups with given cost functions f(xi, xj) so that the total value of the cost function is minimal:

Partition of Data Sequence G(k, n) is cost function for optimal partition of n

Partition of Data Sequence G(k, n) is cost function for optimal partition of n points into k non-overlapping groups: Recursive equation:

Examples: Image Quantization Input Quantized Here, cost function is: Square Error Quantize value

Examples: Image Quantization Input Quantized Here, cost function is: Square Error Quantize value

Examples: Polygonal Approximation 5004 points are approximated by 78 points. Given approximated points M,

Examples: Polygonal Approximation 5004 points are approximated by 78 points. Given approximated points M, errors are minimized. Given error ε, number of approximated points are minimized. Here, cost function is:

Examples: Route segmentation Ski Non-moving Running and Jogging Divide the routes into several segments

Examples: Route segmentation Ski Non-moving Running and Jogging Divide the routes into several segments by speed consistency Here, cost function is: Speed variance Time duration

Examples: Route classification Determine the moving type only by speed will cause mis-classification. Frequent

Examples: Route classification Determine the moving type only by speed will cause mis-classification. Frequent Moving type dependency of 1 st order HMM

Examples: Route classification (cont. ) 1 st order HMM, maximize: mi : moving type

Examples: Route classification (cont. ) 1 st order HMM, maximize: mi : moving type of segment i Xi : feature vector (e. g. speed) Solve by dynamic programming similar with the Assembly-line scheduling problem

Longest Common Subsequence (LCS) Find a maximum length common subsequence between two sequences. For

Longest Common Subsequence (LCS) Find a maximum length common subsequence between two sequences. For instance, Sequence 1: president Sequence 2: providence Its LCS is priden. president providence

How to compute LCS? Let A=a 1 a 2…am and B=b 1 b 2…bn.

How to compute LCS? Let A=a 1 a 2…am and B=b 1 b 2…bn. len(i, j): the length of an LCS between a 1 a 2…ai and b 1 b 2…bj With proper initializations, len(i, j) can be computed as follows.

Running time and memory: O(mn) and O(mn).

Running time and memory: O(mn) and O(mn).

Time Series Matching using Longest Common Subsequence delta = time matching region (left &

Time Series Matching using Longest Common Subsequence delta = time matching region (left & right) epsilon = spatial matching region (up & down) Recursive equation:

Spatial Data Matching using Longest Common Subsequence epsilon = spatial matching distance Recursive equation:

Spatial Data Matching using Longest Common Subsequence epsilon = spatial matching distance Recursive equation:

Conclusion Main idea: - Divide into sub-problems - Design cost function and recursive function

Conclusion Main idea: - Divide into sub-problems - Design cost function and recursive function - Optimization (fill in the table) - Backtracking