Week 4.1 - Genetic Algorithm
GA:
genetic algorithm (GA) is a method for solving both constrained and unconstrained optimization problems based on a natural selection process that mimics biological evolution. The algorithm repeatedly modifies a population of individual solutions.
% Defining our search space
x = linspace(0,0.6,150);
yy = linspace(0,0.6,150);
%creating a 2Dimensional mesh
[xx yy] = meshgrid(x, yy);
%Evaluting 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
surface(xx,yy,f)
xlabel('x value')
ylabel('y value')
[x,fval] = ga(@stalagmite,2)
