%Program to calculate Global maxima of a Stalagmite function
clear all
close all
clc
%Creating lines
x = linspace(0,0.6,150);
y = linspace(0,0.6,150);
num_cases=50;
% Creating Plots
[xx yy] = meshgrid(x,y);
for i = 1 : length(xx);
for j = 1 : length(yy);
input_value(1)= xx(i,j);
input_value(2) = yy(i,j);
f(i,j) = stalagmite_func(input_value);
end
end
%For Calculating and Genrating the Plot
tic
for i=1:num_cases;
[inputs1,fopt1(i)]=ga(@stalagmite_func,2);
xopt(i)=inputs1(1);
yopt(i)=inputs1(2);
end
study1_time=toc;
figure(1)
subplot(2,1,1)
hold on
surfc(xx,yy,-f)
zlabel('function value')
shading interp
plot3(xopt,yopt,-fopt1,'marker','o','markersize',5,'markerfacecolor','r')
title('Unbounded Statistical Behvaiour')
subplot(2,1,2)
plot(-fopt1)
xlabel('iterations')
ylabel('function maximum')
%For Second Plot same function
tic;
for i=1:num_cases;
[inputs2,fopt2(i)]=ga(@stalagmite,2,[],[],[],[],[0;0],[1;1]);
xopt(i)=inputs2(1);
yopt(i)=inputs2(2);
end
study2_time=toc;
figure(2)
subplot(2,1,1)
hold on
surfc(xx,yy,-f)
zlabel('function value')
shading interp
plot3(xopt,yopt,-fopt2,'marker','o','markersize',5,'markerfacecolor','r')
title('Bounded Statistical Behvaiour')
subplot(2,1,2)
plot(-fopt2)
xlabel('iterations')
ylabel('function maximum')
%Sucess Completed