Module org.chocosolver.solver
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 setdefault Constraint
allDisjoint(SetVar... sets)
Creates a constraint stating that the intersection of sets should be empty Note that there can be multiple empty setsdefault Constraint
allEqual(SetVar... sets)
Creates a constraint stating that sets should be all equaldefault 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 emptydefault Constraint
element(IntVar index, SetVar[] sets, int offset, SetVar set)
Creates a constraint enabling to retrieve an element set in sets: sets[index-offset] = setdefault Constraint
element(IntVar index, SetVar[] sets, SetVar set)
Creates a constraint enabling to retrieve an element set in sets: sets[index] = setdefault Constraint
intersection(SetVar[] sets, SetVar intersectionSet)
Creates a constraint which ensures that the intersection of sets is equal to intersectionSetdefault Constraint
intersection(SetVar[] sets, SetVar intersectionSet, boolean boundConsistent)
Creates a constraint which ensures that the intersection of sets is equal to intersectionSetdefault 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} = maxElementValuedefault Constraint
max(SetVar set, IntVar maxElementValue, boolean notEmpty)
Creates a constraint over the maximum element in a set: max{i | i in set} = maxElementValuedefault Constraint
member(int cst, SetVar set)
Creates a member constraint stating that the constant cst is in setdefault Constraint
member(IntVar intVar, SetVar set)
Creates a member constraint stating that the value of intVar is in setdefault Constraint
member(SetVar[] sets, SetVar set)
Creates a member constraint stating that set belongs to setsdefault 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} = minElementValuedefault Constraint
min(SetVar set, IntVar minElementValue, boolean notEmpty)
Creates a constraint over the minimum element in a set: min{i | i in set} = minElementValuedefault Constraint
nbEmpty(SetVar[] sets, int nbEmpty)
Creates a constraint counting the number of empty sets sets |{s in sets where |s|=0}| = nbEmptydefault Constraint
nbEmpty(SetVar[] sets, IntVar nbEmpty)
Creates a constraint counting the number of empty sets sets |{s in sets where |s|=0}| = nbEmptydefault Constraint
notEmpty(SetVar set)
Creates a constraint preventing set to be emptydefault Constraint
notMember(int cst, SetVar set)
Creates a member constraint stating that the constant cst is not in setdefault Constraint
notMember(IntVar intVar, SetVar set)
Creates a member constraint stating that the value of intVar is not in setdefault 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 set2default 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] = TRUEdefault Constraint
setBoolsChanneling(BoolVar[] bools, SetVar set, int offset)
Creates a constraint channeling a set variable with boolean variables : i in set <=> bools[i-offset] = TRUEdefault Constraint
setsIntsChanneling(SetVar[] sets, IntVar[] ints)
Creates a constraint channeling set variables and integer variables : x in sets[y] <=> ints[x] = ydefault 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] = ydefault Constraint
subsetEq(SetVar... sets)
Creates a constraint establishing that sets[i] is a subset of sets[j] if idefault Constraint
sum(SetVar set, IntVar sum)
Creates a constraint summing elements of set sum{i | i in set} = sumdefault 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 variablesunion
- 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 variablesunionSet
- 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 variablesintersectionSet
- 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 variablesintersectionSet
- a set variable representing the intersection of setsboundConsistent
- 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 variablesnbEmpty
- 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 variablesnbEmpty
- 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 variableset2
- a set variableoffset
- 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 variablesum
- 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 variableweights
- integers representing the weight of each element in indicessum
- 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 variableweights
- integers representing the weight of each element in indicesoffset
- 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 variablemaxElementValue
- an integer variable representing the maximum element in setnotEmpty
- 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 indicesoffset
- 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 indicesnotEmpty
- 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 variableminElementValue
- an integer variable representing the minimum element in setnotEmpty
- 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 indicesoffset
- 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 indicesnotEmpty
- 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 variablesset
- 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 variablesset
- a set variableoffset
- 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 variablesints
- 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 variablesints
- an array of integer variablesoffset1
- 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 variableset2
- 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 universeuniverse
- 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 variablesinvSets
- an array of set variablesoffset1
- 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 variablesoffset
- 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 setssets
- an array of set variables representing possible values for setset
- 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 setssets
- an array of set variables representing possible values for setoffset
- 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 setset
- 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 setset
- 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 integerset
- 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 setset
- 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 integerset
- a set variable- Returns:
- a constraint ensuring that cst is not in set
-
-