1 / 13

6.4: The Brute-Force Algorithms

6.4: The Brute-Force Algorithms. List all of the possible Hamilton circuits Calculate the total weights for each of the possible Hamilton circuit Choose an optimal circuit (cheapest, shortest, or fastest…). A,B,C,D,E,A = 812 A,B,C,E,D,A = 777 A,B,D,C,E,A = 762 A,B,D,E,C,A = 773

cecily
Download Presentation

6.4: The Brute-Force Algorithms

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 6.4: The Brute-Force Algorithms • List all of the possible Hamilton circuits • Calculate the total weights for each of the possible Hamilton circuit • Choose an optimal circuit (cheapest, shortest, or fastest…)

  2. A,B,C,D,E,A = 812 A,B,C,E,D,A = 777 A,B,D,C,E,A = 762 A,B,D,E,C,A = 773 A,B,E,C,D,A = 831 A,B,E,D,C,A = 877 A,C,B,D,E,A = 722 A,C,B,E,D,A = 791 A,C,D,B,E,A = 776 A,C,E,B,D,A = 741 A,D,B,C,E,A = 676 A,D,C,B,E,A = 780 The Brute-Force Algorithms There are 5 vertices so we have (5-1)! = 24 Hamilton circuits Optimal route Plus 12 mirror images

  3. The Brute-Force Algorithms • Start at C C,A,B,D,C =70+20+10+50=150 C,A,D,B,C =70+30+10+15=125 C,B,A,D,C =15+20+30+50=115 C,B,D,A,C =125 C,D,A,B,C =115 C,D,B,A,C =150 Therefore: optimal circuits are C,B,A,D,C or C,D,A,B,C If the problem asks to start at A then the optimal circuits are A,D,C,B,A or A,B,C,D,A A 20 70 30 C 15 B Mirror images 50 10 D

  4. 6.5: The Nearest-Neighbor Algorithm • From the starting vertex, go to its nearest neighbor (the edge has the smallest weight) • Repeating step 1 with the next vertex and the next vertex until there is no more vertex to visit • From the last vertex, return to the starting point

  5. The Nearest-Neighbor Algorithm Start at A, pick AC = 119 From C, pick CE = 120 From E, pick ED = 199 From D, pick DB = 150 No more vertex left so connect B and A, with BA=185 Therefore the trip is: A,C,E,D,B,A = 773 dollars

  6. The Nearest-Neighbor Algorithm • Start at C, pick CB = 15 • From B, pick BD = 10 • From D, pick DA = 30 • No more vertex left, so connect A and C, with AC = 70 • Therefore, the route is C,B,D,A,C = 125

  7. Practice with the Nearest Neighbor

  8. Apply the Nearest Neighbor Algorithm to find the way to go to the bank, dry cleaner, post office, and Wegmans starting and ending at home. The mileage chart is shown below. D W B P HOME

  9. 6.7 The repetitive Nearest-Neighbor Algorithm

  10. The Brute-Force Algorithm: optimal but inefficient algorithm • The Nearest-Neighbor Algorithm and Repetitive Nearest-Neighbor: efficient but not optimal algorithms.

  11. The Repetitive Nearest-Neighbor Algorithm • Apply the Nearest Neighbor Algorithm to each of the vertices to calculate the total weights. • Choose the best circuit. If there is a designated starting vertex, rewrite the circuit using that vertex as the reference point

  12. The Repetitive Nearest-Neighbor Algorithm • From A: A, C, E, D, B, A = 773 • From B: B, C, A, E, D, B = 722 • From C: C, A, E, D, B, C = 722 • From D: D, B, C, A, E, D = 722 • From E: E, C, A, D, B, E = 741 Therefore, one of the best routes is B, C, A, E, D, B so we rewrite it so the starting point is at A (his home): A, E, D, B, C, A

  13. The Repetitive Nearest-Neighbor Algorithm • From A: A, B, D, C, A = 20+10+50+70= 150 • From B: B, D, A, C, B = 10+30+70+15= 125 • From C: C, B, D, A, C = 15+10+30+70= 125 • From D: D, B, C, A, D = 10+15+70+30 = 125 One of the best routes is C,B,D,A,C = 125 or if re-write with starting point A: A,C,B,D,A

More Related