Class NbUnassignedWidth<T>

java.lang.Object
org.ddolib.common.heuristics.width.NbUnassignedWidth<T>
Type Parameters:
T - the type of the states
All Implemented Interfaces:
WidthHeuristic<T>

public class NbUnassignedWidth<T> extends Object implements WidthHeuristic<T>
Width heuristic giving to the decision diagrams compiled from a subproblem a maximum width equal to its number of unassigned variables, i.e. the number of variables minus the depth of the subproblem (at least 1). It is the default width heuristic of ddo (NbUnassignedWidth): the diagrams compiled close to the root are wide, those compiled deep in the search are narrow, where they are cheap to compile exactly.

The width can be scaled by a constant factor, like the Times heuristic of ddo.

  • Constructor Summary

    Constructors
    Constructor
    Description
    NbUnassignedWidth(int nbVars)
    Creates a width heuristic equal to the number of unassigned variables.
    NbUnassignedWidth(int nbVars, int factor)
    Creates a width heuristic equal to the number of unassigned variables times a factor.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    maximumWidth(T state)
    Returns the width at the root, where no variable is assigned: the number of variables (times the factor).
    int
    maximumWidth(T state, int depth)
    Computes the maximum width allowed for the decision diagrams compiled from a subproblem, given its state and its depth (the number of variables already assigned).
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • NbUnassignedWidth

      public NbUnassignedWidth(int nbVars)
      Creates a width heuristic equal to the number of unassigned variables.
      Parameters:
      nbVars - the number of variables of the problem
    • NbUnassignedWidth

      public NbUnassignedWidth(int nbVars, int factor)
      Creates a width heuristic equal to the number of unassigned variables times a factor.
      Parameters:
      nbVars - the number of variables of the problem
      factor - the factor applied to the number of unassigned variables (at least 1)
      Throws:
      IllegalArgumentException - if nbVars is negative or factor < 1
  • Method Details

    • maximumWidth

      public int maximumWidth(T state)
      Returns the width at the root, where no variable is assigned: the number of variables (times the factor). The solvers call maximumWidth(Object, int) instead.
      Specified by:
      maximumWidth in interface WidthHeuristic<T>
      Parameters:
      state - the state of the subproblem
      Returns:
      the width at the root
    • maximumWidth

      public int maximumWidth(T state, int depth)
      Description copied from interface: WidthHeuristic
      Computes the maximum width allowed for the decision diagrams compiled from a subproblem, given its state and its depth (the number of variables already assigned). The solvers call this method; by default, it ignores the depth and returns WidthHeuristic.maximumWidth(Object).
      Specified by:
      maximumWidth in interface WidthHeuristic<T>
      Parameters:
      state - the state of the subproblem
      depth - the depth of the subproblem, i.e. its number of assigned variables
      Returns:
      the maximum width for the layers of the decision diagrams
    • toString

      public String toString()
      Overrides:
      toString in class Object