Class DebugUtil

java.lang.Object
org.ddolib.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 decision are both equal and have the same hash code.

  • Constructor Details

    • DebugUtil

      public DebugUtil()
  • Method Details

    • checkHashCodeAndEquality

      public static <T> void checkHashCodeAndEquality(T state, Decision decision, BiFunction<T,Decision,T> transition)
      Checks the consistency of a transition function by generating two states from the same origin state and decision, 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, decision, and resulting states.

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

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

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

      Type Parameters:
      T - The type of the states.
      Parameters:
      toCheck - The states to check.
      model - A model used to initialize solvers ran during the tests.
      solver - Returns a solver given a root state.
    • checkFlbConsistency

      public static <T> void checkFlbConsistency(SubProblem<T> current, SubProblem<T> next, double transitionCost)
      Given the current node and one of its successor. Checks if the lower bound is consistent.
      Type Parameters:
      T - The type of the states.
      Parameters:
      current - The current node.
      next - A successor of the current node.
      transitionCost - The transition cost from current to next.