Class Node
- All Implemented Interfaces:
Comparable<Node>
- Direct Known Subclasses:
AssignmentState, BoardState, Game, InterleavingNode, PuzzleState
State Space Tree Node
An abstract representation of a distinct mathematical state within the execution tree of a Branch and Bound algorithmic process.
This class establishes the fundamental topological contract for any state node,
providing built-in mechanisms for unique identification, lineage tracking (parenting),
depth monitoring, and heuristic cost evaluation. It implements the Comparable
interface to allow automatic prioritization within the execution engine's exploration queue.
- Author:
- vicegd
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intThe topological depth of this state within the execution tree.protected intThe calculated lower-bound metric evaluating the optimistic cost of this state.protected final UUIDThe immutable unique identifier for this specific state configuration.protected UUIDThe unique identifier of the preceding node from which this state was derived, allowing the extraction of the final path lineage. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedNode()Initializes the foundational properties of a new state node, generating its unique identity and establishing it as an unlinked topological root by default. -
Method Summary
Modifier and TypeMethodDescriptionabstract voidExecutes the mathematical formulation to compute the specific lower-bound heuristic estimate for this state configuration.intDefines the prioritization logic for the execution engine's priority queue.booleanEvaluates topological equivalence between this state and another object.expand()Generates all mathematically valid state configurations extending from this specific topological juncture.intgetDepth()Retrieves the execution depth of this state.intRetrieves the optimistic heuristic evaluation cost of this state.getId()Retrieves the unique identifier of this node.Retrieves the unique identifier of the parent node.inthashCode()intEstablishes the preliminary upper-bound limit to trigger the initial pruning phase.abstract booleanDetermines whether the current node represents a fully resolved configuration satisfying all problem constraints.
-
Field Details
-
id
The immutable unique identifier for this specific state configuration. -
parentId
The unique identifier of the preceding node from which this state was derived, allowing the extraction of the final path lineage. -
depth
protected int depthThe topological depth of this state within the execution tree. Represents the number of discrete moves or transitions applied since the root node. -
heuristicValue
protected int heuristicValueThe calculated lower-bound metric evaluating the optimistic cost of this state.
-
-
Constructor Details
-
Node
protected Node()Initializes the foundational properties of a new state node, generating its unique identity and establishing it as an unlinked topological root by default.
-
-
Method Details
-
getId
Retrieves the unique identifier of this node.- Returns:
- The UUID assigned to this state.
-
getParentId
Retrieves the unique identifier of the parent node.- Returns:
- The UUID of the parent state, or
nullif this is the root.
-
getDepth
public int getDepth()Retrieves the execution depth of this state.- Returns:
- The integer depth level within the execution tree.
-
getHeuristicValue
public int getHeuristicValue()Retrieves the optimistic heuristic evaluation cost of this state.- Returns:
- The calculated integer bounding value.
-
equals
Evaluates topological equivalence between this state and another object.By default, it determines equivalence by comparing the serialized string representation of the states. Subclasses may override this behavior if a more highly optimized mathematical comparison (e.g., matrix hashing) is required.
-
hashCode
-
initialValuePruneLimit
public int initialValuePruneLimit()Establishes the preliminary upper-bound limit to trigger the initial pruning phase.By default, this assumes no prior domain knowledge, returning the maximum theoretical integer value. Subclasses should override this method to provide a tighter mathematical baseline (e.g., a greedy heuristic estimate) if available.
- Returns:
- The initial upper bound estimate.
-
compareTo
Defines the prioritization logic for the execution engine's priority queue. States with a lower heuristic value are granted higher priority, enforcing the Best-First Search exploration pattern.- Specified by:
compareToin interfaceComparable<Node>- Parameters:
other- The competing state node to compare against.- Returns:
- A negative integer, zero, or a positive integer as this node is prioritized higher, equal to, or lower than the specified node.
-
calculateHeuristicValue
public abstract void calculateHeuristicValue()Executes the mathematical formulation to compute the specific lower-bound heuristic estimate for this state configuration. -
expand
-
isSolution
public abstract boolean isSolution()Determines whether the current node represents a fully resolved configuration satisfying all problem constraints.- Returns:
trueif the state is a complete mathematical solution;falseotherwise.
-