Class BoardState

java.lang.Object
topics.branchandbound.utils.Node
topics.branchandbound.rectangles.BoardState
All Implemented Interfaces:
Comparable<Node>

class BoardState extends Node

Represents a distinct physical configuration of the board within the state space tree. It tracks placed rectangles, calculates the bounding area heuristic, and generates valid subsequent placements.

  • Constructor Details

    • BoardState

      public BoardState(int boardSize, List<Piece> pieces)
      Constructs the root node representing an empty board.
      Parameters:
      boardSize - The dimension of the square board.
      pieces - The list of pieces pending placement.
    • BoardState

      public BoardState(int[][] board, List<Piece> pieces, int depth, UUID parentID)
      Constructs a child node representing a subsequent placement state.
      Parameters:
      board - The new board configuration.
      pieces - The list of pieces pending placement.
      depth - The current depth in the state space tree.
      parentID - The unique identifier of the parent node.
  • Method Details

    • expand

      public ArrayList<Node> expand()
      Generates all mathematically valid mathematical configurations extending from the current state by placing the next available piece.
      Specified by:
      expand in class Node
      Returns:
      A list containing the resulting child nodes.
    • calculateHeuristicValue

      public void calculateHeuristicValue()
      Computes the bounding box area of all placed pieces. This serves as the lower-bound heuristic estimate to prune sub-optimal configurations.
      Specified by:
      calculateHeuristicValue in class Node
    • isSolution

      public boolean isSolution()
      Determines whether the current node represents a fully resolved configuration.
      Specified by:
      isSolution in class Node
      Returns:
      true if all pieces have been placed; false otherwise.
    • toString

      public String toString()
      Overrides:
      toString in class Object