Class WeightedDegree<T extends Var>

java.lang.Object
org.jacop.search.WeightedDegree<T>
Type Parameters:
T - type of variable being compared.
All Implemented Interfaces:
ComparatorVariable<T>

public class WeightedDegree<T extends Var> extends Object implements ComparatorVariable<T>
Defines a WeightedDegree comparator for variables. Every time a constraint failure is encountered all variables within the scope of that constraints have increased weight. The comparator will choose the variable with the highest weight divided by its size. This implementation is not equivalent to AFCMaxDeg since it takes all accumulated failures for a variable while AFCMaxDeg sums up weights for still active constraints only!
Version:
4.10
  • Constructor Details

    • WeightedDegree

      private WeightedDegree()
    • WeightedDegree

      public WeightedDegree(Store store)
  • Method Details

    • compare

      public int compare(double left, T var)
      Description copied from interface: ComparatorVariable
      It compares the baseline metric to the variable metric.
      Specified by:
      compare in interface ComparatorVariable<T extends Var>
      Parameters:
      left - the baseline for comparison.
      var - variable which is compared to baseline.
      Returns:
      1 if metric is larger than variable, 0 if equal, -1 if baseline is smaller.
    • compare

      public int compare(T leftVar, T rightVar)
      Description copied from interface: ComparatorVariable
      It compares the metric of the left variable against the right one.
      Specified by:
      compare in interface ComparatorVariable<T extends Var>
      Parameters:
      leftVar - left variable
      rightVar - right variable
      Returns:
      1 if metric for left variable is greater, 0 is they are equal, -1 if smaller.
    • metric

      public double metric(T var)
      Description copied from interface: ComparatorVariable
      It returns the metric of the variable given according to the comparator.
      Specified by:
      metric in interface ComparatorVariable<T extends Var>
      Parameters:
      var - variable for which metric is computed.
      Returns:
      the metric of the variable according to the comparator.