Challenge

Week 4.1 - Genetic Algorithm

%STALAGMITE FUNCTION

* stalagmite is aspecial type rock that the usaually formed inside the cave

*the stalagmite normally rises from the floor

*the rock formed function because the accmuluation of the material on the floor from the dripping of ceiling

*the function got name from the particular rock because of the silmiliarity with a surface graph produecd by the function

* FORMULA f(x,y) = f1,xf2xf1,yf2y

% Genetic algorithim

*the algorithim repeatedly modifies a population of individual solution

*at each step the genetic algorithim randomly selects individual from the current population and the uses as parents to produce to the next generation

% stopping criteria

*all the steps of genetic algorithim are well definied expect the stopping crietiraia

*the parctitionars use the stopping criteria based on a time or fitness value

*the time based stopping criteriz are mainly of the two kinds

*the popular one is to decide upfront the number of itration to be executed

*another is based on ececution time of the algorithim

% MAIN CODE

*writting programme for optimizing the stalagmite function using the algorithim

*the objectives is to find the glopal optimum point of stalagmite

*the optimization time will be measured for each study to compare with each other and to the most efficiancy way to use the genetic algorithim

solve optimization problem

% solve = genetic algorithim

% STALAGMITE FUNCTION CODE

function [f] = stalagmite (input_vector)

x = input_vector(1);

y = input_vector(2);

f1x = (sin(((5.1*pi).*x)+0.5)).^6;

f1y = (sin(((5.1*pi).*y)+0.5)).^6;

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

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

f = -(f1x*f1y*f2x*f2y)

end

% MAIN CODE

close all
clear all
clc
num_cases = 200;
% 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(input_vector);
end
end
surfc(xx,yy,f)
shading interp
for i = 1:num_cases
[inputs, fopt(i)] = ga (@stalagmite, 2);
xopt(i) = inputs(1);
yopt(i) = inputs(2);
end
fopt = -fopt
figure(1)
subplot(2,2,1)
hold on
surfc(x,y,-f)
shading interp
plot3(xopt,yopt,fopt,'marker','o','markersize',5,'markerfacecolor','r')
title('unbounding inputs')

% stalagmite output

https://skill-lync.com/challenges/question/77780/38/288587#:~:text=stalagm%E2%80%A6tput.fig%201.37%20MB

% stalagmite fucntion code

https://skill-lync.com/challenges/question/77780/38/288587#:~:text=fig%201.37%20MB-,stalagmite.m%20294%20B,-ga_main.m%20790

% ga_main code

https://skill-lync.com/challenges/question/77780/38/288587#:~:text=m%20294%20B-,ga_main.m%20790%20B,-Your%20answer%20saved

% RESULTS

as we can that the computation time taken bye the bounded space with the increased population size is very high compare to other

% GLOBAL MAXIMA

x 0.4671144

y 0.4550.34

z 0.000263554

%LOCAL MAXIMA

x 0.0724832

y 0.0684564

z 0.0001618

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.