Class BlockSpec

java.lang.Object
edu.cmu.tetrad.search.blocks.BlockSpec
All Implemented Interfaces:
TetradSerializable, Serializable

public final class BlockSpec extends Object implements TetradSerializable
Represents a block specification that organizes data into blocks, each associated with a variable and a rank. The class is designed for immutability and serialization.

A block specification consists of: - A dataset (DataSet). - A list of blocks, where each block is a list of indices. - A list of variables (Node) corresponding to each block. - A list of ranks, corresponding to each block and variable, where each rank is an integer greater than or equal to 1.

Constructor validation ensures the integrity of the input, including size consistency between blocks, variables, and ranks, as well as ensuring non-null and well-formed inputs.

This class satisfies the TetradSerializable interface, adhering to restrictions on serializable fields.

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    BlockSpec(DataSet dataSet, List<List<Integer>> blocks, List<Node> blockVariables)
    Constructs an instance of BlockSpec with the specified data set, blocks, and block variables.
    BlockSpec(DataSet dataSet, List<List<Integer>> blocks, List<Node> blockVariables, List<Integer> ranks)
    Constructs an instance of BlockSpec with the specified data set, blocks, block variables, and their corresponding ranks.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the blocks associated with this BlockSpec instance.
    Returns the list of block variables associated with this BlockSpec instance.
    Returns the data set associated with this block specification.
    boolean
    Indicates whether some other object is "equal to" this one.
    int
    Computes the hash code for this object.
    Returns the list of ranks associated with this BlockSpec instance.
    @NotNull String
     

    Methods inherited from class java.lang.Object

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

    • BlockSpec

      public BlockSpec(DataSet dataSet, List<List<Integer>> blocks, List<Node> blockVariables)
      Constructs an instance of BlockSpec with the specified data set, blocks, and block variables. Validates input parameters to ensure they are non-null, and the sizes of blocks and block variables are equal.
      Parameters:
      dataSet - the data set associated with this block specification; must not be null
      blocks - a list of lists of integers representing the blocks; must not be null and must match the size of blockVariables
      blockVariables - a list of Node objects corresponding to the block variables; must not be null and must match the size of blocks
      Throws:
      NullPointerException - if the data set is null
      IllegalArgumentException - if blocks or blockVariables are null, or if the sizes of blocks and blockVariables do not match
    • BlockSpec

      public BlockSpec(DataSet dataSet, List<List<Integer>> blocks, List<Node> blockVariables, List<Integer> ranks)
      Constructs an instance of BlockSpec with the specified data set, blocks, block variables, and their corresponding ranks. Validates the input parameters to ensure they are non-null, and that the sizes of the blocks, block variables, and ranks are consistent. Ensures all rank values are greater than or equal to 1.
      Parameters:
      dataSet - the data set associated with this block specification; must not be null
      blocks - a list of lists of integers representing the blocks; must not be null, must match the size of blockVariables and ranks
      blockVariables - a list of Node objects corresponding to the block variables; must not be null and must match the size of blocks and ranks
      ranks - a list of integers representing the rank of each block; must not be null and all values must be >= 1
      Throws:
      NullPointerException - if the dataSet is null
      IllegalArgumentException - if blocks, blockVariables, or ranks are null, the sizes of blocks, blockVariables, and ranks do not match, or if any rank is less than 1
  • Method Details

    • dataSet

      public DataSet dataSet()
      Returns the data set associated with this block specification.
      Returns:
      the DataSet object representing the data set associated with this BlockSpec instance
    • blocks

      public List<List<Integer>> blocks()
      Returns the blocks associated with this BlockSpec instance.
      Returns:
      a list of lists of integers, where each inner list represents a block
    • blockVariables

      public List<Node> blockVariables()
      Returns the list of block variables associated with this BlockSpec instance.
      Returns:
      a list of Node objects representing the block variables
    • ranks

      public List<Integer> ranks()
      Returns the list of ranks associated with this BlockSpec instance.
      Returns:
      a list of integers representing the ranks of the blocks
    • toString

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

      public boolean equals(Object obj)
      Indicates whether some other object is "equal to" this one. Two BlockSpec instances are considered equal if their respective dataSet, blocks, blockVariables, and ranks fields are equal.
      Overrides:
      equals in class Object
      Parameters:
      obj - the reference object with which to compare
      Returns:
      true if this object is the same as the obj argument, or if obj is a BlockSpec instance with the same dataSet, blocks, blockVariables, and ranks; false otherwise
    • hashCode

      public int hashCode()
      Computes the hash code for this object. The hash code is calculated based on the dataSet, blocks, blockVariables, and ranks fields of this instance.
      Overrides:
      hashCode in class Object
      Returns:
      an integer representing the hash code value for this object