1. 程式人生 > 其它 >A* star A星搜尋 reopen/revisit state

A* star A星搜尋 reopen/revisit state

Admissibility + A* with reopen we can derive that we could find the optimal path。

Reopening is what happens when we find a new, better path to a previously expanded node. This is a potentially confusing point because admissibility guarantees for the goal node that this will not happen, but it makes no such guarantee for other nodes.

Have a look at this search problem, where the red numbers are our heuristic.

Note that the heuristic is quite odd, but it is admissible, mostly thanks to the massive 20-cost action required to reach the goal.

Now let's run A* on this problem. Start with Priority Queue (PQ) of {a: 0}.

  • Expand a, adding b

    (f=3) and d (f=5) to the priority queue. PQ={b: 3, d: 5}

  • Expand b, adding c (f=12). PQ={d: 5, c: 12}

  • Expand d, adding e (f=24). PQ={c: 12, e: 24}

  • Expand c, adding d (f=4). PQ={d: 4, e: 24}

  • ???

We clearly need to expand d next in order to find the optimal solution (a->b->c->d->e (23)). But d

was already added to the closed set! This is where slide 32/50 from Chapter 2: Search Algorithms (the slides) comes into play. It allows us to reopen the state d, hence "A* with reopen". If this is not allowed, this node will be discarded and we will instead expand the only remaining node. It contains a goal state, so we return the path a->d->e (24).

This seems like a bit of a problem for A* search, since we can end up with multiple nodes representing the same state. See here how A* has two nodes (n2 and n4) both representing state d.

I haven't thought about how big a problem this is, the possibility that the number of nodes could end up asymptotically dominating the number of states?

Important note: The heuristic in the problem I gave is not consistent - check the transition from state c to state d. I'm not sure whether a consistent heuristic removes the need for reopening, so I'll have a think about that. This answer is already long enough though, so I'll leave it with the code specification for the problem in case anyone else would like to play around with it.

 1 problem = Problem(
 2     "a",
 3     {"a", "b", "c", "d", "e"},
 4     {"e"},
 5     {
 6         "a": {("a", "b"), ("a", "d")},
 7         "b": {("b", "c")},
 8         "c": {("c", "d")},
 9         "d": {("d", "e")},
10         "e": {},
11     },
12     {
13         ("a", ("a", "b")): "b",
14         ("a", ("a", "d")): "d",
15         ("b", ("b", "c")): "c",
16         ("c", ("c", "d")): "d",
17         ("d", ("d", "e")): "e",
18     },
19     {
20         ("a", "b"): 1,
21         ("a", "d"): 4,
22         ("b", "c"): 1,
23         ("c", "d"): 1,
24         ("d", "e"): 20
25     }
26 )
27 heuristic = {
28     "a": 3,
29     "b": 2,
30     "c": 10,
31     "d": 1,
32     "e": 0
33 }

A consistent heuristic, reopening is not needed.

Given that c was expanded before b, and our heuristic is consistent, is it possible that P2 is shorter than P1? I will try to show that it is not.

At expansion-time of c, we must have had f(c) <= f(b). I will use C_P(a,b) to denote the cost of going from a to b via a subset of path P. f(c) = g(c) + h(c) = C_P1(a,c) + h(c), and similarly f(b) = C_P2(a,b) + h(b), giving us the inequality

C_P1(a,c) + h(c) <= C_P2(a,b) + h(b) [1]

Now because h is consistent, we can be sure that h(b) <= h(c) + C_P2(b,c). Substituting into [1], we get

C_P1(a,c) + h(c) <= C_P2(a,b) + h(c) + C_P2(b,c),

therefore C_P1(a,c) <= C_P2(a,b) + C_P2(b,c) = C_P2(a,c) as required; P2 is no shorter than P1.

Proofs related to A* and heuristics:Generalized best-first search strategies and the optimality of A*, Rina Dechter and Judea Pearl, 1985

It is possible that the number of node expansions during the search are greater than the number of states in the transition system. But not always. It depends upon the heuristic function.

So, if we give an admissible and consistent heuristic function to the A* algorithm discussed in the lectures, we will always expand less or equal number of nodes than there are states.

Overall, the worst case the time complexity is exponential in the depth of the solution O(b^d), if b is the branching factor. A good heuristic function is important as it will allow the algorithm to forego expansion of nodes which uninformed search will expand.

There are additional issues related to space complexity for which you may want to look at memory bounded variants including IDA*, MA*.

Vedio:https://youtu.be/_zE5z-KZGRw