Commit 319ae73
committed
Evaluate the A* heuristic lazily and simplify atom grounding
A* search:
- Only compute the heuristic (and create the child node) for a successor
once we know it reaches its state more cheaply than any path seen so
far. The heuristic value is only ever used when a node is enqueued, so
computing it for non-improving successors was wasted work. This is
behavior-preserving (identical expansions and plans) and roughly halves
heuristic evaluations on transposition-heavy tasks (e.g. ~50% fewer on
gripper/task03). It benefits astar, gbfs and wastar, which share this
loop.
Grounding:
- Build the grounded argument list of an atom with a comprehension and
dict.get instead of an explicit loop with membership tests. This is
simpler and slightly faster in a function called for every atom of
every grounded operator. Grounded operator counts are unchanged.1 parent 67fd2e7 commit 319ae73
2 files changed
Lines changed: 15 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
313 | 313 | | |
314 | 314 | | |
315 | 315 | | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
| 316 | + | |
322 | 317 | | |
323 | 318 | | |
324 | 319 | | |
| |||
329 | 324 | | |
330 | 325 | | |
331 | 326 | | |
332 | | - | |
| 327 | + | |
333 | 328 | | |
334 | 329 | | |
335 | 330 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
138 | 144 | | |
139 | 145 | | |
140 | 146 | | |
141 | 147 | | |
142 | 148 | | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
152 | 156 | | |
153 | 157 | | |
154 | 158 | | |
| |||
0 commit comments