class KACBinConstraint : public 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;
   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


KACBinTableConstraint KConstraint



Public Types

enum acAlgorithms

Differents level of propagation for the constraints.


enumerator ALGORITHM_AC3
enumerator ALGORITHM_AC2001

Public Functions

KACBinConstraint(KIntVar &v1, KIntVar &v2, int acAlgorithm = ALGORITHM_AC2001, const char *name = 0)

Constructor. This constructor takes threee arguments

  • v1 – the first variable of the constraint

  • v2 – the second variable of the constraint

  • acAlgorithm – ALGORITHM_AC2001 (default value) for propagation by the AC2001 algorithm , ALGORITHM_AC3 for propagation by the AC3 algorithm

  • name – label for pretty printing of the constraint

virtual bool testIfSatisfied(int val1, int val2)

Abstract interface for generic propagation of any binary constraint


true if and only if the constraint is satisfied when v1 == val1 & v2 == val2

virtual KACBinConstraint *getInstanceCopyPtr(const KProblem &problem) const

Virtual copy method. Each modeling elements stored (and used) in the binary constraint must be copied using the KProblem::getCopyPtr() method.