this repo has no description
1include "alldifferent_except.mzn";
2
3enum Flatmates = { Anne, Bert, Ceci, Dave };
4enum Robots = { R2D2, C3PO, Marvin };
5
6% Higher number = higher preference
7array[Flatmates,Chores] of int: preference =
8 [| 1, 2, 3, 4, 5
9 | 2, 1, 3, 4, 5
10 | 3, 5, 4, 1, 2
11 | 1, 5, 4, 2, 3 |];
12
13array[Robots,Chores] of int: benefit =
14 [| 20, 100, 20, 100, 30
15 | 10, 120, 40, 40, 60
16 | 50, 500, 30, 10, 70 |];
17
18enum Chores = { Cooking, Vacuuming, Bathroom, Kitchen, Rubbish };
19
20enum Workers = F(Flatmates) ++ R(Robots);
21
22enum ChoreOrNothing = C(Chores) ++ { Nothing };
23
24% Create preference and benefit arrays with added values for Nothing
25
26array[Flatmates,ChoreOrNothing] of int: prefWithNothing =
27 array2d(Flatmates,ChoreOrNothing,
28 [ if c=Nothing then 0 else preference[f,C^-1(c)] endif
29 | f in Flatmates, c in ChoreOrNothing]);
30
31array[Robots,ChoreOrNothing] of int: benefitWithNothing =
32 array2d(Robots,ChoreOrNothing,
33 [ if c=Nothing then 0 else benefit[r,C^-1(c)] endif
34 | r in Robots, c in ChoreOrNothing]);
35
36array[Workers] of var ChoreOrNothing: assignment;
37
38constraint alldifferent_except(assignment, {Nothing});
39
40var int: overall_preferences =
41 sum(f in Flatmates)(prefWithNothing[f, assignment[F(f)]]);
42
43var int: overall_benefit =
44 sum(r in Robots)(benefitWithNothing[r, assignment[R(r)]]);
45
46solve maximize overall_benefit + overall_preferences;
47
48output [ if w in F(Flatmates) then show(F^-1(w)) else show(R^-1(w)) endif++":\t"++
49 if fix(assignment[w])=Nothing then "Nothing\n"
50 else show(C^-1(assignment[w]))++"\n" endif
51 | w in Workers];