Skip to content

v2.4.0

Choose a tag to compare

@rcrida rcrida released this 14 May 16:12
· 160 commits to main since this release

What's new

Typed generics throughout the constraint hierarchy

`Variable<T>` is now a phantom type carrying the value type at compile time. This propagates through the entire API so the compiler enforces consistency between variables, domains, and constraints.

CSP builder methods are now type-safe:

Variable<Integer> x = Variable.Factory.INSTANCE.create("x");
csp.variableDomain(x, IntRangeDomain.of(0, 9))   // Domain<Integer> required
   .equalsConstraint(x, "wrong")                  // compile error — String ≠ Integer
   .notEqualsConstraint(x, 0)                     // ok
   .atMostOneConstraint(Set.of(boolVar))           // Set<Variable<Boolean>> required

Assignment.getValue returns typed Optional:

Optional<Integer> v = assignment.getValue(intVar);   // no cast needed

getDomain / findDomain return typed Domain:

Domain<Integer> d = csp.getDomain(intVar);           // no cast needed

Other changes since v2.3.0

  • `UnaryConstraint<T>` and `BinaryConstraint<L,R>` — `isSatisfiedBy` no longer requires unchecked casts
  • `Domain<T>` propagated throughout domains and consistency algorithms
  • `UniformNaryConstraint<T>` for same-type n-ary constraints (`AllDiffConstraint<T>`, `AtMostOneConstraint`)
  • Timetabling test improvements: room specialisation, teacher unavailability, session frequency