All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Main code clear all close all clc % Input variables x = linspace(0, 0.6, 150); y = linspace(0, 0.6, 150); num_case = 250; % creating an arraay [xx, yy] = meshgrid(x,y); % loop for passing 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…
Aatas A G
updated on 10 Nov 2021
Main code
clear all
close all
clc
% Input variables
x = linspace(0, 0.6, 150);
y = linspace(0, 0.6, 150);
num_case = 250;
% creating an arraay
[xx, yy] = meshgrid(x,y);
% loop for passing 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(x , y , -f)
colorbar
xlabel('x values')
ylabel('y values')
zlabel('function values')
title('stalagmite function')
shading interp
[x_output , fval] = ga(@stalagmite , 2);
% case study 1
tic
for i = 1 : num_case
[inputs , f_optima(i)] = ga(@stalagmite , 2)
x_optima(i) = inputs(1);
y_optima(i) = inputs(2);
end
case1 = toc;
figure(2)
subplot(2,1,1)
surfc(x , y, -f)
shading interp
xlabel('x values')
ylabel('y values')
zlabel('function values')
hold on
plot3(x_optima, y_optima, -f_optima, 'marker', 'o', 'markersize', 5, 'markerfacecolor', 'g')
title('unbounded input')
subplot(2, 1, 2)
plot(-f_optima);
xlabel('number of iterations')
ylabel('max. value of the function')
% case study 2
tic
for i = 1 : num_case
[inputs , f_optima(i)] = ga(@stalagmite , 2, [], [], [], [], [0;0], [0.5;0.5]);
x_optima(i) = inputs(1);
y_optima(i) = inputs(2);
end
case2 = toc;
figure(3)
subplot(2,1,1)
surfc(x , y, -f)
shading interp
xlabel('x values')
ylabel('y values')
zlabel('function values')
hold on
plot3(x_optima, y_optima, -f_optima, 'marker', 'o', 'markersize', 5, 'markerfacecolor', 'g')
title('unbounded input')
subplot(2, 1, 2)
plot(-f_optima);
xlabel('number of iterations')
ylabel('max. value of the function')
% case study 3
options = optimoptions('ga');
options = optimoptions(options, 'populationsize', 250);
tic
for i = 1 : num_case
[inputs , f_optima(i)] = ga(@stalagmite , 2, [ ], [ ], [ ], [ ], [0;0], [0.5 ; 0.5], [ ], [ ],options);
x_optima(i) = inputs(1);
y_optima(i) = inputs(2);
end
case3 = toc;
figure(4)
subplot(2,1,1)
surfc(x , y, -f)
shading interp
xlabel('x values')
ylabel('y values')
zlabel('function values')
hold on
plot3(x_optima, y_optima, -f_optima, 'marker', 'o', 'markersize', 5, 'markerfacecolor', 'g')
title('unbounded input')
subplot(2, 1, 2)
plot(-f_optima);
xlabel('number of iterations')
ylabel('max. value of the function')
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(-4*log(2)*((x- 0.0667)^2)/0.64);
f2y = exp(-4*log(2)*((y - 0.0667)^2)/0.64);
f = - f1x*f1y*f2x*f2y;
end
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...
Week 4 - CHT Analysis on Exhaust port
AIM: To perform the simulation of Conjugate heat transfer analysis on given exhaust port geometry by using ANSYS FLUENT. OBJECTIVE: To study the importance of Conjugate heat transfer analysis and importance of y+ value during meshing of the components. To perform the simulation of Conjugate heat transfer analysis on given…
12 Dec 2022 08:19 AM IST
Week 10 - Simulating Combustion of Natural Gas.
AIM To perform a combustion simulation on the combustor model. Objective Part I Perform a combustion simulation on the combustor model and plot the variation of the mass fraction of the different species’ in the simulation using line probes at different locations of the combustor as shown in Fig. You need to plot…
07 Dec 2022 11:26 AM IST
Week 9 - Parametric study on Gate valve.
Aim: To perform a parametric study on Gate valve. Objective: Simulate the flow of fluid through a gate valve. Perform the parametric study on the gate valve by setting design points corresponding to the positions of the lift of the spindle. Calculate the mass flow rate corresponding to all the design points Gate…
07 Dec 2022 10:12 AM IST
Project 2
AIM: To deal with the development of a forward energy-based fuel consumption model of a P1 hybrid vehicle. OBJECTIVE: Load the Project2 folder as the Current Folder in Matlab. Run the “Project2_InitFile.m” Matlab script. Copy the Conventional vehicle Simulink model created for Project 1 in this folder. Figure…
25 Oct 2022 01:11 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.