[job shop scheduling] solving job shop scheduling (jobshop-3) problem based on MATLAB simulated annealing algorithm [including Matlab source code phase 1082]

Matlab scientific research 2021-08-10 09:15:22 阅读数:709

本文一共[544]字,预计阅读时长:1分钟~
job shop scheduling solving job

One 、 brief introduction

Introduction to simulated annealing algorithm
 Insert picture description here
3
 Insert picture description here
 Insert picture description here
3 Parameters of simulated annealing algorithm
Simulated annealing is an optimization algorithm , It cannot exist independently , There needs to be an application , Temperature is the parameter to be optimized in simulated annealing , If it is applied to cluster analysis , In other words, one or several parameters in cluster analysis need to be optimized , And this parameter , Or the parameter set is represented by the temperature . It can be an indicator , A certain degree of relevance , A certain distance, etc .

Two 、 Source code

clc
clear
%========= Data entry , Parameter adjustment =================
swarminitNum=20;% Number of initially generated particles ;
MM=[1 2 3 4 5 6
6 6 6 6 6 6];% workpiece 、 Operation quantity matrix ,MM The first line represents the artifact , The second line represents the number of operations per workpiece ;
machineNum=6; % Number of processing machines ;
initT=500; % Simulated annealing initial temperature ;
gen=1000; % Cyclic iterates ;
w1=0.35; % Variation rate ;
changeNum=3; % Mutation transformation logarithm ;
restrictmatrixM=[3 1 2 4 6 5
2 3 5 6 1 4
3 4 6 1 2 5
2 1 3 4 5 6
3 2 5 6 1 4
2 4 6 1 5 3];%job-shop Machine constraint matrix ;
restrictmatrixT=[1 3 6 7 3 6
8 5 10 10 10 4
5 4 8 9 1 7
5 5 5 3 8 9
9 3 5 4 3 1
3 3 9 10 4 1];%job-shop Time constraint matrix ;
%===============PSO Algorithm ==========================
swarminit=cell(1,swarminitNum);
swarminitLong=sum(MM(2,:)); % Number of all processes, i.e. particle length ;
for i=1:swarminitNum,
swarminit{i}=randomparticle(MM) ;
end % Randomly generate the initial particle population
[popu,s] = size(swarminit);
trace = ones(1,gen);
trace(1) = 10000; % The initial global optimal fitness is set to be large enough
for i = 1:s,
bestfit(i) = 10000; % The optimal fitness of the initial individual history is set to be large enough
end
bestpar = swarminit; % Individual history best particle initialization
for u=1:swarminitNum,
fitlist=[0];
end
T=initT;
for step = 1:gen,
for q=1:swarminitNum,
fitlist(q)=timedecode(swarminit{q},restrictmatrixM,restrictmatrixT,machineNum) ;
end % Calculate the fitness of each particle in the current particle swarm
[minval,sub] = min(fitlist); % The minimum fitness and its subscript of this generation of particles are obtained
if(trace(step) > minval) ,
trace(step) = minval;
bestparticle = swarminit{sub};
end
if(step~= gen) ,
trace(step + 1) = trace(step); % Global optimal fitness and optimal particle adjustment
end
T=0.97*T;
for i = 1:s,
tt=fitlist(i)-bestfit(i);
if(tt<0)|(min(1,exp(-tt/T))>=rand(1,1));
bestfit(i) = fitlist(i);
bestpar{i} = swarminit{i};
end
end % Individual history best particle and fitness adjustment ;
for j = 1:s,
if rand(1,1)<w1,
bestparticle1=bianyi(bestparticle,changeNum,swarminitLong);
else
bestparticle1=bestparticle;
end % Particle variation ;
l1=1000;
l2=1;
l3=1000;
l4=1;
while (l1-l2)>swarminitLong,
m=fix(swarminitLong*rand(1,1));
n=fix(swarminitLong*rand(1,1));
l1=max(m,n)+1;
l2=min(m,n)+1;
end
while (l3-l4)>swarminitLong,
m1=fix(swarminitLong*rand(1,1));
n1=fix(swarminitLong*rand(1,1));
l3=max(m1,n1)+1;
l4=min(m1,n1)+1;
end
swarminit{j}=cross(bestpar{j},swarminit{j},l2,l1);
swarminit{j}=cross(bestparticle1,swarminit{j},l4,l3);% Particle crossover ;
end
end
function gant(particle,swarminitLong,restrictmatrixM,restrictmatrixT,b)
%particle=[1.0 1.0 3.0 2.0 3.0 4.0 2.0 6.0 4.0 3.0 1.0 6.0 5.0 5.0 6.0 4.0 3.0 2.0 4.0 3.0 2.0 5.0 4.0 6.0 1.0 2.0 1.0 5.0 5.0 6.0 1.0 4.0 2.0 6.0 3.0 5.0];
% restrictmatrixM=[ 3 1 2 4 6 5
% 2 3 5 6 1 4
% 3 4 6 1 2 5
% 2 1 3 4 5 6
% 3 2 5 6 1 4
% 2 4 6 1 5 3];
%restrictmatrixT= [ 1 3 6 7 3 6
% 8 5 10 10 10 4
% 5 4 8 9 1 7
% 5 5 5 3 8 9
% 9 3 5 4 3 1
% 3 3 9 10 4 1];
% swarminitLong=36;
for i=1:6
counter(i)=[1] ; % Position counter
s(i)=[0] ; % The end time of the last operation of the workpiece
t(i)=[0] ; % The end time of the last process of the machine
end
for j=1:swarminitLong,
k=particle(j);
time(k,counter(k))=restrictmatrixT(k ,counter(k)) ;
% Time matrix decoding
machine(k,counter(k))=restrictmatrixM(k,counter(k));
% Machine matrix decoding
[rom]=max( s(k), t(machine(k,counter(k))) );
s(k)=rom+time(k,counter(k));
t(machine(k,counter(k)))=rom+time(k,counter(k));
% Calculate the processing time on each machine
% Generate Gantt Chart
x=[rom t(machine(k,counter(k)))];
y=[machine(k,counter(k)) machine(k,counter(k))];
x1=[t(machine(k,counter(k)))-0.1 t(machine(k,counter(k)))];
y1=[machine(k,counter(k)) machine(k,counter(k))];
plot(x,y,'LineWidth',7.5,'Color','k');
hold on
plot(x1,y1,'LineWidth',7.5,'Color','white');
hold on
a=k*10+counter(k);
text((rom+t(machine(k,counter(k))))/2-1,machine(k,counter(k))-0.5,num2str(a)) ;
% text((rom+t(machine(k,counter(k))))/2-1,machine(k,counter(k))-0.5,num2str(a)) ;
hold on
axis([0 b+5 0 7]) ;
counter(k)=counter(k)+1 ;
end
xlabel('time(minute)');
ylabel('machine');
title(' Gantt Chart ');

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76.
  • 77.
  • 78.
  • 79.
  • 80.
  • 81.
  • 82.
  • 83.
  • 84.
  • 85.
  • 86.
  • 87.
  • 88.
  • 89.
  • 90.
  • 91.
  • 92.
  • 93.
  • 94.
  • 95.
  • 96.
  • 97.
  • 98.
  • 99.
  • 100.
  • 101.
  • 102.
  • 103.
  • 104.
  • 105.
  • 106.
  • 107.
  • 108.
  • 109.
  • 110.
  • 111.
  • 112.
  • 113.
  • 114.
  • 115.
  • 116.
  • 117.
  • 118.
  • 119.
  • 120.
  • 121.
  • 122.
  • 123.
  • 124.
  • 125.
  • 126.
  • 127.
  • 128.
  • 129.
  • 130.
  • 131.
  • 132.
  • 133.
  • 134.
  • 135.
  • 136.
  • 137.
  • 138.
  • 139.
  • 140.
  • 141.
  • 142.
  • 143.
  • 144.
  • 145.
  • 146.
  • 147.
  • 148.
  • 149.
  • 150.

3、 ... and 、 Running results

 Insert picture description here

Four 、 remarks

edition :2014a

版权声明:本文为[Matlab scientific research]所创,转载请带上原文链接,感谢。 https://car.inotgo.com/2021/08/20210810091259357J.html