Class AStar<T>
- java.lang.Object
-
- com.inductiveautomation.ignition.designer.blockandconnector.routing.AStar<T>
-
public abstract class AStar<T> extends java.lang.ObjectA* algorithm implementation using the method design pattern.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classAStar.Path
-
Constructor Summary
Constructors Constructor Description AStar()Default c'tor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.util.List<T>compute(T start)Find the shortest path to a goal starting fromstart.protected java.lang.Doublef(AStar.Path p, T from, T to)Total cost function to reach the nodetofromfrom.protected abstract java.lang.Doubleg(AStar.Path path, T from, T to)Cost for the operation to go totofromfrom.protected abstract java.util.List<T>generateSuccessors(T node)Generate the successors for a given node.java.lang.DoublegetCost()Get the cost to reach the last node in the path.intgetExpandedCounter()Check how many times a node was expanded.protected abstract java.lang.Doubleh(T from, T to)Estimated cost to reach a goal node.protected abstract booleanisGoal(T node)Check if the current node is a goal for the problem.
-
-
-
Method Detail
-
isGoal
protected abstract boolean isGoal(T node)
Check if the current node is a goal for the problem.- Parameters:
node- The node to check.- Returns:
trueif it is a goal,false otherwise.
-
g
protected abstract java.lang.Double g(AStar.Path path, T from, T to)
Cost for the operation to go totofromfrom.- Parameters:
from- The node we are leaving.to- The node we are reaching.- Returns:
- The cost of the operation.
-
h
protected abstract java.lang.Double h(T from, T to)
Estimated cost to reach a goal node. An admissible heuristic never gives a cost bigger than the real one.from.- Parameters:
from- The node we are leaving.to- The node we are reaching.- Returns:
- The estimated cost to reach an object.
-
generateSuccessors
protected abstract java.util.List<T> generateSuccessors(T node)
Generate the successors for a given node.- Parameters:
node- The node we want to expand.- Returns:
- A list of possible next steps.
-
getExpandedCounter
public int getExpandedCounter()
Check how many times a node was expanded.- Returns:
- A counter of how many times a node was expanded.
-
f
protected java.lang.Double f(AStar.Path p, T from, T to)
Total cost function to reach the nodetofromfrom.The total cost is defined as: f(x) = g(x) + h(x).
- Parameters:
from- The node we are leaving.to- The node we are reaching.- Returns:
- The total cost.
-
getCost
public java.lang.Double getCost()
Get the cost to reach the last node in the path.- Returns:
- The cost for the found path.
-
-