Class DebugUtil

java.lang.Object
org.ddolib.nolayer.util.debug.DebugUtil

public class DebugUtil extends Object
Utility class providing methods useful for debugging state transitions.

This class helps to verify the correctness of the state transition function by checking that states generated from the same origin with the same label are both equal and have the same hash code.

  • Method Details

    • checkHashCodeAndEquality

      public static <T> void checkHashCodeAndEquality(T state, int label, BiFunction<T,Integer,T> transition)
      Checks the consistency of a transition function by generating two states from the same origin state and label, then verifying that they are equal and have the same hash code.

      If the generated states either differ in hash code or are not equal, a RuntimeException is thrown with detailed information about the origin state, label, and resulting states.

      Type Parameters:
      T - the type of the states
      Parameters:
      state - the original state from which the new states are generated
      label - the label applied to the original state
      transition - the transition function that generates a new state from a state and a label
      Throws:
      RuntimeException - if the generated states are not equal or have different hash codes
    • checkFlbAdmissibility

      public static <T> void checkFlbAdmissibility(Set<T> toCheck, Model<T> model, Function<T,Solver> solver)
      Given a set of states, checks if the FastLowerBound is admissible, i.e., whether the bound does not overestimate the path from the states to a target state.

      The checks are performed by running solvers starting from the tested states.

      Type Parameters:
      T - the type of the states
      Parameters:
      toCheck - the states to check
      model - a model used to initialize solvers run during the tests
      solver - returns a solver given a root state