All Courses
All Courses
OBJECTIVE : Writing Matlab code the concept of genetic algorithm & optimize the stalagmite function and find the GLOBAL MAXIMA of the function. GENETIC ALGORITHM : The genetic algorithm is amethod for solving both constrained and unconstrained optimization problems that is based on natural selection,the…
Babilu M S
updated on 16 Nov 2021
OBJECTIVE :
Writing Matlab code the concept of genetic algorithm & optimize the stalagmite function and find the GLOBAL MAXIMA of the function.
GENETIC ALGORITHM :
The genetic algorithm is amethod for solving both constrained and unconstrained optimization problems that is based on natural selection,the process that drives biological evolution.The genetic algorithm repeatedly modifies a population of individual solutions.At each step, the genetic algorithm selects individuals at random from the current population to be parents and uses them to produce the children for the next generation.Over successive generations, the population "evolves" towards an optimal solution.You can apply the genetic algorithm to solve a variety of optimization problems that are not well suited for standard optimization algorithms,including problems in which the objective function is discontinuous,nondifferentiable,stochastic or highly nonlinear.The genetic algorithem can address problems of mixed-integer programming,where some components are restricted to be integer-valued.
The genetic algorithm uses three main types of rules at each step to create the next generation from the current population:
OPTIMIZATION :
Optimization is the process of making something better.In any process we have a set of inputs and set of outputs.
Optimization refers to finding the values of input such a way that we get the "best" output values.The defenition of the "best" varies from prpblem to problem,but in the mathematical terms,it refers to maximizing or minimizing one or more objective functions by varing the input parameters
The set of all possible input values which the input can take make up the search space.In such a space, lies apoint or set of points which gives the optimal solution. The aim of optimization to find tha point or set of point in the search space
GLOBAL MAXIMA:
A global maximum, also known as an absolute maximum the largest overall value of a set,function,etc.. over its entire range . It is impossible to construct an algorithm that will find global maximaum for an arbitary function.SEE also Global Minimum,Local Maxima,Maximum.
MAIN PROGRAM:
% Define search space
x = linspace(0,0.6,150);
y = linspace(0,0.6,150);
num_cases = 50
% calculating 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);
GA(i,j) = stalagmite(input_vector);
end
end
% case 1
% study1-statical behaviour
tic
for i = 1:num_cases
[input, GA_opt(i)] = ga(@stalagmite,2);
xopt(i) = input(1);
yopt(i) = input(2);
end
study1_time = toc
%Plotting the graph
figure(1)
subplot(2,1,1)
hold on
surfc(x,y,-GA)
shading interp
plot3(xopt,yopt,-GA_opt,'marker','o','markersize',5,'markerfacecolor','r')
title('Unbounded inputs')
subplot(2,1,2)
plot(-GA_opt)
xlabel('Iteration')
ylabel('Function Minium')
%% statistical behaviour - with upper & lower bounds
% tic_toc command for calculating the itration time
tic
for i = 1:num_cases
[input, GA_opt(i)] = ga(@stalagmite,2,[],[],[],[],[0,0],[1,1]);
xopt(i) = input(1);
yopt(i) = input(2);
end
study2_time = toc
%plotting the Graph
figure(2)
subplot(2,1,1)
hold on
surfc(x,y,-GA)
shading interp
plot3(xopt,yopt,-GA_opt,'marker','o','markersize',5,'markerfacecolor','r')
title('Bounded inputs')
subplot(2,1,2)
plot(-GA_opt)
xlabel('Iteration')
ylabel('Function Minium')
%% study-3
%calculating the optimum solution for 'ga' and save in options(variable)
options = optimoptions('ga');
%increasing the size of population
options = optimoptions(options,'PopulationSize',240);
%tic_toc command for calculating the itraction time
tic
for i = 1:num_cases
[input, GA_opt(i)] = ga(@stalagmite,2,[],[],[],[],[0;0],[1;1],[],[],options);
xopt(i) = input(1);
yopt(i) = input(2);
end
study3_time = toc
%plotting the Graph
figure(3)
subplot(2,1,1)
hold on
surfc(x,y,-GA)
shading interp
plot3(xopt,yopt,-GA_opt,'marker','o','markersize',5,'markerfacecolor','r')
title('Bounded inputs')
subplot(2,1,2)
plot(-GA_opt)
xlabel('Iteration')
ylabel('Function Minium')
PROCEDURE:
step1: Assigning the input values range value of x & y is 0,0.6,150 values with the command of linspace for both x & y
2:mesh grid command used to create the grid size of these vale 150 * 150 dimension.
xx =150*150
yy =150*150
3:For loop are used to define the value in a range of [xx],[yy] according to that its run the defined value.
4:command with tic & toc used to calculate the simulation time
5:using shading interp so that we do not get lines over the graph and we get a smooth plot on it.
6:seperate function should be used to calculate the stalagmite and its call to the main function.
formula to using in stalagimite function
Stalagmite Function code:
function [GA] = stalagmite(input_vector)
x = input_vector(1);
y = input_vector(2);
term1 = pi*5.1*x;
term2 = pi*5.1*y;
term3 = ((x-0.0667)^2/0.64);
term4 = ((y-0.0667)^2/0.64);
term5 = (-4)*log(2);
xf1 = (sin(term1+0.5)).^6;
yf1 = (sin(term2+0.5)).^6;
xf2 = exp(term5*term3);
yf2 = exp(term5*term4);
GA = -(xf1*yf1*xf2*yf2);
end
Study1 : OUTPUT
STUDY1 time = 3.6284
From the above fig,it shows that its not clearly to define the maximum values due to a lot of minimum value it has been defined
STUDY2 : output
STUDY2 time = 4.0473
In study 2 shows that with the same procedure are followed to improve the result to find the global maxima with lower bonds variable are provided
with the help of tic and toc command used to calculate the simulation time
The empty brackets are used to read the linear equality and in equality.
STUDY3 : OUTPUT
STUDY3 TIME = 12.2018
In study3 we have another constraint function as options as it helps us to increase the population to increase the size,Getting the local minima and maxima
With the help of tic and toc command used to calculate the simulation time
ERRORS :
CONCLUSION:
From the above results we clearly see that optimizing the global maxima with various studies in that we need to get accurate value means we need to increase through the population options to get required output according to the value.
REFERENCE :
https://skill-lync.com/knowledgebase/genetic-algorithm-explained
https://www.tutorialspoint.com/genetic_algorithms/genetic_algorithms_introduction.htm
GOOGLE DRIVE :
https://drive.google.com/drive/folders/1D4Gdoktia7mQ_n2sWNPy55vkk1Z4TwFW?usp=sharing
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...
Underbody Coating
UNDER BODY COATING: We all are aware of the fact that the underbody of the previous models was made from durable metals such as steel, which is easily damaged and oxidized, forming rust While you are sitting on the driving seat enjoying the smooth ride, the underbody of your car is always exposed to muddy water, stones,…
11 Jul 2022 01:11 PM IST
Benchmarking
BENCHMARKING Benchmarking is a process of measuring the performance of a company's products, services, or processes against those of another business considered to be the best in the industry, "best in class." The point of benchmarking is to identify internal opportunities for improvement. By studying companies with…
11 Jul 2022 12:16 PM IST
Advanced Sheet Metal Design Using NX Cad Challenge_7_ Metal bracket-II
Advanced Sheet Metal Design Using NX Cad Challenge_7_ Meal bracket-11 Objective: The objective of this challenge is to design a metal bracket with mentioned tools and measurements in Sheet metal Application of Siemens NX. Introduction: A Bracket is a component used to support load or any attachments to structural…
06 Jul 2022 06:52 AM IST
Advanced Sheet Metal Design Using NX Cad Challenge_6_Bracket
Title of the project:- Advanced Sheet Metal Design Using NX Cad Challenge_6_Bracket Objective: To design a Bracket using Siemens NX Sheet metal application. Introduction:- 1. SIEMENS NX:- NX formerly known as "unigraphics", is an advanced high-end CAD/CAM/CAE, which has been owned since 2007 by Siemens PLM Software.…
06 Jul 2022 06:16 AM IST
Related Courses
0 Hours of Content