Week 5 - Genetic Algorithm
% code
clear
close
clc
<!-- [if mso]>
<![endif]-->
<![endif]-->
�fining our search spaces
x=linspace(0,0.6,150);
y=linspace(0,0.6,150);
<!-- [if mso]>
<![endif]-->
<![endif]-->
% creating a 2d mesh
[xx, yy]=meshgrid(x,y);
<!-- [if mso]>
<![endif]-->
<![endif]-->
% evaluating the stalagmite function
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)=stalagmite(input_vector);
end
end
<!-- [if mso]>
<![endif]-->
<![endif]-->
surf(xx,yy,f)
shading interp
<!-- [if mso]>
<![endif]-->
<![endif]-->
[x,fval]=ga(@stalagmite,2);