All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Aim - Use MATLAB to optimise the stalagmite function and find the global maxima of the function. %Global maxima of the given function. clear all close all clc x=linspace(0,0.6,150); y=linspace(0,0.6,150); [xx yy]=meshgrid(x, y); for i=1:length(xx) for j=1:length(yy) input_vector(1)=xx(i,j); input_vector(2)=yy(i,j);…
Prahar Dave
updated on 02 Dec 2020
Aim - Use MATLAB to optimise the stalagmite function and find the global maxima of the function.
%Global maxima of the given function.
clear all
close all
clc
x=linspace(0,0.6,150);
y=linspace(0,0.6,150);
[xx yy]=meshgrid(x, y);
for i=1:length(xx)
for j=1:length(yy)
input_vector(1)=xx(i,j);
input_vector(2)=yy(i,j);
f(i,j)=stalgmite(input_vector);
end
end
%case1
iterations=100;
tic
for i=1:iterations
[inputa fval1(i)]=ga(@stalgmite,2);
x1(i)=inputa(1);
y1(i)=inputa(2);
end
time=toc
%plots
figure(1)
subplot(2,1,1)
hold on
surfc(x,y,f)
shading interp
plot3(x1,y1,fval1,'marker','*')
title("Case 1 (Unbounded Values)")
subplot(2,1,2)
plot(fval1)
xlabel('No. of Iterations')
ylabel('Function Minimum')
%case 2
tic
for i=1:iterations
[inputb fval2(i)]=ga(@stalgmite,2,[],[],[],[],[0;0],[1;1]);
x2(i)=inputb(1);
y2(i)=inputb(2);
end
time2=toc
figure(2)
subplot(2,1,1)
hold on
surfc(x,y,f)
shading interp
plot3(x2,y2,fval2,'marker','*')
title("Case 2 (Bounded values)")
subplot(2,1,2)
plot(fval2)
xlabel('No. of Iterations')
ylabel('Function Minimum')
%case 3
options=optimoptions('ga');
options=optimoptions(options,'populationsize',500)
tic
for i=1:iterations
[inputc fval3(i)]=ga(@stalgmite,2,[],[],[],[],[0;0],[1;1],[],[],options);
x3(i)=inputc(1);
y3(i)=inputc(2);
end
time3=toc
figure(3)
subplot(2,1,1)
hold on
surfc(x,y,f)
shading interp
plot3(x3,y3,fval3,'marker','*')
title("Case 3 (Increased Population)")
subplot(2,1,2)
plot(fval3)
xlabel('No. of Iterations')
ylabel('Function Minimum')
Leave a comment
Thanks for choosing to leave a comment. Please keep in mind that all the comments are moderated as per our comment policy, and your email will not be published for privacy reasons. Please leave a personal & meaningful conversation.
Other comments...
Hood design-Week 2
Hood - The Hood/Bonnet is an opening body panel or BiW part, which covers the front of a vehicle It covers the engine room in case of the front-engine vehicles and luggage room in rear-engine ones A hood is similar to a door Commonly used materials in Hood - These materials are selected based on the required properties…
14 Sep 2022 06:56 AM IST
Related Courses
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.