Dynamic Programming
Last updated
Last updated
Jobstarts at , finishes at , and has weight .
Two jobs are compatible if they don’t overlap.
Goal: find a max-weight subset of mutually compatible jobs.
largest index such that job is compatible with .
To efficiently computer we can sort jobs in ascending order of finish time.
Constraints on the interval time (subproblem)
Seek max weights (open values)
Max weight with an increasing ordering subset of mutually compatible intervals.
means empty set and no intervals scheduled
Subproblem is a binary choice problem.
Constraints on the continuous subarray (subproblem)
Seek max weights (open values)
Max sum with an increasing ending index. (or increasing ordering subset)
Subproblem is a binary choice problem.
Goal. Pack knapsack so as to maximize the total value of items taken.
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)
Max value with an increasing ending index with a change of weight limit. (or increasing ordering subset)
The Subproblem is a two-variable problem. (Constraints is weight limit updating, compared to a compatible interval scheduling)
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)
The minimum number of coins with an increasing value of changes.
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.
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.
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
The maximum number of WC pairs with an increasing ending index of the substring. Each subproblem is solved by all substrings within.
1 means pair (t, j)
The subproblem is a two-interval problem
Edit distance. [Levenshtein 1966, Needleman–Wunsch 1970]
Cost = sum of gap and mismatch penalties.
Constraints on the two substrings
(subproblem, increasing ending index of the two strings)
The minimum cost of alignment with an increasing ending index of the two substrings.
max sum of any subarray of whose rightmost index is .
means first element or subset with length of 1
There are items: item provides value and weighs .
optimal value of knapsack problem with items subject to weight limit .
means empty set and no item gets loaded
Goal. Given n coin denominations and a target value , find the fewest coins needed to make change for (or report impossible).
min number of coins to make change for. (The current subproblem can be set by choosing any coin denomination. (Multi-way choice))
means the value there are no possible changes such that the value is $$\infty$$ because we are seeking a minimum number
RNA. String B = over alphabet { A, C, G, U }.
[No sharp turns] The ends of each pair are separated by at least 4 intervening bases. If , then.
[Non-crossing] If and are two pairs in , then we cannot have .
Goal. Given an RNA molecule, find a secondary structure that maximizes the number of base pairs.
maximum number of base pairs in a secondary structure of the substring
If it is an interval subproblem then the starting index should be iterated. (Ordering increasing subsets with an iterating starting index)
Gap penalty ; mismatch penalty .
Sequence alignment. Given two strings and , find a min-cost alignment.
An alignment M is a set of ordered pairs such that each character appears in at most one pair and no crossings.
min cost of aligning prefix strings and .
means gap penalty
means match penalty. Match zero, mismatch 1.