Skip to content

v2.12.0

Choose a tag to compare

@rcrida rcrida released this 01 Jun 12:34
· 108 commits to main since this release

What's new

New constraints (MiniZinc compatibility)

  • CountConstraintcount(vars, value) <op> n: counts occurrences of a specific value across a set of variables and compares to a bound. Generalises AtLeastN/AtMostN to any domain type. Demo: AustraliaMapColouringTest finds colorings with exactly 3 RED territories.

  • NaryTuplesConstrainttable(vars, tuples): the combined assignment of variables must match one of a set of allowed Assignment tuples. Variable order is irrelevant; all tuples must share exactly the same variable set (validated at construction). Demo: MenuCombinationTest selects valid three-course menus from an explicit compatibility table.

  • BinaryElementConstraintresult = array[index]: 1-based array lookup with a variable index. Out-of-bounds indices violate the constraint. Equivalent to MiniZinc's element(i, array, result). Demo: TwoSumTest finds index pairs where array[i] + array[j] == 9.

New csp builder methods

csp.countConstraint(Set.of(v1, v2, v3), value, Operator.EQ, 2)
csp.tuplesConstraint(Set.of(Assignment.of(...), ...))
csp.elementConstraint(index, result, array)