this repo has no description
at develop 2.0 kB view raw
1% RUNS ON mzn20_fd 2% RUNS ON mzn-fzn_fd 3% RUNS ON mzn20_fd_linear 4% RUNS ON mzn20_mip 5% RUNS OM minizinc_cpx 6 7%% Product example from the OPL book! 8%% product_int.mzn 9%% Ralph Becket June 26 2007 10%% 11%% This is a version of product.mzn changed to use FD integers rather than 12%% LP floats (everything has been scaled up by 10). 13 14%enum Products = {kluski, capellini, fettucine}; 15int: NumProducts = 3; 16set of int: Products = 1..NumProducts; 17int: kluski = 0; 18int: capellini = 1; 19int: fettucine = 2; 20 21%enum Resources = {flour, eggs}; 22int: NumResources = 2; 23set of int: Resources = 1..NumResources; 24int: flour = 0; 25int: eggs = 1; 26 27array[Products] of int: demand = [100, 200, 300]; 28array[Products] of int: insideCost = [60, 80, 30]; 29array[Products] of int: outsideCost = [80, 90, 40]; 30array[Products, Resources] of int: consumption = 31 [|5, 2 32 |4, 4 33 |3, 6 34 |]; 35 36array[Resources] of int: capacity = [200, 400]; 37 38% Original specification: 39% 40% array[Products] of var int: inside; 41% array[Products] of var int: outside; 42% 43% Preprocessed one restricting the domains to relevant finite ranges: 44 45array[Products] of var 0..max(capacity): inside; % from constraints 1 and 2 46array[Products] of var 0..max(demand): outside; % from constraints 1 and 3 47 48constraint 49 forall (p in Products) ( 50 inside[p] >= 0 51 /\ outside[p] >= 0 52 ); 53 54constraint 55 forall(r in Resources) ( 56 sum (p in Products) ( 57 consumption[p, r] * inside[p] 58 ) 59 <= 60 capacity[r] 61 ); 62 63constraint 64 forall(p in Products) ( 65 inside[p] + outside[p] >= demand[p] 66 ); 67 68solve minimize 69 sum (p in Products) ( 70 insideCost[p]*inside[p] + outsideCost[p]*outside[p] 71 ); 72 73output [ 74 "production planning (FD version)\n", 75 " \tkluski\t\tfettucine\tcapellini\n", 76 "make inside: \t", 77 show(inside[1]), "\t\t", 78 show(inside[2]), "\t\t", 79 show(inside[3]), "\n", 80 "make outside: \t", 81 show(outside[1]), "\t\t", 82 show(outside[2]), "\t\t", 83 show(outside[3]), "\n" 84];