Challenge

Week 4.1 - Genetic Algorithm

Aim:

To calculate the global maxima of a stalagmite function.

Genetic algorithm :

Genetic algorithm are primarily used in optimization problems of various kinds, but they are frequently used in other application areas as well.it select random inputs called as population check their fitness for selection and pairing purposes to generate new data.Genetic algorithm is used for solving both constrained and unconstrained optimization.thos generation data is mutated from data acquired from parents which is essential for computing optimized output.

Its uses three type of rules  1.selection rules,2.crossover rules,3.mutation rules

Syntax of ga:

X= ga(fun,nvars,A,b,aeq,beq,ub)

A set of lower and upper bounds on the design variable ,x, so that a solution is found in the range ib

[x,fval]=ga(____),

Any pervious inputs arguments, also return fval, the value of the fitness function at x.

Code for stalagmite function:

F(x,y) =f1x.f2x.f1y.f2y

F1x = (sin(5.1*7.14x+0.5))^6

F1y = (sin(5.1*7.14y+0.5))^6

F2x = exp(-4 ln2*(x-0.0667)^2/0.64)

F2y = exp(-4 ln2*(x-0.0667)^2/0.64)

Code:

Explanation:

Write a code to define the stalagmite function. We break down the formula into 4 terms for convenience. A main code were we define two inputs x and y both of which are one dimensional equally spaced arry containing 100 elements. Utilize meshgrid command to creat an arry of x and y values.

Now we use for loop to input values of 2D array in stalagmite function. Encounter an problem. Every time the code is executed different values for stalagmite function are obtained.overcome by introducing another loop into the code. We algorithm”ga” function used.

.impri=ove genetic algorithm undertake three cases to optimize the function so the we can accurately find the global maxima of the function.need to do this because the ga randomly takes values and global maxima can change according to that.in case 2 we put an upper bound and lower bomd on “ga” function and again plot two plots which we plot during case1. In case 3 we increase GA iteration . do this because in GA after successive . the population”evolves”toward an optimal solution .more the number of iteration ,optimal the solution will be.now we use same commands to plot the graph and curve.

Refernce;

http://wikipidia.org/wiki/genetic-alogrithm.

http://mathsworks.com/help/gods/what-is-the-genetic-algorithm.html

http://skill-lync.com/student-projects/-16732

Aim:

To calculate the global maxima of a stalagmite function.

Genetic algorithm :

Genetic algorithm are primarily used in optimization problems of various kinds, but they are frequently used in other application areas as well.it select random inputs called as population check their fitness for selection and pairing purposes to generate new data.Genetic algorithm is used for solving both constrained and unconstrained optimization.thos generation data is mutated from data acquired from parents which is essential for computing optimized output.

Its uses three type of rules  1.selection rules,2.crossover rules,3.mutation rules

Syntax of ga:

X= ga(fun,nvars,A,b,aeq,beq,ub)

A set of lower and upper bounds on the design variable ,x, so that a solution is found in the range ib

[x,fval]=ga(____),

Any pervious inputs arguments, also return fval, the value of the fitness function at x.

Code for stalagmite function:

F(x,y) =f1x.f2x.f1y.f2y

F1x = (sin(5.1*7.14x+0.5))^6

F1y = (sin(5.1*7.14y+0.5))^6

F2x = exp(-4 ln2*(x-0.0667)^2/0.64)

F2y = exp(-4 ln2*(x-0.0667)^2/0.64)

Code:

Explanation:

Write a code to define the stalagmite function. We break down the formula into 4 terms for convenience. A main code were we define two inputs x and y both of which are one dimensional equally spaced arry containing 100 elements. Utilize meshgrid command to creat an arry of x and y values.

Now we use for loop to input values of 2D array in stalagmite function. Encounter an problem. Every time the code is executed different values for stalagmite function are obtained.overcome by introducing another loop into the code. We algorithm”ga” function used.

.impri=ove genetic algorithm undertake three cases to optimize the function so the we can accurately find the global maxima of the function.need to do this because the ga randomly takes values and global maxima can change according to that.in case 2 we put an upper bound and lower bomd on “ga” function and again plot two plots which we plot during case1. In case 3 we increase GA iteration . do this because in GA after successive . the population”evolves”toward an optimal solution .more the number of iteration ,optimal the solution will be.now we use same commands to plot the graph and curve.

Refernce;

http://wikipidia.org/wiki/genetic-alogrithm.

http://mathsworks.com/help/gods/what-is-the-genetic-algorithm.html

http://skill-lync.com/student-projects/-16732

