this repo has no description
at develop 1.1 kB view raw
1enum Guests = { bride, groom, bestman, bridesmaid, bob, carol, 2 ted, alice, ron, rona, ed, clara}; 3set of int: Seats = 1..12; 4set of int: Hatreds = 1..5; 5array[Hatreds] of Guests: h1 = [groom, carol, ed, bride, ted]; 6array[Hatreds] of Guests: h2 = [clara, bestman, ted, alice, ron]; 7set of Guests: Males = {groom, bestman, bob, ted, ron,ed}; 8set of Guests: Females = {bride,bridesmaid,carol,alice,rona,clara}; 9 10array[Guests] of var Seats: pos; % seat of guest 11 12include "alldifferent.mzn"; 13constraint alldifferent(pos); 14 15constraint forall(g in Males)( pos[g] mod 2 == 1 ); 16constraint forall(g in Females)( pos[g] mod 2 == 0 ); 17 18constraint not (pos[ed] in {1,6,7,12}); 19constraint abs(pos[bride] - pos[groom]) <= 1 /\ 20 (pos[bride] <= 6 <-> pos[groom] <= 6); 21 22solve maximize sum(h in Hatreds)( 23 let { var Seats: p1 = pos[h1[h]]; 24 var Seats: p2 = pos[h2[h]]; 25 var 0..1: same = bool2int(p1 <= 6 <-> p2 <= 6); } in 26 same * abs(p1 - p2) + (1-same) * (abs(13 - p1 - p2) + 1)); 27 28output [ show(g)++" " | s in Seats,g in Guests where fix(pos[g]) == s] 29 ++ ["\n"];