Project

Genetic Algorithm using Matlab

This Problem is to write a program on Generic Algorithm using Matlab.

The Program Code is;

function[f] = stalagmite(input_vector)

f1x = (sin(5.1*pi*input_vector(1) + 0.5)).^6;

f1y = (sin(5.1*pi*input_vector(2) + 0.5)).^6;

f2x = exp((-4*log(2))*((input_vector(1) - 0.0667).^2)/0.64);

f2y = exp((-4*log(2))*((input_vector(2) - 0.0667).^2)/0.64);

f = (f1x*f1y*f2x*f2y);

f = 1/(f+1);

end

 

 

 

clear all

close all

clc

x= linspace(0,0.6,150);

y= linspace(0,0.6,150);

num_iterations = 100;

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

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

end

options = optimoptions(\'ga\');

options = optimoptions(options,\'populationsize\',500);

tic

for i=1:num_iterations

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

xopt(i) = inputs(1);

yopt(i) = inputs(2);

end

total_time = toc

figure(1)

subplot(2,1,1)

hold on

surfc(x,y,f)

shading interp

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

subplot(2,1,2)

plot(fopt)

axis([0 100 0.4 0.6])

xlabel(\'iteractions\')

ylabel(\'function maximum\')
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.