core
Interface HeuristicProblem<T>
- Type Parameters:
T
- the type of the states used throughout the search
- All Superinterfaces:
- Problem<T>, TreeProblem<T>
public interface HeuristicProblem<T>
- extends TreeProblem<T>
This is the base of all problems which can be solved in an heuristic search.
Additional to the TreeProblem a HeuristicProblem consists of two methods to evaluate
the sum of the path costs and the proximity to a goal for a given state.
These two methods enables some algorithms to direct their search towards a goal.
If you implement this interface, your problem can additionally be solved by the following search algorithms:
- basic.UniformCostSearch
- basic.GreedySearch
- basic.AStarCostSearch
- basic.IterativDeepeningAStar
Note: The method which computes the proximity to a goal (called heuristic)
is of great importance for the performance of the algorithms above, (but not for the UniformCostSearch).
There are some constraints for a good heuristic function which must hold for all states s in the search domain:
-
h(s) <= h(s') + cost(s,s')
for all successors s'
of state s
.
This constraint is called monotony and ensures that
the heuristic function h
is constantly falling.
-
h(s) <= g(t)
where t
is the nearest goal to state s
This constraint makes the heuristic function optimistic and
ensures that the best solution is found first.
- Author:
- eden06
Method Summary |
double |
g(T state)
This method returns the sum of all path costs from the initial to the given state. |
double |
h(T state)
This method computes the proximity of the given state to a goal. |
g
double g(T state)
- This method returns the sum of all path costs from the initial to the given state.
- Parameters:
state
- to be inspected
- Returns:
- the sum of the path costs from the initial state to the given state
h
double h(T state)
- This method computes the proximity of the given state to a goal.
The value returned should express how much the path
from the given state to a goal state may cost.
Note: For optimality and completeness it is important
to obeys the following rules for all states s in the search domain.
-
h(s) <= h(s') + cost(s,s')
for all successors s'
of state s
.
-
h(s) <= g(t)
where t
is the nearest goal to state s
- Parameters:
state
- which should be used to reach a goal
- Returns:
- an approximation of the path costs needed to reach a goal.