Challenge

Week 4.1 - Genetic Algorithm

% stalogmite mathematical model

%defining our search space
x=linspace(0,0.6,150);
y=linspace(0,0.6,150);

%creating a 2dimensional mesh
[xx, yy]=meshgrid(x,y);
%evaluating the stalagmite function
%function


% function
function f[i,j] = stalagmite_function(input_vector)
x = input_vector(1);
y = input_vector(2);
f1 = (sin(5.1*pi*x+0.5))^6;
f2 = (sin(5.1*pi*y+0.5))^6;
f3 = exp((-4*log(2)*(x-0.0667)^2)/0.64);
f4 = exp((-4*log(2)*(y-0.0667)^2)/0.64);
f = -(f1*f2*f3*f4);
end

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

%surface=(xx,yy,f)

sharding interp

[x,fval]=ga(@stalagmite,2);
xlabel('x value')
ylabel('y value')

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.