KElement2D

class KElement2D : public KConstraint

This class creates a X == Tab[I + cste1][J + cste2] constraint

Example :

KIntArray Tab(...);
KIntVar X(...);
KIntVar I(...);
KIntVar J(...);
// ...
problem.post(KElement2D(Tab, I, J, X, 4, 8, "X == Tab[I + 4][J+8]"));

See

KConstraint

Since

2016.1

Public Functions

KElement2D(KIntMatrix &matrix, const KIntVar &I, const KIntVar &J, const KIntVar &X, const int offset1, const int offset2, char *name = 0)

Primary Constructor

Parameters
  • matrix – the values

  • I – the first index variable

  • J – the second index variable

  • X – the value variable

  • offset1 – constant offset of first index variable

  • offset2 – constant offset of second index variable

  • name – name of the constraint

KElement2D(const KEltTerm2D &eltTerm2D, const KIntVar &X, char *name = 0)

Constructor with KEltTerm2D

Parameters
  • eltTerm2D – the two dimensional element term

  • X – the value variable

  • name – name of the constraint

KElement2D(const KElement2D &toCopy)

Copy constructor

~KElement2D()

Destructor

int getValueForIndex(int index1, int index2)

Get the value for I = index1 and J = index2

void setUseValueFunction(bool useValueFunction)

Choose value method between Table and method ‘getValueForIndex’