summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Seguin <guillaume@segu.in>2007-12-18 02:02:32 +0100
committerGuillaume Seguin <guillaume@segu.in>2007-12-18 02:02:32 +0100
commitfbbe4cf3710777bd394e201602f27b031f0abfeb (patch)
tree485221031a6df57c433fb435d54460c10c334331
parent3486d364a59e20253209b3ea4f43b3242160a041 (diff)
downloadtsp-fbbe4cf3710777bd394e201602f27b031f0abfeb.tar.gz
tsp-fbbe4cf3710777bd394e201602f27b031f0abfeb.tar.bz2
* Cleanup Monte Carlo perturbation using random_swap
-rwxr-xr-xtsp.py4
1 files changed, 1 insertions, 3 deletions
diff --git a/tsp.py b/tsp.py
index d6b2f6d..6bdc1e3 100755
--- a/tsp.py
+++ b/tsp.py
@@ -371,9 +371,7 @@ class Algo_MonteCarlo (Algo_2opt):
def perturbate (self, path):
'''Perturbate a path by exchanging two points'''
- i, j = random.sample (xrange (len (path)), 2)
- path[j], path[i] = path[i], path[j]
- return Path (self.context, path)
+ return self.random_swap (path)
class AlgoThread (threading.Thread):
'''Threading running a given algorithm'''