1%% TooMany.mzn (too many solutions)
2int: n; % number of machines
3set of int: MACHINE = 1..n;
4int: k; % production per day
5int: red = 1; int: white = 2; int: black = 3; int: blue = 4;
6set of int: COLOR = 1..4;
7array[COLOR] of int: l; % lower bound on production
8array[COLOR] of int: u; % upper bound on production
9
10array[MACHINE,COLOR] of var 0..k div 2: produce;
11
12constraint forall(m in MACHINE)
13                 (sum(c in COLOR)(produce[m,c]) <= k);
14constraint forall(c in COLOR)
15                 (sum(m in MACHINE)(produce[m,c]) >= l[c]);
16constraint forall(c in COLOR)
17                 (sum(m in MACHINE)(produce[m,c]) <= u[c]);
18constraint forall(m in MACHINE)
19                 (produce[m,white] > 0 /\ produce[m,black] > 0 -> produce[m,blue] = 0);
20constraint forall(m in MACHINE)
21                 (produce[m,blue] <= produce[m,red]);
22constraint forall(m in MACHINE)
23                 (produce[m,red] mod 4 = 0);
24constraint forall(m in MACHINE)
25                 (produce[m,white] mod 3 = 0);
26
27
28solve maximize sum(m in MACHINE, c in COLOR)(produce[m,c]);
29
30output [ show_int(3,produce[m,c]) ++
31         if c = 4 then "\n" else " " endif
32       | m in MACHINE, c in COLOR ];
33
34n = 4;
35k = 11;
36l = [8,7,10,6];
37u = [14,16,12,20];
38
39