end
for i=n-nmutationR+1:n
p(i,1:var)=valuemin(1:var)+rand(1,var).*(valuemax(1:var)...
-valuemin(1:var));
end
for i=1:n
for l=1:var
if p(i,l)<valuemin(l)
p(i,l)=valuemin(l);
elseif p(i,l)>valuemax(l)
p(i,l)=valuemax(l);
end
end
end
end
p;
m=m+1;
max1;
maxvalue(m)=maxvalue1(1);
maxvalue00(m-m0)=maxvalue1(1);
mean00(m-m0)=sum(s)/n;
meanvalue(m)=mean00(m-m0);
figure(1)
if var~=2
hold off
plot(maxvalue00)
hold on
plot(mean00,'g')
hold on
title({'Performance of GA',...
'best value GA:blue, mean value GA:green',''}...
,'color','b')
xlabel('number of generations')
ylabel('value')
end
pause(0.001)
end
clc
disp(' Genetic Algorithm(real coding) ')
disp(' By: Javad Ivakpour ')
disp(' E-mail: javad7@gmail.com ')
disp('**************************************')
num_of_fun_evaluation=n*m
max_point_GA=max1(1,:)
maxvalue_GA=maxvalue00(m-m0)
if var==2
figure(1)
hold on
plot3(max1(1,1),max1(1,2),maxvalue1,'yp')
hold on
end
figure(2)
title('Performance of GA(best value)','color','b')
xlabel('number of generations')
ylabel('max value of best solution')
hold on
plot(maxvalue00)
hold on
toc