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

Loading...

All Courses

All Courses

logo

Loading...
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. Yogessvaran T/
  3. Week 4.1 - Genetic Algorithm

Week 4.1 - Genetic Algorithm

CODE : Function code : function [f] = stalagmite(input_vector)x = input_vector(1);y = input_vector(2); f1_x = (sin((5.1*pi*x)+0.5)).^6; f1_y = (sin((5.1*pi*y)+0.5)).^6; f2_x = exp(((-4*log(2))*(x-0.0667).^2)/0.64); f2_y = exp(((-4*log(2))*(y-0.0667).^2)/0.64); [f] = -(f1_x.*f1_y.*f2_x.*f2_y); end Main code : clear all…

    • Yogessvaran T

      updated on 12 Aug 2022

    CODE :

    Function code :

    function [f] = stalagmite(input_vector)
    x = input_vector(1);
    y = input_vector(2);

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

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

    f2_x = exp(((-4*log(2))*(x-0.0667).^2)/0.64);

    f2_y = exp(((-4*log(2))*(y-0.0667).^2)/0.64);

    [f] = -(f1_x.*f1_y.*f2_x.*f2_y);

    end


    Main code :

    clear all

    close all

    clc

    %Defining our search space

    x = linspace(0,0.6,150);

    y = linspace(0,0.6,150);

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

    num_cases = 80 ;

    %calling 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

    %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(1)

    subplot(2,1,1)

    hold on

    surfc(xx,yy,f)

    shading interp

    title('Unbound inputs')

    xlabel('X values')

    ylabel('Y values')

    plot3(xopt,yopt,fopt,'marker','o','markersize',5,'markerfacecolor','r')

    subplot(2,1,2)

    plot(fopt)

    xlabel('Iterations')

    ylabel('Function maximum')

     

    %Study 2 - Statistical behavior with upper and lower bounds

    tic

    for i=1:num_cases

    [inputs, fopt(i)] = ga(@stalagmite,2,[],[],[],[],[0;0],[0.6;0.6]);

    xopt(i) = inputs(1);

    yopt(i) = inputs(2);

    end

     

    study2_time = toc

    figure(2)

    subplot(2,1,1)

    hold on

    surfc(xx,yy,f)

    shading interp

    title('Bounded inputs')

    xlabel('X values')

    ylabel('Y values')

    plot3(xopt,yopt,fopt,'marker','o','markersize',5,'markerfacecolor','r')

    subplot(2,1,2)

    plot(fopt)

    xlabel('Iterations')

    ylabel('Function maximum')

    %Study 3 - Increasing GA iterations

    options = optimoptions('ga')

    options = optimoptions(options,'populationSize',200)

    tic

    for i=1:num_cases

    [inputs, fopt(i)] = ga(@stalagmite,2,[],[],[],[],[0;0],[0.6;0.6],[],[],options);

    xopt(i) = inputs(1);

    yopt(i) = inputs(2);

    end

    study3_time = toc

    figure(3)

    subplot(2,1,1)

    hold on

    surfc(xx,yy,f)

    shading interp

    xlabel('X values')

    ylabel('Y values')

    plot3(xopt,yopt,fopt,'marker','o','markersize',5,'markerfacecolor','r')

    subplot(2,1,2)

    plot(fopt)

    xlabel('Iterations')

    ylabel('Function maximum')

     

    STEPS :

    The code starts with defining x and y as inputs using linspace

    A function known as Stalagmite_func is defined as hown in the 2nd stage of codes.

    2 for loops are incorporated in the main code so that all the combinations of x and y values is taken in the stalagmite_func

    function

    In the 1st study GA function runs for 80 iterations. Plots of the stalagmites and maximum values generated in each iteration

    is shown.

    In the 2nd study GA function is incorporated with lower and upper bounds and runs for 80 iterations. Plots of the stalagmites

    and maximum values generated in each iteration is shown.

    In the 3rd study GA function is incorporated with lower and upper bounds along with the population size of 200. Plots of the

    stalagmites and maximum values generated in each iteration is shown.

    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 Yogessvaran T (50)

    Week 14 challenge

    Objective:

    ASSEMBLY OF BUTTERFLY VALVE:- 1.All the parts that are saved in the required folder is opened in the Add components tool box. 2.Now using the Move option and Assembly Constraints option the different parts are joined together with the help of Align,touch,infer/Axis operations. 3. Finally,the assembly of butterfly valve…

    calendar

    18 Feb 2023 09:34 AM IST

      Read more

      Project - Position control of mass spring damper system

      Objective:

      To design a closed loop control scheme for a DC motor the following changes need to be done in the model in the previously created model. Speed is the controllable parameter, so we will set the reference speed in step block as 10,20, 40 whichever you want.  Subtract the actual speed from the reference speed to generate…

      calendar

      21 Jan 2023 10:29 AM IST

      • MATLAB
      Read more

      Project - Analysis of a practical automotive wiring circuit

      Objective:

      Identify each of the major elements in the above automotive wiring diagram.  Ans: Major Elements in the above automotive wiring diagram are - Genarator,                   Battery,              …

      calendar

      14 Dec 2022 03:37 AM IST

        Read more

        Week 6 - Data analysis

        Objective:

        -

        calendar

        04 Dec 2022 11:06 AM IST

          Read more

          Schedule a counselling session

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

          Related Courses

          coursecardcoursetype

          Accelerated Career Program in Embedded Systems (On-Campus) - Powered by NASSCOM

          Recently launched

          0 Hours of Content

          coursecard

          5G Protocol and Testing

          Recently launched

          4 Hours of Content

          coursecard

          Automotive Cybersecurity

          Recently launched

          9 Hours of Content

          coursecardcoursetype

          Pre-Graduate Program in Bioengineering and Medical Devices

          Recently launched

          90 Hours of Content

          coursecardcoursetype

          Pre-Graduate Program in 5G Design and Development

          Recently launched

          49 Hours of Content

          Schedule a counselling session

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

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