You are on page 1of 4

OPTIMAL CONTROL

ASSIGNMENT 02

MUHAMMAD MOHSIN KHAWAJA


MS-EE(EPC-3)
118339

1.

Contour plot of the function with a plot of iterates


1 9.5

9.59.5

0.9 9.45 9.45 9.45

0.8 9.4

9.49.4

0.7 9.35 9.35 9.35

0.6 9.3

9.39.3

0.5 9.25 9.25 9.25

0.4 9.2

9.29.2

0.3 9.15 9.15 9.15

0.2 9.1

9.19.1

0.1 9.05 9.05 9.05

0
-3

9.59.5

9.59.5

9.45 9.45

9.45 9.45

9.49.4

9.49.4

9.35 9.35

9.35 9.35

9.39.3

9.39.3

9.25 9.25

9.25 9.25

9.29.2

9.29.2

9.15 9.15

9.15 9.15

9.19.1

9.19.1

9.05 9.05

9.05 9.05

-2

9.5

9.45

9.4

9.35

9.3

9.25

9.2

9.15

9.1

9.05

9.59.5

9.59.5

9.59.5

9.59.5

9.45 9.45

9.45 9.45

9.45 9.45

9.45 9.45

9.49.4

9.49.4

9.49.4

9.49.4

9.35 9.35

9.35 9.35

9.35 9.35

9.35 9.35

9.39.3

9.39.3

9.39.3

9.39.3

9.25 9.25

9.25 9.25

9.25 9.25

9.25 9.25

9.29.2

9.29.2

9.29.2

9.29.2

9.15 9.15

9.15 9.15

9.15 9.15

9.15 9.15

9.19.1

9.19.1

9.19.1

9.19.1

9.05 9.05

9.05 9.05

9.05 9.05

9.05 9.05

-1

9.5

9.45

9.4

9.35

9.3

9.25

9.2

9.15

9.1

9.05

9.59.5

9.59.5

9.59.5

9.59.5

9.45 9.45

9.45 9.45

9.45 9.45

9.45 9.45

9.49.4

9.49.4

9.49.4

9.49.4

9.35 9.35

9.35 9.35

9.35 9.35

9.35 9.35

9.39.3

9.39.3

9.39.3

9.39.3

9.25 9.25

9.25 9.25

9.25 9.25

9.25 9.25

9.29.2

9.29.2

9.29.2

9.29.2

9.15 9.15

9.15 9.15

9.15 9.15

9.15 9.15

9.19.1

9.19.1

9.19.1

9.19.1

9.05 9.05

9.05 9.05

9.05 9.05

9.05 9.05

9.5

9.45

9.4

9.35

9.3

9.25

9.2

9.15

9.1

9.05

9.59.5

9.459.45

9.49.4

9.359.35

9.39.3

9.259.25

9.29.2

9.159.15

9.19.1

9.059.05

2.

Plot of the value of the function with respect to the iteration


number
9.5
9.45
9.4

Value of func

9.35
9.3
9.25
9.2
9.15
9.1
9.05
9

3.

4
5
Iteration number

Insight
In this example we used anti-gradient as search direction and step length
of 1. We can clearly see from the figure above that value of the function
remains same after 1 iteration as we have accumulation points.
So, it is proved from this example the anti-gradient search direction cannot
always gives us the minimum point.

4.

MATLAB Code

% f=x.^2 + (y.^2)/2;
% df/dx=2*x;
% df/dy=y;
F=zeros(1,10);
X=[3,zeros(1,9)];
Y=[1,zeros(1,9)];
% x0=3;
% y0=1;
for k=1:10
F(k)=X(k).^2 + (Y(k).^2)/2;
if( 2*(X(k))==0 && (Y(k))==0)
display('static value is')
display('X=')
display(X(k+1))
display('Y=')
display(Y(k+1))
else
if(k<10)
X(k+1)= X(k) - 2*(X(k));
Y(k+1)= Y(k) - Y(k);
end
end
end
[X1,Y1] = meshgrid(X,Y);
fx=X1.^2 + (Y1.^2)/2;
contour(X1,Y1,fx,'ShowText','on')
figure
K=0:9;
plot(K,F)
xlabel('Iteration number')
ylabel('Value of func')

You might also like