]> Skullheadx's Git Forge - The-Traveling-Salesman-Problem.git/commitdiff
random swap explanation
authorSkullheadx <94652084+Skullheadx@users.noreply.github.com>
Tue, 10 Jan 2023 13:32:47 +0000 (08:32 -0500)
committerSkullheadx <94652084+Skullheadx@users.noreply.github.com>
Tue, 10 Jan 2023 13:32:47 +0000 (08:32 -0500)
README.md
tour_improvements/random_swapping.py

index 0c71d0995da307d28a4896f137e5514947ca0f1d..82dc369c0fea014828e338d1577abd61dd15972d 100644 (file)
--- a/README.md
+++ b/README.md
@@ -114,3 +114,10 @@ This method of improving a candidate solution created by a heuristic is called l
 
 **Random Swapping**
 
+One easy tour improvement to implement is random swapping. We simply randomly select two nodes which we swap in the tour, if the resulting route has less cost, we use this new route.
+
+--------------------------------------------------------------------------------------------------------------
+
+**2-Opt Improvement**
+
+O
\ No newline at end of file
index 18a23134a21b78cb734c3d2b14f655f6425ebf44..3fc88bcbf5adc156182345dd72dfa5dab739aedc 100644 (file)
@@ -1,7 +1,7 @@
 from graph import calculate_route
 from random import sample
 
-
+# For swapping once
 def random_swap(route: list) -> list:
     r = route[:]
 
@@ -13,7 +13,7 @@ def random_swap(route: list) -> list:
 
     return r
 
-
+# check and swap if better n times
 def random_swapping(route: list, n: int) -> list:
     d = calculate_route(route)
     r = route[:]