Class SubProblem<T>

java.lang.Object
org.ddolib.nolayer.solving.astar.core.solver.SubProblem<T>
Type Parameters:
T - the type of the state

public class SubProblem<T> extends Object
A subproblem used in the AStarSolver. Represents a node in the A* search tree.
  • Constructor Summary

    Constructors
    Constructor
    Description
    SubProblem(T state, double g, double h, List<Integer> path)
    Creates a new subproblem.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Two subproblems are considered equal if they share the same state.
    double
    f()
    Returns the f = g + h value of this subproblem, used to order the search.
    double
    Returns the fast lower bound estimating the cost from this state to a target state.
    Returns the sequence of labels applied from the initial state to reach this state.
    Returns the state of this subproblem.
    double
    Returns the cost of the path from the initial state to this state.
    int
     
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • SubProblem

      public SubProblem(T state, double g, double h, List<Integer> path)
      Creates a new subproblem.
      Parameters:
      state - the state of this subproblem
      g - the cost of the path from the initial state to this state
      h - the fast lower bound estimating the cost from this state to a target state
      path - the sequence of labels applied from the initial state to reach this state
  • Method Details

    • getState

      public T getState()
      Returns the state of this subproblem.
      Returns:
      the state of this subproblem
    • getValue

      public double getValue()
      Returns the cost of the path from the initial state to this state.
      Returns:
      the cost of the path from the initial state to this state
    • getLowerBound

      public double getLowerBound()
      Returns the fast lower bound estimating the cost from this state to a target state.
      Returns:
      the fast lower bound estimating the cost from this state to a target state
    • f

      public double f()
      Returns the f = g + h value of this subproblem, used to order the search.
      Returns:
      the f = g + h value of this subproblem
    • getPath

      public List<Integer> getPath()
      Returns the sequence of labels applied from the initial state to reach this state.
      Returns:
      an unmodifiable view of the sequence of labels applied to reach this state
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object obj)
      Two subproblems are considered equal if they share the same state. Solvers rely on this to keep at most one entry per state in their priority queues (e.g. when a better path to an already open state replaces the stale entry).
      Overrides:
      equals in class Object
      Parameters:
      obj - the object to compare with
      Returns:
      true if both subproblems have the same state, false otherwise
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object