Class NoGood


public class NoGood extends Constraint
NoGood constraints implements a constraint which disallows given combination of values for given variables. NoGoods are special constraints as they can be only triggered only when all variables except one are grounded and equal to disallow values. This allows efficient implementation based on watched literals idea from SAT community.

Do not be fooled by watched literals, if you add thousands of no-goods then traversing even 1/10 of them if they are watched by variable which has been grounded can slow down search considerably.

NoGoods constraints are imposed at all levels once added. Do not use in subsearches, as it will not take into account the assignments performed in master search.

Version:
4.10
  • Field Details

    • idNumber

      static AtomicInteger idNumber
    • listOfVars

      protected IntVar[] listOfVars
      It specifies a list of variables in no-good constraint.
    • listOfValues

      protected int[] listOfValues
      It specifies a list of values in no-good constraint.
    • firstWatch

      private IntVar firstWatch
    • firstValue

      private int firstValue
    • secondWatch

      private IntVar secondWatch
    • secondValue

      private int secondValue
    • debug

      private static final boolean debug
      See Also:
  • Constructor Details

    • NoGood

      public NoGood(IntVar[] listOfVars, int[] listOfValues)
      It creates a no-good constraint.
      Parameters:
      listOfVars - the scope of the constraint.
      listOfValues - no-good values which all-together assignment to variables within constraint scope is a no-good.
    • NoGood

      public NoGood(List<? extends IntVar> listOfVars, List<Integer> listOfValues)
      It creates a no-good constraint.
      Parameters:
      listOfVars - the scope of the constraint.
      listOfValues - no-good values which all-together assignment to variables within constraint scope is a no-good.
  • Method Details

    • commonInitialization

      private void commonInitialization(IntVar[] listOfVars, int[] listOfValues)
    • consistency

      public void consistency(Store store)
      Description copied from class: Constraint
      It is a (most probably incomplete) consistency function which removes the values from variables domains. Only values which do not have any support in a solution space are removed.
      Specified by:
      consistency in class Constraint
      Parameters:
      store - constraint store within which the constraint consistency is being checked.
    • getDefaultConsistencyPruningEvent

      public int getDefaultConsistencyPruningEvent()
      Specified by:
      getDefaultConsistencyPruningEvent in class Constraint
    • impose

      public void impose(Store store)
      Description copied from class: Constraint
      It imposes the constraint in a given store.
      Overrides:
      impose in class Constraint
      Parameters:
      store - the constraint store to which the constraint is imposed to.
    • removeConstraint

      public void removeConstraint()
      This function does nothing as constraints can not be removed for a given level. In addition, watched literals mechanism makes sure that constraint is not put in the queue when it can not propagate.
      Overrides:
      removeConstraint in class Constraint
    • toString

      public String toString()
      Description copied from class: Constraint
      It produces a string representation of a constraint state.
      Overrides:
      toString in class Constraint