Project

Week 4 - Genetic Algorithm

function [fx_y] = stag(input_parameter)

x = input_parameter(1);
y = input_parameter(2);

f1_x = (sin((5.1*pi.*x)+0.5)).^6;   % Define the function f1.x
f1_y = (sin((5.1*pi.*y)+0.5)).^6;   % Define the function f1.y
f2_x = exp(-4*log(2).*(((x-0.0667).^2)/0.64)); % Define the function f2.x
f2_y = exp(-4*log(2).*(((y-0.0667).^2)/0.64)); % Define the function f2.y

fx_y = -(f1_x.*f1_y.*f2_x.*f2_y); % main function 
end
clear all
close all
clc

% Define the search space 

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

% To create a two dimensional mesh

[xx,yy] = meshgrid(x,y);

% To evaluate the Stalagmite Function

for i = 1:length(xx)
    for j = 1:length(yy)
         input_parameter(1) = xx(i,j);
         input_parameter(2)= yy(i,j);
        f(i,j) = stag(input_parameter);
    end
end

% To visualize data in 3 Dimension

surfc(xx,yy,f) % Contour plot for 3 Dimensional surface plot

%shading interp  % To set the shading properties used shading command prompt and interp used to single quote color 
shading faceted

xlabel(\'X axis\');
ylabel(\'Y axis\');

[y,fval] = ga(@stag,2)

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.