function [f]=stalagmite_func(input_vector)
f1x=(sin((5.1*pi).*input_vector(1)+0.5)).^6;
f1y=(sin((5.1*pi).*input_vector(2)+0.5)).^6;
f2x=exp((((input_vector(1)-0.0667).^2)/0.64).*(-4*log(2)));
f2y=exp((((input_vector(2)-0.0667).^2)/0.64).*(-4*log(2)));
f1=f1x*f1y*f2x*f2y;
f=-f1;
end
clear all
close all
clc
%inputs
x=linspace(0,0.6,150);
y=linspace(0,0.6,150);
num_case = 50;
%forming 2d array
[xx, yy]=meshgrid(x,y);
for i=1:length(x)
for j=1:length(y)
input_vector(1)=xx(i,j);
input_vector(2)=yy(i,j);
f(i,j)=stalagmite_func(input_vector);
end
end
%study 1 - unbounded
tic
for i=1:num_case
[input,fopt(i)]=ga(@stalagmite_func,2);
xopt(i)=input(1);
yopt(i)=input(2);
end
study_time1=toc
figure(1)
subplot(2,1,1)
hold on
surfc(x,y,-f)
shading interp
plot3(xopt,yopt,-fopt,'marker','o','markersize',5,'markerfacecolor','r')
title('unbounded inputs')
subplot(2,1,2)
plot(-fopt)
xlabel('Interaction')
ylabel('Function maximum')
%study 2 - statistical study with upper bound and lower bound
tic
for i=1:num_case
[input,fopt(i)]=ga(@stalagmite_func,2,[],[],[],[],[0;0],[1;1]);
xopt(i)=input(1);
yopt(i)=input(2);
end
study_time2=toc
figure(2)
subplot(2,1,1)
hold on
surfc(x,y,-f)
shading interp
plot3(xopt,yopt,-fopt,'marker','o','markersize',5,'markerfacecolor','r')
title('unbounded inputs')
subplot(2,1,2)
plot(-fopt)
xlabel('Interaction')
ylabel('Function maximum')
%study 3 - Increasing iterations
options=optimoptions('ga');
options=optimoptions(options,'Populationsize',150);
tic
for i=1:num_case
[input,fopt(i)]=ga(@stalagmite_func,2,[],[],[],[],[0;0],[1;1],[],[],options);
xopt(i)=input(1);
yopt(i)=input(2);
end
study_time2=toc
figure(3)
subplot(2,1,1)
hold on
surfc(x,y,-f)
shading interp
plot3(xopt,yopt,-fopt,'marker','o','markersize',5,'markerfacecolor','r')
title('unbounded inputs')
subplot(2,1,2)
plot(-fopt)
xlabel('Interaction')
ylabel('Function maximum')