Class Tuples
- java.lang.Object
-
- org.chocosolver.solver.constraints.extension.Tuples
-
public class Tuples extends Object
A unique interface to declare tuples for table constraints. Handles both feasible tuples and forbidden tuples.- Since:
- 22/04/2014
- Author:
- Charles Prud'homme
-
-
Constructor Summary
Constructors Constructor Description Tuples()
Create a list of tuples which represents all allowed tuples, i.e. other tuples are forbiddenTuples(boolean feasible)
Create a list of tuples which represents all allowed tuples if feasible=true or a set of forbidden tuples if feasible=falseTuples(int[][] values, boolean feasible)
Create a list of tuples which represents all allowed tuples if feasible=true or a set of forbidden tuples if feasible=false.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int... tuple)
Add a new tuple to the set of tuplesvoid
add(int[]... tuples)
Add a tuple setboolean
allowUniversalValue()
ESat
check(IntVar... vars)
Checks entailment of a table constraint over vars with this Tuples objectint[]
get(int idx)
Return the idx^th tupleint
getStarValue()
boolean
isFeasible()
Return true if these are allowed tuples, false otherwiseint
max(int idx)
Return the maximum value for the idx^th column among all tuplesint
min(int idx)
Return the minimum value for the idx^th column among all tuplesint
nbTuples()
Return the number of tuples storedvoid
setUniversalValue(int star)
One can allow the presence of universal values, meaning that some variables can take any values from their domain.void
sort()
int[][]
toMatrix()
String
toString()
-
-
-
Field Detail
-
tuples
protected final List<int[]> tuples
-
-
Constructor Detail
-
Tuples
public Tuples(int[][] values, boolean feasible)
Create a list of tuples which represents all allowed tuples if feasible=true or a set of forbidden tuples if feasible=false. Lately, one can allow the presence of universal values, callingsetUniversalValue(int)
, meaning that some variables can take any values from their domain.- Parameters:
values
- list of tuplesfeasible
- indicates whether the tuples are allowed or forbidden
-
Tuples
public Tuples(boolean feasible)
Create a list of tuples which represents all allowed tuples if feasible=true or a set of forbidden tuples if feasible=false- Parameters:
feasible
- indicates whether the tuples are allowed or forbidden
-
Tuples
public Tuples()
Create a list of tuples which represents all allowed tuples, i.e. other tuples are forbidden
-
-
Method Detail
-
setUniversalValue
public void setUniversalValue(int star)
One can allow the presence of universal values, meaning that some variables can take any values from their domain.- Parameters:
star
- the universal value that can appear in any tuple.
-
allowUniversalValue
public boolean allowUniversalValue()
- Returns:
- true if the presence of universal values is allowed.
-
getStarValue
public int getStarValue()
- Returns:
- the value of the symbol which denotes that some variables can take any values from their domain.
-
check
public ESat check(IntVar... vars)
Checks entailment of a table constraint over vars with this Tuples object- Parameters:
vars
- set of integer variables to test- Returns:
- an ESat object indicating the entailement of the table over vars and this
-
add
public void add(int... tuple)
Add a new tuple to the set of tuples- Parameters:
tuple
- a tuple.- Throws:
SolverException
- if the size of the tuple added does not correspond to a the previous ones (if any).
-
add
public void add(int[]... tuples)
Add a tuple set- Parameters:
tuples
- tuple set
-
isFeasible
public boolean isFeasible()
Return true if these are allowed tuples, false otherwise- Returns:
- a boolean
-
min
public int min(int idx)
Return the minimum value for the idx^th column among all tuples- Parameters:
idx
- idx of the column- Returns:
- the minimum value
-
max
public int max(int idx)
Return the maximum value for the idx^th column among all tuples- Parameters:
idx
- index of the column- Returns:
- the maximum value
-
nbTuples
public int nbTuples()
Return the number of tuples stored- Returns:
- number of tuples stored
-
get
public int[] get(int idx)
Return the idx^th tuple
-
toMatrix
public int[][] toMatrix()
- Returns:
- an array of tuples, each tuple is an int array
-
sort
public void sort()
-
-