1. Engineering
  2. Computer Science
  3. question 2 this problem is a variation of the classic...

Question: question 2 this problem is a variation of the classic...

Question details

Question 2 This problem is a variation of the classic diet problem in linear programming. The diet problem was one of the first optimization problems studied in the 1940s and was motivated by the Armys desire to minimize the cost of feeding soldiers while providing a healthy diet. Suppose that exactly four foods are available to you: milk, chocolate chip cookies, chicken soup and Brussels sprouts. You have recently been informed that you must reduce your daily intake of fat. You wish to find a new diet that maximizes gastronomical enjoyment while also satisfying the following conditions 1. you must consume at least 600 units of vitamin X, 2. at least 300 units of vitamin Y 3. at least 550 units of vitamin Z each day, and 4. the daily fat intake must be below 12000 units. The relevant measurements for the four foods are shown, where the numerical entries denote units: Food X Y Z Fat Enjoyment 200 Cookies (dozen) 3 10 35 6000 6000 Soup (cup) 150 75 75 1000 3000 -200 Milk (quarts) 50 10 150 800 Brussel sprouts (pounds) 100 100 5 400 Let xi , X2 x3 and X4 denote the amounts of the four foods in the diet, l e , xị IS the number of quarts of milk, x2 is the number of dozens of cookies. *3 is the number of cups of soup, and x4 is the number of pounds of Brussel sprouts. We formulate the linear program whose solution will tell you the best new diet as maximize cTx xER subject to Ax 2 b where A, b, and c are defined in the following code cell# Run this cell to load the variables! using LinearAlgebra c [200; 6000; 3000; -200] A-[50 3 150 100; 10 10 75 100; 150 35 75 5; 800-6000-1000 -400 1 00 0 0 01 0 b [600; 300; 550; -12000; 0; 0; 0; 0] # Define a function r(x) to compute the residual given A and b above. # You can use r(x) below in your solutions r(x) Ax-b Q2.1 For this problem, we will Julias ability to extract rows (or columns) of a matrix given a subset. For example, if I want to extract the 5th and 3rd rows of A in that order: AI[5:31.] # Some other examples myset [3; 1]: display(A(,mysel) # columns 3 and 1 of A display(A[8].:) #row 8 ofA display(A[[5; 6; 7; 8],]) # rows 5-8 ofA display(blmyset) # elements 3 and 1 from b In class, we define a corner point as a feasible point that lies at the intersection of at least n hyperplanes.Lets find a point that lies on constraints (1,2,3,4) of this problem s1-[1: 2:3:4] # Print out the residual at this point display(r(x)) Computer arithmetic makes small rounding errors at each step of the calculation of the corner point, so any small negative values would be zero in exact arithmetic. (This is something you learn about in Math 170A) Because the residual of xi is nonnegative, this is a feasible point and in fact, a corner point. There are two more corner points for this problem and a maximum of 70 corner points for this problem! Luckily, we dont have to go through all 70 possibilities. Youre given the hint that two of the following subsets of constraints define corner points: 15,6,7,8), (2,3,4,8), (3,4,6,7), (1,3,4,7). Determine which of these subsets defines the remaining two corner points for this problem. Define your answers as *2 and S2 (for the second corner point and the corresponding set of constraints) and x3 and s3 (for the third corner point and the corresponding set of constraints). X2 53 # YOUR CODE HERE error(Solution not implemented) println(The other two corner points are $x2 defined by constraints $s2 and $xa defined by constraints $sa.) # Did you get the right corner points? @assert abs(norm(x2) 5.563270075266202)1.0e-4 ll abs(norm(x3) 5.563270075266202)1.0e-4 @assert abs4.132079348625395) 1.0e-4 ll abs(norm() 4.132079348625395) 1.0e-4

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution