public class RecursiveBestFirstSearch extends java.lang.Object implements SearchForActions
function RECURSIVE-BEST-FIRST-SEARCH(problem) returns a solution, or failure
return RBFS(problem, MAKE-NODE(problem.INITIAL-STATE), infinity)
function RBFS(problem, node, f_limit) returns a solution, or failure and a new f-cost limit
if problem.GOAL-TEST(node.STATE) then return SOLUTION(node)
successors <- []
for each action in problem.ACTION(node.STATE) do
add CHILD-NODE(problem, node, action) into successors
if successors is empty then return failure, infinity
for each s in successors do // update f with value from previous search, if any
s.f <- max(s.g + s.h, node.f)
repeat
best <- the lowest f-value node in successors
if best.f > f_limit then return failure, best.f
alternative <- the second-lowest f-value among successors
result, best.f <- RBFS(problem, best, min(f_limit, alternative))
if result != failure then return result
Figure 3.26 The algorithm for recursive best-first search.
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
METRIC_MAX_RECURSIVE_DEPTH |
static java.lang.String |
METRIC_NODES_EXPANDED |
static java.lang.String |
METRIC_PATH_COST |
| Constructor and Description |
|---|
RecursiveBestFirstSearch(EvaluationFunction ef) |
RecursiveBestFirstSearch(EvaluationFunction ef,
boolean avoidLoops)
Constructor which allows to enable the loop avoidance strategy.
|
RecursiveBestFirstSearch(EvaluationFunction ef,
boolean avoidLoops,
NodeExpander nodeExpander) |
| Modifier and Type | Method and Description |
|---|---|
java.util.List<Action> |
findActions(Problem p)
Returns a list of actions to the goal if the goal was found, a list
containing a single NoOp Action if already at the goal, or an empty list
if the goal could not be found.
|
EvaluationFunction |
getEvaluationFunction() |
Metrics |
getMetrics()
Returns all the search metrics.
|
NodeExpander |
getNodeExpander()
Returns the node expander used by the search.
|
public static final java.lang.String METRIC_NODES_EXPANDED
public static final java.lang.String METRIC_MAX_RECURSIVE_DEPTH
public static final java.lang.String METRIC_PATH_COST
public RecursiveBestFirstSearch(EvaluationFunction ef)
public RecursiveBestFirstSearch(EvaluationFunction ef, boolean avoidLoops)
public RecursiveBestFirstSearch(EvaluationFunction ef, boolean avoidLoops, NodeExpander nodeExpander)
public java.util.List<Action> findActions(Problem p)
SearchForActionsfindActions in interface SearchForActionsp - the search problempublic EvaluationFunction getEvaluationFunction()
public NodeExpander getNodeExpander()
SearchForActionsgetNodeExpander in interface SearchForActionspublic Metrics getMetrics()
getMetrics in interface SearchForActions