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