All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Genetic Algorithm : A genetic algorithm is a search heuristic that is inspired by Charles Darwin’s theory of natural evolution. This algorithm reflects the process of natural selection where the fittest individuals are selected for reproduction in order to produce offspring of the next generation. Genetic…
Aadil Shaikh
updated on 25 Mar 2020
Genetic Algorithm :
Syntax
x = ga(fun,nvars)
x = ga(fun,nvars,A,b)
x = ga(fun,nvars,A,b,Aeq,beq)
x = ga(fun,nvars,A,b,Aeq,beq,lb,ub)
x = ga(fun,nvars,A,b,Aeq,beq,lb,ub,nonlcon)
x = ga(fun,nvars,A,b,Aeq,beq,lb,ub,nonlcon,options)
x = ga(fun,nvars,A,b,[],[],lb,ub,nonlcon,IntCon)
x = ga(fun,nvars,A,b,[],[],lb,ub,nonlcon,IntCon,options)
x = ga(problem)
[x,fval] = ga(___)
[x,fval,exitflag,output] = ga(___)
[x,fval,exitflag,output,population,scores] = ga(___)
Stalagmite Function :
clear all
close all
clc
x = linspace(0,0.6,250);
y = linspace(0,0.6,250);
[xx, yy] = meshgrid(x,y);
% Evaluating the stalagmite function
for i = 1:length(xx)
for j = 1:length(yy)
input_vec(1) = xx(i,j);
input_vec(2) = yy(i,j);
f(i,j) = stalagmite(input_vec);
end
end
surfc(x,y,f)
xlabel('x-axis')
ylabel('Y-axis')
shading interp
[input , fval] = ga(@stalagmite , 2)
Studies for optimization of stalagmite function to find Global Maxima :-
clear all
close all
clc
x = linspace(0,0.6,250);
y = linspace(0,0.6,250);
[X,Y] = meshgrid(x,y);
% assigning 200 cases
num_cases = 200;
f = get_stalagmite; % calling the stalagmite function
% study 1_ statistical behavior
tic
for i = 1:num_cases
[inputs , fopt(i)] = ga(@stalagmite, 2);
xopt(i) = inputs(1);
yopt(i) = inputs(2);
end
study1_time = toc
% figure one from study one
figure(1)
subplot(2 ,1 ,1)
hold on
surfc (X,Y,f)
shading interp
plot3(xopt ,yopt ,fopt, 'marker' , 'o', 'markersize',5,'markerfacecolor' ,'r')
title('Study 1 : Unbounded inputs')
subplot(2,1,2)
plot(fopt)
xlabel('Iterations')
ylabel('Function maximum')
tic
%study 2 - statistical behaviour with upper and lower bounds
for i = 1:num_cases
[inputs , fopt(i)] = ga(@stalagmite, 2, [],[] ,[],[],[0;0],[1;1]);
xopt(i) = inputs(1);
yopt(i) = inputs(2);
end
study2_time = toc
% figure from study two
figure(2)
subplot(2,1,1)
hold on
surf(X,Y,f)
shading interp
plot3(xopt ,yopt ,fopt, 'marker' , 'o', 'markersize',5,'markerfacecolor' ,'r')
title('Study 2 : Bounded inputs')
subplot(2,1,2)
plot(fopt)
xlabel('Iterations')
ylabel('Function maximum')
% study 3 and also increasing ga iteratins
options = optimoptions('ga');
options = optimoptions(options,'populationsize',500);
tic
for i = 1:num_cases
[inputs , fopt(i)] = ga(@stalagmite, 2, [], [] ,[],[],[0;0],[1;1],[],[],options);
xopt(i) = inputs(1);
yopt(i) = inputs(2);
end
study3 = toc
% figure from study 3
figure(3)
subplot(2,1,1)
hold on
surf(X,Y,f)
shading interp
plot3(xopt ,yopt ,fopt, 'marker' , 'o', 'markersize',5,'markerfacecolor' ,'r')
title('Study 3 : Bounded inputs')
subplot(2,1,2)
plot(fopt)
xlabel('Iterations')
ylabel('Function maximum')
function f = get_stalagmite
x = linspace(0,0.6,250);
y = linspace(0,0.6,250);
[X,Y] = meshgrid(x,y);
% Evaluating the stalagmite function
for i = 1:length(X)
for j = 1:length(Y)
input_vec(1) = X(i,j);
input_vec(2) = Y(i,j);
f(i,j) = stalagmite(input_vec);
end
end
end
function input = stalagmite(vec)
x = vec(1);
y = vec(2);
fx1 = [sin(5.1*pi*x+0.5)]^6 ;
fy1 = [sin(5.1*pi*y+0.5)]^6 ;
fx2 = exp((-4)*log(2)*((x - 0.0067)^2)/0.64);
fy2 = exp((-4)*log(2)*((y - 0.0067)^2)/0.64);
input = -(fx1 * fx2 * fy1 * fy2);
end
Output :
Leave a comment
Thanks for choosing to leave a comment. Please keep in mind that all the comments are moderated as per our comment policy, and your email will not be published for privacy reasons. Please leave a personal & meaningful conversation.
Other comments...
Flow over a Throttle body - Using CONVERGE CFD
I. Introduction: In this Project, A Steady & Transient state simulation is done of a Flow through an Elbow joint consisting of a throttle valve. The steady state case is solved with the Throttle valve fully open until convergence is reached. While the Transient case is ran with the throttle valve rotating i.e…
18 Sep 2020 08:29 PM IST
Literature review – RANS Derivation and analysis
Introduction: The Reynolds-averaged Navier–Stokes equations (or RANS equations) are time-averaged equations of motion for fluid flow. The idea behind the equations is Reynolds decomposition, whereby an instantaneous quantity is decomposed into its time-averaged and fluctuating quantities,…
18 Sep 2020 08:28 PM IST
C.H.T Analysis on a Graphic card using ANSYS FLUENT
I. Introduction : In this project, A steady state conjugate heat transfer analysis on a Graphic card model is done. Graphic card has become an everyday used object and a very importat part of any computer system, laptops etc. This product is mass produced daily in millions and has made computers exceptionally efficient.…
18 Sep 2020 08:23 PM IST
Aerodynamics : Flow around the Ahmed Body using ANSYS FLUENT
I. Introduction : Automotive aerodynamics comprises of the study of aerodynamics of road vehicles. Its main goals are reducing drag, minimizing noise emission, improving fuel economy, preventing undesired lift forces and minimising other causes of aerodynamic instability at high speeds. Also, in order to maintain…
18 Sep 2020 08:21 PM IST
Related Courses
0 Hours of Content
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.