|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectai.search.SearchEngineForDoubleCostFn.SearchNodeForDoubleCostFn<S>
protected static class SearchEngineForDoubleCostFn.SearchNodeForDoubleCostFn<S extends SearchStateForDoubleCostFn>
A search node is a data structure created by a search engine to keep track of the portion of the search space explored so far. Each search node contains a single search state and is linked to one other search node, its predecessor in the search tree. Search nodes consist of five essetial components:
null
null
double
represents the accumulated
cost of all the actions along the path from the node containing the initial
state to this node
Usually a search engine will generate more and more search nodes while it
explores a search space. If the search space is a graph, search nodes cannot
store all the predecessors to a given node; there is only one field for one
predecessor. In this case the predecessor that is kept should usually be the
one on the shortest path to this node. Should a search engine later discover
a shorter path to a node through a different predecessor than is initially
stored with a node, then it can use the function adjustPredecessor(ai.search.SearchEngineForDoubleCostFn.SearchNodeForDoubleCostFn
to change the predecessor of a node. This function updates all fields of the
search node as required.
, ai.search.DoubleCostAction)
Finally, for debugging purposes this class also keeps track of the number of
instances that have been created, or, how often a constructor of this class
has been called. This number can be accessed at any time through the function
getInstanceCount()
.
DoubleCostAction
,
SearchStateForDoubleCostFn
Field Summary | |
---|---|
protected DoubleCostAction |
action
the action that resulted in the state contained in this node |
protected int |
depth
the depth of this node in the search space |
protected double |
pathCost
the accumulated path cost leading to this node |
protected SearchEngineForDoubleCostFn.SearchNodeForDoubleCostFn<S> |
predecessor
the predecessor node of this node |
protected S |
state
the search state contained in this node |
Constructor Summary | |
---|---|
SearchEngineForDoubleCostFn.SearchNodeForDoubleCostFn(S state,
SearchEngineForDoubleCostFn.SearchNodeForDoubleCostFn<S> predecessor,
DoubleCostAction action)
This constructor creates a new search node holding the given state. |
Method Summary | |
---|---|
void |
adjustPredecessor(SearchEngineForDoubleCostFn.SearchNodeForDoubleCostFn<S> predecessor,
DoubleCostAction action)
This function can be used to adjust the predecessor for this node. |
protected java.lang.Object |
clone()
This class does not support cloning and an exception will be thrown if this method is called. |
boolean |
equals(java.lang.Object obj)
Two search nodes are considered equal if and only if they are identical. |
DoubleCostAction |
getAction()
This function returns the action that leads from the predecessor to the state contained in this node. |
int |
getDepth()
This function returns the depth of this node in the search tree. |
static long |
getInstanceCount()
This function returns the number of instances that have been created of this class. |
double |
getPathCost()
This function returns the total cost of the path leading from the initial state to this node's state. |
SearchEngineForDoubleCostFn.SearchNodeForDoubleCostFn<S> |
getPredecessor()
This function returns the predecessor node linked to by this node. |
S |
getState()
This function returns the state contained in and represented by this search node. |
int |
hashCode()
This function computes the hash code of this search node which is the hash code of the search state contained in this node. |
java.lang.String |
toString()
This function returns a printable representation of this node which is the sequence number followed by the string printed for the search state contained in this node. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected S extends SearchStateForDoubleCostFn state
protected SearchEngineForDoubleCostFn.SearchNodeForDoubleCostFn<S extends SearchStateForDoubleCostFn> predecessor
protected DoubleCostAction action
protected int depth
protected double pathCost
Constructor Detail |
---|
public SearchEngineForDoubleCostFn.SearchNodeForDoubleCostFn(S state, SearchEngineForDoubleCostFn.SearchNodeForDoubleCostFn<S> predecessor, DoubleCostAction action)
This constructor creates a new search node holding the given state. Predecessor node and action are set to the given values. The given state must not be null, but predecessor and action may be null for the initial state. Depth and path cost to this node are automatically computed from the predecessor's corresponding values.
state
- the SearchStateForDoubleCostFn contained in this nodepredecessor
- the SearchNodeForDoubleCostFn that is the direct
predecessor for this node (null for the initial state)action
- the DoubleCostAction leading from the predecessor to this
node's search state (null for the initial state)Method Detail |
---|
protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
This class does not support cloning and an exception will be thrown if this method is called.
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
- will be thrownpublic S getState()
This function returns the state contained in and represented by this search node.
public SearchEngineForDoubleCostFn.SearchNodeForDoubleCostFn<S> getPredecessor()
This function returns the predecessor node linked to by this node.
public DoubleCostAction getAction()
This function returns the action that leads from the predecessor to the state contained in this node.
public int getDepth()
This function returns the depth of this node in the search tree.
public double getPathCost()
This function returns the total cost of the path leading from the initial state to this node's state.
public void adjustPredecessor(SearchEngineForDoubleCostFn.SearchNodeForDoubleCostFn<S> predecessor, DoubleCostAction action)
This function can be used to adjust the predecessor for this node. This can be useful when a newly generated state turns out to be identical to the previously generated state contained in this node, only the path to the new state may be shorter. The depth of the node as well as the path cost are automatically recomputed.
predecessor
- the SearchNodeForDoubleCostFn that is the new
predecessor for this nodeaction
- the DoubleCostAction leading from the new predecessor to
this statepublic boolean equals(java.lang.Object obj)
Two search nodes are considered equal if and only if they are identical. Technically, this is the case if (this == obj).
equals
in class java.lang.Object
obj
- the Object this is compared to
public int hashCode()
This function computes the hash code of this search node which is the hash code of the search state contained in this node.
hashCode
in class java.lang.Object
public java.lang.String toString()
This function returns a printable representation of this node which is the sequence number followed by the string printed for the search state contained in this node.
toString
in class java.lang.Object
public static long getInstanceCount()
This function returns the number of instances that have been created of this class. It does not deduct instances that have been removed from memory through garbage collection.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |