Challenge

Week 4.1 - Genetic Algorithm

clear all
close all
clc

% 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
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_func(input_vector);
end
end


surfc(xx,yy,f)

shading interp

[x, fval] = GA(@stalagmite_func , 2);

FUNCTION

function[stalagmite] = stalagmite_func(input_vector)

x = input_vector (1)
y = input_vector (2)

f1_x = (sin(5.1*pi* x+0.5)).^6
f2_y = (sin(5.1*pi* y+0.5)).^6
f3_x = exp((-4*0.6931).*(x-0.0667)^2/(0.64));
f4_y = exp((-4*0.6931).*(y-0.0667)^2/(0.64));
stalagmite = (f1_x.*f2_y.*f3_x.*f4_y)
end

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.