新型GA算法
一种好的改进遗传算法function [opy,optimy]=GA(pt,gennum,psize)% 输入参数:% pt m*n的加工时间矩阵(n是工件数目,m是机器数目)由已知给的T矩阵,可得n=100,m=10% gennum 迭代的次数(代数)% psize 种群的规模大小%输出参数:% opy 最优的Makespan值pc=0.9;%交叉因子pm=0.1;%变异因子[m,n]=size(pt);current_gen=1;%current_gen means the current generationnewgen=zeros(psize,n+1); %mewgen is the new generation of the populationnewgen(1:psize,1:n)=rand(psize,n);%主种群初始化,0-1之间的随机数 %Generalize the initial groupfather=zeros(2,n); %father is used to store the two genes for crossover and mutation avgen=zeros(1,gennum); %avgen is the matrix of the average of all the generationsoptimx=zeros(1,n);optimy=ones(1,gennum);%Generalize the initial groupfor i=1:psize [Ya,pop(i,1:n)]=sort(newgen(i,1:n));%种群排序,实数编码转换为自然数编码 随机生成的0-1之间的小数进行排序然后取每个从小到大数对应的位置 newg
- 2022-03-18 14:25:18下载
- 积分:1