int n = 13;
IntVar[] vars = new IntVar[n];
for (int i = 0; i < n; i++) {
vars[i] = VariableFactory.enumerated("x_" + i, 0, 2, solver);
}
FiniteAutomaton auto = new FiniteAutomaton();
int start = auto.addState();
int end = auto.addState();
auto.setInitialState(start);
auto.setFinal(start);
auto.setFinal(end);
auto.addTransition(start, start, 0, 1);
auto.addTransition(start, end, 2);
auto.addTransition(end, start, 2);
auto.addTransition(end, start, 0, 1);
solver.post(IntConstraintFactory.regular(vars, auto));
solver.set(IntStrategyFactory.lexico_LB(vars));
solver.findAllSolutions();