this repo has no description
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; % 客人的座位 11array[Hatreds] of var Seats: p1; % 互相憎恶的客人1的座位 12array[Hatreds] of var Seats: p2; % 互相憎恶的客人2的座位 13array[Hatreds] of var 0..1: sameside; % 互相憎恶的客人是否坐在同一边 14array[Hatreds] of var Seats: cost; % 互相憎恶的客人的距离 15 16include "alldifferent.mzn"; 17constraint alldifferent(pos); 18constraint forall(g in Males)( pos[g] mod 2 == 1 ); 19constraint forall(g in Females)( pos[g] mod 2 == 0 ); 20constraint not (pos[ed] in {1,6,7,12}); 21constraint abs(pos[bride] - pos[groom]) <= 1 /\ 22 (pos[bride] <= 6 <-> pos[groom] <= 6); 23constraint forall(h in Hatreds)( 24 p1[h] = pos[h1[h]] /\ 25 p2[h] = pos[h2[h]] /\ 26 sameside[h] = bool2int(p1[h] <= 6 <-> p2[h] <= 6) /\ 27 cost[h] = sameside[h] * abs(p1[h] - p2[h]) + 28 (1 - sameside[h]) * (abs(13 - p1[h] - p2[h]) + 1) ); 29 30solve maximize sum(h in Hatreds)(cost[h]); 31 32output [ show(g)++" " | s in Seats,g in Guests where fix(pos[g]) == s] 33 ++ ["\n"];