% % Post office problem in Minizinc % % From http://www-128.ibm.com/developerworks/linux/library/l-glpk2/ % % See post_office_problem.mzn. % % Compared with post_office_problem.mzn this is a more general model % which adds costs per day (more for working at holidays). % % Model created by Hakan Kjellerstrand, hakank@bonetmail.com % See also my MiniZinc page: http://www.hakank.org/minizinc % set of 0..6: DAYS = 0..6; % monday 0 array[1..7] of int: Need; array[1..7] of int: Cost; % decision variables. x[i]: No. of workers starting at day i array[DAYS] of var int: x; % objective function: total cost var int: z2 = sum(i in DAYS, j in DAYS where j != (i+5) mod 7 /\ j != (i+6) mod 7) (x[i] * Cost[j+1]); solve :: int_search(x, "first_fail", "indomain", "complete") minimize z2; % solve satisfy; constraint forall(i in DAYS) ( x[i] >= 0 % /\ x[i] <= 10 ) /\ forall(i in DAYS) ( sum(j in DAYS where j != (i+5) mod 7 /\ j != (i+6) mod 7) (x[j]) >= Need[i+1] ) ; % % data % Need = [17, 13, 15, 19, 14, 16, 11]; % Total cost for the 5 day schedule. % Base cost per day is 100. % Working saturday is 100 extra % Working sunday is 200 extra. Cost = [500, 600, 800, 800, 800, 800, 700];