You are on page 1of 3

16.

323 Principles of Optimal Control


Problem Set 1 Issued: Monday, February 7, 2014 Due: Friday, February 20, 2014

1. In this problem, you will write a simple BFGS solver, including a line search routine, in MATLAB, and test the solver by nding the minimum of the Rosenbrock function. (a) The Rosenbrock function is often used to test the performance of optimization programs. The Rosenbrock function in two dimensions is dened by
2 f (x) = (1 x1 )2 + 100(x2 x2 1)

Write a MATLAB routine, rosen.m, to compute the value of the function and the its gradient. The rst lines of the MATLAB function should be: function [f,g] = rosen(x) global nf nf = nf + 1; The second two lines allow the number of function calls to be determined later. The function should be called with x a vector of length two, and return the value of the function, f, and the gradient, g. Use the nargout mechanism in MATLAB to ensure that the gradient is computed only when rosen is asked to return both the function value and its gradient. Although the computation of the gradient is trivial for this problem, for harder problems, its best to compute the gradient only if needed. (b) Write a line search routine linesearch.m that has rst line function [alpha,xk1,fk1,gk1] = linesearch(f,xk,fk,gk,dk) The inputs to the routine are a handle to the function f , the last estimate of the minimum, xk , the search direction, dk , and the gradient gk = f (xk ). The returned values are the new estimate of the minimum, xk+1 , and the gradient gk+1 = f (xk+1 ). The search should stop when the Wolfe conditions are satised, that is, when f (xk + k dk ) f (xk ) + c1 k dT k f ( xk )
T dT k f (xk + k dk ) c2 dk f (xk )

where 0 < c1 < c2 < 1 The rst condition (the Armijo rule) ensures that the step length k decreases f suciently, and the second conditon (the curvature condition) ensures that

the slope has been reduced signicantly. The second condition can be strengthed by requiring that
T dT k f (xk + k dk ) c2 dk f (xk )

The constants c1 and c2 are somewhat arbitrary, but c1 should always be less than 0.5. For this problem, set c2 = 0.9, c1 = 0.0001. These values are not very strict, but are the default values in the widely used L-BFGS package, and seem to work well. To do the iteration, note that any violation of the Armijo rule places an upper limit on . For an that satises the Armijo rule, a violation of the curvature condition by a slope that is too negative places a lower limit on ; a violation with too positive a slope places an upper limit on . The a priori limits are 0 < < . This information should be sucient to design a bisection search for an acceptable . (c) Write a MATLAB routine bfgs.m that does a BFGS search. The rst lines of the program should be function [x,fval] = bfgs(f,x0) global xpath ni nf ni = 0; nf = 0; xpath = []; In addition, for each time you set xk in the iteration, you should have lines like xpath = [xpath ; xk(:)]; ni = ni + 1; This code will allow you to see the path taken by the search algorithm, and to determine the number of iterations. The stopping criterion should be that the norm of the gradient vector is less than a tolerance, gtol. For this problem, try gtol = 1020 , which is too strict, but will allow the problem to completely converge. (d) Debug your routines, and demonstrate that they work by nding the minimum of the Rosenbrock function, by using the MATLAB command x=bfgs(@rosen,[-1.9 2]) Plot the search history as points in the x1 , x2 plane, over the region 2 x1 2, 1 x2 3. Include appropriate contours of the Rosenbrock function. Also, plot the convergence history, that is, the distance of each point xk in the BFGS iteration from the optimal solution. How many iteration and functions call are required? How does your algorithm compare to the MATLAB result using fminunc?

2. Find the minimum of the objective function


4 f ( x) = x4 1 + 100x2

using the BFGS method, by modifying the MATLAB routines used in Problem 1 appropriately. Of course, you will need to modify the objective function. For this problem, try gtol = 10100 to ensure convergence to the minimum. Use the same starting point as in Problem 1. Is the convergence linear or superlinear? Explain why. 3. For the following function, 1 6 2 4 F = 2x2 1 1.05x1 + x1 x1 x2 + x2 6 (a) Find the minima in the region 3 x1 3, 3 x2 3. (b) Are there any other stationary points? If so, what are they? 4. (From B&H) Find the rectangle of maximum perimeter that can be inscribed in an ellipse; that is, maximize P = 4(x + y ) subject to the constraint x2 y 2 + 2 =1 a2 b 5. (From B&H) Find the rectangular parallelpiped of maximum volume that can be contained in an ellipsoid;. that is, maximize V = 8xyz subbject to the constraint x2 y 2 z 2 + 2 + 2 =1 a2 b c 6. For the cost function, f (x, y ) = x2 + y 2 6xy 4x 5y (a) Show analytically how to minimize the cost subject to the constraints, y (x 2)2 + 4 y x + 1 (b) How is the optimal cost aected if the rst constraint is changed to y (x 2)2 + 4.1 Estimate this dierence and explain your answer. (c) Write a Matlab script to conrm your results in parts (a) and (b). 7. Read the article on Stellar by Bryson on the history of optimal control and write a short summary (approximately 1/2 page). In particular, identify some of the key players and the main algorithmic/technological steps made in those 35 years. 3

You might also like