A list,

An improved particle swarm optimization (PSO) algorithm based on adaptive weight and chaos was proposed for job shop scheduling. A multi-constraint job-shop scheduling model was established to minimize machine processing time. The mapping relationship between particle parameters and process sequence was obtained by coding method based on process arrangement. The inertia coefficient and acceleration factor of particle swarm optimization algorithm are improved based on adaptive weight, so that the algorithm can adjust the parameter factor dynamically according to the fitness value. Reverse learning strategy is used to improve the quality of initial solution. Levy flight, variable neighborhood search and chaos are introduced to enhance the search ability of the algorithm and avoid falling into local optimal solution. The experimental results show that the improved particle swarm optimization algorithm can effectively improve the particle utilization rate, balance the global search and local search capabilities, improve the traditional particle swarm optimization algorithm is easy to premature shortcomings, and get better solutions.

Ii. Source code

function []=FJSP_PSO()
[~, ~, alldata] = xlsread('data2.xlsx');
[row, columns]=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,:)=[X_process,X_machine];
end;
 
[objective,chrom_X_P,chrom_X_M,minP,minM,minfit]=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
    
    [objective,chrom_X_P,chrom_X_M,minP,minM,minfit]=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);
[T,~,trace1,trace2,trace3,~]=FJSP_ADV_fitness4(population_best_P,population_best_M,population_best_W);
 
minXulie=[population_best_P,population_best_M,population_best_W]
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);
[Trow,Tcol]=size(T);
for i=1:Trow
    for j=1:Tcol
        if trace2(i,j)~=0
            fill([T(i,j),T(i,j)+trace1(i,j),T(i,j)+trace1(i,j),T(i,j)],[1*i0.3.1*i0.3.1*i+0.3.1*i+0.3],[trace2(i,j)/TaskAmo,0.9*colorset1(trace2(i,j)),0.8*colorset2(trace2(i,j))]);hold on
            text(T(i,j),i,strcat(num2str(trace2(i,j)),', ',num2str(trace3(i,j))));
        end
    end
end
end
        
        
 
Copy the code

3. Operation results

Fourth, note

Version: 2014 a