dk.deepthought.sidious.planner.graph
Class AStarGraph

java.lang.Object
  extended by dk.deepthought.sidious.planner.graph.AStarGraph
All Implemented Interfaces:
Graph

public final class AStarGraph
extends java.lang.Object
implements Graph

Represents a graph for use with the A-Star algorithm.

Author:
Deepthought

Field Summary
private  Vertex goalVertex
          The goal vertex of this.
private  Heuristic heuristic
          The heuristic to be used with this.
private static org.apache.commons.logging.Log logger
          The logger of this class.
private  SuperLinkID requesterId
          The id of the requester.
private  RuleEngine ruleEngine
          Cached instance of the rule engine.
private  Vertex sourceVertex
          The source vertex of this.
private  java.util.List<Vertex> vertices
          The vertices of this.
 
Constructor Summary
AStarGraph(State sourceState, State goalState, java.util.Collection<Adjustable> adjustables, Heuristic heuristic, SuperLinkID requester)
          Constructs an AStarGraph with a start and end-state, and the set adjustables.
 
Method Summary
(package private)  double calculateCost(State current, State next, Step step)
          Method returns the calculated cost of getting from current to next.
 java.util.Collection<Edge> getEdges(Vertex v)
          This method retrieves the edges emanating from the Vertex v.
 Vertex getGoalVertex()
          Gets the goal Vertex of this Graph.
 SuperLinkID getId()
          Returns the id of the owner/requester for this graph.
 Vertex getSourceVertex()
          Gets the source Vertex of this Graph.
(package private)  Vertex getVertexFromState(State state)
          This method checks if the state is represented by a Vertex in the graph, and returns either the representing vertex or a new vertex, which is added to the graph.
 void setApproximateGoal(Vertex v)
          Method sets the goalVertex to this vertex if all the goal state descriptors are contained in the input vertex.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

private static final org.apache.commons.logging.Log logger
The logger of this class.


vertices

private final java.util.List<Vertex> vertices
The vertices of this.


sourceVertex

private final Vertex sourceVertex
The source vertex of this.


goalVertex

private Vertex goalVertex
The goal vertex of this. It can be substituted if an approximate goal is set.


heuristic

private final Heuristic heuristic
The heuristic to be used with this.


requesterId

private final SuperLinkID requesterId
The id of the requester.


ruleEngine

private final RuleEngine ruleEngine
Cached instance of the rule engine.

Constructor Detail

AStarGraph

public AStarGraph(State sourceState,
                  State goalState,
                  java.util.Collection<Adjustable> adjustables,
                  Heuristic heuristic,
                  SuperLinkID requester)
Constructs an AStarGraph with a start and end-state, and the set adjustables.

Parameters:
sourceState - the beginning state of any path
goalState - the end state of any path
adjustables - the adjustables of the current requester
heuristic - the heuristic of the graph
requester - the id of the plan requester
Method Detail

getEdges

public java.util.Collection<Edge> getEdges(Vertex v)
This method retrieves the edges emanating from the Vertex v. It does this by calculating the edges and vertices on-the-fly.

Specified by:
getEdges in interface Graph
Parameters:
v - the starting Vertex
Returns:
all edges starting in the specified Vertex
See Also:
Graph.getEdges(dk.deepthought.sidious.planner.graph.Vertex)

calculateCost

double calculateCost(State current,
                     State next,
                     Step step)
Method returns the calculated cost of getting from current to next.

Parameters:
current - the current state
next - the next state
step - the step
Returns:
the cost

getVertexFromState

Vertex getVertexFromState(State state)
This method checks if the state is represented by a Vertex in the graph, and returns either the representing vertex or a new vertex, which is added to the graph.

Parameters:
state - the state
Returns:
the vertex representing the state

getGoalVertex

public Vertex getGoalVertex()
Description copied from interface: Graph
Gets the goal Vertex of this Graph. The goal vertex is defined as the ending point of any path in this graph.

The implementing graph class must guarantee that any preconditions for the goal vertex of the Pathfinder are not violated.

Specified by:
getGoalVertex in interface Graph
Returns:
the goal vertex of this graph

getSourceVertex

public Vertex getSourceVertex()
Description copied from interface: Graph
Gets the source Vertex of this Graph. The source vertex is defined as the starting point of any path in this graph.

The implementing graph class must guarantee that any preconditions for the source vertex of the Pathfinder are not violated.

Specified by:
getSourceVertex in interface Graph
Returns:
the source vertex of this graph

getId

public SuperLinkID getId()
Description copied from interface: Graph
Returns the id of the owner/requester for this graph.

Specified by:
getId in interface Graph
Returns:
the id of the requester

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

setApproximateGoal

public void setApproximateGoal(Vertex v)
Description copied from interface: Graph
Method sets the goalVertex to this vertex if all the goal state descriptors are contained in the input vertex.

Specified by:
setApproximateGoal in interface Graph
Parameters:
v - the approximate goal candidate


Copyright © Deepthought Development - All Rights Reserved.