Anniversary Scholarship 2025: up to ₹79,000 | 6 Guaranteed Job Interviews | Limited to 100 Seats. Apply Now

00D 00H 00M 00S

Menu

Executive Programs

Workshops

Projects

Blogs

Careers

Placements

Student Reviews


For Business


More

Academic Training

Informative Articles

Find Jobs

We are Hiring!


All Courses

Choose a category

Mechanical

Electrical

Civil

Computer Science

Electronics

Offline Program

All Courses

All Courses

logo

CHOOSE A CATEGORY

Mechanical

Electrical

Civil

Computer Science

Electronics

Offline Program

Top Job Leading Courses

Automotive

CFD

FEA

Design

MBD

Med Tech

Courses by Software

Design

Solver

Automation

Vehicle Dynamics

CFD Solver

Preprocessor

Courses by Semester

First Year

Second Year

Third Year

Fourth Year

Courses by Domain

Automotive

CFD

Design

FEA

Tool-focused Courses

Design

Solver

Automation

Preprocessor

CFD Solver

Vehicle Dynamics

Machine learning

Machine Learning and AI

POPULAR COURSES

coursePost Graduate Program in Hybrid Electric Vehicle Design and Analysis
coursePost Graduate Program in Computational Fluid Dynamics
coursePost Graduate Program in CAD
coursePost Graduate Program in CAE
coursePost Graduate Program in Manufacturing Design
coursePost Graduate Program in Computational Design and Pre-processing
coursePost Graduate Program in Complete Passenger Car Design & Product Development
Executive Programs
Workshops
For Business

Success Stories

Placements

Student Reviews

More

Projects

Blogs

Academic Training

Find Jobs

Informative Articles

We're Hiring!

phone+91 9342691281Log in
  1. Home/
  2. Mohan Babu H/
  3. Week 4.1 - Genetic Algorithm

