【车间调度】基于matlab粒子群算法求解车间调度问题【含Matlab源码 013期】
一、简介
针对作业车间调度问题,提出一种基于自适应权重和混沌的改进粒子群优化算法。构建以机器加工时间最短为优化目标的多约束作业车间调度模型,采用基于工序排列的编码方式得到粒子参数与工序序列的映射关系;基于自适应权重改进粒子群算法中的惯性系数和加速因子,使得算法可以根据适应度值动态调整参数因子;采用反向学习策略改善种群初始解的质量;引入莱维飞行、变邻域搜索、混沌,增强了算法的搜索能力,避免陷入局部最优解。试验结果表明:改进粒子群算法可以有效地提高粒子利用率,平衡全局搜索与局部搜索能力,改善传统粒子群算法易早熟的缺点,得到更优的解。
二、源代码
function []=FJSP_PSO()
[~, ~, alldata] = xlsread('data2.xlsx');
=size(alldata);
for i=2:row
for j=1:columns
if ischar(cell2mat(alldata(i,j)))
alldata(i,j)={str2num(cell2mat(alldata(i,j)))};
end
end
end
TaskAmo=alldata{row,1};
SubtaskAmo=row-1;
SubtaskNum=zeros(1,TaskAmo);
MachineAmo=0;
for i=1:SubtaskAmo
MachineAmo=max(MachineAmo,max(alldata{i+1,5}));
end
count1=0;
for i=2:row
if ~isnan(alldata{i,2})
count1=count1+1;
SubtaskNum(count1)=alldata{i,2};
end
end
tic
nind=50;
maxgen=20;
w=0.72;
c1=1.79;
c2=1.79;
gen=0;
trace=zeros(2,maxgen);
chrom=zeros(nind,2*SubtaskAmo);
X_process=zeros(1,SubtaskAmo);
chrom_operating=zeros(nind,2*SubtaskAmo);
chrom_temp_P=zeros(nind,SubtaskAmo);
chrom_temp_M=zeros(nind,SubtaskAmo);
% individual_best=zeros(nind,3);
% population_best=zeros(1,3);
for r=1:nind
for i=1:SubtaskAmo
X_process(i)=alldata{i+1,1};
end
Queue=randperm(numel(X_process));
X_process=X_process(Queue);
X_machine=M_generate3(alldata,X_process,TaskAmo,SubtaskAmo,SubtaskNum);
chrom(r,:)=;
end;
=FJSP_objv3(alldata,TaskAmo,SubtaskAmo,SubtaskNum,nind,chrom);
individual_best_object=objective;
individual_best_P=chrom_X_P;
individual_best_M=chrom_X_M;
population_best_objective=minfit;
population_best_P=minP;
population_best_M=minM;
while gen<maxgen
for r=1:nind
for i=1:SubtaskAmo
chrom_temp_P(r,i)=w*chrom(r,i)+c1*rand*(individual_best_P(r,i)-chrom(r,i))+c2*rand*(population_best_P(i)-chrom(r,i));
end
[~,temp_node]=sort(chrom_temp_P(r,:));
temp=chrom(r,1:SubtaskAmo);
chrom(r,1:SubtaskAmo)=temp(temp_node);
chrom(r,SubtaskAmo+1:2*SubtaskAmo)=M_generate3(alldata,chrom(r,1:SubtaskAmo),TaskAmo,SubtaskAmo,SubtaskNum);
end
=FJSP_objv3(alldata,TaskAmo,SubtaskAmo,SubtaskNum,nind,chrom);
for r=1:nind
if objective(r)<individual_best_object(r)
individual_best_object(r)=objective(r);
individual_best_P(r,:)=chrom(1:SubtaskAmo);
individual_best_M(r,:)=chrom(SubtaskAmo+1:2*SubtaskAmo);
end
end
if minfit<population_best_objective
population_best_objective=minfit;
population_best_P=minP;
population_best_M=minM;
end
gen=gen+1;
trace(1,gen)=min(objective);
trace(2,gen)=sum(objective)/length(objective);
end
toc
population_best_W=W_generate2(alldata,SubtaskAmo,TaskAmo,SubtaskNum,population_best_P,population_best_M);
=FJSP_ADV_fitness4(population_best_P,population_best_M,population_best_W);
minXulie=
minFitness=population_best_W
figure(1);
plot(trace(1,1:gen));
hold on;
plot(trace(2,1:gen),'-.');grid;
figure(2);
colorset1=rand(1,TaskAmo);
colorset2=rand(1,TaskAmo);
=size(T);
for i=1:Trow
for j=1:Tcol
if trace2(i,j)~=0
fill(,,);hold on
text(T(i,j),i,strcat(num2str(trace2(i,j)),',',num2str(trace3(i,j))));
end
end
end
end
三、运行结果
四、备注
版本:2014a
页:
[1]