Objective
Program a Stalagmite function using the Genetic Algorithm Theory and find the Global Maxima for the gi*
Mathematical Formula.
Theory of Genetic Algorithm:
Genetic Algorithm is the evolution theory proposed by Charles Darwin.
The genetic algorithm is a random-based classical evolutionary algorithm. By random here we mec
order to find a solution using the GA, random changes applied to the current solutions to generate r
'GA' solves any function to find the optimum values (min/max) based on the requirement of the fun
• Matlab provides an inbuilt function that actually helps to do GA quite comfortably.
Optimization
• Optimization in a genetic algorithm is finding out the best solution. In our problem statement, we are
find out the best value of Global Maxima (Global Optima).
• In the simplest case, an optimization problem consists of maximizing & minimizing a real function by
systematically choosing input values from within an allowed set and computing the value of the funcTION
PROGRAM:
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 (-4*10g(2) * ( (x-0.0667) ^2) /0.64) ;
f2y= exp(-4*10g(2)* ((y-0.0667) ^2) /0.64) ;
f = -(f1x*f2x*f1y*f2y);
end
% clear all
% close all
% clc
% defining our reasearch space
x = linspace(0,0.6,150);
y = linspace(0,0.6,150);
% creating a 2D mesh
[xx,yy] = meshgrid (x,y);
% evaluate 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
% surf(xx,yy,f)
shading intrupt
[x,fval] = ga(@stalagmite, 2)