简体   繁体   English

求解N难题的A *启发式方法的比较

[英]Comparison of A* heuristics for solving an N-puzzle

I am trying to solve the N-puzzle using the A* algorithm with 3 different heuristic functions. 我正在尝试使用具有3种不同启发式功能的A *算法来解决N难题。 I want to know how to compare each of the heuristics in terms of time complexity. 我想知道如何在时间复杂度方面比较每种启发式方法。 The heuristics I am using are: manhattan distance , manhattan distance + linear conflict, N-max swap. 我使用的试探法是:曼哈顿距离,曼哈顿距离+线性冲突,N-max交换。 And specifically for an 8-puzzle and an 15-puzzle. 特别是8拼图和15拼图。

The N-puzzle is, in general, NP hard to find the shortest solution, so no matter what heuristic you use it's unlikely you'll be able to find any difference in complexity between them, since you won't be prove the tightness of any bound. 通常,N难题很难找到最短的解决方案,因此,无论您使用哪种启发式方法,都不太可能发现它们之间的复杂性差异,因为您将无法证明它的紧密性任何界限。

If you restrict yourself to the 8-puzzle or 15-puzzle, an A* algorithm with any admissible heuristic will run in O(1) time since there are a finite (albeit large) number of board positions. 如果将自己限制为8拼图或15拼图,则由于板子位置数量有限(尽管很大),因此具有允许的启发式算法的A *算法将在O(1)时间内运行。

As @Harold said in his comment, the approach to compare time complexity of heuristic functions is tipically by experimental tests. 正如@Harold在评论中所说,比较启发式函数的时间复杂度的方法主要是通过实验测试。 In your case, generate a set of n random problems for the 8-puzzle and the 15-puzzle and solve them using the different heuristic functions. 在您的情况下,为8难题和15难题生成一组n个随机问题,并使用不同的启发式函数解决它们。 Things to be aware of are: 要注意的事情是:

  1. The comparison will always depend on several factors, like hardware expecs, programming language, your skills when implementing the algorithm, ... 比较将始终取决于几个因素,例如硬件技术,编程语言,实现算法的技能,...

  2. Generally speaking, a more informed heuristic will always expand less nodes than a less informed one, and will probably be faster. 一般而言,一种较有见识的启发式方法将总是比较少有见识的启发式方法扩展更少的节点,并且可能会更快。

And finally, in order to compare the three heuristics for each problem set, I would suggest a graphic with average running times (repeat for example 5 times each problem) where: 最后,为了比较每个问题集的三种启发式方法,我建议使用平均运行时间的图形(例如,每个问题重复5次),其中:

  1. The problems are in the x-axis sorted by difficulty. 问题在x轴上按难度排序。
  2. The running times are in the y-axis for each heuristic function (perhaps in logarithmic scale if the difference between the alternatives cannot be easily seen). 每个启发式函数的运行时间都在y轴上(如果无法轻易看到替代方法之间的差异,则可能以对数标度表示)。

and a similar graphic with the number of explored states. 和带有探索状态数量的相似图形。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM