Dynamic programming is an important optimization technique, but designing efficient dynamic programming algorithms can be difficult for even professional programmers. Thinning, a technique developed for systematically deriving efficient dynamic programming algorithms, has received much attention in studies because of its effectiveness for a large class of problems. Despite the success of thinning in theory, its practical usage is still limited because (1) applying thinning requires mathematical and algorithmic background, and (2) applying thinning solely may not be enough to generate algorithms as efficient as proposed by human experts. In this paper, we propose two approaches, MetHyl and MetHyl+, to resolve both problems. First, MetHyl automates the application of thinning via program synthesis and thus eliminates the burden to the user for applying thinning. Second, MetHyl+ integrates three rules into MetHyl that optimize three important factors on the time complexity of dynamic programming algorithms that are ignored by thinning, and thus make it able to automatically generate expert-level dynamic programming algorithms on many tasks. We evaluate our approaches on 37 tasks related to 16 optimization problems collected from Introduction to Algorithm, a popular textbook for algorithm courses. The results show that MetHyl+ achieves exponential speed-ups on 97.3% of tasks with an average time cost of less than one minute. Moreover, MetHyl+ generates algorithms that are as efficient as the reference programs provided by human experts on 70.3% of tasks.
翻译:动态规划是一种重要的优化技术,但即使对于专业程序员来说,设计高效的动态规划算法也可能具有挑战性。稀疏化作为一种系统性推导高效动态规划算法的技术,因其对大量问题的有效性而受到学术界的广泛关注。尽管稀疏化在理论上取得了成功,但其实际应用仍受到以下限制:(1) 应用稀疏化需要数学和算法背景知识;(2) 仅应用稀疏化可能不足以生成与人类专家提出的算法同样高效的结果。本文提出两种方法——MetHyl和MetHyl+,以解决这两个问题。首先,MetHyl通过程序合成自动化稀疏化的应用,从而消除用户应用稀疏化的负担。其次,MetHyl+将三条规则集成到MetHyl中,这些规则优化了动态规划算法时间复杂度中稀疏化忽略的三个关键因素,从而使其能够在多项任务中自动生成专家级别的动态规划算法。我们在从算法课程常用教材《算法导论》收集的16个优化问题相关的37项任务上评估了我们的方法。结果表明,MetHyl+在97.3%的任务上实现了指数级加速,平均耗时不到一分钟。此外,MetHyl+在70.3%的任务上生成了与人类专家提供的参考程序同样高效的算法。