Algebraic Dynamic Programming Session 4 ADP Theory II

advertisement
Symbolic Evaluation
Algebraic Dynamic Programming
Yield parsing
Algebraic Dynamic Programming
Session 4
ADP Theory II: Algebraic Dynamic Programming
and Bellman’s Principle
Mathias Möhl, Rolf Backofen (Lecture)
Daniel Maticzka, Sita Lange (Exercises)
Department of Computer Science
Albert-Ludwigs-University Freiburg
Summer 2010
http://www.bioinf.uni-freiburg.de/Lehre/Courses/2010 SS/V ADP
mmohl@informatik.uni-freiburg.de.de
Mathias Möhl, Rolf Backofen (Lecture) Daniel Maticzka, Sita Lange (Exercises)
ADP Lecture Summer 2010
Albert-Ludwigs-University Freiburg
Symbolic Evaluation
Algebraic Dynamic Programming
Yield parsing
Another thought on symbolic evaluation
Think of a calculation that returns some result – say a search for a
minimmal answer from some search space yields the number
42
Several operations have led to this result, starting from the input
data, which were (say)
3, 4, 5, 6, 7, 8
Let’s assume we executed this calculation symbolically – we would
obtain (say)
3 + min(4 ∗ 10, 5 + min(6 + 7 ∗ 4, 8 ∗ 9))
Written as a term/tree in a appropriate signature this is
plus(3, min(times10 (4), plus(5, min(plus(6, times4 (7)), times(8, 9)))))
Mathias Möhl, Rolf Backofen (Lecture) Daniel Maticzka, Sita Lange (Exercises)
ADP Lecture Summer 2010
Albert-Ludwigs-University Freiburg
Symbolic Evaluation
Algebraic Dynamic Programming
Yield parsing
Distribution of choice over evaluation
Since min is monotone with respect to + and ∗, we can move it to
be the last operation, obtaining
min[3 + 4 ∗ 10, 3+5 + 6 + 7 ∗ 4, 3 + 5+8 ∗ 9]
Here we evaluate all candidates separately – this means increased
effort.
The initial formula finds the minimum without making the
computations shown in green here.
Mathias Möhl, Rolf Backofen (Lecture) Daniel Maticzka, Sita Lange (Exercises)
ADP Lecture Summer 2010
Albert-Ludwigs-University Freiburg
Symbolic Evaluation
Algebraic Dynamic Programming
Yield parsing
Combinatorial explosion
Typically we face the following situation:
the size of the formula with min applied to sub-formulas is
polynomial in the size of the input
the expanded list of all candidates – with min applied once at
the top – has exponential size.
This is analogous to turning a DAG into a tree by duplicating
shared subtrees ...
Mathias Möhl, Rolf Backofen (Lecture) Daniel Maticzka, Sita Lange (Exercises)
ADP Lecture Summer 2010
Albert-Ludwigs-University Freiburg
Symbolic Evaluation
Algebraic Dynamic Programming
Yield parsing
Combinatorial explosion
Typically we face the following situation:
the size of the formula with min applied to sub-formulas is
polynomial in the size of the input
the expanded list of all candidates – with min applied once at
the top – has exponential size.
This is analogous to turning a DAG into a tree by duplicating
shared subtrees ...
Consequence: If we cannot distribute the choice function towards
the inside of the candidates, we cannot solve the problem
efficiently.
Mathias Möhl, Rolf Backofen (Lecture) Daniel Maticzka, Sita Lange (Exercises)
ADP Lecture Summer 2010
Albert-Ludwigs-University Freiburg
Symbolic Evaluation
Algebraic Dynamic Programming
Yield parsing
Algebraic dynamic programming – conceptual idea
We solve our optimization problem conceptually in three phases:
compute a list of trees that represent all the candidates,
evaluate them all to a list of values,
apply the objective function to this list.
In the implementation, these phases will be amalgamated, as
the objective function is applied to intermediate results.
But for algorithm design, we do not want worry about this issue of
efficiency. We only need to make sure that the amalgamation is
mathematically correct.
Mathias Möhl, Rolf Backofen (Lecture) Daniel Maticzka, Sita Lange (Exercises)
ADP Lecture Summer 2010
Albert-Ludwigs-University Freiburg
Symbolic Evaluation
Algebraic Dynamic Programming
Yield parsing
Yield parsing: Constructing the candidate space from the
input
The yield of a tree is its string of leaf symbols
Yield language of tree grammar: {yield(t)|t ∈ L(G)}
Note: Yield languages are context-free (string) languages,
whereas tree languages are regular!
A tree grammar used to parse (yield) strings is called yield
grammar.
Mathias Möhl, Rolf Backofen (Lecture) Daniel Maticzka, Sita Lange (Exercises)
ADP Lecture Summer 2010
Albert-Ludwigs-University Freiburg
Symbolic Evaluation
Algebraic Dynamic Programming
Yield parsing
Bellman’s Principle
Let X , Xi , Y denote lists over the value domain of a Σ-algebra A.
A satisfies Bellman’s Principle if
for all operators f in Σ,
h[f (x1 , . . . , xn )|x1 ← X1 , . . . , xn ← Xn ] =
h[f (x1 , . . . , xn )|x1 ← h(X1 ), . . . , xn ← h(Xn )]
For all lists X and Y ,
h(X ++Y ) = h(h(X )++h(Y ))
Mathias Möhl, Rolf Backofen (Lecture) Daniel Maticzka, Sita Lange (Exercises)
ADP Lecture Summer 2010
Albert-Ludwigs-University Freiburg
Symbolic Evaluation
Algebraic Dynamic Programming
Yield parsing
Remarks on formulation of BP
The second equation implies for Y = [ ] idempotence of h
h(h(X )) = h(X )
Usually, h also satisfies
h(X ) ⊆ X
and hence
h([ ]) = [ ].
The functions f may also take arguments from A which come from
the input. They can be considered (arbitrary) constants in the
above equation. They come from the input strings and not from
lists of subproblem solutions.
Mathias Möhl, Rolf Backofen (Lecture) Daniel Maticzka, Sita Lange (Exercises)
ADP Lecture Summer 2010
Albert-Ludwigs-University Freiburg
Symbolic Evaluation
Algebraic Dynamic Programming
Yield parsing
The most frequent special case
Most often we have
f (x) = x + c, or
f (x, y ) = x + y , or
f (x) = some other function on numbers
h = min or h = max
In this case, Bellman’s Principle specializes to monotonicity of f :
x < y ⇒ f (. . . , x, . . .) ≤ f (. . . , y , . . .)
Mathias Möhl, Rolf Backofen (Lecture) Daniel Maticzka, Sita Lange (Exercises)
ADP Lecture Summer 2010
Albert-Ludwigs-University Freiburg
Symbolic Evaluation
Algebraic Dynamic Programming
Yield parsing
The most frequent special case
Most often we have
f (x) = x + c, or
f (x, y ) = x + y , or
f (x) = some other function on numbers
h = min or h = max
In this case, Bellman’s Principle specializes to monotonicity of f :
x < y ⇒ f (. . . , x, . . .) ≤ f (. . . , y , . . .)
For h = mink or h = maxk , Bellman’s Principle specializes to strict
monotonicity of f :
x < y ⇒ f (. . . , x, . . .) < f (. . . , y , . . .)
Mathias Möhl, Rolf Backofen (Lecture) Daniel Maticzka, Sita Lange (Exercises)
ADP Lecture Summer 2010
Albert-Ludwigs-University Freiburg
Symbolic Evaluation
Algebraic Dynamic Programming
Yield parsing
Historical formulation of Bellman’s Principle
Bellman 1964: An optimal solution for a given problem is always
composed exclusively from optimal solution of it’s subproblems.
This is less general than the definition of the previous slide:
it speaks of a single solution (rather than lists of solutions)
it speaks of “optimal” and thinks of minimization or
maximization
Our objective function h may also compute other types of
information.
The historical formulation is also more general (vague...?), as
nothing is said about how evaluation works, how candidate
solutions are obtained, etc.
Mathias Möhl, Rolf Backofen (Lecture) Daniel Maticzka, Sita Lange (Exercises)
ADP Lecture Summer 2010
Albert-Ludwigs-University Freiburg
Symbolic Evaluation
Algebraic Dynamic Programming
Yield parsing
Who satisfies Bellman’s Priciple?
Positive examples are
min and max with respect to + and ∗ on positive numbers
mink , maxk just as well
∗ distributes over +
(e.g. Mc Caskill algorithm, computation of partition function)
Negative examples are:
min, max when f is not monotone
second best in terms of min, max
Mathias Möhl, Rolf Backofen (Lecture) Daniel Maticzka, Sita Lange (Exercises)
ADP Lecture Summer 2010
Albert-Ludwigs-University Freiburg
Symbolic Evaluation
Algebraic Dynamic Programming
Yield parsing
Algebraic dynamic programming – definition
An ADP algorithm is specified by
an evaluation signature Σ over an alphabet A
a tree grammar over Σ
a concrete evaluation algebra E with an objective function h
satisfying Bellman’s Principle of Optimality.
Bellman’s Principle ensures that the objective function distributes
over evaluation.
Mathias Möhl, Rolf Backofen (Lecture) Daniel Maticzka, Sita Lange (Exercises)
ADP Lecture Summer 2010
Albert-Ludwigs-University Freiburg
Symbolic Evaluation
Algebraic Dynamic Programming
Yield parsing
Solution of an ADP problem
Given: yield grammar G, evaluation algebra E with objective
function h, and input sequence x
Definition (Solving an ADP problem)
Compute
G(E, x) = h[E(t)|t ∈ L(G), yield(t) = x]
in polynomial time and space.
Mathias Möhl, Rolf Backofen (Lecture) Daniel Maticzka, Sita Lange (Exercises)
ADP Lecture Summer 2010
Albert-Ludwigs-University Freiburg
Symbolic Evaluation
Algebraic Dynamic Programming
Yield parsing
Implementation of an ADP algorithm
Implement a generic yield-parser based on CYK algorithm via
templates in C++
class methods in Java
combinators in Haskell
or use the native ADP → C Compiler ...
Mathias Möhl, Rolf Backofen (Lecture) Daniel Maticzka, Sita Lange (Exercises)
ADP Lecture Summer 2010
Albert-Ludwigs-University Freiburg
Symbolic Evaluation
Algebraic Dynamic Programming
Yield parsing
Fun for theoreticians
yield parsing paradox
optimal table design (NP-complete)
semantic ambiguity (undecidable)
scope of ADP (yield languages beyond context free)
Mathias Möhl, Rolf Backofen (Lecture) Daniel Maticzka, Sita Lange (Exercises)
ADP Lecture Summer 2010
Albert-Ludwigs-University Freiburg
Symbolic Evaluation
Algebraic Dynamic Programming
Yield parsing
First fun for programmers
Exploit modularization for development & testing
opt: optimization algebra
k-opt: for near-optimals
enum: for program introspection
pretty: for output, ambiguity checking
count: for combinatorics and testing
prob: for statistical significance, E-values
Mathias Möhl, Rolf Backofen (Lecture) Daniel Maticzka, Sita Lange (Exercises)
ADP Lecture Summer 2010
Albert-Ludwigs-University Freiburg
Symbolic Evaluation
Algebraic Dynamic Programming
Yield parsing
Preview next session
Next session we will
have a Haskell crash course
understand how ADP is implemented in Haskell
look at the online examples using ADP pages at
http://bibiserv.techfak.uni-bielefeld.de/adp/
adpapp.html
Mathias Möhl, Rolf Backofen (Lecture) Daniel Maticzka, Sita Lange (Exercises)
ADP Lecture Summer 2010
Albert-Ludwigs-University Freiburg
Download