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
  • Constructor Details

    • KACBinConstraint

      protected KACBinConstraint(long cPtr, boolean cMemoryOwn)
    • KACBinConstraint

      public KACBinConstraint(KIntVar v1, KIntVar v2, int acAlgorithm, String name)
      Constructor.
      This constructor takes threee arguments

      Parameters:
      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
    • KACBinConstraint

      public KACBinConstraint(KIntVar v1, KIntVar v2, int acAlgorithm)
      Constructor.
      This constructor takes threee arguments

      Parameters:
      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
    • KACBinConstraint

      public KACBinConstraint(KIntVar v1, KIntVar v2)
      Constructor.
      This constructor takes threee arguments

      Parameters:
      v1 - the first variable of the constraint
      v2 - the second variable of the constraint

    • KACBinConstraint

      public KACBinConstraint(KACBinConstraint toCopy)
  • Method Details

    • getCPtr

      protected static long getCPtr(KACBinConstraint obj)
    • finalize

      protected void finalize()
      Overrides:
      finalize in class KConstraint
    • delete

      public void delete()
      Overrides:
      delete in class KConstraint
    • swigDirectorDisconnect

      protected void swigDirectorDisconnect()
    • swigReleaseOwnership

      public void swigReleaseOwnership()
    • swigTakeOwnership

      public void swigTakeOwnership()
    • getInstance

      public KConstraint getInstance(long pb)
      Overrides:
      getInstance in class KConstraint
    • 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 class KConstraint
    • print

      public void print()
      Overrides:
      print in class KConstraint
    • 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 class KConstraint