Class DefaultVariableHeuristic<T>

java.lang.Object
org.ddolib.ddo.core.heuristics.variable.DefaultVariableHeuristic<T>
Type Parameters:
T - the type representing the problem state
All Implemented Interfaces:
VariableHeuristic<T>

public final class DefaultVariableHeuristic<T> extends Object implements VariableHeuristic<T>
A default implementation of VariableHeuristic that selects the next variable to branch on without applying any specific strategy.

This heuristic simply returns the first element obtained from the iterator of the provided variables set. Therefore, it does not guarantee any particular or deterministic order, as the iteration order of a Set depends on its concrete implementation (e.g., HashSet is not ordered).

This class serves as a minimal or placeholder heuristic to ensure that the compilation or search process can proceed when no specific variable ordering rule has been defined by the user.

See Also:
  • Constructor Details

    • DefaultVariableHeuristic

      public DefaultVariableHeuristic()
  • Method Details

    • nextVariable

      public Integer nextVariable(Set<Integer> variables, Iterator<T> states)
      Returns the next variable to branch on by selecting the first element from the set of remaining variables.

      This implementation applies no logic based on the current layer states and provides no guarantees on reproducibility unless a deterministic Set implementation (e.g., LinkedHashSet) is used.

      Specified by:
      nextVariable in interface VariableHeuristic<T>
      Parameters:
      variables - the set of variables that have not yet been assigned
      states - an iterator over the states in the current layer (unused)
      Returns:
      the next variable to branch on, as given by variables.iterator().next()
      Throws:
      NoSuchElementException - if the variables set is empty