Genetic algorithm (ga) is not converging

10 views (last 30 days)
lb = [1,1];
ub = [20,20];
nvars = 2;
IntCon = [1,2];
n = 100
options = optimoptions('ga','MaxGenerations',n,'MaxStallGenerations',n,...
'MutationFcn',{@mutationadaptfeasible,0.0625},'crossoverFraction',0.65,...
'CrossoverFcn',{@crossoverintermediate,0.9375},'FunctionTolerance',0.01,...
'OutputFcn',@func_gaoutfun,'Display','iter',...
'EliteCount',2,'PlotFcn',{@gaplotbestf,@gaplotdistance});
x = ga(@func_optimization,nvars,[],[],[],[],lb,ub,[],IntCon,options);
Hello,
I am trying to find the global minimization using genetic algorithm. I used two variables and they always should be integer number. I put above information in the options. the OutputFcn is used to check the record informations of each generation. i run the iteration 1000 times as well but the plot is not converging at all. Is this because of crossover and mutation fuction? kindly help me to find the convergence.
I added the plot here based on 100 iteration. you can see that they are not converging or no tendency to converge. What might be the problem and how to solve this? If you can help, that would be very helpful.
Thank you.
  2 Comments
Star Strider
Star Strider on 5 Jan 2021
The problem most likely is your function. Also, see Mixed Integer ga Optimization to understand how to use integer optimization.
MD. Rokibujjaman sovon
MD. Rokibujjaman sovon on 5 Jan 2021
I am actually trying to find the hiddenlayer and number of neurons in the hiddenlayer. the objective is to minimize the performance. I used the matlab neuralnet to prepare the objective function for the optimization. Here i shared the code of my objective function. Can you kindly tell me whether it is okay or not.
function Perf = func_optimization(HL)
% global data
data = xlsread('data all.xlsx');
u = data(:,1:4);
v = data(:,5:8);
normu = u - min(u(:,:));
x = normu ./ max(normu(:,:));
normv = v - min(v(:,:));
y = normv ./ max(normv(:,:));
xnew=x;
xnew2 = xnew';
ynew = y';
trainFcn = 'traincgb';
net = fitnet(HL,trainFcn); % HL = Hidden Layer
net.input.processFcns = {'removeconstantrows','mapminmax'};
net.output.processFcns = {'removeconstantrows','mapminmax'};
net.divideFcn = 'divideind';
net.divideParam.trainInd = 1:19;
net.divideParam.valInd = 20:23;
net.divideParam.testInd = 24:27;
[net,tr] = train(net,xnew2,ynew);
yTrain = net(xnew2);
yTrue = ynew;
Perf = perform(net,yTrue,yTrain); % Perf = Performance (error) of the neural net
end

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!