-
Notifications
You must be signed in to change notification settings - Fork 9
/
run.m
75 lines (71 loc) · 3.87 KB
/
run.m
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
clear all;
% chromosome_size: 输入染色体长度 即节点个数
%least:枢纽最少值
%most:枢纽最多值
chromosome_size = 15;
least = 3;
most = 8;
% population_size: 输入种群大小 为偶数
% generation_size: 输入迭代次数
% cross_rate: 输入交叉概率
% mutate_rate: 输入变异概率
% elitism: 输入是否精英选择
elitism = 1;
mutate_rate = 0.2;
cross_rate = 0.5;
generation_size =8;
population_size = 8;
global Distance;
global TravelTime;
global Flow;
global FixedHubCost;
Distance = [0,757,948,1128,1399,205,950,1210,296,854,1062,1342,1025,684,972;
757,0,191,382,653,912,421,453,998,840,305,585,268,77,215;
948,191,0,273,544,1103,567,262,1189,896,114,394,159,268,134;
1128,382,273,0,271,1283,414,243,1368,1169,159,375,342,459,407;
1399,653,544,271,0,1554,602,320,1633,1440,430,188,613,730,678;
205,912,1103,1283,1554,0,1143,1365,95,701,1217,1497,1180,839,1067;
950,421,567,414,602,1143,0,601,1151,1261,453,733,636,498,612;
1210,453,262,243,320,1365,601,0,1451,1158,148,132,331,530,396;
296,998,1189,1368,1633,95,1151,1451,0,796,1303,1583,1266,925,1162;
854,840,896,1169,1440,701,1261,1158,796,0,1010,1290,973,763,843;
1062,305,114,159,430,1217,453,148,1303,1010,0,280,183,382,248;
1342,585,394,375,188,1497,733,132,1583,1290,280,0,463,662,528;
1025,268,159,342,613,1180,636,331,1266,973,183,463,0,345,173;
684,77,268,459,730,839,498,530,925,763,382,662,345,0,292;
972,215,134,407,678,1067,612,396,1162,843,248,528,173,292,0];
TravelTime = [0,687,801,1039,1276,211,869,995,318,571,893,1104,886,629,848;
687,0,134,372,609,867,414,328,968,852,226,437,215,61,176;
801,134,0,238,474,976,507,193,1076,921,91,303,117,176,132;
1039,372,238,0,279,1214,422,139,1314,1159,166,197,325,414,370;
1276,609,474,279,0,1450,648,293,1551,1396,410,156,561,650,606;
211,867,976,1214,1450,0,1081,1169,100,483,1067,1279,1061,799,1023;
869,414,507,422,648,1081,0,485,1087,1217,488,594,600,480,568;
995,328,193,139,293,1169,485,0,1270,1115,129,122,280,369,325;
318,968,1076,1314,1551,100,1087,1270,0,570,1168,1379,1161,900,1123;
571,852,921,1159,1396,483,1217,1115,570,0,1013,1224,922,784,892;
893,226,91,166,410,1067,488,129,1168,1013,0,239,174,268,224;
1104,437,303,197,156,1279,594,122,1379,1224,239,0,390,479,435;
886,215,117,325,561,1061,600,280,1161,922,174,390,0,261,104;
629,61,176,414,650,799,480,369,900,784,268,479,261,0,219;
848,176,132,370,606,1023,568,325,1123,892,224,435,104,219,0];
Flow = [0,39190,2500,20184,4307,12794,4762,108156,6555,3385,7035,5790,5716,3548,2078;
37216,0,16062,129681,27674,82201,30595,694878,42116,21748,45201,37202,36721,22798,13350;
2513,17003,0,8757,1869,5551,2066,46926,2844,1469,3052,2512,2480,1540,902;
19733,133508,8517,0,14674,43587,16223,368455,22332,11532,23967,19726,19471,12088,7079;
4318,29211,1863,15045,0,9537,3550,80617,4886,2523,5244,4316,4260,2645,1549;
12654,85609,5461,44093,9409,0,10403,236265,14320,7394,15369,12649,12486,7752,4539;
4770,32271,2059,16621,3547,10536,0,89061,5398,2787,5793,4768,4706,2922,1711;
93030,629407,40152,324172,69179,205484,76481,0,105280,54365,112992,92997,91795,56990,33372;
6547,44296,2826,22815,4869,14462,5383,122249,0,3826,7952,6545,6460,4011,2349;
3398,22989,1467,11840,2527,7505,2794,63446,3845,0,4127,3397,3353,2082,1219;
7022,47505,3031,24467,5221,15509,5772,131104,7946,4103,0,7019,6928,4301,2519;
5790,39176,2499,20177,4306,12790,4760,108118,6553,3384,7033,0,5714,3547,2077;
5716,38674,2467,19919,4251,12626,4699,106732,6469,3340,6943,5714,0,3502,2051;
3561,24093,1537,12409,2648,7866,2928,66492,4030,2081,4325,3560,3514,0,1277;
2090,14142,902,7284,1554,4617,1718,39028,2365,1221,2539,2089,2062,1280,0];
FixedHubCost = [774.842802,310,527,296,406,515,649,230,566,742,630,460,621,635,728,774.842802,310,527,296,406,515,649,230,566,742,630,460,621,635,728];
global population;
global fitness_value;
global population_new;
genetic_algorithm(population_size, chromosome_size, generation_size, cross_rate, mutate_rate, elitism,least,most);