Aim:

To calculate the global maxima of a stalagmite function.

Genetic algorithm :

Genetic algorithm are primarily used in optimization problems of various kinds, but they are frequently used in other application areas as well.it select random inputs called as population check their fitness for selection and pairing purposes to generate new data.Genetic algorithm is used for solving both constrained and unconstrained optimization.thos generation data is mutated from data acquired from parents which is essential for computing optimized output.

Its uses three type of rules  1.selection rules,2.crossover rules,3.mutation rules

Syntax of ga:

X= ga(fun,nvars,A,b,aeq,beq,ub)

A set of lower and upper bounds on the design variable ,x, so that a solution is found in the range ib

[x,fval]=ga(____),

Any pervious inputs arguments, also return fval, the value of the fitness function at x.

Code for stalagmite function:

F(x,y) =f1x.f2x.f1y.f2y

F1x = (sin(5.1*7.14x+0.5))^6

F1y = (sin(5.1*7.14y+0.5))^6

F2x = exp(-4 ln2*(x-0.0667)^2/0.64)

F2y = exp(-4 ln2*(x-0.0667)^2/0.64)

Code:

Explanation:

Write a code to define the stalagmite function. We break down the formula into 4 terms for convenience. A main code were we define two inputs x and y both of which are one dimensional equally spaced arry containing 100 elements. Utilize meshgrid command to creat an arry of x and y values.

Now we use for loop to input values of 2D array in stalagmite function. Encounter an problem. Every time the code is executed different values for stalagmite function are obtained.overcome by introducing another loop into the code. We algorithm”ga” function used.

.impri=ove genetic algorithm undertake three cases to optimize the function so the we can accurately find the global maxima of the function.need to do this because the ga randomly takes values and global maxima can change according to that.in case 2 we put an upper bound and lower bomd on “ga” function and again plot two plots which we plot during case1. In case 3 we increase GA iteration . do this because in GA after successive . the population”evolves”toward an optimal solution .more the number of iteration ,optimal the solution will be.now we use same commands to plot the graph and curve.

Refernce;

http://wikipidia.org/wiki/genetic-alogrithm.

http://mathsworks.com/help/gods/what-is-the-genetic-algorithm.html

http://skill-lync.com/student-projects/-16732

Aim:

To calculate the global maxima of a stalagmite function.

Genetic algorithm :

Genetic algorithm are primarily used in optimization problems of various kinds, but they are frequently used in other application areas as well.it select random inputs called as population check their fitness for selection and pairing purposes to generate new data.Genetic algorithm is used for solving both constrained and unconstrained optimization.thos generation data is mutated from data acquired from parents which is essential for computing optimized output.

Its uses three type of rules  1.selection rules,2.crossover rules,3.mutation rules

Syntax of ga:

X= ga(fun,nvars,A,b,aeq,beq,ub)

A set of lower and upper bounds on the design variable ,x, so that a solution is found in the range ib

[x,fval]=ga(____),

Any pervious inputs arguments, also return fval, the value of the fitness function at x.

Code for stalagmite function:

F(x,y) =f1x.f2x.f1y.f2y

F1x = (sin(5.1*7.14x+0.5))^6

F1y = (sin(5.1*7.14y+0.5))^6

F2x = exp(-4 ln2*(x-0.0667)^2/0.64)

F2y = exp(-4 ln2*(x-0.0667)^2/0.64)

Code:

Explanation:

Write a code to define the stalagmite function. We break down the formula into 4 terms for convenience. A main code were we define two inputs x and y both of which are one dimensional equally spaced arry containing 100 elements. Utilize meshgrid command to creat an arry of x and y values.

Now we use for loop to input values of 2D array in stalagmite function. Encounter an problem. Every time the code is executed different values for stalagmite function are obtained.overcome by introducing another loop into the code. We algorithm”ga” function used.

.impri=ove genetic algorithm undertake three cases to optimize the function so the we can accurately find the global maxima of the function.need to do this because the ga randomly takes values and global maxima can change according to that.in case 2 we put an upper bound and lower bomd on “ga” function and again plot two plots which we plot during case1. In case 3 we increase GA iteration . do this because in GA after successive . the population”evolves”toward an optimal solution .more the number of iteration ,optimal the solution will be.now we use same commands to plot the graph and curve.

Refernce;

http://wikipidia.org/wiki/genetic-alogrithm.http://mathsworks.com/help/gods/what-is-the-genetic-algorithm.html

http://skill-lync.com/student-projects/-16732

Aim:

