public abstract class AStar<T>
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
class |
AStar.Path |
Constructor and Description |
---|
AStar()
Default c'tor.
|
Modifier and Type | Method and Description |
---|---|
java.util.List<T> |
compute(T start)
Find the shortest path to a goal starting from
start . |
protected java.lang.Double |
f(AStar.Path p,
T from,
T to)
Total cost function to reach the node
to from from . |
protected abstract java.lang.Double |
g(AStar.Path path,
T from,
T to)
Cost for the operation to go to
to from from. |
protected abstract java.util.List<T> |
generateSuccessors(T node)
Generate the successors for a given node.
|
java.lang.Double |
getCost()
Get the cost to reach the last node in the path.
|
int |
getExpandedCounter()
Check how many times a node was expanded.
|
protected abstract java.lang.Double |
h(T from,
T to)
Estimated cost to reach a goal node.
|
protected abstract boolean |
isGoal(T node)
Check if the current node is a goal for the problem.
|
protected abstract boolean isGoal(T node)
node
- The node to check.true
if it is a goal, false otherwise.
protected abstract java.lang.Double g(AStar.Path path, T from, T to)
to
from from.
from
- The node we are leaving.to
- The node we are reaching.protected abstract java.lang.Double h(T from, T to)
from.
from
- The node we are leaving.to
- The node we are reaching.protected abstract java.util.List<T> generateSuccessors(T node)
node
- The node we want to expand.public int getExpandedCounter()
protected java.lang.Double f(AStar.Path p, T from, T to)
to
from from
.
The total cost is defined as: f(x) = g(x) + h(x).from
- The node we are leaving.to
- The node we are reaching.public java.lang.Double getCost()