od9 pl metaheuristics

Upload: carolinarvsocn

Post on 07-Mar-2016

216 views

Category:

Documents


2 download

DESCRIPTION

asdgasdg

TRANSCRIPT

  • OPTIMIZAO E DECISO 10/11PL #9 Metaheuristics

    Alexandra Moutinho

    (from Hillier & Lieberman Introduction to Operations Research, 8th edition)

    1

    Problem 1

    Consider the Travelling Salesman Problem (TSP) shown in figure 1, where city 1 is the home city.

    a) List all the possible tours, except exclude those that are simply the reverse of previouslylisted tours. Calculate the distance of each of these tours and thereby identify the optimaltour.

    b) Starting with 1-2-3-4-5-6-1 as the initial trial solution, apply the sub-tour reversal algorithmto this problem.

    c) Apply the sub-tour reversal algorithm to this problem when starting with 1-2-5-4-3-6-1 asthe 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 annealingalgorithm presented in Sec. 13.3 by hand. Follow the instructions given in the following to obtain theneeded random numbers.

    Instructions for obtaining Random Numbers: for each problem or its part where random numbersare 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 adecimal point in front of each group of five random digits (0.09656, 0.96657, etc.) in the order thatyou need random numbers. Always restart from the front of the top row for each new problem or itspart.

    TABLE 20.3 Table of random digits09656 96657 64842 49222 49506 10145 48455 23505 90430 0418024712 55799 60857 73479 33581 17360 30406 05842 72044 9076407202 96341 23699 76171 79126 04512 15426 15980 88898 0635884575 46820 54083 43918 46989 05379 70682 43081 66171 3894238144 87037 46626 70529 27918 34191 98668 33482 43998 7573348048 56349 01986 29814 69800 91609 65374 22928 09704 5934341936 58566 31276 19952 01352 18834 99596 09302 20087 1906373391 94006 03822 81845 76158 41352 40596 14325 27020 17546

    2

    53

    41 8

    15

    12

    8

    7 7

    13

    16

    13

    9

    6

    7 9

    Figure 1 TSP data

  • Optimizao e Deciso 09/10 - PL #9 Metaheuristics - Alexandra Moutinho 2

    57580 08954 73554 28698 29022 11568 35668 59906 39557 2721792646 41113 91411 56215 69302 86419 61224 41936 56939 2781607118 12707 35622 81485 73354 49800 60805 05648 28898 6093357842 57831 24130 75408 83784 64307 91620 40810 06539 7038765078 44981 81009 33697 98324 46928 34198 96032 98426 7748804294 96120 67629 55265 26248 40602 25566 12520 89785 9393248381 06807 43775 09708 73199 53406 02910 83292 59249 1859700459 62045 19249 67095 22752 24636 16965 91836 00582 4672138824 81681 33323 64086 55970 04849 24819 20749 51711 8617391465 22232 02907 01050 07121 53536 71070 26916 47620 0161950874 00807 77751 73952 03073 69063 16894 85570 81746 0756826644 75871 15618 50310 72610 66205 82640 86205 73453 90232

    Source: Reproduced with permission from The Rand Corporation, A Million Random Digits with 700,000Normal 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) andthe next-to-last slot (5). Possibilities (subdivide 0 - 0.9999 into 4 intervals, corresponding to the 4possible beginning slots):

    0.00000-0.24999: Sub-tour begins in slot 2. 0.25000-0.49999: Sub-tour begins in slot 3. 0.50000-0.74999: Sub-tour begins in slot 4. 0.75000-0.99999: Sub-tour begins in slot 6.

    Generate a random number. The random number is 0.09656, so we choose a sub-tour that beginsin 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 (subdivide0 - 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 2 3 4 5 6 7 81 14 15 172 13 14 20 213 11 21 17 9 94 11 10 8 205 15 18 6 9 7 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 ofrandom numbers would need to be generated until a feasible solution is obtained.

  • Optimizao e Deciso 09/10 - PL #9 Metaheuristics - Alexandra Moutinho 3

    a) When applying the basic genetic algorithm presented in Sec. 13.4, suppose that members 2-10of the initial population are the following.

    Member Initial Population Distance12 1-8-7-6-5-2-4-3-1 1143 1-3-6-5-7-4-8-2-1 1284 1-2-5-6-4-7-3-8-1 1025 1-2-4-5-6-7-3-8-1 976 1-2-5-6-7-3-4-8-1 1157 1-3-5-6-7-8-4-2-1 1218 1-3-4-7-6-5-2-8-1 1169 1-3-6-5-7-8-4-3-1 126

    10 1-3-2-5-4-6-7-8-1 108

    Use the procedure described in the fifth paragraph of the subsection Sec. 13.4 entitled TheTraveling 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 obtainthe needed random numbers.

    b) Begin the first iteration of the basic genetic algorithm presented in Sec. 13.4 by selecting theparents, pairing up the parents to form couples, and then using the first couple to generate theirfirst child.

    Resolution

    a) Start from city 1.Possible links: 1-2, 1-3, 1-8Random Number: 0.09656 Choose 1-2.

    Start from city 2. Current tour 1-2Possible links: 2-3, 2-4, 2-5, 2-8Random Number: 0.96657 Choose 2-8.

    Start from city 8. Current tour 1-2-8Possible links: 8-3, 8-4, 8-7Random Number: 0.64842 Choose 8-4.

    Start from city 4. Current tour 1-2-8-4Possible links: 4-3, 4-5, 4-6, 4-7Random Number: 0.49222 Choose 4-5.

    Start from city 5. Current tour 1-2-8-4-5Possible links: 5-3, 5-6, 5-7Random Number: 0.49506 Choose 5-6.

    Start from city 6. Current tour 1-2-8-4-5-6Possible links: 6-3, 6-7Random Number: 0.10145 Choose 6-3.

    Start from city 3. Current tour 1-2-8-4-5-6-3Possible links: 3-7Random Number: 0.48455 Choose 3-7.

    Start from city 7. Current tour 1-2-8-4-5-6-3-7

  • Optimizao e Deciso 09/10 - PL #9 Metaheuristics - Alexandra Moutinho 4

    Dead End. Repeat this process again.

    Start from city 1.Possible links: 1-2, 1-3, 1-8Random Number: 0.23505 Choose 1-2.

    Start from city 2. Current tour 1-2Possible links: 2-3, 2-4, 2-5, 2-8Random Number: 0.90430 Choose 2-8.

    Start from city 8. Current tour 1-2-8Possible links: 8-3, 8-4, 8-7Random 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 endeventually. We begin the process of generating parent 1 again.

    Start from city 1.Possible links: 1-2, 1-3, 1-8Random Number: 0.24712 Choose 1-2.

    Start from city 2. Current tour 1-2Possible links: 2-3, 2-4, 2-5, 2-8Random Number: 0.55799 Choose 2-5.

    Start from city 5. Current tour 1-2-5Possible links: 5-3, 5-4, 5-6, 5-7Random Number: 0.60857 Choose 5-6.

    Start from city 6. Current tour 1-2-5-6Possible links: 6-3, 6-4, 6-7Random Number: 0.73479 Choose 6-7.

    Start from city 7. Current tour 1-2-5-6-7Possible links: 7-3, 7-4, 7-8Random Number: 0.33581 Choose 7-4.

    Start from city 4. Current tour 1-2-5-6-7-4Possible links: 4-3, 4-8Random Number: 0.17360 Choose 4-3.

    Start from city 3. Current tour 1-2-5-6-7-4-3Possible links: 3-8Random 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 isavailable 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 Initial Population Distance1 1-2-5-6-7-4-3-8-1 103

  • Optimizao e Deciso 09/10 - PL #9 Metaheuristics - Alexandra Moutinho 5

    2 1-8-7-6-5-2-4-3-1 1143 1-3-6-5-7-4-8-2-1 1284 1-2-5-6-4-7-3-8-1 1025 1-2-4-5-6-7-3-8-1 976 1-2-5-6-7-3-4-8-1 1157 1-3-5-6-7-8-4-2-1 1218 1-3-4-7-6-5-2-8-1 1169 1-3-6-5-7-8-4-3-1 126

    10 1-3-2-5-4-6-7-8-1 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 theone just rejected and choose one of them randomly.

    Possible links: 2-3, 2-4, 2-8Random number: 0.17953 Choose 2-3.

    Start from city 3. Current Tour: 1-2-3Possible links: 3-7, 3-8, 3-5Random 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 eventhough it is not a link used by either parent. The reason is that the second parent does not havea link from city 3 to any of the cities not already in the tour because the child is using a sub-tour

  • Optimizao e Deciso 09/10 - PL #9 Metaheuristics - Alexandra Moutinho 6

    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-7Possible links: 7-4, 7-6, 7-8Random Number: 0.55799 Choose 7-6.

    0.60857 No mutation

    Start from city 6. Current Tour: 1-2-3-7-6Possible links: 6-5, 6-4, 6-4Random Number: 0.23479 Choose 6-5.

    0.33581 No mutation

    Start from city 5. Current Tour: 1-2-3-7-6-5Possible links: 5-4, 5-4Random 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 sub-tour reversal (reversing 5-6) of the first parent, which requires adding link 5-4 to complete thesub-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.