Dynamic Programming Tutorial Elaine Chew QMUL: ELE021/ELED021/ELEM March 2012
Sources Hillier, F. S. & G. J. Lieberman. Introduction to Operations Research. Chapter 11: Dynamic Programming, 7 th, 8 th, 9 th editions, McGraw-Hill. Dixon, S. & Widmer, G. (2005). MATCH: A Music Alignment Tool Chest. In Proceedings of the 6 th Intl Conf on Music Information Retrieval, London, UK, Yang, A., E. Chew & A. Volk (2005). A Dynamic Programming Approach to Adaptive Tatum Assignment for Rhythm Transcription. In Proceedings of the 1 st IEEE Intl Wkshop on Multimedia Information Processing and, Irvine, CA,
Sources Hillier, F. S. & G. J. Lieberman. Introduction to Operations Research. Chapter 11: Dynamic Programming, 7 th, 8 th, 9 th editions, McGraw-Hill. Dixon, S. & Widmer, G. (2005). MATCH: A Music Alignment Tool Chest. In Proceedings of the 6 th Intl Conf on Music Information Retrieval, London, UK, Yang, A., E. Chew & A. Volk (2005). A Dynamic Programming Approach to Adaptive Tatum Assignment for Rhythm Transcription. In Proceedings of the 1 st IEEE Intl Wkshop on Multimedia Information Processing and, Irvine, CA,
Shortest Path Problem V = set of vertices (or nodes) E = set of edges (or arcs), including s (source) and t (sink) C = [c ij ] = set of arc costs X = indicator variable for whether arc ij is used Linear Programming Problem Formulation: Min Σ ij c ij x ij s.t.Σ i x ij = 1 Σ j x ij = 1 0 ≤ x ij ≤ 1
Hogwarts (Shortest Path) Example Determine which route from entrance to exit has the shortest distance G O EQ R MC 3 Gringott’s Wizarding Bank Entrance to Wizarding World Quality Quidditch Supplies Ollivander’s Exit to Charing Cross Road The Leaky Cauldron Magical Menagerie
Algorithm At iteration i – Objective: find the i-th nearest node to the origin – Input: i-1 nearest node to the origin, shortest path and distance – Candidates for i-th nearest node: nearest unsolved node to one solved – Calculation for i-th nearest node: for each new candidate, add new edge to previously found shortest path to the i-1-th nearest node. Among the new candidates, the node with shortest distance becomes the i-th nearest node.
Implementation Iteration, iSolved nodes connected to unsolved Closest connected unsolved node Total distance involved i-th nearest node Minimum distance Last connection
Hogwarts (Shortest Path) Example G O EQ R MC 3 0
Implementation Iteration, iSolved nodes connected to unsolved Closest connected unsolved node Total distance involved i-th nearest node Minimum distance Last connection 1RQ5Q5Q
Hogwarts (Shortest Path) Example G O EQ R MC 3 5 0
Implementation Iteration, iSolved nodes connected to unsolved Closest connected unsolved node Total distance involved i-th nearest node Minimum distance Last connection 1RQ5Q5R 2QRQR CCCC 6767 C6Q
Hogwarts (Shortest Path) Example G O EQ R MC
Implementation Iteration, iSolved nodes connected to unsolved Closest connected unsolved node Total distance involved i-th nearest node Minimum distance Last connection 1RQ5Q5R 2QRQR CCCC 6767 C6Q 3QCQC OOOO 9999 O9QCQC
Hogwarts (Shortest Path) Example G O EQ R MC
Implementation Iteration, iSolved nodes connected to unsolved Closest connected unsolved node Total distance involved i-th nearest node Minimum distance Last connection 1RQ5Q5R 2QRQR CCCC 6767 C6Q 3QCQC OOOO 9999 O9QCQC 4QCOQCO GMMGMM M COCO
Hogwarts (Shortest Path) Example G O EQ R MC
Implementation Iteration, iSolved nodes connected to unsolved Closest connected unsolved node Total distance involved i-th nearest node Minimum distance Last connection 1RQ5Q5R 2QRQR CCCC 6767 C6Q 3QCQC OOOO 9999 O9QCQC 4QCOQCO GMMGMM M COCO 5QOMQOM GGEGGE G11O
Hogwarts (Shortest Path) Example G O EQ R MC
Implementation Iteration, iSolved nodes connected to unsolved Closest connected unsolved node Total distance involved i-th nearest node Minimum distance Last connection 1RQ5Q5R 2QRQR CCCC 6767 C6Q 3QCQC OOOO 9999 O9QCQC 4QCOQCO GMMGMM M COCO 5QOMQOM GGEGGE G11O
Implementation Iteration, iSolved nodes connected to unsolved Closest connected unsolved node Total distance involved i-th nearest node Minimum distance Last connection 5QOMQOM GGEGGE G11O 6OMGOMG EEEEEE E G
Hogwarts (Shortest Path) Example G O EQ R MC
Sources Hillier, F. S. & G. J. Lieberman. Introduction to Operations Research. Chapter 11: Dynamic Programming, 7 th, 8 th, 9 th editions, McGraw-Hill. Dixon, S. & Widmer, G. (2005). MATCH: A Music Alignment Tool Chest. In Proceedings of the 6 th Intl Conf on Music Information Retrieval, London, UK, Yang, A., E. Chew & A. Volk (2005). A Dynamic Programming Approach to Adaptive Tatum Assignment for Rhythm Transcription. In Proceedings of the 1 st IEEE Intl Wkshop on Multimedia Information Processing and, Irvine, CA,
Dynamic Time Warping
Euclidean Distance
(i,j )
Sources Hillier, F. S. & G. J. Lieberman. Introduction to Operations Research. Chapter 11: Dynamic Programming, 7 th, 8 th, 9 th editions, McGraw-Hill. Dixon, S. & Widmer, G. (2005). MATCH: A Music Alignment Tool Chest. In Proceedings of the 6 th Intl Conf on Music Information Retrieval, London, UK, Yang, A., E. Chew & A. Volk (2005). A Dynamic Programming Approach to Adaptive Tatum Assignment for Rhythm Transcription. In Proceedings of the 1 st IEEE Intl Wkshop on Multimedia Information Processing and, Irvine, CA,
Tatum Segmentation Tatum = smallest perceptual time unit in music
Example Results
Segmentation Example of tatum selection Input: – Note onset times, O(1,n) = {O 1, O 2,…, O n } Output: – Segmentation points, S = {S 1, S 2,…,S m } – Optimal tatum in each segment
Remainder Squared Error o(1) … o(j) p 1 … j j+1 p
ERR(.) The error incurred by a tatum assignment, p, for onsets O(i+ 1,k) is given by the remainder squared error (RSE) function: where o j (= O j+1 – O j ) is the inter onset interval (IOI) between onsets j and j+1.
Optimal Segmentation Define OPT(k) to be the best segmentation (cost) for a given set of onsets O(1,k): where ERR(.) returns the error incurred by the best tatum assignment for the set of onsets O(i+1,k). k i i+1 … 1 …