Challenge

Week 4.1 - Genetic Algorithm

theory:- genetic algorithm 

  • Genetic algorithm is an optimization tool in matlab that is used to find the minimum value of a function.
  • A genetic algorithm works with the fitness function. This function evaluates the fitness of the individuals. Fitness function defines the eligibility criteria for selection of the fruitful candidates.
  • It is based on the evolution process in which the eligible candidates are selected, then these fit candidates undergo mutation during their lifetime in the generation. 
  • These points run through fitness functions in order to select the better candidates,here local maxima are chosen.
  • The new set undergo mutation.This initial population keeps on increasing and repeating for the next 100 generation default.The generation are interchanged into the better candidates for the next upcoming generations.
  • syntax :- [x, fval] = ga(fun,nvars,A,b,[],[],lb,ub,option)
  • x-an array which stores the point generated by ga at which local and global minima can be found.
  • fval-stores local minima
  • fun-fitness function
  • A,b-inequality
  • lb-lower bond
  • ub-upper bond
  • options-structure data type.
  • code:fitness function

function [f] = stalagmite(input_vector)

x = input_vector(1);
y = input_vector(2);

t1=(sin((5.1*pi*a)+0.5))^6;
t2=(sin((5.1*pi*b)+0.5))^6;
t3=exp(-4*log(2)*((a-0.0667)^2)/0.64);
t4=exp(-4*log(2)*((b-0.0667)^2)/0.64);

[f]=(t1*t2*t3*t4);
end

  • stalgmite function:-

Stalagmite functon is a methametical function model which helps to generate  local minima and maxima.It is a 3D function and the way the function is designed is that it has a lot of local maxima or minima and one global maxima and minima .

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

 

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.