Simplifying dynamic programming via mode-directed tabling

  • Authors:
  • Hai-Feng Guo;Gopal Gupta

  • Affiliations:
  • Department of Computer Science, University of Nebraska at Omaha, Omaha, Nebraska 68182-0500, U.S.A.;Department of Computer Science, University of Texas at Dallas, Richardson, TX 75083-0688, U.S.A.

  • Venue:
  • Software—Practice & Experience
  • Year:
  • 2008

Quantified Score

Hi-index 0.00

Visualization

Abstract

In the dynamic programming paradigm the value of an optimal solution is recursively defined in terms of optimal solutions to subproblems. Such dynamic programming definitions can be tricky and error-prone to specify. This paper presents an elegant method based on tabled logic programming (TLP) that simplifies the specification of such dynamic programming solutions. Our method introduces a new mode declaration for tabled predicates. The arguments of each tabled predicate are divided into indexed and non-indexed arguments so that tabled predicates can be regarded as functions: indexed arguments represent input values and non-indexed arguments represent output values. The non-indexed arguments in a tabled predicate can be further declared to be aggregated, for example, the minimum, so that while generating answers, the global table will dynamically maintain the smallest value for that argument. This mode-declaration scheme, coupled with recursion, provides an easy-to-use method for dynamic programming: there is no need to define the value of an optimal solution recursively, as the definition of a general solution suffices. The optimal value as well as its corresponding concrete solution can be derived implicitly and automatically using tabled logic programming systems. Our experimental results show that mode declarations improve performance in solving dynamic programming problems on TLP systems. Copyright © 2007 John Wiley & Sons, Ltd. This is an expanded version of the authors' paper ‘Simplifying Dynamic Programming via Tabling’ that appeared in the Proceedings of the 6th International Symposium on Practical Aspects of Declarative Languages, 2004, pp. 163–177