Package com.artelys.kalis
Class KACBinConstraint
- java.lang.Object
-
- com.artelys.kalis.KConstraint
-
- com.artelys.kalis.KACBinConstraint
-
public class KACBinConstraint 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 + C
class XEqualYC : public KACBinConstraint { int _C; public: XEqualYC(const char* name, KIntVar& v1, KIntVar& v2, int cst) : KACBinConstraint(v1, v2, KACBinConstraint::ALGORITHM_AC2001, "XEqualYC") { _C = cst; } virtual bool testIfSatisfied(int valX, int valY) { return (valX == valY + _C); // the constraint is true if only iff valX == valY + C } };
- Since:
- 2016.1
- See Also:
KConstraint
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
KACBinConstraint.acAlgorithms
Differents level of propagation for the constraints
-
Field Summary
-
Fields inherited from class com.artelys.kalis.KConstraint
swigCMemOwn
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
KACBinConstraint(long cPtr, boolean cMemoryOwn)
KACBinConstraint(KACBinConstraint toCopy)
KACBinConstraint(KIntVar v1, KIntVar v2)
Constructor.
This constructor takes threee arguments
KACBinConstraint(KIntVar v1, KIntVar v2, int acAlgorithm)
Constructor.
This constructor takes threee arguments
KACBinConstraint(KIntVar v1, KIntVar v2, int acAlgorithm, java.lang.String name)
Constructor.
This constructor takes threee arguments
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
delete()
protected void
finalize()
protected static long
getCPtr(KACBinConstraint obj)
KConstraint
getInstance(long pb)
KConstraint
getInstanceCopyPtr(KProblem problem)
Virtual copy method.
Each modeling elements stored (and used) in the binary constraint must be copied using the KProblem::getCopyPtr() method.void
print()
void
print(com.artelys.kalis.SWIGTYPE_p_void ctx, com.artelys.kalis.SWIGTYPE_p_f_p_void_p_q_const__char__int pfp)
protected void
swigDirectorDisconnect()
void
swigReleaseOwnership()
void
swigTakeOwnership()
boolean
testIfSatisfied(int val1, int val2)
Abstract interface for generic propagation of any binary constraint
-
Methods inherited from class com.artelys.kalis.KConstraint
askIfEntailed, getArity, getCopyPtr, getCPtr, getLinearRelaxation, getLinearRelaxation, getName, getPriority, getProblem, getTag, getTypeInfo, isGetLinearRelaxationImplemented, setName, setPriority, setTag
-
-
-
-
Constructor Detail
-
KACBinConstraint
protected KACBinConstraint(long cPtr, boolean cMemoryOwn)
-
KACBinConstraint
public KACBinConstraint(KIntVar v1, KIntVar v2, int acAlgorithm, java.lang.String name)
Constructor.
This constructor takes threee arguments
- Parameters:
v1
- the first variable of the constraintv2
- the second variable of the constraintacAlgorithm
- ALGORITHM_AC2001 (default value) for propagation by the AC2001 algorithm , ALGORITHM_AC3 for propagation by the AC3 algorithmname
- label for pretty printing of the constraint
-
KACBinConstraint
public KACBinConstraint(KIntVar v1, KIntVar v2, int acAlgorithm)
Constructor.
This constructor takes threee arguments
- Parameters:
v1
- the first variable of the constraintv2
- the second variable of the constraintacAlgorithm
- ALGORITHM_AC2001 (default value) for propagation by the AC2001 algorithm , ALGORITHM_AC3 for propagation by the AC3 algorithm
-
KACBinConstraint
public KACBinConstraint(KIntVar v1, KIntVar v2)
Constructor.
This constructor takes threee arguments
- Parameters:
v1
- the first variable of the constraintv2
- the second variable of the constraint
-
KACBinConstraint
public KACBinConstraint(KACBinConstraint toCopy)
-
-
Method Detail
-
getCPtr
protected static long getCPtr(KACBinConstraint obj)
-
finalize
protected void finalize()
- Overrides:
finalize
in classKConstraint
-
delete
public void delete()
- Overrides:
delete
in classKConstraint
-
swigDirectorDisconnect
protected void swigDirectorDisconnect()
-
swigReleaseOwnership
public void swigReleaseOwnership()
-
swigTakeOwnership
public void swigTakeOwnership()
-
getInstance
public KConstraint getInstance(long pb)
- Overrides:
getInstance
in classKConstraint
-
testIfSatisfied
public boolean testIfSatisfied(int val1, int val2)
Abstract interface for generic propagation of any binary constraint
- Returns:
- true if and only if the constraint is satisfied when v1 == val1 & v2 == val2
-
getInstanceCopyPtr
public KConstraint getInstanceCopyPtr(KProblem problem)
Virtual copy method.
Each modeling elements stored (and used) in the binary constraint must be copied using the KProblem::getCopyPtr() method.- Overrides:
getInstanceCopyPtr
in classKConstraint
-
print
public void print()
- Overrides:
print
in classKConstraint
-
print
public void print(com.artelys.kalis.SWIGTYPE_p_void ctx, com.artelys.kalis.SWIGTYPE_p_f_p_void_p_q_const__char__int pfp)
- Overrides:
print
in classKConstraint
-
-