Project

Optimization of Stalagmite Function Using Genetic Algorithm- Haseeb Ahmad

clear all
close all
clc

x=linspace(0,0.6,150);
y=linspace(0,0.6,150);
numcases=50;

[X,Y]=meshgrid(x,y);

for i=1:length(X)
    for j=1:length(Y)
        input_vector(1)=X(i,j);
        input_vector(2)=Y(i,j);
      input_vector= [input_vector(1);input_vector(2)];
       fval(i,j)=stalagmite(input_vector);
    end
end

% Unbounded Results
for i=1:numcases
[inputs,fopt1(i)]=ga(@stalagmite,2);
xvalue1(i)=inputs(1);
yvalue1(i)=inputs(2);
end
subplot(3,2,1)
surfc(x,y,-fval)
shading interp
hold on
plot3(xvalue1,yvalue1,-fopt1,\'marker\',\'o\',\'markersize\',5,\'markerfacecolor\',\'r\')
xlabel(\'x-axis\')
ylabel(\'y-axis\')
title(\'Unbounded Results\')
shading interp
subplot(3,2,2)
plot(-fopt1)
xlabel(\'iterations\')
ylabel(\'fopt\')
title(\'Unbounded Results\')

%Bounded Results (Bounded by the respective domains of x and y)
for i=1:numcases
[inputs,fopt2(i)]=ga(@stalagmite,2,[],[],[],[],[0;0],[0.6;0.6]);
xvalue2(i)=inputs(1);
yvalue2(i)=inputs(2);
end
subplot(3,2,3)
surfc(x,y,-fval)
shading interp
hold on
plot3(xvalue2,yvalue2,-fopt2,\'marker\',\'o\',\'markersize\',5,\'markerfacecolor\',\'r\')
xlabel(\'x-axis\')
ylabel(\'y-axis\')
title(\'Bounded Results\')

shading interp
subplot(3,2,4)
plot(-fopt2)
xlabel(\'iterations\')
ylabel(\'fopt\')
title(\'Bounded Results\')


%Bounded Results (Increaing Population Size from a Default of 50 to 200
options = gaoptimset(@ga)
options=gaoptimset(\'PopulationSize\',400);
for i=1:numcases
[inputs,fopt3(i)]=ga(@stalagmite,2,[],[],[],[],[0;0],[0.6;0.6],[],[],options);
xvalue3(i)=inputs(1);
yvalue3(i)=inputs(2);
end
subplot(3,2,5)
surfc(x,y,-fval)
shading interp
hold on
plot3(xvalue3,yvalue3,-fopt3,\'marker\',\'o\',\'markersize\',5,\'markerfacecolor\',\'r\')
xlabel(\'x-axis\')
ylabel(\'y-axis\')
title(\'Bounded Results & PopulationSize=400\')

shading interp
subplot(3,2,6)
plot(-fopt3)
xlabel(\'iterations\')
ylabel(\'fopt\')
title(\'Bounded Results & PopulationSize=400\')

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.