Challenge

Week 4.1 - Genetic Algorithm

close all
clear all
clc

% defining our space using [x and y]

x = linspace(0,0.6,150); [ linspace used for get 150 value]
y = linspace(0,0.6,150);

% creating a 2d using function [ meshgrid]

[x y] = meshgrid(x,y); [ converting in 2d array]

% calculating the stalagmite function

for i=1:length(x); [ loop used for [x,y] to repeat 150 value]

for j=1:length(y);
input_vector(1)=x(i,j);
input_vector(2)=y(i,j);

f(i,j) = stalagmite(input_vector); [ value given in search space]
end
end

surfc(x,y,f) [ surfacing the value]

xlabel('x axis') [ label both x and y]
ylabel('y axis') [ to remove the line make it smooth]
shading interp
[x,fval]= ga(@stalagmite,2)

search space formula

function [f] = stalagmite(input_vector)
x = input_vector(1)
y = input_vector(2)

f1_x = (sin(5.1*pi*x + 0.5)).^6;
f1_y = (sin(5.1*pi*y + 0.5)).^6;

R1 = ((x-0.0667).^2)/(0.64);
f2_x = exp(-4.*log(2)*R1);

R2 = ((y-0.0667).^2)/(0.64);
f2_y = exp(-4.*log(2)*R2);

f = (f1_x.*f2_x.*f1_y.*f2_y);
end

https://drive.google.com/file/d/1vi5o8sMxe9oNb6aMp0cAcbmwF0qVgp_j/view?usp=sharing

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.