Interface ISetConstraintFactory

  • All Known Subinterfaces:
    IConstraintFactory, IModel
    All Known Implementing Classes:
    Model

    public interface ISetConstraintFactory
    Interface to make constraints over SetVar A kind of factory relying on interface default implementation to allow (multiple) inheritance
    Since:
    4.0.0
    Author:
    Jean-Guillaume FAGES
    • Method Summary

      All Methods Instance Methods Default Methods 
      Modifier and Type Method Description
      default Constraint allDifferent​(SetVar... sets)
      Creates a constraint stating that sets should all be different (not necessarily disjoint) Note that there cannot be more than one empty set
      default Constraint allDisjoint​(SetVar... sets)
      Creates a constraint stating that the intersection of sets should be empty Note that there can be multiple empty sets
      default Constraint allEqual​(SetVar... sets)
      Creates a constraint stating that sets should be all equal
      default Constraint disjoint​(SetVar set1, SetVar set2)
      Creates a constraint stating that the intersection of set1 and set2 should be empty Note that they can be both empty
      default Constraint element​(IntVar index, SetVar[] sets, int offset, SetVar set)
      Creates a constraint enabling to retrieve an element set in sets: sets[index-offset] = set
      default Constraint element​(IntVar index, SetVar[] sets, SetVar set)
      Creates a constraint enabling to retrieve an element set in sets: sets[index] = set
      default Constraint intersection​(SetVar[] sets, SetVar intersectionSet)
      Creates a constraint which ensures that the intersection of sets is equal to intersectionSet
      default Constraint intersection​(SetVar[] sets, SetVar intersectionSet, boolean boundConsistent)
      Creates a constraint which ensures that the intersection of sets is equal to intersectionSet
      default Constraint inverseSet​(SetVar[] sets, SetVar[] invSets, int offset1, int offset2)
      Creates a constraint stating that : x in sets[y-offset1] <=> y in invSets[x-offset2]
      default Constraint max​(SetVar indices, int[] weights, int offset, IntVar maxElementValue, boolean notEmpty)
      Creates a constraint over the maximum element induces by a set: max{weights[i-offset] | i in indices} = maxElementValue
      default Constraint max​(SetVar set, IntVar maxElementValue, boolean notEmpty)
      Creates a constraint over the maximum element in a set: max{i | i in set} = maxElementValue
      default Constraint member​(int cst, SetVar set)
      Creates a member constraint stating that the constant cst is in set
      default Constraint member​(IntVar intVar, SetVar set)
      Creates a member constraint stating that the value of intVar is in set
      default Constraint member​(SetVar[] sets, SetVar set)
      Creates a member constraint stating that set belongs to sets
      default Constraint min​(SetVar indices, int[] weights, int offset, IntVar minElementValue, boolean notEmpty)
      Creates a constraint over the minimum element induces by a set: min{weights[i-offset] | i in indices} = minElementValue
      default Constraint min​(SetVar set, IntVar minElementValue, boolean notEmpty)
      Creates a constraint over the minimum element in a set: min{i | i in set} = minElementValue
      default Constraint nbEmpty​(SetVar[] sets, int nbEmpty)
      Creates a constraint counting the number of empty sets sets |{s in sets where |s|=0}| = nbEmpty
      default Constraint nbEmpty​(SetVar[] sets, IntVar nbEmpty)
      Creates a constraint counting the number of empty sets sets |{s in sets where |s|=0}| = nbEmpty
      default Constraint notEmpty​(SetVar set)
      Creates a constraint preventing set to be empty
      default Constraint notMember​(int cst, SetVar set)
      Creates a member constraint stating that the constant cst is not in set
      default Constraint notMember​(IntVar intVar, SetVar set)
      Creates a member constraint stating that the value of intVar is not in set
      default Constraint offSet​(SetVar set1, SetVar set2, int offset)
      Creates a constraint linking set1 and set2 with an index offset : x in set1 <=> x+offset in set2
      default Constraint partition​(SetVar[] sets, SetVar universe)
      Creates a constraint stating that partitions universe into sets: union(sets) = universe intersection(sets) = {}
      default Constraint setBoolsChanneling​(BoolVar[] bools, SetVar set)
      Creates a constraint channeling a set variable with boolean variables : i in set <=> bools[i] = TRUE
      default Constraint setBoolsChanneling​(BoolVar[] bools, SetVar set, int offset)
      Creates a constraint channeling a set variable with boolean variables : i in set <=> bools[i-offset] = TRUE
      default Constraint setsIntsChanneling​(SetVar[] sets, IntVar[] ints)
      Creates a constraint channeling set variables and integer variables : x in sets[y] <=> ints[x] = y
      default Constraint setsIntsChanneling​(SetVar[] sets, IntVar[] ints, int offset1, int offset2)
      Creates a constraint channeling set variables and integer variables : x in sets[y-offset1] <=> ints[x-offset2] = y
      default Constraint subsetEq​(SetVar... sets)
      Creates a constraint establishing that sets[i] is a subset of sets[j] if i
      default Constraint sum​(SetVar set, IntVar sum)
      Creates a constraint summing elements of set sum{i | i in set} = sum
      default Constraint sumElements​(SetVar indices, int[] weights, int offset, IntVar sum)
      Creates a constraint summing weights given by a set of indices: sum{weights[i-offset] | i in indices} = sum Also ensures that elements in indices belong to [offset, offset+weights.length-1]
      default Constraint sumElements​(SetVar indices, int[] weights, IntVar sum)
      Creates a constraint summing weights given by a set of indices: sum{weights[i] | i in indices} = sum Also ensures that elements in indices belong to [0, weights.length-1]
      default Constraint symmetric​(SetVar... sets)
      Creates a constraint stating that sets are symmetric sets: x in sets[y] <=> y in sets[x]
      default Constraint symmetric​(SetVar[] sets, int offset)
      Creates a constraint stating that sets are symmetric sets: x in sets[y-offset] <=> y in sets[x-offset]
      default Constraint union​(IntVar[] ints, SetVar union)
      Creates a constraint ensuring that union is exactly the union of values taken by ints,
      default Constraint union​(SetVar[] sets, SetVar unionSet)
      Creates a constraint which ensures that the union of sets is equal to unionSet
    • Method Detail

      • union

        default Constraint union​(IntVar[] ints,
                                 SetVar union)
        Creates a constraint ensuring that union is exactly the union of values taken by ints,
        Parameters:
        ints - an array of integer variables
        union - a set variable
        Returns:
        a constraint ensuring that union = {x | x in ints}
      • union

        default Constraint union​(SetVar[] sets,
                                 SetVar unionSet)
        Creates a constraint which ensures that the union of sets is equal to unionSet
        Parameters:
        sets - an array of set variables
        unionSet - set variable representing the union of sets
        Returns:
        A constraint ensuring that the union of sets is equal to unionSet
      • intersection

        default Constraint intersection​(SetVar[] sets,
                                        SetVar intersectionSet)
        Creates a constraint which ensures that the intersection of sets is equal to intersectionSet
        Parameters:
        sets - an array of set variables
        intersectionSet - a set variable representing the intersection of sets
        Returns:
        A constraint ensuring that the intersection of sets is equal to intersectionSet
      • intersection

        default Constraint intersection​(SetVar[] sets,
                                        SetVar intersectionSet,
                                        boolean boundConsistent)
        Creates a constraint which ensures that the intersection of sets is equal to intersectionSet
        Parameters:
        sets - an array of set variables
        intersectionSet - a set variable representing the intersection of sets
        boundConsistent - adds an additional propagator to guarantee BC
        Returns:
        A constraint ensuring that the intersection of sets is equal to intersectionSet
      • subsetEq

        default Constraint subsetEq​(SetVar... sets)
        Creates a constraint establishing that sets[i] is a subset of sets[j] if i
        Parameters:
        sets - an array of set variables
        Returns:
        A constraint which ensures that sets[i] is a subset of sets[j] if i
      • nbEmpty

        default Constraint nbEmpty​(SetVar[] sets,
                                   int nbEmpty)
        Creates a constraint counting the number of empty sets sets |{s in sets where |s|=0}| = nbEmpty
        Parameters:
        sets - an array of set variables
        nbEmpty - integer restricting the number of empty sets in sets
        Returns:
        A constraint ensuring that |{s in sets where |s|=0}| = nbEmpty
      • nbEmpty

        default Constraint nbEmpty​(SetVar[] sets,
                                   IntVar nbEmpty)
        Creates a constraint counting the number of empty sets sets |{s in sets where |s|=0}| = nbEmpty
        Parameters:
        sets - an array of set variables
        nbEmpty - integer variable restricting the number of empty sets in sets
        Returns:
        A constraint ensuring that |{s in sets where |s|=0}| = nbEmpty
      • offSet

        default Constraint offSet​(SetVar set1,
                                  SetVar set2,
                                  int offset)
        Creates a constraint linking set1 and set2 with an index offset : x in set1 <=> x+offset in set2
        Parameters:
        set1 - a set variable
        set2 - a set variable
        offset - offset index
        Returns:
        a constraint ensuring that x in set1 <=> x+offset in set2
      • notEmpty

        default Constraint notEmpty​(SetVar set)
        Creates a constraint preventing set to be empty
        Parameters:
        set - a SetVar which should not be empty
        Returns:
        a constraint ensuring that set is not empty
      • sum

        default Constraint sum​(SetVar set,
                               IntVar sum)
        Creates a constraint summing elements of set sum{i | i in set} = sum
        Parameters:
        set - a set variable
        sum - an integer variable representing sum{i | i in set}
        Returns:
        a constraint ensuring that sum{i | i in set} = sum
      • sumElements

        default Constraint sumElements​(SetVar indices,
                                       int[] weights,
                                       IntVar sum)
        Creates a constraint summing weights given by a set of indices: sum{weights[i] | i in indices} = sum Also ensures that elements in indices belong to [0, weights.length-1]
        Parameters:
        indices - a set variable
        weights - integers representing the weight of each element in indices
        sum - an integer variable representing sum{weights[i] | i in indices}
        Returns:
        a constraint ensuring that sum{weights[i] | i in indices} = sum
      • sumElements

        default Constraint sumElements​(SetVar indices,
                                       int[] weights,
                                       int offset,
                                       IntVar sum)
        Creates a constraint summing weights given by a set of indices: sum{weights[i-offset] | i in indices} = sum Also ensures that elements in indices belong to [offset, offset+weights.length-1]
        Parameters:
        indices - a set variable
        weights - integers representing the weight of each element in indices
        offset - offset index : should be 0 by default but generally 1 with MiniZinc API which counts from 1 to n instead of counting from 0 to n-1 (Java standard)
        sum - an integer variable representing sum{weights[i-offset] | i in indices}
        Returns:
        a constraint ensuring that sum{weights[i-offset] | i in indices} = sum
      • max

        default Constraint max​(SetVar set,
                               IntVar maxElementValue,
                               boolean notEmpty)
        Creates a constraint over the maximum element in a set: max{i | i in set} = maxElementValue
        Parameters:
        set - a set variable
        maxElementValue - an integer variable representing the maximum element in set
        notEmpty - true : the set variable cannot be empty false : the set may be empty (if set is empty, this constraint is not applied)
        Returns:
        a constraint ensuring that max{i | i in set} = maxElementValue
      • max

        default Constraint max​(SetVar indices,
                               int[] weights,
                               int offset,
                               IntVar maxElementValue,
                               boolean notEmpty)
        Creates a constraint over the maximum element induces by a set: max{weights[i-offset] | i in indices} = maxElementValue
        Parameters:
        indices - a set variable containing elements in range [offset,weights.length-1+offset]
        weights - integers representing the weight of each element in indices
        offset - offset index : should be 0 by default but generally 1 with MiniZinc API which counts from 1 to n instead of counting from 0 to n-1 (Java standard)
        maxElementValue - an integer variable representing the maximum weight induced by indices
        notEmpty - true : the set variable cannot be empty false : the set may be empty (if indices is empty, this constraint is not applied)
        Returns:
        a constraint ensuring that max{weights[i-offset] | i in indices} = maxElementValue
      • min

        default Constraint min​(SetVar set,
                               IntVar minElementValue,
                               boolean notEmpty)
        Creates a constraint over the minimum element in a set: min{i | i in set} = minElementValue
        Parameters:
        set - a set variable
        minElementValue - an integer variable representing the minimum element in set
        notEmpty - true : the set variable cannot be empty false : the set may be empty (if set is empty, this constraint is not applied)
        Returns:
        a constraint ensuring that min{i | i in set} = minElementValue
      • min

        default Constraint min​(SetVar indices,
                               int[] weights,
                               int offset,
                               IntVar minElementValue,
                               boolean notEmpty)
        Creates a constraint over the minimum element induces by a set: min{weights[i-offset] | i in indices} = minElementValue
        Parameters:
        indices - a set variable containing elements in range [offset,weights.length-1+offset]
        weights - integers representing the weight of each element in indices
        offset - offset index : should be 0 by default but generally 1 with MiniZinc API which counts from 1 to n instead of counting from 0 to n-1 (Java standard)
        minElementValue - an integer variable representing the minimum weight induced by indices
        notEmpty - true : the set variable cannot be empty false : the set may be empty (if indices is empty, this constraint is not applied)
        Returns:
        a constraint ensuring that min{weights[i-offset] | i in indices} = minElementValue
      • setBoolsChanneling

        default Constraint setBoolsChanneling​(BoolVar[] bools,
                                              SetVar set)
        Creates a constraint channeling a set variable with boolean variables : i in set <=> bools[i] = TRUE
        Parameters:
        bools - an array of boolean variables
        set - a set variable
        Returns:
        a constraint ensuring that i in set <=> bools[i] = TRUE
      • setBoolsChanneling

        default Constraint setBoolsChanneling​(BoolVar[] bools,
                                              SetVar set,
                                              int offset)
        Creates a constraint channeling a set variable with boolean variables : i in set <=> bools[i-offset] = TRUE
        Parameters:
        bools - an array of boolean variables
        set - a set variable
        offset - offset index : should be 0 by default but generally 1 with MiniZinc API which counts from 1 to n instead of counting from 0 to n-1 (Java standard)
        Returns:
        a constraint ensuring that i in set <=> bools[i-offset] = TRUE
      • setsIntsChanneling

        default Constraint setsIntsChanneling​(SetVar[] sets,
                                              IntVar[] ints)
        Creates a constraint channeling set variables and integer variables : x in sets[y] <=> ints[x] = y
        Parameters:
        sets - an array of set variables
        ints - an array of integer variables
        Returns:
        a constraint ensuring that x in sets[y] <=> ints[x] = y
      • setsIntsChanneling

        default Constraint setsIntsChanneling​(SetVar[] sets,
                                              IntVar[] ints,
                                              int offset1,
                                              int offset2)
        Creates a constraint channeling set variables and integer variables : x in sets[y-offset1] <=> ints[x-offset2] = y
        Parameters:
        sets - an array of set variables
        ints - an array of integer variables
        offset1 - offset index : should be 0 by default but generally 1 with MiniZinc API which counts from 1 to n instead of counting from 0 to n-1 (Java standard)
        offset2 - offset index : should be 0 by default but generally 1 with MiniZinc API which counts from 1 to n instead of counting from 0 to n-1 (Java standard)
        Returns:
        a constraint ensuring that x in sets[y-offset1] <=> ints[x-offset2] = y
      • disjoint

        default Constraint disjoint​(SetVar set1,
                                    SetVar set2)
        Creates a constraint stating that the intersection of set1 and set2 should be empty Note that they can be both empty
        Parameters:
        set1 - a set variable
        set2 - a set variable
        Returns:
        a constraint ensuring that set1 and set2 are disjoint (empty intersection)
      • allDisjoint

        default Constraint allDisjoint​(SetVar... sets)
        Creates a constraint stating that the intersection of sets should be empty Note that there can be multiple empty sets
        Parameters:
        sets - an array of disjoint set variables
        Returns:
        a constraint ensuring that sets are all disjoint (empty intersection)
      • allDifferent

        default Constraint allDifferent​(SetVar... sets)
        Creates a constraint stating that sets should all be different (not necessarily disjoint) Note that there cannot be more than one empty set
        Parameters:
        sets - an array of different set variables
        Returns:
        a constraint ensuring that sets are all different
      • allEqual

        default Constraint allEqual​(SetVar... sets)
        Creates a constraint stating that sets should be all equal
        Parameters:
        sets - an array of set variables to be equal
        Returns:
        a constraint ensuring that all sets in sets are equal
      • partition

        default Constraint partition​(SetVar[] sets,
                                     SetVar universe)
        Creates a constraint stating that partitions universe into sets: union(sets) = universe intersection(sets) = {}
        Parameters:
        sets - an array of set variables whose values are subsets of universe
        universe - a set variable representing the union of sets
        Returns:
        a constraint which ensures that sets forms a partition of universe
      • inverseSet

        default Constraint inverseSet​(SetVar[] sets,
                                      SetVar[] invSets,
                                      int offset1,
                                      int offset2)
        Creates a constraint stating that : x in sets[y-offset1] <=> y in invSets[x-offset2]
        Parameters:
        sets - an array of set variables
        invSets - an array of set variables
        offset1 - offset index : should be 0 by default but generally 1 with MiniZinc API which counts from 1 to n instead of counting from 0 to n-1 (Java standard)
        offset2 - offset index : should be 0 by default but generally 1 with MiniZinc API which counts from 1 to n instead of counting from 0 to n-1 (Java standard)
        Returns:
        a constraint ensuring that x in sets[y-offset1] <=> y in invSets[x-offset2]
      • symmetric

        default Constraint symmetric​(SetVar... sets)
        Creates a constraint stating that sets are symmetric sets: x in sets[y] <=> y in sets[x]
        Parameters:
        sets - an array of set variables
        Returns:
        a constraint ensuring that x in sets[y] <=> y in sets[x]
      • symmetric

        default Constraint symmetric​(SetVar[] sets,
                                     int offset)
        Creates a constraint stating that sets are symmetric sets: x in sets[y-offset] <=> y in sets[x-offset]
        Parameters:
        sets - an array of set variables
        offset - offset index : should be 0 by default but generally 1 with MiniZinc API which counts from 1 to n instead of counting from 0 to n-1 (Java standard)
        Returns:
        a constraint ensuring that x in sets[y-offset] <=> y in sets[x-offset]
      • element

        default Constraint element​(IntVar index,
                                   SetVar[] sets,
                                   SetVar set)
        Creates a constraint enabling to retrieve an element set in sets: sets[index] = set
        Parameters:
        index - an integer variable pointing to set's index into array sets
        sets - an array of set variables representing possible values for set
        set - a set variable equal to sets[index]
        Returns:
        a constraint ensuring that sets[index] = set
      • element

        default Constraint element​(IntVar index,
                                   SetVar[] sets,
                                   int offset,
                                   SetVar set)
        Creates a constraint enabling to retrieve an element set in sets: sets[index-offset] = set
        Parameters:
        index - an integer variable pointing to set's index into array sets
        sets - an array of set variables representing possible values for set
        offset - offset index : should be 0 by default but generally 1 with MiniZinc API which counts from 1 to n instead of counting from 0 to n-1 (Java standard)
        set - a set variable equal to sets[index-offset]
        Returns:
        a constraint ensuring that sets[index-offset] = set
      • member

        default Constraint member​(SetVar[] sets,
                                  SetVar set)
        Creates a member constraint stating that set belongs to sets
        Parameters:
        sets - set variables representing possible values for set
        set - a set variable which takes its value in sets
        Returns:
        a constraint ensuring that set belongs to sets
      • member

        default Constraint member​(IntVar intVar,
                                  SetVar set)
        Creates a member constraint stating that the value of intVar is in set
        Parameters:
        intVar - an integer variables which takes its value in set
        set - a set variables containing possible values for intVar
        Returns:
        a constraint ensuring that the value of intVar is in set
      • member

        default Constraint member​(int cst,
                                  SetVar set)
        Creates a member constraint stating that the constant cst is in set
        Parameters:
        cst - an integer
        set - a set variable
        Returns:
        a constraint ensuring that cst is in set
      • notMember

        default Constraint notMember​(IntVar intVar,
                                     SetVar set)
        Creates a member constraint stating that the value of intVar is not in set
        Parameters:
        intVar - an integer variables which does not take its values in set
        set - a set variables representing impossible values for intVar
        Returns:
        a constraint ensuring that the value of intVar is not in set
      • notMember

        default Constraint notMember​(int cst,
                                     SetVar set)
        Creates a member constraint stating that the constant cst is not in set
        Parameters:
        cst - an integer
        set - a set variable
        Returns:
        a constraint ensuring that cst is not in set