[workshop scheduling] solve the workshop scheduling problem based on MATLAB simulated annealing algorithm [including Matlab source code 894]

Matlab scientific research 2021-08-10 09:15:06 阅读数:845

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

One 、 brief introduction

1 Application background of simulated annealing algorithm
Simulated annealing algorithm is proposed for 1982 year .Kirkpatrick They first realized that there is a similarity between the solid annealing process and the optimization problem ;Metropolis Their simulation of the process of solid reaching thermal equilibrium at constant temperature also gave them enlightenment . Through the Metropolis The algorithm is introduced into the optimization process , Finally get a pair of Metropolis The iterative algorithm is optimized , This algorithm is similar to the solid annealing process , be called “ Simulated annealing algorithm ”.
Simulated annealing algorithm is a random search algorithm suitable for solving large-scale combinatorial optimization problems . at present , Simulated annealing algorithm is solving TSP,VLSI Satisfactory results have been obtained on combinatorial optimization problems such as circuit design . The simulated annealing algorithm is combined with other computational intelligence methods , More and more attention has been paid to the modeling and optimization of various complex systems , It has gradually become an important development direction .
2 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;
close all;
%% Problem Definition
model=CreateModel(); % Create Model of the Problem
CostFunction=@(q) MyCost(q,model); % Cost Function
nVar=model.nVar; % Number of Decision Variables
VarSize=[1 nVar]; % Size of Decision Variables Matrix
%% SA Parameters
MaxIt=500; % Maximum Number of Iterations
MaxIt2=25; % Maximum Number of Inner Iterations
T0=10; % Initial Temperature
alpha=0.97; % Temperature Damping Rate
%% Initialization
% Create Initial Solution
x.Position=CreateRandomSolution(model);
[x.Cost, x.Sol]=CostFunction(x.Position);
% Update Best Solution Ever Found
BestSol=x;
% Array to Hold Best Cost Values
BestCost=zeros(MaxIt,1);
% Set Initial Temperature
T=T0;
%% SA Main Loop
for it=1:MaxIt
for it2=1:MaxIt2
% Create Neighbor
xnew.Position=CreateNeighbor(x.Position);
[xnew.Cost, xnew.Sol]=CostFunction(xnew.Position);
if xnew.Cost<=x.Cost
% xnew is better, so it is accepted
x=xnew;
else
% xnew is not better, so it is accepted conditionally
delta=xnew.Cost-x.Cost;
p=exp(-delta/T);
if rand<=p
x=xnew;
end
end
function model=CreateModel()
p=[ 48 27 18 15
23 52 50 59
35 39 25 10
45 38 36 49
55 56 18 51
58 24 40 54
37 48 23 14
17 48 43 30
17 29 45 23
23 38 48 50
52 13 32 32
22 12 14 56
51 37 21 19
22 49 56 23
57 57 17 17
27 16 52 16
20 39 37 54
22 33 60 39
41 10 13 38
34 27 32 17];
I=size(p,1);
J=size(p,2);
s(:,:,1)=[4 7 5 7 7 5 2 7 5 3 8 6 6 6 7 2 6 2 8 6
3 5 8 5 6 6 5 2 7 4 2 2 5 2 4 7 5 2 3 4
6 8 6 8 3 2 7 8 4 2 3 2 4 7 3 4 5 3 3 4
3 4 3 6 6 6 8 8 5 5 2 7 2 2 2 6 6 3 4 5
2 7 3 6 2 4 3 8 2 4 5 8 7 2 7 8 2 4 2 4
7 4 4 7 6 2 3 8 3 3 2 5 4 6 3 5 4 4 6 4
3 7 7 8 6 5 5 7 6 3 8 2 6 4 4 6 7 3 4 5
5 7 7 8 7 3 6 5 4 8 3 7 7 6 5 7 6 3 8 7
6 4 7 2 8 2 4 3 8 6 2 4 2 7 3 5 2 8 4 4
4 3 4 8 8 3 3 4 2 5 4 4 2 6 6 6 2 6 6 5
7 7 5 6 7 3 8 2 8 8 5 7 5 7 5 2 2 5 3 2
4 8 2 8 6 3 2 2 5 2 2 2 5 3 3 8 2 3 4 2
6 4 2 5 8 2 2 8 6 7 8 2 8 7 7 3 4 3 3 4
6 6 2 5 6 6 2 4 8 7 4 6 7 8 2 3 6 2 7 4
5 5 6 7 2 3 3 4 4 5 4 6 7 8 4 7 7 8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5 6 3 7 8 6 5 8 4 8 3 6 4 6 5
7 7 8 3 5 2 5 5 6 4 7 2 8 4 2 7 7 5 8 2
4 8 5 8 4 2 8 8 7 2 7 7 4 8 6 6 3 4 3 6
7 6 5 4 2 2 4 2 7 7 4 6 5 2 7 3 6 7 4 5
5 4 5 7 3 6 3 5 2 3 4 8 4 6 3 5 6 8 8 2
7 8 6 6 2 3 6 7 8 3 5 8 6 3 8 4 8 3 4 8
4 5 2 4 5 7 6 2 5 6 4 8 7 7 7 6 2 3 6 4
2 3 7 8 2 8 4 6 7 3 7 4 7 3 7 7 5 6 8 3
6 4 2 7 8 8 7 8 7 4 7 2 2 5 6 2 5 4 8 2
8 6 5 5 6 5 8 3 7 4 5 5 7 8 7 7 2 8 6 4
3 5 3 7 2 3 8 2 3 4 3 3 2 4 4 7 8 8 2 3
5 7 4 8 2 3 2 6 5 4 6 3 4 2 3 4 8 6 2 6
7 8 6 5 3 5 3 8 6 6 3 4 7 3 4 5 5 8 6 2
2 8 3 4 5 7 2 6 8 3 5 2 7 4 6 6 7 4 5 3
8 5 3 6 2 4 6 8 7 3 4 7 4 4 7 6 3 6 8 3];
model.I=I;
model.J=J;
model.p=p;
model.s=s;
model.nVar=I+J-1;
end

  • 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.
  • 151.
  • 152.
  • 153.
  • 154.
  • 155.
  • 156.
  • 157.
  • 158.
  • 159.
  • 160.
  • 161.
  • 162.
  • 163.
  • 164.
  • 165.
  • 166.
  • 167.
  • 168.
  • 169.
  • 170.
  • 171.
  • 172.
  • 173.
  • 174.
  • 175.
  • 176.
  • 177.
  • 178.
  • 179.
  • 180.
  • 181.
  • 182.
  • 183.
  • 184.
  • 185.

3、 ... and 、 Running results

 Insert picture description here
 Insert picture description here

Four 、 remarks

edition :2014a

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