Dynamic Programming
Weighted interval scheduling (Binary Choice of Opti Sub)
Jobjstarts at sj, finishes at fj, and has weight wj>0.
Two jobs are compatible if they don’t overlap.
Goal: find a max-weight subset of mutually compatible jobs.
p(j)=largest index i<j such that job i is compatible with j.
To efficiently computer p(j)we can sort jobs in ascending order of finish time.
Constraints on the interval time (subproblem)
Seek max weights (open values)
Optimum Subproblem
Max weight with an increasing ordering subset of mutually compatible intervals.
Bellman equation
j=0means empty set and no intervals scheduled
Subproblem is a binary choice problem.
Maximum Continuous Subarray Sum-KADANE ’ S ALGORITHM (Binary Choice of Opti Sub)
Constraints on the continuous subarray (subproblem)
Seek max weights (open values)
Optimum Subproblem
Max sum with an increasing ending index. (or increasing ordering subset)
OPT(i)= max sum of any subarray of x whose rightmost index is i.
Bellman equation
i=1means first element or subset with length of 1
Subproblem is a binary choice problem.
Knapsack problem (Two variable Opti Subp)
Goal. Pack knapsack so as to maximize the total value of items taken.
There are n items: item i provides value vi>0 and weighs wi>0.
Value of a subset of items = sum of values of individual items.
The Knapsack has a weight limit of W.
Constraints on the weights and at most 1 items for each item (subproblem)
Seek max values (open values)
Optimum Subproblem
Max value with an increasing ending index with a change of weight limit. (or increasing ordering subset)
OPT(i,w)= optimal value of knapsack problem with items 1,…,i, subject to weight limit w.
Bellman equation
i=0means empty set and no item gets loaded
The Subproblem is a two-variable problem. (Constraints is weight limit updating, compared to a compatible interval scheduling)
Coin Changing (Multiway-choice Opti Subp)
Goal. Given n coin denominations d1,d2,…,dn and a target value V, find the fewest coins needed to make change for V (or report impossible).
Constraints on the change values (subproblem, increasing changes of values, subproblem is created by choosing any coins currently)
Seek max number of coins (open questions, because for each coin we do not know we need how many)
Optimum Subproblem
The minimum number of coins with an increasing value of changes.
OPT(v)=min number of coins to make change forv. (The current subproblem can be set by choosing any coin denomination. (Multi-way choice))
Bellman equation
v<0means the value there are no possible changes such that the value is $$\infty$$ because we are seeking a minimum number
The Subproblem is a multiway problem, a single-variable problem. (Constraints is weight limit updating, compared to a compatible interval scheduling)
Coin changing is like the opposite problem of Knapsack problem which one is with fixed values to seek a minimum number of items, the other is with at most one present for each item to seek a maximum possible values.
RNA(String) secondary structure (Substring) (Intervals Opti Subp)
RNA. String B = b1,b2,…,bn over alphabet { A, C, G, U }.
Secondary structure. RNA is single-stranded so it tends to loop back and form base pairs with itself with the following rules:
[Watson–Crick] Pairs with Watson–Crick complement: A–U, U–A, C–G, or G–C.
[No sharp turns] The ends of each pair are separated by at least 4 intervening bases. If (bi,bj)∈S, theni<j–4.
[Non-crossing] If (bi,bj) and (bk,bℓ) are two pairs in S, then we cannot have i<k<j<ℓ.
Goal. Given an RNA moleculeB=b1b2…bn, find a secondary structure S that maximizes the number of base pairs.
Constraints on the substrings
(subproblem, increasing ending index of the substring, subproblem is created by choosing any letter that comes before the current letter to form two new substrings.)
These two substrings for the subproblems form an interval optimal subproblems.
Seek max number of Watson-Crick pairs
Optimum Subproblem
The maximum number of WC pairs with an increasing ending index of the substring. Each subproblem is solved by all substrings within.
OPT(i,j)=maximum number of base pairs in a secondary structure of the substring B=b1b2…bn
Bellman equation
1 means pair (t, j)
The subproblem is a two-interval problem
If it is an interval subproblem then the starting index i should be iterated. (Ordering increasing subsets with an iterating starting index)
Sequence Alignment (Substring) (Two-Variable Opti Subp)
Edit distance. [Levenshtein 1966, Needleman–Wunsch 1970]
Gap penalty δ; mismatch penalty αpq.
Cost = sum of gap and mismatch penalties.
Sequence alignment. Given two strings x1x2...xm and y1y2...yn , find a min-cost alignment.
An alignment M is a set of ordered pairs xi–yj such that each character appears in at most one pair and no crossings.
cost(M)=mismatch(xi,yj)∈M∑αxiyj+gapxi∈unmatched∑α+yj∈unmatched∑δ
Constraints on the two substrings
(subproblem, increasing ending index of the two strings)
Optimum Subproblem
The minimum cost of alignment with an increasing ending index of the two substrings.
OPT(i,j)=min cost of aligning prefix strings x1x2...xi and y1y2...yj.
Bellman equation
δmeans gap penalty
αmeans match penalty. Match zero, mismatch 1.
Last updated