The function f(x, y) = (x + y-11) + (x+y-7) is known as Himmelblau's function which...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
The function f(x, y) = (x + y-11) + (x+y-7) is known as Himmelblau's function which is a function designed for testing per- formance of optimization algorithms (you can see more examples here). Writeup Problem 1 is about visualizing this function, so if you are having trouble seeing what's happening you could work on visualizing it. Himmelblau's function has multiple local minima. In this problem we will find one of those local minima. (a) Create an anonymous function that computes f using only one input, an ar- ray with two elements: [y]. To make sure that your function is defined correctly, compute f(3, 4) (using the array [3, 4]) and save the answer to the variable A5. (b) Use scipy. optimize. fmin with an initial guess of [-3 -2] to find the argmin of f (the array that minimizes f) and save it to the variable A6. (c) Create an anonymous function (with only one input) that calculates the gra- dient Vf(x, y). The gradient is given by the following formula Vf(x, y) = Recall that the gradient of f should be zero at a local minimum. Calculate Vf(x, y) at the r and y values found in part (b) and save the result to the variable A7. Then save the 2-norm of A7 to the variable A8. In other words, if you found (x, y) = (1, 1) above, save ||Vf(x1, y)||2 (423-42x + 4xy + 2y2-14) 4y-26y + 4xy + 2x - 22) (2) to the variable A8. The 2-norm is calculated in python via np.linalg.norm. (d) Recall from class that we wrote the following code to perform one step of gradient descent (given on next page). p = np.array ( [6, 4]) # Choose an initial guess gradf (p) # Find which direction to go lambda t: p t grad # Define the path grad phi f_of_phi lambda t: f(phi(t)) # Create a function of # "heights along path" tmin=scipy. optimize. fminbound (f_of_phi,0,1) # Find time it takes # to reach min height. p phi (tmin); # Find the point on the path and update your guess Adapt the code so that it performs up to 2000 iterations of gradient descent and stops if the 2-norm of the vector grad is less than a tolerance of 10-7. (e) Now use your gradient descent code to find the argmin of the function f(x, y). Use an initial guess of (x, y) = (-3,-2). Save the final result to the variable A9 and the number of iterations to the variable A10. The initial guess does not count as an iteration. The function f(x, y) = (x + y-11) + (x+y-7) is known as Himmelblau's function which is a function designed for testing per- formance of optimization algorithms (you can see more examples here). Writeup Problem 1 is about visualizing this function, so if you are having trouble seeing what's happening you could work on visualizing it. Himmelblau's function has multiple local minima. In this problem we will find one of those local minima. (a) Create an anonymous function that computes f using only one input, an ar- ray with two elements: [y]. To make sure that your function is defined correctly, compute f(3, 4) (using the array [3, 4]) and save the answer to the variable A5. (b) Use scipy. optimize. fmin with an initial guess of [-3 -2] to find the argmin of f (the array that minimizes f) and save it to the variable A6. (c) Create an anonymous function (with only one input) that calculates the gra- dient Vf(x, y). The gradient is given by the following formula Vf(x, y) = Recall that the gradient of f should be zero at a local minimum. Calculate Vf(x, y) at the r and y values found in part (b) and save the result to the variable A7. Then save the 2-norm of A7 to the variable A8. In other words, if you found (x, y) = (1, 1) above, save ||Vf(x1, y)||2 (423-42x + 4xy + 2y2-14) 4y-26y + 4xy + 2x - 22) (2) to the variable A8. The 2-norm is calculated in python via np.linalg.norm. (d) Recall from class that we wrote the following code to perform one step of gradient descent (given on next page). p = np.array ( [6, 4]) # Choose an initial guess gradf (p) # Find which direction to go lambda t: p t grad # Define the path grad phi f_of_phi lambda t: f(phi(t)) # Create a function of # "heights along path" tmin=scipy. optimize. fminbound (f_of_phi,0,1) # Find time it takes # to reach min height. p phi (tmin); # Find the point on the path and update your guess Adapt the code so that it performs up to 2000 iterations of gradient descent and stops if the 2-norm of the vector grad is less than a tolerance of 10-7. (e) Now use your gradient descent code to find the argmin of the function f(x, y). Use an initial guess of (x, y) = (-3,-2). Save the final result to the variable A9 and the number of iterations to the variable A10. The initial guess does not count as an iteration.
Expert Answer:
Answer rating: 100% (QA)
a Create the function that computes fx y def fx y return x 2 y 11 2 x y 2 7 2 Compute f3 4 A15 f3 4 printA15 A15 b Create the function to find the gradient of f def gradientfx y dfdx 2 2 x x 2 y 11 x ... View the full answer
Related Book For
Smith and Roberson Business Law
ISBN: 978-0538473637
15th Edition
Authors: Richard A. Mann, Barry S. Roberts
Posted Date:
Students also viewed these programming questions
-
es Last year Minden Company introduced a new product and sold 25,400 units of it at a price of $100 per unit. The product's variable expenses are $70 per unit and its fixed expenses are $838,500 per...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-5. Ivan's grandfather died and left a portfolio of municipal bonds. In 2012, they pay Ivan...
-
Write a java program that will find the minimum value and print it to the console for the given array: {72, 101, 108, 108, 111, 32, 101, 118, 101, 114, 121, 111, 110, 101, 33, 32, 76, 111, 111, 107,...
-
For a 25-kW, 230-V, three-phase, 60-Hz squirrel-cage motor operating at rated voltage and frequency, the rotor I2R loss at maximum torque is 9.0 times that at full-load torque, and the slip at...
-
Do firms always accrue and record loss contingencies in the financial statements? Explain.
-
If people pay for good weather, who ultimately receives the good-weather payment?
-
Lean Accounting. Flexible Security Devices (FSD) has introduced a just-in-time production process and is considering the adoption of lean accounting principles to support its new production...
-
1 What is HRM? Explain the Functions of HRM? 2 What is HRP? Explain the process of HRP? 3 4 5 6 7 What is Recruitment? Explain the factors affecting Recruitment. What are the different Sources of...
-
Angus Walker, CFA, is reviewing the defined benefit pension plan of Acme Industries. Based in London, Acme has operations in North America, Japan, and several European countries. Next month, the...
-
What is an organizational approach to managing ethics within an IS?
-
Pick a firm of interest and peruse its annual reports over a 5- to 10-year period. Assess the information presented on M&As in the annual reports. Do you see any explicit mention of the link between...
-
The Captain Candy store (earlier known as Pirate Candy) in Prague, Czech Republic, manufactures unique pirate-themed candy products. Assume that the town currently levies a 1 per-bag tax on all candy...
-
In the box entitled How Would You Do That? 1, you learned how SAP America responded to performance problems primarily through changes in strategy implementation. Find one or two firms that were once...
-
The following diagram shows the cost structure of a monopoly firm as well as market demand. Identify on the graph and calculate the following: a. Profit-maximizing output level b. Profit-maximizing...
-
Calculate the present value of the income streams A to E in Table 1 at an 8 percent interest rate and again at a 10 percent rate. Suppose the investment behind the flow of income in E is a machine...
-
Question 3. a) Write the thrust equation and explain the meaning of the symbols used in the thrust equation. (10p) b) The F-4 aircraft with two jet engines accelerates at take-off. The exhaust exit...
-
The Cholesterol Level data sets give cholesterol levels of heart attack patients. Cholesterol measures are taken 2, 4, and 14 days aft er a patient has suffered a heart attack. Is there a significant...
-
The California Dental Association (CDA) is a voluntary nonprofit association of local dental societies to which some nineteen thousand dentists belong, about three-quarters of those practicing in the...
-
Nancy owed Sharon $1,500, but Sharon did not initiate a lawsuit to collect the debt within the time prescribed by the statute of limitations. Nevertheless, Nancy promises Sharon that she will pay the...
-
On August 12, Mr. and Mrs. Mitchell, the owners of a small secondhand store, attended Alexanders Auction, where they bought a used safe for $50. The safe, part of the Sumstad estate, contained a...
-
The following are some costs incurred by a shoe manufacturer. Decide whether each one is a fixed cost or a variable cost or has some element of both. (a) The cost of leather; (b) The fee paid to an...
-
Why does the marginal cost curve pass through the bottom of the average cost curve and the average variable cost curve?
-
Outline the main factors that might influence the size of the profit mark-up set by a business.
Study smarter with the SolutionInn App