/* Good Burger (PuzzlOR) in Picat. http://www.puzzlor.com/2014-08_GoodBurger.html """ Item Sodium(mg) Fat(g) Calories Item cost($) Beef Patty 50 17 220 $0.25 Bun 330 9 260 $0.15 Cheese 310 6 70 $0.10 Onions 1 2 10 $0.09 Pickles 260 0 5 $0.03 Lettuce 3 0 4 $0.04 Ketchup 160 0 20 $0.02 Tomato 3 0 9 $0.04 As the owner of a fast food restaurant with declining sales, your customers are looking for something new and exciting on the menu. Your market research indicates that they want a burger that is loaded with everything as long as it meets certain health requirements. Money is no object to them. The ingredient list in Table 1 shows what is available to include on the burger. You must include at least one of each item and no more than five of each item. You must use whole items (for example, no half servings of cheese). The final burger must contain less than 3,000 mg of sodium, less than 150 grams of fat and less than 3,000 calories. To maintain certain taste quality standards you’ll need to keep the servings of ketchup and lettuce the same. Also, you’ll need to keep the servings of pickles and tomatoes the same. Question: What is the most expensive burger you can make? Send your answer to puzzlor@gmail.com by Oct. 15 [2014]. The winner, chosen randomly from correct answers, will receive a $25 Amazon Gift Card. Past questions can be found at puzzlor.com. """ This Picat model was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import util. % import mip. % import sat. import cp. main => go. go => items(Items), N = Items.length, % Amount of each ingredient (min 1, max 5) X = new_list(N), X :: 1..5, % ingredients NameIx = 1, SodiumIx = 2, FatIx = 3, CaloriesIx = 4, CostIx = 5, % in cent % items (as index number in Items) _BeefPattyIx = 1, _BunIx = 2, _CheeseIx = 3, _OnionsIx = 4, PicklesIx = 5, LettuceIx = 6, KetchupIx = 7, TomatoIx = 8, Costs = [Items[I,CostIx] : I in 1..N], % % constraints % TotalCost #= sum([X[I]*Costs[I] : I in 1..N]), % in cent % % """ % You must use whole items (for example, no half servings of cheese). The final burger % must contain less than 3,000 mg of sodium, less than 150 grams of fat and less % than 3,000 calories. % """ sum([X[I]*Items[I,SodiumIx] : I in 1..N]) #< 3000, sum([X[I]*Items[I,FatIx] : I in 1..N]) #< 150, sum([X[I]*Items[I,CaloriesIx] : I in 1..N]) #< 3000, % % """ % To maintain certain taste quality standards you’ll need to keep the servings of % ketchup and lettuce the same. Also, you’ll need to keep the servings of pickles % and tomatoes the same. % """ X[KetchupIx] #= X[LettuceIx], X[PicklesIx] #= X[TomatoIx], solve($[max(TotalCost),ff],X), println(x=X), println(totalCostCent=TotalCost), println(totalCostDollars=TotalCost / 100), println("\nIngredients:"), println([ to_fstring("%-10w: %d", Items[I,NameIx],X[I]) : I in 1..N].join("\n")), nl. % costs in cent items(Items) => Items = [ % item sodium fat colories cost (cent) ["Beef Patty", 50, 17, 220, 25], ["Bun", 330, 9, 260, 15], ["Cheese", 310, 6, 70, 10], ["Onions", 1, 2, 10, 9], ["Pickles", 260, 0, 5, 3], ["Lettuce", 3, 0, 4, 4], ["Ketchup", 160, 0, 20, 2], ["Tomato", 3, 0, 9, 4] ].