-
Notifications
You must be signed in to change notification settings - Fork 0
/
ateams.mzn
49 lines (36 loc) · 2.03 KB
/
ateams.mzn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
enum DEVS;
enum TEAMS;
% is the dev a software architect?
array[DEVS] of bool: isSA;
array[DEVS] of bool: isFrontendDev;
array[TEAMS] of int: minSize;
array[TEAMS] of int: minFrontendDevs;
array[TEAMS] of var set of DEVS: teams;
array[DEVS,TEAMS] of int: enjoy;
array[DEVS,DEVS] of int: sympathy;
% assert input data
% each dev can only assign <totalPoints> to claim enjoyment for a team or sympathy for a colleague. No negative points allowed.
int: totalPoints = 10;
constraint forall(dev in DEVS)(assert(sum(team in TEAMS)(enjoy[dev,team]) + sum(otherDev in DEVS where otherDev != dev)(sympathy[dev,otherDev])<= totalPoints, "Points for sympathy and enjoyment are restricted to \(totalPoints) in total."));
constraint forall(dev in DEVS,otherDev in DEVS where otherDev != dev)(assert(sympathy[dev,otherDev] >= 0, "Negative sympathy not allowed."));
constraint forall(dev in DEVS,team in TEAMS)(assert(enjoy[dev,team] >= 0, "Negative enjoyment not allowed."));
% Everyone must be part of a team
constraint array_union(teams) = DEVS;
% A dev can only be part of one team
include "all_disjoint.mzn";
constraint all_disjoint(teams);
% Minimum size of team
constraint forall(team in TEAMS)(card(teams[team]) >= minSize[team]);
% At least one SA per team
constraint forall(team in TEAMS)(sum(dev in teams[team])(isSA[dev]) >= 1);
% At least minimum number of frontend devs per team
constraint forall(team in TEAMS)(sum(dev in teams[team])(isFrontendDev[dev]) >= minFrontendDevs[team]);
% Total enjoyment = sum of enjoyments for realized team position of each dev
constraint totalEnjoyment = sum(dev in DEVS, team in TEAMS where dev in teams[team])(enjoy[dev,team]);
var int: totalEnjoyment;
% Total sympathy = sum of sympathies for devs being in one team
var int: totalSympathy;
constraint totalSympathy = sum(devOne in DEVS, devTwo in DEVS, team in TEAMS where devOne < devTwo /\ devOne in teams[team] /\ devTwo in teams[team])(sympathy[devOne,devTwo] + sympathy[devTwo,devOne]);
var int: rating;
constraint rating = totalSympathy + totalEnjoyment;
solve maximize rating;