Class MaxCardDiff<T extends SetVar>

java.lang.Object
org.jacop.set.search.MaxCardDiff<T>
Type Parameters:
T - type of variable being used in search.
All Implemented Interfaces:
ComparatorVariable<T>

public class MaxCardDiff<T extends SetVar> extends Object implements ComparatorVariable<T>
Defines a maximum cardinality difference variable comparator. The variable with the maximum difference in cardinality between the greatest lower bound and the least upper bound has the priority.
Version:
4.10
  • Constructor Summary

    Constructors
    Constructor
    Description
    It constructs a maximum cardinality difference variable comparator.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    compare(double left, T var)
    Compares the cardinality difference of the variable to the float value.
    int
    compare(T leftVar, T rightVar)
    Compares the cardinality difference of the variables.
    double
    metric(T var)
    Returns the metric(Cardinality difference) of the variable.

    Methods inherited from class java.lang.Object

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

    • MaxCardDiff

      public MaxCardDiff()
      It constructs a maximum cardinality difference variable comparator.
  • Method Details

    • compare

      public int compare(double left, T var)
      Compares the cardinality difference of the variable to the float value.
      Specified by:
      compare in interface ComparatorVariable<T extends SetVar>
      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)
      Compares the cardinality difference of the variables.
      Specified by:
      compare in interface ComparatorVariable<T extends SetVar>
      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)
      Returns the metric(Cardinality difference) of the variable.
      Specified by:
      metric in interface ComparatorVariable<T extends SetVar>
      Parameters:
      var - variable for which metric is computed.
      Returns:
      the metric of the variable according to the comparator.