To calculate the global maxima of a stalagmite function.

Genetic algorithm :

Genetic algorithm are primarily used in optimization problems of various kinds, but they are frequently used in other application areas as well.it select random inputs called as population check their fitness for selection and pairing purposes to generate new data.Genetic algorithm is used for solving both constrained and unconstrained optimization.thos generation data is mutated from data acquired from parents which is essential for computing optimized output.

Its uses three type of rules  1.selection rules,2.crossover rules,3.mutation rules

Syntax of ga:

X= ga(fun,nvars,A,b,aeq,beq,ub)

A set of lower and upper bounds on the design variable ,x, so that a solution is found in the range ib

[x,fval]=ga(____),

Any pervious inputs arguments, also return fval, the value of the fitness function at x.

Code for stalagmite function:

F(x,y) =f1x.f2x.f1y.f2y

F1x = (sin(5.1*7.14x+0.5))^6

F1y = (sin(5.1*7.14y+0.5))^6

F2x = exp(-4 ln2*(x-0.0667)^2/0.64)

F2y = exp(-4 ln2*(x-0.0667)^2/0.64)

Code:

clear all 
close all
clc

%input
x=linspace(0,0.6,150);
y=linspace(0,0.6,150);

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

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
num=150;
%study 1
tic
for i= 1:num_case
    [inputs,Fout(i)]= ga(@stalagmite,2);
    xout(i)=inputs(1);
    yout(j)=inputs(2);
end

study_time_1=toc

fig(1)
subplot(2,1,1);
hold on
surfc(xx,yy,-F);
shading interp;
ylabel('y data');
xlabel('x data');
plot3(xout,yout,-Fout,'marker','o','markersize',5,'markerfacecolor','k');
title('unbounded inputs');
subplot(2,1,2);
plot(-Fout);
xlabel('iteractions');
ylabel('function maximum');

%study 2
tic
for i =1:num_case
    [inputs,Fout(i)]=ga(@stalagmite,2,[],[],[],[],[0;0],[1;1]);
    xout(i)=inputs(1);
    yout(i)=inputs(2);
end
study_time_2=toc

fig(2)
subplot(2,1,1);
hold on
surfc(xx,yy,-F);
shading interp;
ylabel('y data');
xlabel('x data');
plot3(xout,yout,-Fout,'marker','o','markersize',5,'markerfacecolor','k');
title('unbounded inputs');
subplot(2,1,2);
plot(-Fout);
xlabel('iteractions');
ylabel('function maximum');

%study 3
options=optimoptions('ga')
options=optimoptions(option,'populationsize',450);
tic
for i =1:num_case
    [inputs,Fout(i)]=ga(@stalagmite,2,[],[],[],[],[0;0],[1;1]);
    xout(i)=inputs(1);
    yout(i)=inputs(2);
end
study_time_3=toc

fig(3)
subplot(2,1,1);
hold on
surfc(xx,yy,-F);
shading interp;
ylabel('y data');
xlabel('x data');
plot3(xout,yout,-Fout,'marker','o','markersize',5,'markerfacecolor','k');
title('bounded inputs with increase population size');
subplot(2,1,2);
plot(-Fout);
xlabel('iteractions');
ylabel('function maximum');


Explanation:

Write a code to define the stalagmite function. We break down the formula into 4 terms for convenience. A main code were we define two inputs x and y both of which are one dimensional equally spaced arry containing 100 elements. Utilize meshgrid command to creat an arry of x and y values.

Now we use for loop to input values of 2D array in stalagmite function. Encounter an problem. Every time the code is executed different values for stalagmite function are obtained.overcome by introducing another loop into the code. We algorithm”ga” function used.

.impri=ove genetic algorithm undertake three cases to optimize the function so the we can accurately find the global maxima of the function.need to do this because the ga randomly takes values and global maxima can change according to that.in case 2 we put an upper bound and lower bomd on “ga” function and again plot two plots which we plot during case1. In case 3 we increase GA iteration . do this because in GA after successive . the population”evolves”toward an optimal solution .more the number of iteration ,optimal the solution will be.now we use same commands to plot the graph and curve.

Refernce;

http://wikipidia.org/wiki/genetic-alogrithm.

http://mathsworks.com/help/gods/what-is-the-genetic-algorithm.html

http://skill-lync.com/student-projects/-16732

https://skill-lync.com/student-projects/week-4-1-genetic-algorithm-623A

https://skill-lync.com/student-projects/implementing-genetic-algorithm-for-analysis-of-stalagmite-function-in-matlab

 

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.