Download PDF

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
OPTIMIZAÇÃO E DECISÃO 10/11
PL #9 – Metaheuristics
Alexandra Moutinho
th
(from Hillier & Lieberman Introduction to Operations Research, 8 edition)
Problem 1
Consider the Travelling Salesman Problem (TSP) shown in figure 1, where city 1 is the home city.
2
13
15
7
8
8
7
12
9
9
5
1
13
3
4
7
16
6
Figure 1 – TSP data
a) List all the possible tours, except exclude those that are simply the reverse of previously
listed tours. Calculate the distance of each of these tours and thereby identify the optimal
tour.
b) Starting with 1-2-3-4-5-6-1 as the initial trial solution, apply the sub-tour reversal algorithm
to this problem.
c) Apply the sub-tour reversal algorithm to this problem when starting with 1-2-5-4-3-6-1 as
the initial trial solution.
Problem 2
Reconsider the TSP given in Figure 1.
Using 1-2-3-4-6-5-1 as the initial trial solution, perform one iteration of the basic simulated annealing
algorithm presented in Sec. 13.3 by hand. Follow the instructions given in the following to obtain the
needed random numbers.
Instructions for obtaining Random Numbers: for each problem or its part where random numbers
are needed, obtain them from the consecutive random digits in Table 20.3 in section 20.3 as follows.
Start from the front of the top row of the table and form five-digit random numbers by placing a
decimal point in front of each group of five random digits (0.09656, 0.96657, etc.) in the order that
you need random numbers. Always restart from the front of the top row for each new problem or its
part.
TABLE 20.3 Table of random digits
09656
24712
07202
84575
38144
48048
41936
73391
96657
55799
96341
46820
87037
56349
58566
94006
64842
60857
23699
54083
46626
01986
31276
03822
49222
73479
76171
43918
70529
29814
19952
81845
49506
33581
79126
46989
27918
69800
01352
76158
10145
17360
04512
05379
34191
91609
18834
41352
48455
30406
15426
70682
98668
65374
99596
40596
23505
05842
15980
43081
33482
22928
09302
14325
90430
72044
88898
66171
43998
09704
20087
27020
04180
90764
06358
38942
75733
59343
19063
17546
1
57580
92646
07118
57842
65078
04294
48381
00459
38824
91465
50874
26644
08954
41113
12707
57831
44981
96120
06807
62045
81681
22232
00807
75871
73554
91411
35622
24130
81009
67629
43775
19249
33323
02907
77751
15618
28698
56215
81485
75408
33697
55265
09708
67095
64086
01050
73952
50310
29022
69302
73354
83784
98324
26248
73199
22752
55970
07121
03073
72610
11568
86419
49800
64307
46928
40602
53406
24636
04849
53536
69063
66205
35668
61224
60805
91620
34198
25566
02910
16965
24819
71070
16894
82640
59906
41936
05648
40810
96032
12520
83292
91836
20749
26916
85570
86205
39557
56939
28898
06539
98426
89785
59249
00582
51711
47620
81746
73453
27217
27816
60933
70387
77488
93932
18597
46721
86173
01619
07568
90232
Source: Reproduced with permission from The Rand Corporation, A Million Random Digits with 700,000
Normal Deviates. Copyright, The Free Press, Glencoe, IL, 1955, top of p. 182.
Resolution
Initial trial solution: 1-2-3-4-6-5-1
Zc = 59 T1 = 0.2
Zc = 11.8
The beginning slot can be anywhere except the first and last slots (1 - reserved for the home city) and
the next-to-last slot (5). Possibilities (subdivide 0 - 0.9999 into 4 intervals, corresponding to the 4
possible beginning slots):
0.00000-0.24999:
0.25000-0.49999:
0.50000-0.74999:
0.75000-0.99999:
Sub-tour begins in slot 2.
Sub-tour begins in slot 3.
Sub-tour begins in slot 4.
Sub-tour begins in slot 6.
“Generate” a random number. The random number is 0.09656, so we choose a sub-tour that begins
in slot 2 (0.00000 < 0.09656 < 0.24999).
By beginning in slot 2, the sub-tour needs to end somewhere in slots 3, 4 or 6. Possibilities (subdivide
0 - 0.9999 into 3 intervals, corresponding to the 3 possible ending slots):
0.00000-0.33332: Sub-tour end in slot 3.
0.33333-0.66666: Sub-tour end in slot 4.
0.66667-0.99999: Sub-tour end in slot 6.
The random number “generated” is 0.96657, so we choose a sub-tour that ends in slot 6.
Reverse 2-3-4-6: new solution: 1-6-4-3-2-5-11 Zn = 56
Since Zn = 56 < Zc = 59, we accept 1-6-4-3-2-5-1 as the new trial solution.
Problem 3
Consider an 8-city TSP. The links for this problem have the associated distances shown in the Table 1
(where a dash indicates the absence of a link).
City
1
2
3
4
5
6
7
2
14
3
15
13
4
—
14
11
5
—
20
21
11
6
—
—
17
10
15
7
—
—
9
8
18
9
8
17
21
9
20
—
—
13
Table 1 – TSP data for Problem 3
1
This is fortunately a feasible solution, where all the cities are connected by a link. If this did not happened, new pairs of
random numbers would need to be generated until a feasible solution is obtained.
Optimização e Decisão 09/10 - PL #9 Metaheuristics - Alexandra Moutinho
2
a)
When applying the basic genetic algorithm presented in Sec. 13.4, suppose that members 2-10
of the initial population are the following.
Member
1
2
3
4
5
6
7
8
9
10
Initial Population
Distance
1-8-7-6-5-2-4-3-1
1-3-6-5-7-4-8-2-1
1-2-5-6-4-7-3-8-1
1-2-4-5-6-7-3-8-1
1-2-5-6-7-3-4-8-1
1-3-5-6-7-8-4-2-1
1-3-4-7-6-5-2-8-1
1-3-6-5-7-8-4-3-1
1-3-2-5-4-6-7-8-1
114
128
102
97
115
121
116
126
108
Use the procedure described in the fifth paragraph of the subsection Sec. 13.4 entitled “The
Traveling Salesman Problem Example” to generate member 1 of this population by hand.
Follow the instructions given at the beginning of the Problems section for Chapter 13 to obtain
the needed random numbers.
b)
Begin the first iteration of the basic genetic algorithm presented in Sec. 13.4 by selecting the
parents, pairing up the parents to form couples, and then using the first couple to generate their
first child.
Resolution
a)
Start from city 1.
Possible links: 1-2, 1-3, 1-8
Random Number: 0.09656
Choose 1-2.
Start from city 2. Current tour 1-2
Possible links: 2-3, 2-4, 2-5, 2-8
Random Number: 0.96657
Choose 2-8.
Start from city 8. Current tour 1-2-8
Possible links: 8-3, 8-4, 8-7
Random Number: 0.64842
Choose 8-4.
Start from city 4. Current tour 1-2-8-4
Possible links: 4-3, 4-5, 4-6, 4-7
Random Number: 0.49222
Choose 4-5.
Start from city 5. Current tour 1-2-8-4-5
Possible links: 5-3, 5-6, 5-7
Random Number: 0.49506
Choose 5-6.
Start from city 6. Current tour 1-2-8-4-5-6
Possible links: 6-3, 6-7
Random Number: 0.10145
Choose 6-3.
Start from city 3. Current tour 1-2-8-4-5-6-3
Possible links: 3-7
Random Number: 0.48455
Choose 3-7.
Start from city 7. Current tour 1-2-8-4-5-6-3-7
Optimização e Decisão 09/10 - PL #9 Metaheuristics - Alexandra Moutinho
3
Dead End. Repeat this process again.
Start from city 1.
Possible links: 1-2, 1-3, 1-8
Random Number: 0.23505
Choose 1-2.
Start from city 2. Current tour 1-2
Possible links: 2-3, 2-4, 2-5, 2-8
Random Number: 0.90430 Choose 2-8.
Start from city 8. Current tour 1-2-8
Possible links: 8-3, 8-4, 8-7
Random Number: 0.04180
Choose 8-3.
Since we now have chosen all the cities that have links to city 1, we will reach a dead end
eventually. We begin the process of generating parent 1 again.
Start from city 1.
Possible links: 1-2, 1-3, 1-8
Random Number: 0.24712
Choose 1-2.
Start from city 2. Current tour 1-2
Possible links: 2-3, 2-4, 2-5, 2-8
Random Number: 0.55799 Choose 2-5.
Start from city 5. Current tour 1-2-5
Possible links: 5-3, 5-4, 5-6, 5-7
Random Number: 0.60857
Choose 5-6.
Start from city 6. Current tour 1-2-5-6
Possible links: 6-3, 6-4, 6-7
Random Number: 0.73479
Choose 6-7.
Start from city 7. Current tour 1-2-5-6-7
Possible links: 7-3, 7-4, 7-8
Random Number: 0.33581
Choose 7-4.
Start from city 4. Current tour 1-2-5-6-7-4
Possible links: 4-3, 4-8
Random Number: 0.17360 Choose 4-3.
Start from city 3. Current tour 1-2-5-6-7-4-3
Possible links: 3-8
Random Number: 0.30406
Choose 3-8.
Start from city 8. Current tour 1-2-5-6-7-4-3-8
Since all the cities now are in the tour, we automatically add the link 8-1 (which fortunately is
available this time) from the last city back to the home city.
Parent 1 is 1-2-5-6-7-4-3-8-1.
b)
Selection of Parents:
We need to select six members from among the following initial population to become parents.
Member
1
Initial Population
1-2-5-6-7-4-3-8-1
Distance
103
Optimização e Decisão 09/10 - PL #9 Metaheuristics - Alexandra Moutinho
4
2
3
4
5
6
7
8
9
10
1-8-7-6-5-2-4-3-1
1-3-6-5-7-4-8-2-1
1-2-5-6-4-7-3-8-1
1-2-4-5-6-7-3-8-1
1-2-5-6-7-3-4-8-1
1-3-5-6-7-8-4-2-1
1-3-4-7-6-5-2-8-1
1-3-6-5-7-8-4-3-1
1-3-2-5-4-6-7-8-1
114
128
102
97
115
121
116
126
108
We choose 4 members among the 5 having the highest degree of fitness (in order): 5, 4, 1, 10,
and 2. A random number is used to select one member to be rejected.
Random number: 0.09656.
The first member listed (member 5) does not become a parent.
We also select 2 members among the less fit members: 6, 8, 7, 9, and 3.
Random number: 0.96657. We select member 3 to become a parent.
The next random number is used to select a parent among 6, 8, 7, and 9.
Random number: 0.64842. We select member 7 to become a parent.
Pairing up the Parents:
The next step is to pair up parents – members 4, 1, 10, 2, 7, and 3.
We use a random number to determine the mate of the first parent listed (member 4).
Random number: 0.29222. Member 10 is selected to pair up with member 4.
Next, we use a random number to pair up the next member listed (member 1).
Random number: 0.49506. Member 7 is selected to pair up with member 1.
This then leaves member 2 and member 3 to become the last couple.
Generation of a Child from the First Pair of Parents:
Pair 1:
M4: 1-2-5-6-4-7-3-8-1
M10: 1-3-2-5-4-6-7-8-1
Start from city 1.
Possible links: 1-2, 1-8, 1-3, 1-8.
Random Number: 0.10145
Choose 1-2.
0.48455
No mutation
Start from city 2. Current Tour: 1-2.
Possible links: 2-5, 2-3, 2-5.
Random Number: 0.23505
Choose 2-5.
0.09430
Mutation
Reject 2-5.
Since a mutation has just occurred, we now list all the possible links from city 2 other than the
one just rejected and choose one of them randomly.
Possible links: 2-3, 2-4, 2-8
Random number: 0.17953
Choose 2-3.
Start from city 3. Current Tour: 1-2-3
Possible links: 3-7, 3-8, 3-5
Random Number: 0.04180
Choose 3-7.
0.24712
No mutation
An interesting feature of the step just completed is that 3-5 is listed as a possible link even
though it is not a link used by either parent. The reason is that the second parent does not have
a link from city 3 to any of the cities not already in the tour because the child is using a sub-tour
Optimização e Decisão 09/10 - PL #9 Metaheuristics - Alexandra Moutinho
5
reversal (reversing 3-2). Completing this sub-tour reversal requires adding the link 3-5. However,
link 3-7 was chosen instead of link 3-5, so we continue with 1-2-3-7 as the current tour.
Start from city 7. Current Tour: 1-2-3-7
Possible links: 7-4, 7-6, 7-8
Random Number: 0.55799
Choose 7-6.
0.60857
No mutation
Start from city 6. Current Tour: 1-2-3-7-6
Possible links: 6-5, 6-4, 6-4
Random Number: 0.23479
Choose 6-5.
0.33581
No mutation
Start from city 5. Current Tour: 1-2-3-7-6-5
Possible links: 5-4, 5-4
Random Number: 0.17360
Choose 5-4.
0.30406
No mutation
The link 5-4 comes from the first parent as well as the second because the child is using a subtour reversal (reversing 5-6) of the first parent, which requires adding link 5-4 to complete the
sub-tour reversal.
Start from city 4. Current Tour: 1-2-3-7-6-5-4
Since the only city not yet visited on the tour is city 8, link 7-8 is automatically added next,
followed by link 8-1 to return to the home city. Therefore, the complete child is
1-2-3-7-6-5-4-8-1,
which has a distance of 108.
Optimização e Decisão 09/10 - PL #9 Metaheuristics - Alexandra Moutinho
6
Related documents