Class Node

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().