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