Relation Constraints

The following functions set constraints between already existing CSint variables These functions may fail (i.e. return a FALSE value) when set.

IZBOOL cs_Le(CSint *vint1, CSint *vint2)

vint1 must be lower than or equal to vint2 (i.e. cs_getMin(vint1) <= cs_getMin(vint2) and cs_getMax(vint1) <= cs_getMax(vint2)).

IZBOOL cs_Ge(CSint *vint1, CSint *vint2)

vint1 must be greater than or equal to vint2.

IZBOOL cs_Lt(CSint *vint1, CSint *vint2)

vint1 must be strictly lower than vint2.

IZBOOL cs_Gt(CSint *vint1, CSint *vint2)

vint1 must be strictly greater than vint2.

IZBOOL cs_Eq(CSint *vint1, CSint *vint2)

vint1 and vint2 are constrained to be equal.

IZBOOL cs_Neq(CSint *vint1, CSint *vint2)

vint2 and vint2 are constrained not to be equal.

The following similar functions are useful when one of the two operands is a constant:

  • IZBOOL cs_LE(CSint *vint, int val)

  • IZBOOL cs_GE(CSint *vint, int val)

  • IZBOOL cs_LT(CSint *vint, int val)

  • IZBOOL cs_GT(CSint *vint, int val)

  • IZBOOL cs_EQ(CSint *vint, int val)

  • IZBOOL cs_NEQ(CSint *vint, int val)

For example, cs_LE() could be defined as:

IZBOOL cs_LE(CSint *vint, int val) {
  return(cs_Le(vint, CSINT(val));
}
IZBOOL cs_AllNeq(CSint **array, int size)

The CSint variables of array must have different values. It could be written like:

IZBOOL cs_AllNeq(CSint **array, int size) {
  int i, j;
  for (i = 0; i < size - 1; i++)
    for (j = i + 1; j < size; j++)
      cs_Neq(array[i], array[j]);
}

The following functions return CSint variable which indicates whether relation constraint is satisfied or not. (satisfied = 1, NOT satisfied = 0)

CSInt *cs_ReifLe(CSint *vint1, CSint *vint2)

Returns a CSint variable which idicates whether vint1 is lower than or equal to vint2 by value 1 and 0.

CSInt *cs_ReifGe(CSint *vint1, CSint *vint2)

Returns a CSint variable which idicates whether vint1 is greater than or equal to vint2 by value 1 and 0.

CSInt *cs_ReifLt(CSint *vint1, CSint *vint2)

Returns a CSint variable which idicates whether vint1 is lower than vint2 by value 1 and 0.

CSInt *cs_ReifGt(CSint *vint1, CSint *vint2)

Returns a CSint variable which idicates whether vint1 is greater than vint2 by value 1 and 0.

CSInt *cs_ReifEq(CSint *vint1, CSint *vint2)

Returns a CSint variable which idicates whether vint1 is equal to vint2 by value 1 and 0.

CSInt *cs_ReifNeq(CSint *vint1, CSint *vint2)

Returns a CSint variable which idicates whether vint1 is different from vint2 by value 1 and 0.

The following functions are useful when second CSint variable is a constant:

  • CSint* cs_ReifLE(CSint *vint, int val)

  • CSint* cs_ReifGE(CSint *vint, int val)

  • CSint* cs_ReifLT(CSint *vint, int val)

  • CSint* cs_ReifGT(CSint *vint, int val)

  • CSint* cs_ReifEQ(CSint *vint, int val)

  • CSint* cs_ReifNEQ(CSint *vint, int val)