concepts.algorithm.search.heuristic_search.run_heuristic_search#
- run_heuristic_search(initial_state, check_goal, get_priority, get_successors, check_visited=True, max_expansions=10000, max_depth=1000)[source]#
A generic implementation for heuristic search.
- Parameters:
initial_state (State) – the initial state.
check_goal (Callable[[State], bool]) – a function mapping from state to bool, returning True if the state has satisfied the goal.
get_priority (Callable[[State, int], float]) – a function mapping from state to float, returning the priority of the state. Smaller priority means higher priority (will be visited first).
get_successors (Callable[[State], Iterator[Tuple[Action, State, float]]]) – a function mapping from state to an iterator of (action, state, cost) tuples.
check_visited (bool) – whether to check if the state has been visited. Set to false if the State representation is not hashable.
max_expansions (int) – the maximum number of expansions.
max_depth (int) – the maximum depth of the search tree.
- Returns:
A tuple of (state_sequence, action_sequence, cost_sequence, nr_expansions).
- Raises:
ValueError – if the search fails.