In this answer we use two different clpfd "flavors": sicstus-prolog and gnu-prolog.
:- use_module(library(clpfd)).
limited_repetitions__SICStus(Zs) :-
length(Zs, 10),
domain(Zs, 1, 4),
domain([C1,C2,C3,C4], 0, 5),
global_cardinality(Zs, [1-C1,2-C2,3-C3,4-C4]),
labeling([], Zs).
limited_repetitions__gprolog(Zs) :-
length(Zs, 10),
fd_domain(Zs, 1, 4),
maplist(fd_atmost(5,Zs), [1,2,3,4]),
fd_labeling(Zs).
Simple sample query run with SICStus Prolog version 4.3.2 and GNU Prolog 1.4.4:
?- limited_repetitions__SICStus(Zs). % ?- limited_repetitions__gprolog(Zs).
Zs = [1,1,1,1,1,2,2,2,2,2] % Zs = [1,1,1,1,1,2,2,2,2,2]
; Zs = [1,1,1,1,1,2,2,2,2,3] % ; Zs = [1,1,1,1,1,2,2,2,2,3]
; Zs = [1,1,1,1,1,2,2,2,2,4] % ; Zs = [1,1,1,1,1,2,2,2,2,4]
; Zs = [1,1,1,1,1,2,2,2,3,2] % ; Zs = [1,1,1,1,1,2,2,2,3,2]
; Zs = [1,1,1,1,1,2,2,2,3,3] % ; Zs = [1,1,1,1,1,2,2,2,3,3]
; Zs = [1,1,1,1,1,2,2,2,3,4] % ; Zs = [1,1,1,1,1,2,2,2,3,4]
; Zs = [1,1,1,1,1,2,2,2,4,2] % ; Zs = [1,1,1,1,1,2,2,2,4,2]
... % ...
Let's measure the time required for counting the number of solutions!
call_succeeds_n_times(G_0, N) :-
findall(t, call(G_0), Ts),
length(Ts, N).
?- call_time(call_succeeds_n_times(limited_repetitions__SICStus(_), N), T_ms).
N = 965832, T_ms = 6550. % w/SICStus Prolog 4.3.2
?- call_time(call_succeeds_n_times(limited_repetitions__gprolog(_), N), T_ms).
N = 965832, T_ms = 276. % w/GNU Prolog 1.4.4