state -> List ( state
, Basics.Bool
}
Defines the type of the step function that produces new states from existing ones. This is how the graph over the search space is defined. The step function takes a state and provides a list of other states that can be reached from it. Each of the listed states is paired with a Bool that when true indiciates that a state is considered to be a goal of the search.
{ step : Step state
, cost : state -> Basics.Float
}
Defines the type of a bundle of operators that need to be supplied to conduct an uninformed (non-heuristic) search.
{ step : Step state
, cost : state -> Basics.Float
, heuristic : state -> Basics.Float
}
Defines the type of a bundle of operators that need to be supplied to conduct an informed (heuristic) search.
{ a | step : Step state
, cost : state -> Basics.Float
}
Defines the type of a bundle of operators that need to be supplied to conduct an uninformed (non-heuristic) search. This is an extensible record so that heuristic searches can also have this type since they use the same cost and step functions. This makes it easy to switch from a heuristic to anon-heuristic search.
Defines the possible outcomes of a search. A search may produce the following results:
next : SearchResult state -> SearchResult state
Steps a search result, to produce the next result.
nextN : Basics.Int -> SearchResult state -> SearchResult state
Continues a search result, to produce the next search goal up to a limited number of iterations.
nextGoal : SearchResult state -> SearchResult state
Continues a search result, to produce the next search goal.
breadthFirst : WithUninformed a state -> List ( state, Basics.Bool ) -> SearchResult state
Performs an unbounded breadth first search. Breadth first searches store a lot of pending nodes in the buffer, so quickly run out of space.
depthFirst : WithUninformed a state -> List ( state, Basics.Bool ) -> SearchResult state
Performs an unbounded depth first search. Depth first searches can easily fall into infinite loops.
depthBounded : WithUninformed a state -> Basics.Int -> List ( state, Basics.Bool ) -> SearchResult state
Implements an uninformed search that is bounded to a specified maximum depth.
costBounded : WithUninformed a state -> Basics.Float -> List ( state, Basics.Bool ) -> SearchResult state
Implements a cost bounded search. This search will proceed depth first.
uniformCost : WithUninformed a state -> List ( state, Basics.Bool ) -> SearchResult state
Performs a uniform-cost search. This always follows the search node that has the lowest path cost. It is called a uniform cost search because the boundary of the search will have a roughly uniform cost as the search space is searched by increasing cost.
iterativeDeepening : Basics.Int -> WithUninformed a state -> List ( state, Basics.Bool ) -> SearchResult state
Implements an iterative deepening search. This search proceed depth first but repeats at progressively larger depth limits. The iteration number is multiplied by a specified multiple to calculate the maximum depth allowed at a given iteration.
iterativeCostIncreasing : Basics.Float -> WithUninformed a state -> List ( state, Basics.Bool ) -> SearchResult state
Implements an iterative cost increasing search. This search proceed depth first but repeats at progressively larger cost limits. The iteration number is multiplied by a specified multiple to calculate the maximum cost allowed at a given iteration.
aStar : Informed state -> List ( state, Basics.Bool ) -> SearchResult state
Performs an A* search. This is one that always follows the search node that has the highest f value (f = heuristic + cost). The seach will only be optimal if the heuristic function is monotonic.
greedy : Informed state -> List ( state, Basics.Bool ) -> SearchResult state
Performs a greedy heuristic search. This is one that always follows the search node that has the highest h value (h = heuristic).
fBounded : Informed state -> Basics.Float -> List ( state, Basics.Bool ) -> SearchResult state
Implements an f value (f = heuristic + cost) bounded search. This search will proceed depth first.
iterativeDeepeningAStar : Basics.Float -> Informed state -> List ( state, Basics.Bool ) -> SearchResult state
Implements an iterative deepding A-star search. This search proceed depth first but repeats at progressively larger f-limits (f = cost + heuristic). The iteration number is multiplied by a specified multiple to calculate the maximum cost allowed at a given iteration.
Like the A-star search, this search will find the optimal soluation given an admissable heuristic. As this search progresses depth first rather than sleecting the most promising nodes to follow, its memory requirements are lower than A-star.
Note that to find the optimal solution, the search will need to be run until it completes an entire iteration, as when progressing depth first a less than optimal solution may be found first within the current iteration. There is currently no way to signal the completion of an iteration.