trickster.search

Generalized A* search with no beam size limit.

See generalized_a_star_search().

Generalized A* search.

Returns the tuple (cost, target_node) if return_path is set to False. Otherwise, returns the target node, the costs of nodes expanded by the algorithm, and the optimal path from the initial node to the target node.

Parameters:
  • start_node – Initial node.
  • expand_fn – Returns an iterable of tuples (neighbour, cost).
  • goal_fn – Returns True if the current node is the target node.
  • heuristic_fn – Returns an estimate of the cost to the target node. By default, is a constant 0.
  • hash_fn – Hash function for nodes. By default equals the identity function f(x) = x.
  • iter_lim – Maximum number of iterations to try.
  • beam_size – Beam size. Turns the search into beam search.
  • return_path – Whether to return the optimal path from the initial node to the target node. By default equals False.

IDA* search.

Returns the tuple (cost, target_node) if return_path is set to False. Otherwise, returns the target node, the costs of nodes expanded by the algorithm, and the optimal path from the initial node to the target node.

Parameters:
  • start_node – Initial node.
  • expand_fn – Returns an iterable of tuples (neighbour, cost).
  • goal_fn – Returns True if the current node is the target node.
  • heuristic_fn – Returns an estimate of the cost to the target node. By default, is a constant 0.
  • hash_fn – Hash function for nodes. By default equals the identity function f(x) = x.
  • iter_lim – Maximum number of iterations to try.
  • return_path – Whether to return the optimal path from the initial node to the target node. By default equals False.