Lecture 9: Dynamic Programming
Continuing the theme from last lecture, let M1, … , Mn be a series of matrices, and r0, … , rn be a series of dimensions such that Mi is an ri-1 * ri matrix.
Our goal is to compute the multiplication of all M:
best(i, j) = mink bestk(i, j)
bestk(i, j) = best(i, k) + best(k, j) + ri-1 * rk * rj
Using these rules, we can carefully fill a lower triangular table (being careful of the order of filling):
Matrix Cost/Order Algorithm:
For i = 1 to n
B[i, i] = 0
EndFor
For gap = 1 to (n-1)
for i = 1 to n - gap
j = i + gap
cost = mink {B[i, k] + B[k+1, j] + ri-1 * rk * rj}
B[i, j] = cost
EndFor
End For
return B[1,n]
- Need to remember choices!
- Whenever we assign B[i, j] we know the best k
- Use another array Mem[i, j] = best k found when doing B[i, j]
- Mem(1, n) tells where to split M1, … , Mn
Dividing a polygon into triangles:
This was once a very popular optimization technique for 3d rendering (and especially games) before graphics hardware supported complex shapes–triangles were fast to draw:

- Find the minimum weight of triangulation
- weight = sum of the lengths of new edges
- Polygon w/ vertices v1, … , vn– assume counterclockwise.
- D[i, j] = distance from vi to vj, unless outside the polygon, in which case the distance is infinite
- C(i, j) = minimum cost for triangulating polygon v1, … , vn
- Ck(1, n) = best answer using vertex k for triangle with v1 and vn
- C(1, n) = min Ck(1, n)
- Ck(1, n) = C(k, n) + C(1, k) + D[k, n] + D[1, k]
Polygon Triangulating Algorithm:
For i = 1 to n
C[i, i+1] = -D[i, i+1]
EndFor
For gap = 2 to n -1
for i = 1 to n - gap
j = i + gap
C[i, j] = mink {C[i, k] + C[k, j] + D[i, k] + D[k, j]}
EndFor
EndFor
return C[1, n]
This entry was posted on Friday, February 11th, 2005 at 1:23 pm and is tagged with nbsp nbsp nbsp nbsp nbsp, optimization technique, triangular table, dynamic programming, polygon, vertices, mink, vertex, graphics hardware, rk, matrices, triangles, multiplication, ck, gap, algorithm, shapes, triangle, array, matrix. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback.
Leave a Reply
Please take time to enjoy the archives: May 2005 (1) April 2005 (11) March 2005 (11) February 2005 (15) January 2005 (7)
Fresh, related resources:
- Dailydave Digest, Vol 37, Issue 9
network security, secure programming, \ computer forensics, etc.) - Any other technical requirements for your lecture - Whether you need visa to enter Brazil or not. Speakers will be allocated 50 minutes of presentation time, although, ... - Kerala University Applied electronics syllabus
of optimality and dynamic programming ? Solution of the discrete Riccati equation ? Sampling period sensitivity. Quadratic optimal control systems ? Introduction ? Steady state quadratic optimal control. Text Books: 1. Ogata K., ... - The Y Combinator (Slight Return)
Another big dividing line in programming languages is between static typing and dynamic typing. A statically-typed language is one where the types of all expressions are determined at compile time, and any type errors cause the ... - Friday August 1, 2008
Thahn-Son Dao, ?A Decentralized Approach to Dynamic Collaborative Driving.? Supervisors, Jan Huissoon and Chris Clark. On display in the faculty of engineering, PHY 3004. Oral defence Monday, August 18, 9:30 am, Engineering III room ... - 1 year fellowship for a doctoral researcher on program analysis
Theory and practice of logic programming (Accepted) 2008. [12] W. Vanhoof. Searching semantically equivalent code fragments in logic programs. In S. Etalle, editor, LOPSTR 2004, volume 3573 of Lecture notes in computer science, pages ...
