Package search
Class Nodes.SimpleTreePathCostNode<S>
java.lang.Object
search.Nodes.SimpleTreePathCostNode<S>
- Type Parameters:
S
- The type of the search state underlying these nodes.
- All Implemented Interfaces:
KnowsOwnCost
,SearchTreeNode<Nodes.SimpleTreePathCostNode<S>,S>
,SearchTreePathNode<Nodes.SimpleTreePathCostNode<S>,S>
- Enclosing class:
- Nodes
public static class Nodes.SimpleTreePathCostNode<S> extends Object
Implementation of search tree nodes
which have a notion of cost, and which contain links to their
parent node.
-
Constructor Summary
Constructors Constructor Description SimpleTreePathCostNode(Function<S,Iterable<Nodes.CostAndStep<S>>> expander, double cost, S state)
SimpleTreePathCostNode(Nodes.SimpleTreePathCostNode<S> parent, double cost, S state)
-
Method Summary
Modifier and Type Method Description Iterable<Nodes.SimpleTreePathCostNode<S>>
expand()
Expands the search node into successor nodes.double
getCost()
Nodes.SimpleTreePathCostNode<S>
getParent()
Returns the node from which this node was expanded.S
getState()
Returns the search state underlying this node.static <S> Function<S,Nodes.SimpleTreePathCostNode<S>>
initializer(Function<S,Iterable<Nodes.CostAndStep<S>>> expander)
Returns a factory for tree nodes with track both their parent and their own cost, given an expander from a state to the states underlying expanded nodes.String
toString()
Format this node as a string, typically for debugging.
-
Constructor Details
-
SimpleTreePathCostNode
public SimpleTreePathCostNode(Function<S,Iterable<Nodes.CostAndStep<S>>> expander, double cost, S state)- Parameters:
expander
- Function from the underlying state to an iterable collection of information for the construction of expanded nodes.cost
- Cost associated with this node.state
- The state underlying this node.
-
SimpleTreePathCostNode
- Parameters:
parent
- Parent of this node.cost
- Cost associated with this node.state
- The state underlying this node.
-
-
Method Details
-
expand
Expands the search node into successor nodes.- Returns:
- An
Iterable
instance of the successor nodes.
-
initializer
public static final <S> Function<S,Nodes.SimpleTreePathCostNode<S>> initializer(Function<S,Iterable<Nodes.CostAndStep<S>>> expander)Returns a factory for tree nodes with track both their parent and their own cost, given an expander from a state to the states underlying expanded nodes. -
getCost
public double getCost()- Specified by:
getCost
in interfaceKnowsOwnCost
- Returns:
- The cost of reaching the state in this node.
-
toString
Format this node as a string, typically for debugging. -
getParent
Returns the node from which this node was expanded.- Specified by:
getParent
in interfaceSearchTreePathNode<Self extends search.Nodes.SimpleCoreTreePathNode<Self,Exp,S>,Exp>
- Returns:
null
if this is the initial node.
-
getState
Returns the search state underlying this node.- Specified by:
getState
in interfaceSearchTreeNode<Self extends search.Nodes.SimpleCoreTreeNode<Self,Exp,S>,Exp>
-