[CP-SAT] Add AtMostOne/AtLeastOne/ExactlyOne constraint in all languages; rewrite linear expressions in java

This commit is contained in:
Laurent Perron
2022-01-03 09:43:59 +01:00
parent ce02461741
commit 62d506143b
34 changed files with 754 additions and 525 deletions

View File

@@ -31,8 +31,8 @@ public class OptionalIntervalSampleSat {
IntVar startVar = model.newIntVar(0, horizon, "start");
IntVar endVar = model.newIntVar(0, horizon, "end");
Literal presence = model.newBoolVar("presence");
IntervalVar intervalVar = model.newOptionalIntervalVar(
startVar, LinearExpr.constant(10), LinearExpr.affine(endVar, 1, 2), presence, "interval");
IntervalVar intervalVar = model.newOptionalIntervalVar(startVar, LinearExpr.constant(10),
LinearExpr.newBuilder().add(endVar).add(2).build(), presence, "interval");
System.out.println(intervalVar);
// If the size is fixed, a simpler version uses the start expression, the size and the literal.