Staging Dynamic Programming Algorithms


Applications of dynamic programming (DP) algorithms are numerous, and include genetic engineering and operations research problems. At a high level, DP algorithms are specified as a system of recursive equations implemented using memoization. The recursive nature of these equations suggests that they can be written naturally in a functional language. However, the requirement for memoization poses a subtle challenge: memoization can be implemented using monads, but a systematic treatment introduces several layers of abstraction that can have a prohibitive runtime overhead. Inspired by other researchers’ experience with automatic specialization (partial evaluation), this paper investigates the feasibility of explicitly staging DP algorithms in the functional setting. We find that the key challenge is code duplication (which is automatically handled by partial evaluators), and show that a key source of code duplication can be isolated and addressed once and for all. The result is a simple combinator library. We use this library to implement several standard DP algorithms including ones in standard algorithm textbooks (e.g. Introduction to Algorithms by Cormen et al. [10]) in a manner that is competitive with hand-written C programs. Our combinator library has been useful for a variety of applications beyond the scope of dynamic programming, including the generation of hardware circuits.

Extracted Key Phrases

3 Figures and Tables

Cite this paper

@inproceedings{Swadi2005StagingDP, title={Staging Dynamic Programming Algorithms}, author={Kedar N. Swadi and Walid Taha and Oleg Kiselyov}, year={2005} }