




















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





















∗1 Department of Electrical and Computer Engg. 2*Professor ECE Department University of Pittsburgh, Pittsburgh, PA 15261
x∗
i,j
3 Iso-line plots of given objective functions
4 Gradient Methods
4.1 Constant and Variable Step-size Steepest Descent Methods
The minima of f1 found after 39 iterations,
Convergence of f1 using variable steps chosen from 0.05,0.15 and 0.25, and negative direction of gradient is used as the line of exploration.
The minima of f1 found after 30 iterations, using Variable Stepsizes chosen from =0.090,0.150,0.200, gradient method are x1=1.055874 x2=1.133855, and the min value of function is =0.
Convergence of f2: The function f2 did not converge at all for constant and variable stepsize methods, various intial points ranging from [-1 1], [-1. 0.5] [2 2] and various step sizes ranging from 0.05,0.09,0.15 were tried in vain the steepest descent algorithm couldnt locate the descent direction to iterate on and hence a failed output:
iteration x1 x2 f2(x1,x2) Norm(gradient) not a descent direction ... exiting The extremum could not be located after 2 iterations
4.2 Newton-Raphson method
The minima of f2 found after 3 iterations, with initial pt 2.0,2.0,using Newton-Raphson(NR) method are x1=1.001233 x2=1.002467, and the min value of function is =0.
4.3 Conjugate Gradient Method
epsilon = 0.05 %termination condition r0 = gradient_f1(x0_y0) H = hessian_f1(x0_y0) d0 = -r t0 = - <d0,r0> / <d0,(H d0)> x1_y1 = x0_y0 + t0d r1 = gradient_f1(x1_y1) b0 = <r1,r1>/<r0,r0> d1 = -r1 + b0d
while (norm(gradient_f1(xk_yk)) < epsilon) {
H = hessian_f1(x0_y0) xk_yk = xk-1_yk-1 + tk-1 * dk- rk = gradient_f1(xk_yk) bk-1 = <rk,rk> / <rk-1,rk-1> dk = -rk + bk-1 * dk- tk = - <dk,rk> / <dk,(H dk)> }
Results of Convergence of f1 using the conjugate gradient algorithm whose pseudo-code is given above is:
iteration x1 x2 f1(x1,x2) Norm(gradient) 2 1.4975 2.1115 0.2646 1. 3 1.4275 2.1236 0.1901 0. 4 1.4032 2.1165 0.1843 0. 5 1.3242 1.9980 0.1649 0.
The minima of f1 found after 14 iterations,
Convergence of f2: The function f2 does not converge using current implementation of conjugate gradient method. The Gradient vector/Hessian becomes abnormally large after a few iterations, due to precision errors while calculating the gradient when the itinerant approaches the minima. Note the direction of approach of itinerant before the abnormal gradient value is headed in the right direction i.e. towards the minima. A better approach would be to use direct methods to calculate next estimate like the polynomial fit thereby circumventing
The minima of f1 found after 6 iterations,
Results of convergence of f2 using Golden Search method:
The minima of f2 found after 9 iterations,
5.2 Polynomial Approximation -Quadratic fit method
The algorithm for fitting a quadratic polynomial to known three points a,b,c and function values fa,fb,fc at these points is as follows[1]:
d0 is any direction vector that is normalized such that ||d0|| = 1 d0 = [1/sqrt(2) 1/sqrt(2)]^T %(say) x0_y0 = [2 2]^T %initial point t0 = 0.15 %(say) assumed initial step size fa = f(x0_y0) fb = f(x0_y0 + t0.* d0) if fa < fb fc = f(x0_y0 - t0.* d0) else fc = f(x0_y0 + 2t0.d0) while norm(gradient_fl(xk_yk)) < e {
tk = − (^12)
1 f a a^2 1 f b b^2 1 f c c^2
1 a f a 1 b f b 1 c f c
= − 12 (b
(^2) − a (^2) )f a + (c (^2) − a (^2) )f b + (a (^2) − b (^2) )f c (b − c)f a + (c − a)f b + (a − b) ∗ f c =^ −^
α 1 2 α 2
Note: For the algorithm to converge:
α 2 = (c^ −^ b) (f aa −+ ( b)(a^ b− −^ c )cf b)(c^ + ( − ab)^ − c)f c> 0
xk+1^ = xk^ + tkd 0
} The essence of the above algorithm is in approximating the neighbourhood of f(x) with a quadratic polynomial:
f (x + tkd 0 ) ≈ α 0 + α 1 tk + α 2 t^2 k
Results of convergence of f1 using quadratic approximation: iteration x1 x2 f1(x1,x2) Norm(gradient) 2 1.1923 1.1923 0.0896 1. 3 1.0413 1.0413 0.0036 0. 4 1.0024 1.0024 0.0000 0.
6 Observations and interpretation of results of differ-
ent methods
7 Conclusion
References
A Matlab Code for the Project
A.1 Code for Contour Plots of functions
%contour plots By Narayanan Krishnamurthy %For Dr.Simaan ece 2671 class clear,clf,clc n = 30; %# of contours format long g [X,Y] = meshgrid(-1:.02:2,-1.4:.02:4); Z = (X.^2 - Y).^2 + (X - ones(size(X))).^2; %Then, generate a contour plot of Z. [C,h] = contour(X,Y,Z,n);
break; end
disp(sprintf(’%-4d\t\t%3.4f\t\t\t%3.4f\t\t%3.4f\t\t%3.4f’,i,xk_yk(i,1),xk_yk(i,2), f1(xk_yk(i,:)),norm(gradient_f1(xk_yk(i,:))))); if norm(gradient_f1(xk_yk(i,:))) < e disp(’----------------------------------------------------------------------’); disp(sprintf(’The minima of f1 found after %d iterations,’,i)); disp(sprintf(’using constant step of %f, gradient methods are x1=%f x2=%f,’,t, xk_yk(i,1),xk_yk(i,2))); disp(sprintf(’and the min value of function is =%f’, f1(xk_yk(i,:)))); disp(’----------------------------------------------------------------------’); break;
end end
n = 30; %# of contours format long g [X,Y] = meshgrid(-1:.02:2,-1.4:.02:4); Z = (X.^2 - Y).^2 + (X - ones(size(X))).^2; %Then, generate a contour plot of Z. [C,h] = contour(X,Y,Z,n); clabel(C,h),xlabel(’x_1’,’Fontsize’,18),ylabel(’x_2’,’Fontsize’,18), title(sprintf(’f_1(x_1,x_2),Const Stepsize=%1.3f’,t),’Fontsize’,18); grid on
hold on; convergence = [x0_y0’ xk_yk’]; %scatter(convergence(1,:),convergence(2,:)); plot(convergence(1,:),convergence(2,:),’-ro’);
A.3 Code for Variable step size Steepest Descent Method
%Variable Step Size Steepest Descent Method, Narayanan Krishnamurthy %for ee2671 fall 2005 clear,clf,clc
%Gradient methods f clear; echo off; format long g; % initial point
x0_y0 = [2 2]; % termination point e = 0.05; N =1000; % constant step size tf1(1) = 0.09; tf1(2) =0.15; tf1(3) =0.2; t = check_min_t_f1(tf1(1),tf1(2),tf1(3),x0_y0); xk_yk(1,:) = x0_y0 - tf1(t).gradient_f1(x0_y0); disp(’iteration x1 x2 f1(x1,x2) Norm(gradient)’); for i = 2:N t = check_min_t_f1(tf1(1),tf1(2),tf1(3),xk_yk(i-1,:)); xk_yk(i,:) = xk_yk(i-1,:) - tf1(t).gradient_f1(xk_yk(i-1,:));
if f1(xk_yk(i,:)) > f1(xk_yk(i-1,:)) disp(’not a descent direction ... exiting’); disp(sprintf(’The extremum could not be located after %d iterations’,i)); break; end
disp(sprintf(’%-4d\t\t%3.4f\t\t\t%3.4f\t\t%3.4f\t\t%3.4f’,i,xk_yk(i,1), xk_yk(i,2),f1(xk_yk(i,:)),norm(gradient_f1(xk_yk(i,:)))));
if norm(gradient_f1(xk_yk(i,:))) < e disp(’----------------------------------------------------------------------’); disp(sprintf(’The minima of f1 found after %d iterations,’,i)); disp(sprintf(’using Variable Stepsizes chosen from =%1.3f,%1.3f,%1.3f, gradient method are x1=%f x2=%f,’, tf1(1),tf1(2),tf1(3),xk_yk(i,1),xk_yk(i,2))); disp(sprintf(’and the min value of function is =%f’, f1(xk_yk(i,:)))); disp(’----------------------------------------------------------------------’); break;
end end
n = 30; %# of contours format long g [X,Y] = meshgrid(-1:.02:2,-1.4:.02:4); Z = (X.^2 - Y).^2 + (X - ones(size(X))).^2; %Then, generate a contour plot of Z. [C,h] = contour(X,Y,Z,n); clabel(C,h),xlabel(’x_1’,’Fontsize’,18),ylabel(’x_2’,’Fontsize’,18), title(sprintf(’f_1(x_1,x_2) Variable Stepsizes chosen from =