this repo has no description
at develop 1.5 kB view raw
1include "partition_set.mzn"; 2 3int: weeks; set of int: WEEK = 1..weeks; 4int: groups; set of int: GROUP = 1..groups; 5int: size; set of int: SIZE = 1..size; 6int: ngolfers = groups * size; 7set of int: GOLFER = 1..ngolfers; 8 9array[WEEK,GROUP] of var set of GOLFER: Sched; 10 11% Restricciones 12constraint 13 forall (i in 1..weeks-1) ( 14 Sched[i,1] < Sched[i+1,1] 15 ) /\ 16 forall (i in WEEK, j in GROUP) ( 17 card(Sched[i,j]) = size 18 /\ forall (k in j+1..groups) ( 19% Sched[i,j] < Sched[i,k] 20% /\ 21 Sched[i,j] intersect Sched[i,k] = {} 22 ) 23 ) /\ 24 forall (i in WEEK) ( 25 partition_set([Sched[i,j] | j in GROUP], GOLFER) 26% /\ forall (j in 1..groups-1) ( 27% Sched[i,j] < Sched[i,j+1] 28% ) 29 ) /\ 30 forall (i in 1..weeks-1, j in i+1..weeks) ( 31 forall (x,y in GROUP) ( 32 card(Sched[i,x] intersect Sched[j,y]) <= 1 33 ) 34 ); 35% Simetría 36 constraint 37 % Arreglar la primera semana. 38 forall (i in GROUP, j in SIZE) ( 39 ((i-1)*size + j) in Sched[1,i] 40 ) /\ 41 % Arreglar el primer grupo de la segunda semana. 42 forall (i in SIZE) ( 43 ((i-1)*size + 1) in Sched[2,1] 44 ) /\ 45 % Arreglar el tamaño de los jugadores. 46 forall (w in 2..weeks, p in SIZE) ( 47 p in Sched[w,p] 48 ); 49 50solve satisfy; 51 52output [ show(Sched[i,j]) ++ " " ++ 53 if j == groups then "\n" else "" endif | 54 i in WEEK, j in GROUP ];