|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object dk.deepthought.sidious.planner.graph.AStarVertex
@ThreadSafe public final class AStarVertex
This class implements a vertex with respect to the A*-algorithm.
Field Summary | |
---|---|
private double |
costCandidate
The cost-candidate of getting to this vertex from the source vertex. |
private Edge |
edgeToPredecessor
The edge to the predecessor of this. |
private boolean |
goal
Flag to indicate this being a goal vertex. |
private double |
heuristic
The calculated heuristic for this. |
private static org.apache.commons.logging.Log |
logger
Logger of this class. |
private boolean |
source
Flag to indicate this being a source vertex. |
private State |
state
The state this represents. |
Constructor Summary | |
---|---|
|
AStarVertex(State state,
double heuristic)
Creates a AStarVertex with the specified
State and heuristic value. |
private |
AStarVertex(State state,
double heuristic,
Edge edgeToPredecessor,
boolean source,
boolean goal,
double costCandidate)
Private utility constructor. |
Method Summary | |
---|---|
int |
compareTo(AStarVertex v)
This method implements the compareTo method of the
Comparable interface. |
boolean |
equals(java.lang.Object obj)
|
double |
g()
At any given time, this method returns the cost of the shortest path to this vertex, with respect to the set of vertices the algorithm has evaluated at that time. |
Vertex |
getPredecessorVertex()
Gets the predecessor Vertex from the edge. |
State |
getState()
Gets the State represented by this Vertex . |
Step |
getStepToThis()
Gets the Step leading to this Vertex . |
double |
h()
This method returns an estimated cost of getting to the goal from this vertex. |
int |
hashCode()
|
boolean |
isGoal()
Returns true if this Vertex is the goal
vertex. |
boolean |
isSource()
Returns true if this Vertex is the source
vertex. |
boolean |
partiallyEquals(Vertex otherVertex)
Checks whether this vertex is contains all the state descriptors of the input vertex. |
Vertex |
toGoalVertex()
Creates a goal vertex. |
Vertex |
toSourceVertex(Step initialStep)
Creates a source vertex from the specified initial setpoints. |
java.lang.String |
toString()
|
void |
update(Edge edgeToPredecessor,
double cost)
This is the implementation of the update method. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final org.apache.commons.logging.Log logger
private final State state
private final double heuristic
private Edge edgeToPredecessor
private final boolean source
private final boolean goal
private double costCandidate
Constructor Detail |
---|
public AStarVertex(State state, double heuristic)
AStarVertex
with the specified
State
and heuristic value.
According to the A*-algorithm an estimated cost from any vertex to the goal vertex cannot be negative.
state
- the State
this vertex representheuristic
- the heuristicprivate AStarVertex(State state, double heuristic, Edge edgeToPredecessor, boolean source, boolean goal, double costCandidate)
state
- the stateheuristic
- the heuristicedgeToPredecessor
- the edgesource
- is source vertex flaggoal
- is goal vertex flagcostCandidate
- the cost candidateMethod Detail |
---|
public double h()
public double g()
Vertex
g
in interface Vertex
public void update(Edge edgeToPredecessor, double cost)
update
method.
In accordance with the A*-algorithm the following will throw
AssertionError
:
null
, because it will break the
shortest path tree.
edgeToPredecessor
- the edge to the previous vertexcost
- the cost of getting to this vertexVertex.update(dk.deepthought.sidious.planner.graph.Edge,
double)
public Vertex toGoalVertex()
Vertex
toGoalVertex
in interface Vertex
Vertex
public Vertex toSourceVertex(Step initialStep)
Vertex
toSourceVertex
in interface Vertex
initialStep
- the initial step
Vertex
public boolean isGoal()
Vertex
true
if this Vertex
is the goal
vertex. The goal vertex is defined as the end of a path.
isGoal
in interface Vertex
true
if this is the goal vertex.public boolean isSource()
Vertex
true
if this Vertex
is the source
vertex. The source vertex is defined as the start of a path.
isSource
in interface Vertex
true
if this is the source vertex.public Vertex getPredecessorVertex()
Vertex
Vertex
from the edge.
getPredecessorVertex
in interface Vertex
public Step getStepToThis()
Vertex
Step
leading to this Vertex
.
getStepToThis
in interface Vertex
Step
public State getState()
Vertex
State
represented by this Vertex
.
getState
in interface Vertex
public boolean partiallyEquals(Vertex otherVertex)
Vertex
partiallyEquals
in interface Vertex
otherVertex
- the input vertex
public int compareTo(AStarVertex v)
compareTo
method of the
Comparable
interface.
The method is needed to specify the ordering of the
AStarVertex
objects. This ordering is imperative for the
functionality of the pathfinding algorithm.
compareTo
in interface java.lang.Comparable<AStarVertex>
Comparable.compareTo(java.lang.Object)
,
dk.deepthought.sidious.planner.Pathfinder#search()
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |