Package com.artelys.kalis
Class KACBinTableConstraint
- java.lang.Object
-
- com.artelys.kalis.KConstraint
-
- com.artelys.kalis.KACBinTableConstraint
-
public class KACBinTableConstraint extends KConstraint
This class implements a generic class for propagation of any binary constraint by local 2-consistency (arc consistency).
Two algorithms (AC3 and AC2001) are available for propagation of the constraint.
// Example : X == Y + 1 KProblem p(...); KIntVar X(p,"X",0,4); KIntVar Y(p,"Y",0,4); // truth table of constraint X == Y + 1 for X in [0..4] and Y in [0..4] // |0|1|2|3|4| // ------------- // 0 |0|1|0|0|0| // 1 |0|0|1|0|0| // 2 |0|0|0|1|0| // 3 |0|0|0|0|1| // 4 |0|0|0|0|0| // ------------- bool ** truthTable; truthTable = new bool*[X.getSup()]; for (int i=0; i < 5; ++i) { truthTable[i] = new bool[Y.getSup()]; std::memset(truthTable[i],false,Y.getSup() * sizeof(bool)); } truthTable[1][0] = true; // if X = 1 and Y = 0 then X == Y + 1 is satisfied truthTable[2][1] = true; // if X = 2 and Y = 1 then X == Y + 1 is satisfied truthTable[3][2] = true; // if X = 3 and Y = 2 then X == Y + 1 is satisfied truthTable[4][3] = true; // if X = 4 and Y = 3 then X == Y + 1 is satisfied p.post(KACBinTableConstraint(X,Y,truthTable,KACBinTableConstraint::ALGORITHM_AC2001,"X == Y + 1"))
- Since:
- 2016.1
- See Also:
KConstraint
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
KACBinTableConstraint.acAlgorithms
Arc-consistency algorithms for binary table constraint
-
Field Summary
-
Fields inherited from class com.artelys.kalis.KConstraint
swigCMemOwn
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
KACBinTableConstraint(long cPtr, boolean cMemoryOwn)
KACBinTableConstraint(KACBinTableConstraint toCopy)
Copy ConstructorKACBinTableConstraint(KIntVar v1, KIntVar v2, com.artelys.kalis.SWIGTYPE_p_p_bool truthTable)
Main constructor
KACBinTableConstraint(KIntVar v1, KIntVar v2, com.artelys.kalis.SWIGTYPE_p_p_bool truthTable, int acAlgorithm)
Main constructor
KACBinTableConstraint(KIntVar v1, KIntVar v2, com.artelys.kalis.SWIGTYPE_p_p_bool truthTable, int acAlgorithm, java.lang.String name)
Main constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
delete()
protected void
finalize()
protected static long
getCPtr(KACBinTableConstraint obj)
-
Methods inherited from class com.artelys.kalis.KConstraint
askIfEntailed, getArity, getCopyPtr, getCPtr, getInstance, getInstanceCopyPtr, getLinearRelaxation, getLinearRelaxation, getName, getPriority, getProblem, getTag, getTypeInfo, isGetLinearRelaxationImplemented, print, print, setName, setPriority, setTag
-
-
-
-
Constructor Detail
-
KACBinTableConstraint
protected KACBinTableConstraint(long cPtr, boolean cMemoryOwn)
-
KACBinTableConstraint
public KACBinTableConstraint(KIntVar v1, KIntVar v2, com.artelys.kalis.SWIGTYPE_p_p_bool truthTable, int acAlgorithm, java.lang.String name)
Main constructor
- Parameters:
v1
- the first variable of the constraintv2
- the second variable of the constrainttruthTable
- is the truth table of the constraintacAlgorithm
- ALGORITHM_AC2001 (default value) for propagation by the AC2001 algorithmacAlgorithm
- ALGORITHM_AC3 for propagation by the AC3 algorithmname
- label for pretty printing of the constraint
-
KACBinTableConstraint
public KACBinTableConstraint(KIntVar v1, KIntVar v2, com.artelys.kalis.SWIGTYPE_p_p_bool truthTable, int acAlgorithm)
Main constructor
- Parameters:
v1
- the first variable of the constraintv2
- the second variable of the constrainttruthTable
- is the truth table of the constraintacAlgorithm
- ALGORITHM_AC2001 (default value) for propagation by the AC2001 algorithmacAlgorithm
- ALGORITHM_AC3 for propagation by the AC3 algorithm
-
KACBinTableConstraint
public KACBinTableConstraint(KIntVar v1, KIntVar v2, com.artelys.kalis.SWIGTYPE_p_p_bool truthTable)
Main constructor
- Parameters:
v1
- the first variable of the constraintv2
- the second variable of the constrainttruthTable
- is the truth table of the constraint
-
KACBinTableConstraint
public KACBinTableConstraint(KACBinTableConstraint toCopy)
Copy Constructor
-
-
Method Detail
-
getCPtr
protected static long getCPtr(KACBinTableConstraint obj)
-
finalize
protected void finalize()
- Overrides:
finalize
in classKConstraint
-
delete
public void delete()
- Overrides:
delete
in classKConstraint
-
-