Challenge

Week 4.1 - Genetic Algorithm

Aim :- To find Global Maxima & to create Staligmait function

Explanation :- 1) To create function called staligmait with the help of given formula

2) Divide the formula in four parts (f1x,f1yf2x,f2y) then combine it and assing it to F a singal variable

3) GA helps yous to find the global max value or group of max values

4) With x,y,f we find your global max

5) code

tic
%case 2 - Statistical behavior with upper and lower bounds
for i = 1:num_case
[inputs_c , fopt3(i)] = ga(@stalagmait, 2 , [],[],[],[],[0;0],[1;1]);
xopt3(i) = inputs_c(1);
yopt3(i) = inputs_c(2);
end
study_time2=toc
figure(2)
subplot(2,1,1)
hold on
surfc(x,y,f)
shading interp
plot3(xopt3,yopt3,fopt3,'marker','o','markersize',4,'markerfacecolor','r')
legend ('Function','Minima');
title('Unbounded input')
subplot(2,1,2)
plot(fopt3)
xlabel('Iteration')
ylabel('Function minimum')

% Study 3 incerasing GA iterations
options = optimoptions('ga');
options = optimoptions(options,'PopulationSize' , 170);

tic
for i = 1:num_case
[inputs_c , fopt3(i)] = ga(@stalagmait,2,[],[],[],[],[0;0],[1;1],[],[],options);
xopt3(i) = inputs_c(1);
yopt3(i) = inputs_c(2);
end
study_time3=toc
figure(3)
subplot(2,1,1)
hold on
surfc(x,y,f)
shading interp
plot3(xopt3,yopt3,fopt3,'marker','o','markersize',4,'markerfacecolor','r')
legend ('Function','Minima');
title('Unbounded input')
subplot(2,1,2)
plot(fopt3)
xlabel('Iteration')
ylabel('Function minimum')

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.