int r = data.getValue("REST");
for (IntVar[] s : this.shifts) {
for (int t = 0; t + 2 < data.nbDays(); t++) {
//solver.post(Options.E_DECOMP, ConstraintFactory.ifThenElse(ConstraintFactory.eq(s[t], n), ConstraintFactory.or(ConstraintFactory.eq(s[t+1], n), ConstraintFactory.and(ConstraintFactory.eq(s[t+1], r), ConstraintFactory.eq(s[t+2], r)))));
BoolVar[] bvars = VariableFactory.boolArray("b", 4, solver);
LogOp tree = LogOp.implies(
bvars[0],
LogOp.or(bvars[1], bvars[2], bvars[3])
);
SatFactory.addClauses(tree, solver);
solver.post(LogicalConstraintFactory.ifThenElse(bvars[0],
IntConstraintFactory.arithm(s[t], "=", n), IntConstraintFactory.arithm(s[t], "!=", n)));
solver.post(LogicalConstraintFactory.ifThenElse(bvars[1],
IntConstraintFactory.arithm(s[t + 1], "=", n), IntConstraintFactory.arithm(s[t + 1], "!=", n)));
solver.post(LogicalConstraintFactory.ifThenElse(bvars[2],
IntConstraintFactory.arithm(s[t + 1], "=", r), IntConstraintFactory.arithm(s[t + 1], "!=", r)));
solver.post(LogicalConstraintFactory.ifThenElse(bvars[3],
IntConstraintFactory.arithm(s[t + 2], "=", r), IntConstraintFactory.arithm(s[t + 2], "!=", r)));
}
int t = data.nbDays() - 2;
BoolVar[] bvars = VariableFactory.boolArray("b", 2, solver);
// solver.post(ConstraintFactory.ifThenElse(ConstraintFactory.eq(s[t], n), ConstraintFactory.eq(s[t + 1], n)));
LogOp tree = LogOp.implies(bvars[0], bvars[1]);
SatFactory.addClauses(tree, solver);
solver.post(LogicalConstraintFactory.ifThenElse(bvars[0],
IntConstraintFactory.arithm(s[t], "=", n), IntConstraintFactory.arithm(s[t], "!=", n)));
solver.post(LogicalConstraintFactory.ifThenElse(bvars[1],
IntConstraintFactory.arithm(s[t + 1], "=", n), IntConstraintFactory.arithm(s[t + 1], "!=", n)));