### 【车间调度】基于matlab粒子群算法求解生产调度问题【含Matlab源码 412期】

Matlab科研 2021-08-10 09:13:23 阅读数:52

MATLAB 搜索 迭代 粒子群算法 优化算法

## 二、粒子群算法简介

1.1 粒子群优化

1.1.1 算法思想

1.1.2 粒子群优化过程

v i d t + 1 = v i d t + c 1 r 1 ( p i d t − x i d t ) + c 2 r 2 ( p g d t − x i d t ) (1) v_{id}^{t + 1} = v_{id}^t + {c_1}{r_1}\left( {p_{id}^t - x_{id}^t} \right) + {c_2}{r_2}\left( {p_{gd}^t - x_{id}^t} \right)\tag 1vidt+1​=vidt​+c1​r1​(pidt​−xidt​)+c2​r2​(pgdt​−xidt​)(1)

x i d t + 1 = x i d t + v i d t + 1 (2) x_{id}^{t + 1} = x_{id}^t + v_{id}^{t + 1}\tag 2xidt+1​=xidt​+vidt+1​(2)

1.1.3 解读更新等式

1.2 粒子群优化中的参数

## 三、部分源代码

clear;
w=3;% 程序运行次数
genn=50; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%最大代数
PS=50; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 种群规模
e=0.4; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PSO算法惯性因子
ICPSOm=zeros(1,w);
ICPSOOptimy=cell(w,1);
CPSOm=zeros(1,w);
CPSOOptimy=cell(w,1);
T=[ 54 79 16 66 58
83 3 89 58 56
15 11 49 31 20
71 99 15 68 85
77 56 89 78 53
36 70 45 91 35
53 99 60 13 53
38 60 23 59 41
27 5 57 49 69
87 56 64 85 13
76 3 7 85 86
91 61 1 9 72
14 73 63 39 8
29 75 41 41 49
12 47 63 56 47
77 14 47 40 87
32 21 26 54 58
87 86 75 77 18
68 5 77 51 68
94 77 40 31 28];
pt=T';
global v
for v=1:w
[opy,optimya]=ICPSOflowshop(pt,genn,PS,e);
ICPSOm(v)=opy;
%CPSOSE{v,1}=opx;
%CPSOAvgen{v,1}=avgena;
ICPSOOptimy{v,1}=optimya;
[opy,optimyb]=copsoflowshop(pt,genn,PS,e);
CPSOm(v)=opy;
%PSOSE{v,1}=opx;
%PSOAvgen{v,1}=avgen;
CPSOOptimy{v,1}=optimyb;
CPSOm =
1294 1297 1297 1297 1297 1296 1278 1297 1297 1297
CPSOminm =
1278
CPSOmaxm =
1297
CPSOaverage =
1.2947e+003
CPSOstd =
5.9451
??? Undefined variable 'CPSOSE' or class 'CPSOSE'.
Error in ==> C:\MATLAB6p5p1\work\CPSO flow-shop of subswarm\copsomain.m
On line 61 ==> see=CPSOSE{CPSOh(1),1};
fschange('C:\MATLAB6p5p1\work\CPSO flow-shop of subswarm\copsomain.m');
clear copsomain
fschange('C:\MATLAB6p5p1\work\CPSO flow-shop of subswarm\copsomain.m');
clear copsomain
copsomain
CPSOm =
1297 1297 1297 1297 1297 1297 1295 1279 1297 1297
CPSOminm =
1279
CPSOmaxm =
1297
CPSOaverage =
1295
CPSOstd =
5.6569
CPSOm =
1297 1289 1278 1297 1278 1297 1278 1297 1297 1283
CPSOminm =
1278
CPSOmaxm =
1297
CPSOaverage =
1.2891e+003
CPSOstd =
8.9374
CPSOm =
1278 1297 1297 1297 1297 1296 1297 1297 1278 1297
CPSOminm =
1278
CPSOmaxm =
1297
CPSOaverage =
1.2931e+003
CPSOstd =
7.9645
CPSOm =
1294 1297 1296 1297 1297 1297 1278 1297 1294 1297
CPSOminm =
1278
CPSOmaxm =
1297
CPSOaverage =
1.2944e+003
CPSOstd =
5.8916
PSOm =
1297 1297 1297 1297 1278 1297 1278 1297 1297 1297
CPSOm =
1294 1288 1288 1297 1287 1297 1289 1297 1297 1291
PSOminm =
1278
PSOmaxm =
1297
PSOaverage =
1.2932e+003
PSOst =
8.0111
CPSOminm =
1287
CPSOmaxm =
1297
CPSOaverage =
1.2925e+003
CPSOstd =
4.3269
PSOm =
1278 1297 1297 1297 1278 1297 1297 1281 1297 1278
CPSOm =
1297 1293 1278 1297 1297 1297 1297 1297 1297 1297
PSOminm =
1278
PSOmaxm =
1297
PSOaverage =
1.2897e+003
PSOst =
9.4640
CPSOminm =
1278
CPSOmaxm =
1297
CPSOaverage =
1.2947e+003
CPSOstd =
6.0009
PSOm =
1298 1306 1297 1297 1297 1297 1297 1297 1297 1297
CPSOm =
1297 1297 1297 1297 1297 1297 1297 1297 1297 1297
PSOminm =
1297
PSOmaxm =
1306
PSOaverage =
1298
PSOst =
2.8284
CPSOminm =
1297
CPSOmaxm =
1297
CPSOaverage =
1297
CPSOstd =
0
PSOm =
Columns 1 through 9
1618 1596 1607 1618 1607 1604 1605 1613 1604
Column 10
1618
CPSOm =
Columns 1 through 9
1605 1615 1598 1607 1618 1610 1619 1586 1616
Column 10
1609
PSOminm =
1596
PSOmaxm =
1618
PSOaverage =
1609
PSOst =
7.4685
CPSOminm =
1586
CPSOmaxm =
1619
CPSOaverage =
1.6083e+003
CPSOstd =
10.1768
PSOm =
Columns 1 through 9
1617 1623 1625 1616 1633 1597 1622 1618 1600
Column 10
1617
CPSOm =
Columns 1 through 9
1607 1615 1615 1618 1607 1583 1584 1602 1618
Column 10
1617
PSOminm =
1597
PSOmaxm =
1633
PSOaverage =
1.6168e+003
PSOst =
10.9118
CPSOminm =
1583
CPSOmaxm =
1618
CPSOaverage =
1.6066e+003
CPSOstd =
13.3267
PSOm =
4030 3984 4059 4069 4007 4006 3984 4019 4035 3994
CPSOm =
4002 4001 4012 4008 4015 3991 4009 3981 4001 3987
PSOminm =
3984
PSOmaxm =
4069
PSOaverage =
4.0187e+003
PSOst =
29.5599
CPSOminm =
3981
CPSOmaxm =
4015
CPSOaverage =
4.0007e+003
CPSOstd =
11.1858
PSOm =
4044 4019 3980 4027 4046 4047 4035 4076 4050 3989
CPSOm =
4012 4025 4008 3970 3987 3996 4007 4026 4035 3979
PSOminm =
3980
PSOmaxm =
4076
PSOaverage =
4.0313e+003
PSOst =
29.0136
CPSOminm =
3970
CPSOmaxm =
4035
CPSOaverage =
4.0045e+003
CPSOstd =
21.3607
PSOm =
4039 4138 4077 4128 4123 4052 4093 4162 4148 4142
CPSOm =
4105 4171 4111 4105 4147 4141 4168 4044 4066 4098
PSOminm =
4039


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.
186.
187.
188.
189.
190.
191.
192.
193.
194.
195.
196.
197.
198.
199.
200.
201.
202.
203.
204.
205.
206.
207.
208.
209.
210.
211.
212.
213.
214.
215.
216.
217.
218.
219.
220.
221.
222.
223.
224.
225.
226.
227.
228.
229.
230.
231.
232.
233.
234.
235.
236.
237.
238.
239.
240.
241.
242.
243.
244.
245.
246.
247.
248.
249.
250.
251.
252.
253.
254.
255.
256.
257.
258.
259.
260.
261.
262.
263.
264.
265.
266.
267.
268.
269.
270.
271.
272.
273.
274.
275.
276.
277.
278.
279.
280.
281.
282.
283.
284.
285.
286.
287.
288.
289.
290.
291.
292.
293.
294.
295.
296.
297.
298.
299.
300.
301.
302.
303.
304.
305.
306.
307.
308.
309.
310.
311.
312.
313.
314.
315.
316.
317.
318.
319.
320.
321.
322.
323.
324.
325.
326.
327.
328.
329.
330.
331.
332.
333.
334.
335.
336.
337.
338.
339.
340.
341.
342.
343.
344.
345.
346.
347.
348.
349.
350.
351.
352.
353.
354.
355.
356.
357.
358.
359.
360.
361.
362.
363.
364.
365.
366.
367.
368.
369.
370.
371.
372.
373.
374.
375.
376.
377.
378.
379.
380.
381.
382.
383.
384.
385.
386.
387.
388.
389.
390.
391.
392.
393.
394.
395.
396.
397.
398.
399.
400.
401.
402.
403.
404.
405.
406.
407.
408.
409.
410.
411.
412.
413.
414.
415.
416.
417.
418.
419.
420.
421.
422.
423.
424.
425.
426.
427.
428.
429.
430.
431.
432.
433.
434.
435.
436.
437.
438.
439.
440.
441.
442.
443.
444.
445.
446.
447.
448.
449.
450.
451.
452.
453.
454.
455.
456.
457.
458.
459.
460.
461.
462.
463.
464.
465.
466.
467.
468.
469.
470.
471.
472.
473.
474.
475.
476.
477.
478.
479.
480.
481.
482.
483.
484.
485.
486.
487.
488.
489.
490.
491.
492.
493.
494.
495.
496.
497.
498.
499.
500.
501.
502.
503.
504.
505.
506.
507.
508.
509.
510.
511.
512.
513.
514.
515.
516.
517.
518.
519.
520.
521.
522.
523.
524.
525.
526.
527.
528.
529.
530.
531.
532.
533.
534.
535.
536.
537.
538.
539.
540.
541.
542.
543.
544.
545.
546.
547.
548.
549.
550.
551.
552.
553.
554.
555.
556.
557.
558.
559.
560.
561.
562.
563.
564.
565.
566.
567.
568.
569.
570.
571.
572.
573.
574.
575.
576.
577.
578.
579.
580.


## 五、matlab版本及参考文献

1 matlab版本
2014a

2 参考文献
[1] 包子阳,余继周,杨杉.智能优化算法及其MATLAB实例（第2版）[M].电子工业出版社，2016.
[2]张岩,吴水根.MATLAB优化算法源代码[M].清华大学出版社，2017.