implementation exercises for the course heuristic
play

Implementation exercises for the course Heuristic Optimization Dr. - PowerPoint PPT Presentation

Implementation exercises for the course Heuristic Optimization Dr. Manuel L opez-Ib a nez manuel.lopez-ibanez@ulb.ac.be IRIDIA, CoDE, ULB March 6, 2013 Dr. Manuel L opez-Ib a nez Exercises for Heuristic Optimization


  1. Implementation exercises for the course Heuristic Optimization Dr. Manuel L´ opez-Ib´ a˜ nez manuel.lopez-ibanez@ulb.ac.be IRIDIA, CoDE, ULB March 6, 2013 Dr. Manuel L´ opez-Ib´ a˜ nez Exercises for Heuristic Optimization

  2. Implementation Exercise 1 The Traveling Salesman Problem with Time Windows Exercise 1.1. Iterative improvement algorithms for the TSPTW Exercise 1.2. Variable Neighborhood Descent for the TSPTW Dr. Manuel L´ opez-Ib´ a˜ nez Exercises for Heuristic Optimization

  3. The Traveling Salesman Problem with Time Windows TSP + each “node” may only be visited within a time-window Given an undirected complete graph G = ( N , E ) , where N = { 0 , 1 , . . . , n } customer nodes, 0 is the depot a travel time c ( e ij ) for every edge e ij ∈ E a time window [ s i , l i ] for each i ∈ N if node i visited sooner than s i ⇒ wait if node i visited later than l i ⇒ constraint violation Dr. Manuel L´ opez-Ib´ a˜ nez Exercises for Heuristic Optimization

  4. The Traveling Salesman Problem with Time Windows Find a tour π = ( π 0 = 0 , π 1 , . . . , π n , π n + 1 = 0 ) , where ( π 1 , . . . , π n ) is a permutation of the nodes in N \ { 0 } and π k = customer at the k th position of the tour. such that: n � minimize: f ( π ) = c ( e π k ,π k + 1 ) (travel time) k = 0 n + 1 � subject to: Ω( π ) = ω ( π k ) = 0 (constraint violations) k = 0 � if A π k > l π k , 1 ω ( π k ) = where: 0 otherwise; A π k + 1 = max ( A π k , s π k ) + c ( e π k ,π k + 1 ) (arrival time) Dr. Manuel L´ opez-Ib´ a˜ nez Exercises for Heuristic Optimization

  5. The Traveling Salesman Problem with Time Windows [ 0 , 100 ] 0 7 [ 40 , 70 ] [ 70 , 75 ] 8 5 6 5 7 [ 30 , 35 ] [ 40 , 60 ] 9 5 15 1 4 6 9 [ 30 , 45 ] [ 30 , 47 ] 8 11 2 3 Dr. Manuel L´ opez-Ib´ a˜ nez Exercises for Heuristic Optimization

  6. The Traveling Salesman Problem with Time Windows [ 0 , 100 ] A = 85 0 7 [ 40 , 70 ] [ 70 , 75 ] 8 A = 78 A = 70 5 6 5 7 [ 30 , 35 ] [ 40 , 60 ] 9 5 15 A = 30 A = 56 1 4 6 9 [ 30 , 45 ] [ 30 , 47 ] 8 11 A = 36 A = 47 2 3 Dr. Manuel L´ opez-Ib´ a˜ nez Exercises for Heuristic Optimization

  7. The Traveling Salesman Problem with Time Windows [ 0 , 100 ] A = 85 0 7 [ 40 , 70 ] [ 70 , 75 ] 8 A = 78 A = 70 5 6 5 7 [ 30 , 35 ] [ 40 , 60 ] 9 5 15 A = 30 A = 56 1 4 6 9 [ 30 , 45 ] [ 30 , 47 ] 8 11 A = 36 A = 47 2 3 Travel time: f = 5 + 6 + 11 + 9 + 5 + 8 + 7 = 51 Constraint violations: Ω = 1 Dr. Manuel L´ opez-Ib´ a˜ nez Exercises for Heuristic Optimization

  8. Exercise 1.1: Iterative Improvement for the TSPTW Implement 6 iterative improvement algorithms for the TSPTW Dr. Manuel L´ opez-Ib´ a˜ nez Exercises for Heuristic Optimization

  9. Exercise 1.1: Iterative Improvement for the TSPTW Implement 6 iterative improvement algorithms for the TSPTW Pivoting rule: first-improvement 1 best-improvement 2 Neighborhood: Transpose 1 Insert 2 Exchange 3 Initial solution: Random permutation (uninformed random picking) 1 Dr. Manuel L´ opez-Ib´ a˜ nez Exercises for Heuristic Optimization

  10. Exercise 1.1: Iterative Improvement for the TSPTW Implement 6 iterative improvement algorithms for the TSPTW Pivoting rule: first-improvement 1 best-improvement 2 Neighborhood: Transpose 1 Insert 2 Exchange 3 Initial solution: Random permutation (uninformed random picking) 1 2 pivoting rules × 3 neighborhoods × 1 initialization method = 6 combinations Dr. Manuel L´ opez-Ib´ a˜ nez Exercises for Heuristic Optimization

  11. Exercise 1.1: Iterative Improvement for the TSPTW Implement 6 iterative improvement algorithms for the TSPTW Don’t implement 6 programs! Reuse code and use command-line parameters tsptw-ii --first --transpose --init-random tsptw-ii --best --exchange --init-random ... Dr. Manuel L´ opez-Ib´ a˜ nez Exercises for Heuristic Optimization

  12. Exercise 1.1: Iterative Improvement for the TSPTW Iterative Improvement π := GenerateInitialSolution() while π is not a local optimum do choose a neighbour π ′ ∈ N ( π ) such that F ( π ′ ) < F ( π ) π := π ′ Dr. Manuel L´ opez-Ib´ a˜ nez Exercises for Heuristic Optimization

  13. Exercise 1.1: Iterative Improvement for the TSPTW Iterative Improvement π := GenerateInitialSolution() while π is not a local optimum do choose a neighbour π ′ ∈ N ( π ) such that F ( π ′ ) < F ( π ) π := π ′ Which neighbour to choose? Pivoting rule Best Improvement: choose best from all neighbours of s First improvement: evaluate neighbours in fixed order and choose first improving neighbour. Dr. Manuel L´ opez-Ib´ a˜ nez Exercises for Heuristic Optimization

  14. Exercise 1.1: Iterative Improvement for the TSPTW Iterative Improvement π := GenerateInitialSolution() while π is not a local optimum do choose a neighbour π ′ ∈ N ( π ) such that F ( π ′ ) < F ( π ) π := π ′ Which neighbour to choose? Pivoting rule Best Improvement: choose best from all neighbours of s ✔ Better quality ✘ Requires evaluation of all neighbours in each step First improvement: evaluate neighbours in fixed order and choose first improving neighbour. Dr. Manuel L´ opez-Ib´ a˜ nez Exercises for Heuristic Optimization

  15. Exercise 1.1: Iterative Improvement for the TSPTW Iterative Improvement π := GenerateInitialSolution() while π is not a local optimum do choose a neighbour π ′ ∈ N ( π ) such that F ( π ′ ) < F ( π ) π := π ′ Which neighbour to choose? Pivoting rule Best Improvement: choose best from all neighbours of s ✔ Better quality ✘ Requires evaluation of all neighbours in each step First improvement: evaluate neighbours in fixed order and choose first improving neighbour. ✔ More efficient ✘ Order of evaluation may impact quality / performance Dr. Manuel L´ opez-Ib´ a˜ nez Exercises for Heuristic Optimization

  16. Exercise 1.1: Iterative Improvement for the TSPTW Iterative Improvement π := GenerateInitialSolution() while π is not a local optimum do choose a neighbour π ′ ∈ N ( π ) such that F ( π ′ ) < F ( π ) π := π ′ Which neighborhood N ( π ) ? Transpose Insertion Exchange Dr. Manuel L´ opez-Ib´ a˜ nez Exercises for Heuristic Optimization

  17. Exercise 1.1: Iterative Improvement for the TSPTW ¼ A B C D E F ¼ ¶ A C B D E F transpose neighbourhood ¼ A B C D E F ¼ ¶ A E C D B F exchange neighbourhood ¼ A B C D E F ¼ ¶ A C D B E F insert neighbourhood Dr. Manuel L´ opez-Ib´ a˜ nez Exercises for Heuristic Optimization

  18. Exercise 1.1: Iterative Improvement for the TSPTW ¼ A B C D E F π ′ = transp ( π, k ) = Transpose π k and π k + 1 ¼ A C B D E F ¶ transpose neighbourhood Fast (delta) evaluation of travel time: ∆ c = c ( a π k − 1 ,π k + 1 ) + c ( a π k + 1 ,π k ) + c ( a π k ,π k + 2 ) − c ( a π k − 1 ,π k ) − c ( a π k ,π k + 1 ) − c ( a π k + 1 ,π k + 2 ) But what about the time-windows? Dr. Manuel L´ opez-Ib´ a˜ nez Exercises for Heuristic Optimization

  19. Exercise 1.1: Iterative Improvement for the TSPTW ¼ A B C D E F π ′ = transp ( π, k ) = Transpose π k and π k + 1 ¼ A C B D E F ¶ transpose neighbourhood check the windows affected by the transpose move: l k , l k + 1 , l k + 2 update waiting times for k , k + 1 , k + 2 , . . . , n Possible speed-up for i = k + 3 to n + 1 do if we had to wait at node i before and after the transpose move then nothing else changes, break loop else update waiting times and constraint violations at node i Dr. Manuel L´ opez-Ib´ a˜ nez Exercises for Heuristic Optimization

  20. Exercise 1.1: Iterative Improvement for the TSPTW ¼ A B C D E F π ′ = insert ( π, k , j ) = Insert π k at position j ¼ A C D B E F ¶ insert neighbourhood It can be implemented as a sequence of transpose moves: Example: A B C D π π ′ = transp ( π, 1 ) B A C D π ′′ = transp ( π ′ , 2 ) B C A D π ′′′ = transp ( π ′′ , 3 ) = insert ( π, 1 , 4 ) B C D A π ′ = insert ( π, k , k − 1 ) = transp ( π, k − 1 ) Avoid evaluating the same neighbor two times! (You may need to remember and jump back to a previous position) Dr. Manuel L´ opez-Ib´ a˜ nez Exercises for Heuristic Optimization

  21. Exercise 1.1: Iterative Improvement for the TSPTW ¼ A B C D E F π ′ = exchange ( π, k , j ) ¼ ¶ A E C D B F = exchange nodes at π k and π j ( k < j ) exchange neighbourhood Do not worry about fast evaluation of travel time No trivial representation as transpose moves ∀ i < k : nothing changes ∀ i ≥ k : everything changes So order is important! Do not evaluate the same thing twice: n − 1 neighbors Transpose: ( n − 1 ) 2 neighbors Insertion: n · ( n − 1 ) / 2 neighbors Exchange: Dr. Manuel L´ opez-Ib´ a˜ nez Exercises for Heuristic Optimization

  22. Exercise 1.1: Iterative Improvement for the TSPTW How to compare solutions during the search? minimize the number of constraint violations ( Ω ) 1 if equal number of constraint violations, compare the tour travel 2 time ( f ) Dr. Manuel L´ opez-Ib´ a˜ nez Exercises for Heuristic Optimization

Recommend


More recommend