Project

Find the maxima of stalagmite function by applying global optimization method

1. In your own words, describe how Genetic Algorithm Works.

Ans>> Genetic algorithm is based on the ideas of natural selection and genetics, to solve optimization problems they use random search.The genetic algorithm is so designed that they can simulate the natural process of selection necessary for evolution followed by the principles of CHARLES DARWIN.It simulates the survival of the fittest among individuals over a consecutive generation for solving a problem.

The population of the individual are maintained in the GA\'s search space ,each showing representing the possible solution,the algorithm uses the individuals in the current generation to create the next population in each step.Following steps are maintained to create new piopulation.

a) Fitness value of each member of the current population is measured.

b) Scales the raw fitness scores to convert them into a more usable range of values.

c) Members are selected based on their expectation.

d) Some of the individuals which have their lower fitness value are passed to the next generation.

e) Children are produced either by making random changes to a single parent—mutation—or by combining the vector entries of a pair of parents—crossover.

The algorithm stops under some certain conditions.when any of the below given conditions are met the algorithm stops.

a) When the number of generation reaches the value of generation.

b) When the time limit is reached.

c) When fitness function for the best point in the current population is less than or equal to fitness value.

d) when the average relative change in the fitness function value over stall generation is less than Functional tolerance.

<<<<>>>>

%Global optimization

clear all
close all
clc

%Defining our search space

x=linspace(0,1,150);
y=linspace(0,1,150);

%Creating a 2D-mesh

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

%Increasing the GA iteration

options=optimoptions(\'ga\');
options=optimoptions(options,\'PopulationSize\',170);


%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

%sample

surfc(xx,yy,f)
title(\'stalagmite function\')
xlabel(\'x values\')
ylabel(\'y values\')
zlabel(\'z values\')
shading interp

[inputs,fval]=ga(@stalagmite,2,[],[],[],[],[0;0],[1;1],[],[],options)

fprintf(\'The maximum value is: %g \\n\',fval);
fprintf(\'x value: %g \\n\', inputs(1));
fprintf(\'y value: %g \\n\', inputs(2));





<<<>>>>

%Stalagmite functiion

function [f_xy] = stalagmite(input_vec)

 f_1x=(sin(5.1*pi*input_vec(1) + 0.5))^6;
 f_1y=(sin(5.1*pi*input_vec(2) + 0.5))^6;
 f_2x=exp(-4*log(2) * (input_vec(1)-0.0667)^2/(0.64));
 f_2y=exp(-4*log(2) * (input_vec(2)-0.0667)^2/(0.64));
 
 %Formula

 f_xy=- f_1x * f_1y* f_2x* f_2y;
 
end
Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.