Project

Genetic Algorithm

% Main Program
clear all
close all
clc

% Defining our Search Space
x = linspace(0,0.6,150);
y = linspace(0,0.6,150);
f = [0,0];

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

surfc(xx,yy,-f);
xlabel('X Value');
ylabel('Y Value');
shading interp;

[inputs, fval] = ga(@stalagmite, 2);


% Function Program

function[max] = stalagmite(input_vector)


fax = (sin(5.1*pi*input_vector(1)+0.5))^6;
fay = (sin(5.1*pi*input_vector(2)+0.5))^6;
fbx = exp(-4*log(2)*(input_vector(1)-0.0667)^2/0.64);
fby = exp(-4*log(2)*(input_vector(2)-0.0667)^2/0.64);


max = -fax*fbx*fay*fby;
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.