All Implemented Interfaces:
Serializable, Cloneable

public final class Node extends State
This class implements a node of the tree search.
See Also:
Serialized Form
  • Constructor Details

    • Node

      public Node(State state)
      Creates a new node from a specified state.
      Parameters:
      state - the state.
    • Node

      public Node(State state, Node parent, int action, double cost, double heuristic)
      Creates a new node with a specified state, parent node, operator, cost and heuristic value.
      Parameters:
      state - the logical state of the node.
      parent - the parent node of the node.
      action - the action applied to reached the node from its parent.
      cost - the cost to reach the node from the root node.
      heuristic - the estimated distance to reach the goal from the node.
    • Node

      public Node(State state, Node parent, int action, double cost, int depth, double heuristic)
      Creates a new node with a specified state, parent node, operator, cost, depth and heuristic value.
      Parameters:
      state - the logical state of the node.
      parent - the parent node of the node.
      action - the action applied to reached the node from its parent.
      cost - the cost to reach the node from the root node.
      depth - the depth of the node.
      heuristic - the estimated distance to reach the goal from the node.
  • Method Details

    • getAction

      public final int getAction()
      Returns the action applied to reach the node.
      Returns:
      the action applied to reach the node.
    • setAction

      public final void setAction(int action)
      Sets the action applied to reach the node.
      Parameters:
      action - the action to set.
    • getParent

      public final Node getParent()
      Returns the parent node of the node.
      Returns:
      the parent node.
    • setParent

      public final void setParent(Node parent)
      Sets the parent node of the node.
      Parameters:
      parent - the parent to set.
    • getCost

      public final double getCost()
      Returns the cost to reach the node from the root node.
      Returns:
      the cost to reach the node from the root node.
    • setCost

      public final void setCost(double cost)
      Sets the cost needed to reach the node from the root node.
      Parameters:
      cost - the cost needed to reach the node from the root nod to set.
    • getHeuristic

      public final double getHeuristic()
      Returns the estimated distance to the goal from the node.
      Returns:
      the estimated distance to the goal from the node.
    • setHeuristic

      public final void setHeuristic(double estimates)
      Sets the estimated distance to the goal from the node.
      Parameters:
      estimates - the estimated distance to the goal from the node to set.
    • getDepth

      public int getDepth()
      Returns the depth of this node.
      Returns:
      the depth of this node.
    • setDepth

      public void setDepth(int depth)
      Set the depth of this node.
      Parameters:
      depth - the depth of this node.
    • getValueF

      public final double getValueF(double weight)
      Returns the value of the heuristic function, i.e., this.node.getCost() + this.node.getHeuristic().
      Parameters:
      weight - the weight of the heuristic.
      Returns:
      the value of the heuristic function, i.e., this.node.getCost() + this.node.getHeuristic().
    • equals

      public boolean equals(Object obj)
      Returns if a node is equal to an other object. The equals method has the same behaviour as the equals method of the class BitState.
      Overrides:
      equals in class BitSet
      Parameters:
      obj - the other oject.
      Returns:
      true if the node is equal to the other specified object; false otherwise.
      See Also:
      BitSet.equals(Object)
    • hashCode

      public int hashCode()
      Returns the hash code value of the node. The hashcode method has the same behaviour as the hashcode method of the class BitState.
      Overrides:
      hashCode in class BitSet
      Returns:
      the hashcode value for this node.
      See Also:
      BitSet.hashCode()