Week 4.1 - Genetic Algorithm

  Matlab Program to optimise the stalagmite function and finding the global maxima   1.Basics Concepts:   1.1 optimization: Optimization is the area of study which is used to maximize or minimize the particular function, which depends upon multiple parameters to get the desired the output. 1.2 Stalagmite…

    • Mohan Babu H

      updated on 27 Aug 2021

     

    Matlab Program to optimise the stalagmite function and finding the global maxima

     

    1.Basics Concepts:

     

    1.1 optimization:

    Optimization is the area of study which is used to maximize or minimize the particular function, which depends upon multiple parameters to get the desired the output.

    1.2 Stalagmite Mathematical model:

    Stalagmite Mathematical model used to develop the local maxima or minima . Here to determine the optimum solution of the maxima of the function by using the Genetic algorithm technique.

    1.3 Genetic algorithm:

    Genetic algorithm is an optimization technique use to slove Non-linear and Non-differential optimization problems.The name derived from Evolution Biology Technique(Darwin’s Theory of Evolution)

    It starts with a initial generation of a candidate solution that is tested against the objective function. Subsequent Generation evolves from the first through selection crossover and mutation, which continues until the cycle stop with true value

    Initialization

     

    Selection


    Crossover

     

    Mutation

    Let, take a exampleSelection:In this we are selecting best Performing bit strings from one generation to another generation .i.e based on the fitness

    Here we have two parents who have good performance so selecting them based on fitness

    1.parent1 =[1 0 1 0 0 1 1 0 0 0]

    2.parent2 =[1 0 0 1 0 0 1 0 1 0]

    Crossover:Due to they performed well ,therefore taking between them to create a child as shown below

    1.parent1 =[1 0 1 0 0 1 1 0 0 0]

    2.parent2 =[1 0 0 1 0 0 1 0 1 0]

    3.child =[1 0 0 0 0 1 1 0 1 0]

    Mutation:Taking parent and mutate certain variable and create a child based on mutation I.e in mutation we are adding other qualities to thechild

    2.Procedure:

    To solve the global optimization problem we are using the stalagmite Mathematical model which is used to develop the local maxima and minima ,but in our problem we have to get global maxima of the function hence we are using genetic algorithm

    2.1 Initialization

    First we are defining our search space and creating the one dimensional array Xand Y with linspace command then Xand y are the inputs array does not define the workspace for thegenetic algorithm as follows

    x=linspace(0,0.6,150):

    y=linspace(0,0.6,150):

    Where:

    0 is an initial value

    0.6 is an final value at last

    150 is number of terms

    Now creating the two-dimensional array using meshgrid as follows:

    [xx,yy]=meshgrid(x,y);

    for each value of x and y ,we are going to create a input vector (row vector) I.e has two coloumns

    Note: the command line [xx,yy]=meshgrid(x,y) is to beused in seperate function name as “stalagmite_function” which explanation we can get in error and elimination section further.

    Further we are using the for loop to getthe same action multiple times

    for i=1:length(x)

    for j=1:length(y)

    input_vector(1)=xx(i,j);

    input_vector(2)=yy(i,j);

    f(i,j)=stalagmite_function(input_vector);

    end

    end

    where the stalagmite is a seperate function which is based on the formula as follows:

    1_x=(sin(5.1*pi*x+0.5)).^6;

    f2_y=(sin(5.1*pi*y+0.5)).^6;

    f3_x=exp((-4*0.6931).*(x-0.0667)^2/(0.64));

    f4_y=exp((-4*0.6931).*(x-0.0667)^2/(0.64));

    stalagmite=(f1_x.*f2_y.*f3_x.*f4_y)

    in main program we are going to use the one dimensional arrays xand y with linspace command and we know that x and y are input array it does not define the workspace for the workspace for the genetic algorithm

     

    Program for different optimization studies:

    In this program we are going to do three study

    Initially ,we use to one dimensional array x and y with linspace command as we know that x and y are the input array and does not define the workspace of the genetic algorithm ,Here weare using the component used in the program as well

    Study_1:

    In this ,we are calling the ga function and passing a number of variables as an input which is equal to 2 and strong x andy value also the (fopt) the optimum value which the function is produced with out boundary condition

    After opening the new figure window [figure1] and creating the subplot (which creates the multiple plots in the same figure window)The first plot is surf command of optimum value predicts over a 50 studiesThe second plot is which directly optimum value is get plotted as a function of iteratations

    Study_2:

    In study 2 we are going to use the upper and lowerlimits which is known as upper and lower bounds The syntax use is based on our reffered syntax section

    Study_3:

    To optimize the result and getting more accuracy we are increasing the iteration in genetic algorithm. Because by default the ga takes 50value .here we are going to increase the population size because if initial population is too small then it is not going to find out global maxima or minima .it only finds the local minima ans maxima

     

     

    1.Study_12.Study_23.Study_3

    % To find global maxima forastalagmote function
    
    clear all
    close all
    clc
    % input
    x=linspace(0,0.6,150);
    y=linspace(0,0.6,150);
    num_cases=50
    
    % 2d forming array
    [xx,yy]=meshgrid(x,y);
    % Evaluating the stalagmite_function
    for i=1:length(x)
        for j=1:length(y)
           input_vector(1)=xx(i,j);
           input_vector(2)=yy(i,j);
           f(i,j)=stalagmite_function(input_vector);
         end
       end
    
    
    tic
    % study 1- stalagmite behaviour with out any specified boundries
    for i =1:num_cases
    [inputs,fopt1(i)]=ga(stalagmite_function,2);
    xopt1(i)=inputs(1);
    yopt1(j)=inputs(2);
    end
    study1_time=toc
    
    figure(1)
    subplot(2,1,1)
    hold on
    surfc(x,y,f)
    shading interp
    plot3(xopt1,yopt1,fopt1,'Marker','o','markersize',5,'markerfacecolor','r');
    title('unbounded inputs')
    subplot(2,1,2)
    plot(fopt1)
    xlabel('iterations')
    ylabel('function minimum')
    
    tic
    % study 2- stalagmite behaviour-with upper and lower bounds
    for i=1:num_cases
        [inputs,fopt2(i)]=ga(@stalagmite_function,2,[],[],[],[],[0,0],[0.6,0.6]);
        xopt2(i)=inputs(1)
        yopt2(j)=inputs(2)  
    end
    time2_study=toc
    figure(2)
    subplot(2,1,1)
    hold on
    surfc(x,y,f)
    shading interp
    plot3(xopt2,yopt2,fopt2,'Marker','o','markersize',5,'markerfacecolor','r');
    title('bounded inputs')
    subplot(2,1,2)
    plot(fopt2)
    xlabel('iterations')
    ylabel('function minimum')
    
    tic
    % study3-increaasing GA iterations with specified boundaries
    for i=1:num_cases
        [inputs,fopt3(i)]=ga(@stalagmite_function,2,[],[],[],[],[0,0],[0.6,0.6],[],[],option);
        xopt3(i)=inputs(1)
        yopt3(j)=inputs(2)
    end
    
    time3_study=toc
    figure(3)
    subplot(2,1,1)
    hold on
    surfc(x,y,f)
    shading interp
    plot3(xopt3,yopt3,fopt3,'Marker','o','markersize',5,'markerfacecolor','r');
    title('increasing GA iterations')
    subplot(2,1,2)
    plot(fopt3)
    xlabel('iterations')
    ylabel('function minimum')
    
    
    
    % Declaration of stalagmite function
    
    function [stalagmite]=stalagmite_function(input_vector)
    x=input_vector (1)
    y=input_vector (2)
    f1_x=(sin(5.1*pi*x+0.5)).^6;
    f2_y=(sin(5.1*pi*y+0.5)).^6;
    f3_x=exp((-4*0.6931).*(x-0.0667)^2/(0.64));
    f4_y=exp((-4*0.6931).*(x-0.0667)^2/(0.64));
    stalagmite=(f1_x.*f2_y.*f3_x.*f4_y)
    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.

    Please  login to add a comment

    Other comments...

    No comments yet!
    Be the first to add a comment

    Read more Projects by Mohan Babu H (24)

    Week 2 : Basic Calibration of Single cylinder SI-Engine

    Objective:

    Aim: * The Main objective of this project is to set up and run the model for a single cylinder four stroke SI Engine at 1800 rpm *  To run the same model at 3600 rpm and increases the power - output by 10%   Introduction: The Spark ignition (SI) engine is an internal combustion engine , where the air fuel mixture…

    calendar

    06 Jan 2023 01:38 PM IST

      Read more

      Week 1 : Exploring the GUI of GT-POWER

      Objective:

      Aim: To  Explore the GUI of GT-suite and GT-power and explaining the listed the modules in a brief description. GT-Suite: The tool which is used to industry leading simulation tool with capabilities and libraries aimed at a large set of applications in industries. It offers engineering functionalist ranging fast concept…

      calendar

      22 Nov 2022 02:01 PM IST

      • BIM
      • CAE
      • CFD
      • DESIGN
      • FEA
      • GT-POWER
      • GT-SUITE
      • HEV
      • Structural Analysis
      Read more

      Week 11: Project 2 - Emission characterization on a CAT3410 engine

      Objective:

      Aim: To Perform Emission Characterization on a CAT3410 Engine. Objective: To run a 3D Simulation of a CAT3410 Diesel Engine using two different piston bowl profiles and to understand the effect of Piston Bowl geometry on the Performance ans Emission characteristics of the Engine. Geometry: A tool called Make Engine Sector…

      calendar

      04 Nov 2022 10:55 AM IST

        Read more

        Week 10: Project 1 - FULL HYDRO case set up (PFI)

        Objective:

        Aim: To set up a combustion  Simulation with the details given in the challenge and to study different properties of combustion by Post Processing the results  obtained by the calculation of the full hydrodynamic set up of the given geometry. Objective: * What is the compression ratio of this engine? * Why do…

        calendar

        21 Oct 2022 09:11 PM IST

        • CFD
        Read more

        Schedule a counselling session

        Please enter your name
        Please enter a valid email
        Please enter a valid number

        Related Courses

        coursecard

        Design loads considered on bridges

        Recently launched

        10 Hours of Content

        coursecard

        Design of Steel Superstructure in Bridges

        Recently launched

        16 Hours of Content

        coursecard

        Design for Manufacturability (DFM)

        Recently launched

        11 Hours of Content

        coursecard

        CATIA for Medical Product Design

        Recently launched

        5 Hours of Content

        coursecardcoursetype

        Accelerated Career Program in Embedded Systems (On-Campus) Courseware Partner: IT-ITes SSC nasscom

        Recently launched

        0 Hours of Content

        Schedule a counselling session

        Please enter your name
        Please enter a valid email
        Please enter a valid number

        logo

        Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.

        https://d27yxarlh48w6q.cloudfront.net/web/v1/images/facebook.svghttps://d27yxarlh48w6q.cloudfront.net/web/v1/images/insta.svghttps://d27yxarlh48w6q.cloudfront.net/web/v1/images/twitter.svghttps://d27yxarlh48w6q.cloudfront.net/web/v1/images/youtube.svghttps://d27yxarlh48w6q.cloudfront.net/web/v1/images/linkedin.svg

        Our Company

        News & EventsBlogCareersGrievance RedressalSkill-Lync ReviewsTermsPrivacy PolicyBecome an Affiliate
        map
        EpowerX Learning Technologies Pvt Ltd.
        4th Floor, BLOCK-B, Velachery - Tambaram Main Rd, Ram Nagar South, Madipakkam, Chennai, Tamil Nadu 600042.
        mail
        info@skill-lync.com
        mail
        ITgrievance@skill-lync.com

        Top Individual Courses

        Computational Combustion Using Python and CanteraIntroduction to Physical Modeling using SimscapeIntroduction to Structural Analysis using ANSYS WorkbenchIntroduction to Structural Analysis using ANSYS Workbench

        Top PG Programs

        Post Graduate Program in Hybrid Electric Vehicle Design and AnalysisPost Graduate Program in Computational Fluid DynamicsPost Graduate Program in CADPost Graduate Program in Electric Vehicle Design & Development

        Skill-Lync Plus

        Executive Program in Electric Vehicle Embedded SoftwareExecutive Program in Electric Vehicle DesignExecutive Program in Cybersecurity

        Trending Blogs

        How to Learn CAD Design: Step-by-Step GuideGD&T Basics: How to Read and Apply GD&T Symbols SolidWorks vs Creo: Best CAD Software to Learn for Mechanical Engineers Engineering Edtech in India: Busting Myths & Building Careers How to Get a Core Mechanical Engineering Job After Graduation

        © 2025 Skill-Lync Inc. All Rights Reserved.

                    Do You Want To Showcase Your Technical Skills?
                    Sign-Up for our projects.