Week 4.1 - Genetic Algorithm
Genetic algoritm:
GA widely used in bussiness, science and engineering.
- optimizational and search problems
- scheduling and timetabling
There are different ways to implement GA, they all met the below conditions
- Uses concept from evolutionary biology
- Genetic representation of a solutions
- A function to generate new solutions
- Fitness functions
- Selection function
- Crossover functions
- Mutation functions
Need of GA
- Fastest search technique
- Multidimensional systems
- Mutaion testing
- Provide optimistaion over large space state
Genetic algorithm appications
- Design of water resource system(Earth Science)
- Portfolio soptimization (Finance mathematics)
- Design of anti-terrorism system(Social science)
- Automated design, research of composite material
- Control engineering
- DNA, RNA prdiction
- Design of particle accelrator beamlines(Physice)
Program Code
clear all
close all
clc
x=linspace(0,0.6,150);
y=linspace(0,0.6,150);
[xx yy]=meshgrid(x,y);
for i=1:length(x)
for j=1:length(y)
input_vector(1)=xx(i,j);
input_vector(2)=yy(i,j);
f(i,j)=stalagmite(input_vector);
end
end
surfc(xx,yy,f)
xlabel(' X Values')
ylabel(' Y Values')
shading interp
[x,fval]=ga(@stalagmite,2)
Function Code
function f = stalagmite(input)
x=input(1);
y=input(2);
f1x=(sin(5.1*pi*x+0.5)^6);
f1y=(sin(5.1*pi*y+0.5)^6);
f2x=exp((-4*log(2)*(x-0.0667)^2)/0.64);
f2y=exp((-4*log(2)*(y-0.0667)^2)/0.64);
f=(f1x*f2x*f1y*f2y);
end

Explantion
- Linspace is used to get 150 values of X,Y
- By using mesh grip we get two dimesnional array as XX,YY
- for loop is used to evaluate stalgmite function
- Function code named as 'stalagmite' has be written to solve the formual
- by assigning X, fval as output we execute the GA for the stalmite fucntion
- X- Solution
- Y-Objecxtive function value at the solution
- Surfc and annotation is done.