Package org.ddolib.nolayer.util.debug
Class DebugUtil
java.lang.Object
org.ddolib.nolayer.util.debug.DebugUtil
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 Summary
Modifier and TypeMethodDescriptionstatic <T> voidcheckFlbAdmissibility(Set<T> toCheck, Model<T> model, Function<T, Solver> solver) Given a set of states, checks if theFastLowerBoundis admissible, i.e., whether the bound does not overestimate the path from the states to a target state.static <T> voidcheckHashCodeAndEquality(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.
-
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
RuntimeExceptionis 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 generatedlabel- the label applied to the original statetransition- 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 theFastLowerBoundis 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 checkmodel- a model used to initialize solvers run during the testssolver- returns a solver given a root state
-