this repo has no description
at develop 1.9 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_lp.mzn 15%% Ralph Becket June 26 2007 16%% 17%% This is a version of product.mzn changed to use LP integers rather than 18%% LP floats (everything has been scaled up by 10). 19 20% This isn't needed, as "lp" is a built-in annotation in the G12 21% implementation (although it's not listed as such in the Zinc spec). 22%annotation lp; 23 24%enum Products = {kluski, capellini, fettucine}; 25int: NumProducts = 3; 26set of int: Products = 1..NumProducts; 27int: kluski = 0; 28int: capellini = 1; 29int: fettucine = 2; 30 31%enum Resources = {flour, eggs}; 32int: NumResources = 2; 33set of int: Resources = 1..NumResources; 34int: flour = 0; 35int: eggs = 1; 36 37array[Products] of int: demand = [100, 200, 300]; 38array[Products] of int: insideCost = [60, 80, 30]; 39array[Products] of int: outsideCost = [80, 90, 40]; 40array[Products, Resources] of int: consumption = 41 [| 5, 2 42 | 4, 4 43 | 3, 6 44 |]; 45 46array[Resources] of int: capacity = [200, 400]; 47 48array[Products] of var int: inside; 49array[Products] of var int: outside; 50 51constraint 52 forall (p in Products) ( 53 inside[p] >= 0 54 /\ outside[p] >= 0 55 ); 56 57constraint 58 forall(r in Resources) ( 59 sum (p in Products) ( 60 consumption[p, r] * inside[p] 61 ) 62 <= 63 capacity[r] 64 ); 65 66constraint 67 forall(p in Products) ( 68 inside[p] + outside[p] >= demand[p] 69 ); 70 71solve minimize 72 sum (p in Products) ( 73 insideCost[p]*inside[p] + outsideCost[p]*outside[p] 74 ); 75 76output [ 77 "production planning (LP version of integer model)\n", 78 " \tkluski\t\tfettucine\tcapellini\n", 79 "make inside: \t", 80 show(inside[1]), "\t\t", 81 show(inside[2]), "\t\t", 82 show(inside[3]), "\n", 83 "make outside: \t", 84 show(outside[1]), "\t\t", 85 show(outside[2]), "\t\t", 86 show(outside[3]), "\n" 87];