-
Notifications
You must be signed in to change notification settings - Fork 430
Description
After a suggestion by Rob Holte, I'm considering changes to the generic search pseudocode
at https://github.com/aimacode/aima-pseudocode/blob/master/md/Tree-Search-and-Graph-Search.md
I'm trying to sort through the implementation choices for OPEN and CLOSED (which we currently call "frontier" and "explored").
We need to support three operations:
(1) check if a state has been encountered before in the interior of the search tree.
(2) check if a state is on the frontier, and if so, fetch the cost and path to it.
(3) pop the best path from the frontier.
Implementation Choice 1:
explored
is a set of states that have been expandedfrontier
is a priority queue of paths, and also a hashtable of {state: path} mappings.- code:
if x not in explored and (x not in frontier or cost(x) < cost(frontier[x]): frontier.add(x)
Note: "path" and "node" are synonyms.
Implementation Choice 2:
reached
is a hash table of {state: path}frontier
is a priority queue of paths- code:
if x not in reached or cost(x) < cost(reached[x]): frontier.add(x)
It looks like Choice 2 is simpler. Is reached
the best name? Maybe best_path
?
What do you think @ctjoreilly @MrDupin @redblobgames ?