Solving Optimization Problems

Adaptive Re-Start Hybrid Genetic Algorithm (Test the Performance in Case Studies)

Hello everyone. In this post, I am going to show you my innovative version of Genetic Algorithm, which I called: adaptive re-start hybrid Genetic Algorithm. I will test the performance of the proposed Genetic Algorithm in solving a benchmark optimization problem with a well-known optimal solution as shown in the Figure below. In addition, I will show you how to customize my Matlab code of the proposed innovative Genetic Algorithm to solve your optimization problems. Customizing this Matlab code to solve a new optimization problem is very easy and fast. We don’t need to build this kind of Matlab code from scratch. Majority of this Matlab code can be kept the same. Please keep reading and you will see the interesting results.

Genetic Algorithm is a popular metaheuristic, based on the mechanisms of natural selection in Charles Darwin’s theory of natural evolution. Genetic Algorithm was first introduced by Holland in 1975, but now, it is still very popular in various research community. Did you know that Genetic algorithm is one of the most popular stochastic optimization algorithm often used to solve complex large scale optimization problems in various fields. For more details about the popularity of Genetic Algorithm compared with other stochastic optimization algorithms, please see the 2 Figures below:

Popularity of Genetic Algorithm Over the Years

Popularity of Genetic Algorithm in Different Research Fields

Genetic Algorithm is one of the most general global optimisation solution methods used in countless number of research publications. However, like other search techniques, Genetic Algorithm has weak theoretical guarantee of global optimal solution, and can only offer a probabilistic guarantee. To overcome the current limitations of the traditional Genetic Algorithm, and having a Genetic Algorithm capable of searching for the global optimal solution, with very high success probability are always desirable. In this research, an innovative structure of Genetic Algorithm, in which adaptive restart, local search, and chromosome elite transferring strategies are integrated together, is proposed to improve the success rate of achieving global optimal solution of the traditional Genetic Algorithm. The effectiveness of the proposed Genetic Algorithm structure has been demonstrated through a number of case studies, and benchmark optimization problems.

Matlab Code

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); % make sure 2 selected chromosomes are not the same
    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); % exchange
    A2(1,r2:y1)=B1; % exchange
    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);% make sure 2 selected chromosomes are not the same
    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); % exchange the selected gene
    A2(r2)=A0; % exchange the selected gene
    Z(2*i-1,:)=A1;
    Z(2*i,:)=A2;
end
Y=Z;

evaluation.m

function YY=evaluation(P,ot,co)
% P = population
% ot = optimization type, max or min
% co = coefficient for converting min to max problem (to make sure ...
% that the objective function is always positive
[x1 y1]=size(P);
H=zeros(1,x1);
for i = 1:x1
   H(i)= objective_function(P(i,:)); 
end
% depending on type of optimization
if ot == 1 % for maximization problem
    Y = H + co; % add co to make sure all elements in Y are positive
else       % for minimization problem
    K=zeros(1,x1);
    for i = 1:x1
        K(i) = 1/(co + H(i)); % convert from min to max
    end
    Y = K;
end
YY = Y;

To solve an optimization problem (for example: a benchmark optimization problem as shown in the Figure below), here are 2 Sections we need to change:

Section 1 – We need to change the objective function as illustrated below:

Section 2 – We need to change the parameters of the optimization problems and Genetic Algorithm as illustrated below:

The rest of the Matlab code can be kept the same.

Now, let’s see how it works:

Case Study 1:

Case Study 2:

Do you want to get the whole Matlab code of my innovative Genetic Algorithm to use in your research, thesis, report, and publications?

It’s possible to watch the video and re-type the Matlab code yourself – that would take you from 1 to 3 hours; or with just €3.99 (the cost of a cup of coffee), you can download/copy the whole Matlab code within 3 minutes. It’s your choice to make.

Original price is €6.99 but today it’s only €3.99 (save €3 today – available for a limited time only)

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

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!

Dr.Panda

Recent Posts

Adaptive Re-Start Hybrid Genetic Algorithm in Matlab

Hello everyone! In this post, I am going to show you my innovative version of…

7 months ago

Test Your Understanding About Genetic Algorithm (Test 2)

Hello everyone. Let’s take a test to check your understanding about genetic algorithm, with multiple…

7 months ago

Adaptive Restart Hybrid Genetic Algorithm

Hello everyone! In this post, I am going to show you my innovative version of…

7 months ago

Adaptive Re-Start Hybrid Genetic Algorithm in Matlab

Hello everyone! Let’s see how my innovative version of Genetic Algorithm, called Adaptive Re-start Hybrid…

1 year ago

Crypto Quiz (Test Your Knowledge About Cryptocurrency)

Hello everyone! Let’s take a short quiz, to test your knowledge about crypto-currency, or crypto.…

1 year ago

Test Your Crypto Knowledge (Test 2)

Hello everyone! Let’s take a test to check your knowledge in crypto-currency, or crypto. From…

2 years ago