[英]Precalculate Result of A*
Currently learning about the A*
search algorithm and using it to find the quickest solution to the N-Puzzle
. 当前正在学习A*
搜索算法,并使用它来找到N-Puzzle
的最快解决方案。 For some random seed of the initial starting state, the puzzle may be unsolvable which would result in extremely long wait times until the algorithm has search the entire search-space and determined there is not solution to the give start state. 对于初始启动状态的某些随机种子,难题可能无法解决,这将导致非常长的等待时间,直到算法搜索了整个搜索空间并确定没有给定启动状态的解决方案。
I was wondering if there is a method of precalculating whether the A*
algorithm will fail to avoid such a scenario. 我想知道是否有一种方法可以预先计算A*
算法是否无法避免这种情况。 I've read a bit about how it is possible but can't find a direct answer as to a method in which to do it. 我已经阅读了一些有关如何实现的信息,但找不到有关执行该方法的直接答案。
Any guidance or options are appreciated. 任何指导或选择,不胜感激。
I think A* does not offer you a mechanism to know whether or not a problem is solvable. 我认为A *无法为您提供一种机制来了解问题是否可以解决。 Specifically for N-Puzzle
, I think this could help you to check if it can be solved or not: 专门针对N-Puzzle
,我认为这可以帮助您检查它是否可以解决:
http://www.geeksforgeeks.org/check-instance-8-puzzle-solvable/ http://www.geeksforgeeks.org/check-instance-8-puzzle-solvable/
It seems that if you are in a state where you have an odd amount inversion, you know for sure the problem for that permutation is infeasible. 看来,如果您处于数量倒置的状态,则可以肯定知道该排列的问题是不可行的。
For the N-puzzle specifically, there are only two possible parities, so you just need to check which parity the current puzzle is. 特别是对于N-puzzle,只有两个可能的奇偶校验,因此您只需要检查当前谜题是哪个奇偶校验即可。
There is an in-depth explanation on how to do this on the math stackexchange 有关如何在数学stackexchange上执行此操作的深入说明
For general A* problems, no, there is no way to pre-compute if the graph is solvable. 对于一般的A *问题,不可以,如果图形可解,则无法进行预先计算。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.