Adaptive Restart Hybrid Genetic Algorithm for Constrained Optimization Problems (Case study 2 – Mishra’s Bird function)

In this post, I’m going to show you my innovative version of genetic algorithm called adaptive re-start hybrid genetic algorithm for constrained optimization problems in Matlab. This innovative genetic algorithm is much more powerful than the traditional genetic algorithm because of the re-start mechanism and the local search. I have developed a general template code in Matlab, so that new users can quickly and easily customize and update this Matlab code to solve new optimization problems in their fields. No need to waste your time building or typing this powerful genetic algorithm from scratch – you can build up a powerful genetic algorithm from this general template code. I’m going to demonstrate how to use this general template code to solve the Mishra’s Bird function. This is the second case study in a series of videos demonstrating the power of my adaptive re-start hybrid genetic algorithm for constrained optimization problems.

Here are details of the Mishra’s Bird function with the proven global optimal solution.

Here is a general structure of my adaptive restart hybrid genetic algorithm.

Let’s see how it works:

For more videos like this, check my YouTube channel here.

The general template code in Matlab:

population.m

function YY=population(p,nv,lb,ub)
% p = population size
% nv = number of variables
% lb = Lower bound
% ub = Upper bound
for i = 1:p
    for j = 1:nv
        Y(i,j)=(ub(j)-lb(j))*rand+lb(j);
    end
end
YY = Y;

crossover.m

function Y=crossover(P,n)
% P = population
% n = the number of pairs of chromosomes to be 
% crossed (equivalent to the trational crossover rate)
[x1 y1]=size(P);
Z=zeros(2*n,y1);
for i = 1:n
    r1=randi(x1,1,2); % select 2 random parent chromosomes
    while r1(1)==r1(2)
        r1=randi(x1,1,2);
    end
    A1=P(r1(1),:); % parent 1
    A2=P(r1(2),:); % parent 2
    r2=1+randi(y1-1); % random cutting point
    B1=A1(1,r2:y1); % exchange
    A1(1,r2:y1)=A2(1,r2:y1);
    A2(1,r2:y1)=B1;
    Z(2*i-1,:)=A1;
    Z(2*i,:)=A2;
end
Y=Z;

mutation.m

function Y=mutation(P,n)
% P = population
% n = the number of pairs of chromosomes to 
% be mutated (equivalent to the trational mutation rate)
[x1 y1]=size(P);
Z=zeros(2*n,y1);
for i = 1:n
    r1=randi(x1,1,2);
    while r1(1)==r1(2)
        r1=randi(x1,1,2);
    end
    A1=P(r1(1),:); % parent 1
    A2=P(r1(2),:); % parent 2
    r2=randi(y1); % random gene
    A0 = A1(r2); % exchange the selected gene
    A1(r2)=A2(r2);
    A2(r2)=A0;
    Z(2*i-1,:)=A1;
    Z(2*i,:)=A2;
end
Y=Z;

objective_function.m

function YY = objective_function(X)
% X = solution
x = X(1);
y = X(2);
YY = sin(y)*exp((1-cos(x))^2) + cos(x)*exp((1-sin(y))^2) + (x-y)^2;

.
.
.
Sorry! This is only a part of the general template code in Matlab.

Notice: It would take you from 1 to 3 hours to re-type the Matlab code yourself; or with just €4.99 (the cost of a cup of coffee), you can download/copy the whole Matlab code within 2 minutes. It’s your choice to make.

Original price is €9.99 but today it’s only €4.99 (save €5 today – available for a limited time only)

Download the whole Matlab code here (Membership Code ID: 028)

No need to build the Matlab code from scratch because it’s very time-consuming. My idol, Jim Rohn, once said: “Time is more value than money. You can get more money, but you cannot get more time”. If you think this code can be used in your research/teaching work, you should download it and then customize/modify/apply it to your work, without any obligation of citing the original source if you don’t want. However, redistribution (i.e., downloading the code/script here and then making it available on another site on the Internet) is strictly prohibited.

If you have any question or problem, please contact Dr. Panda by email: learnwithpanda2018@gmail.com

Thank you very much and good luck with your research!

7 Replies to “Adaptive Restart Hybrid Genetic Algorithm for Constrained Optimization Problems (Case study 2 – Mishra’s Bird function)”

Leave a Reply

Your email address will not be published. Required fields are marked *