Project

Genetic algorithm

%A PROGRAM TO CALCULATE GLOBAL MAXIMA OF A STALAGMITE FUNCTION

clear all
close all
clc

%Defining our search space
x = linspace(0,0.6,150);
y = linspace(0,0.6,150);

%Getting a 2D 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);
    f(i,j) = stalgmite(input_vector);
end
end

%surfc(xx,yy,f)
xlabel(\'xvalue\')
ylabel(\'yvalue\')

shading interp
[inputs, fval] = ga(@stalagmite, 2)

OUTPUT GRAPH

\"\"

PROGRAM REPORT:

INTRODUCTION:

A program to optimize the stalagmite function and to find the global maxima of the function should be written.

GENETIC ALGORITHM:

The genetic algorithm is a method 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.

SYNTAX FOR GENETIC ALGORITHM:

The following are some of the syntax of genetic algorithm:

x = ga(fun,nvars)

x = ga(fun,nvars,A,b)

x = ga(fun,nvars,A,b,Aeq,beq)

x = ga(fun,nvars,A,b,Aeq,beq,lb,ub)

x = ga(fun,nvars,A,b,Aeq,beq,lb,ub,nonlcon)

x = ga(fun,nvars,A,b,Aeq,beq,lb,ub,nonlcon,options)

x = ga(fun,nvars,A,b,[],[],lb,ub,nonlcon,IntCon)

x = ga(fun,nvars,A,b,[],[],lb,ub,nonlcon,IntCon,options)

x = ga(problem)

[x,fval] = ga(___)

[x,fval,exitflag,output] = ga(___)

[x,fval,exitflag,output,population,scores] = ga(___)

ERRORS FACED:

No errors detected.

CONCLUSION:

The program to optimize the stalagmite function and to calculate the global maxima of the function is written.

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.