this repo has no description
at develop 1.5 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 10% Asientos de los huéspedes. 11array[Guests] of var Seats: pos; 12 13% Asiento del huésped 1 que odia. 14array[Hatreds] of var Seats: p1; 15 16% Asiento del huésped 2 que odia. 17array[Hatreds] of var Seats: p2; 18 19% Asiento de odio en el mismo lado. 20array[Hatreds] of var 0..1: sameside; 21 22% Penalidad de odio. 23array[Hatreds] of var Seats: cost; 24 25include "alldifferent.mzn"; 26constraint alldifferent(pos); 27constraint forall(g in Males)( pos[g] mod 2 == 1 ); 28constraint forall(g in Females)( pos[g] mod 2 == 0 ); 29constraint not (pos[ed] in {1,6,7,12}); 30constraint abs(pos[bride] - pos[groom]) <= 1 /\ 31 (pos[bride] <= 6 <-> pos[groom] <= 6); 32constraint forall(h in Hatreds)( 33 p1[h] = pos[h1[h]] /\ 34 p2[h] = pos[h2[h]] /\ 35 sameside[h] = bool2int(p1[h] <= 6 <-> p2[h] <= 6) /\ 36 cost[h] = sameside[h] * abs(p1[h] - p2[h]) + 37 (1 - sameside[h]) * (abs(13 - p1[h] - p2[h]) + 1) ); 38 39solve maximize sum(h in Hatreds)(cost[h]); 40 41output [ show(g)++" " | s in Seats, g in Guests where fix(pos[g]) == s] 42 ++ ["\n"];