Class SubProblem<T>
java.lang.Object
org.ddolib.nolayer.solving.astar.core.solver.SubProblem<T>
- Type Parameters:
T- the type of the state
A subproblem used in the AStarSolver. Represents a node in the A* search tree.
-
Constructor Summary
ConstructorsConstructorDescriptionSubProblem(T state, double g, double h, List<Integer> path) Creates a new subproblem. -
Method Summary
Modifier and TypeMethodDescriptionbooleanTwo subproblems are considered equal if they share the same state.doublef()Returns thef = g + hvalue of this subproblem, used to order the search.doubleReturns the fast lower bound estimating the cost from this state to a target state.getPath()Returns the sequence of labels applied from the initial state to reach this state.getState()Returns the state of this subproblem.doublegetValue()Returns the cost of the path from the initial state to this state.inthashCode()toString()
-
Constructor Details
-
SubProblem
Creates a new subproblem.- Parameters:
state- the state of this subproblemg- the cost of the path from the initial state to this stateh- the fast lower bound estimating the cost from this state to a target statepath- the sequence of labels applied from the initial state to reach this state
-
-
Method Details
-
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 thef = g + hvalue of this subproblem, used to order the search.- Returns:
- the
f = g + hvalue of this subproblem
-
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
-
equals
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). -
hashCode
public int hashCode()
-