|
@@ -2,8 +2,7 @@ import sys
|
|
|
import copy
|
|
|
import math
|
|
|
from heapq import heappush, heappop
|
|
|
-from secrets import randbelow
|
|
|
-from random import shuffle, sample
|
|
|
+from random import shuffle, sample, randint, SystemRandom
|
|
|
import matplotlib.pyplot as plt
|
|
|
|
|
|
distances = []
|
|
@@ -79,11 +78,13 @@ def bester_child(cities, cost, tabu):
|
|
|
|
|
|
|
|
|
def random_child(cities):
|
|
|
- i = randbelow(len(cities) - 3) + 1
|
|
|
+
|
|
|
+ i = randint(1, len(cities) - 2)
|
|
|
j = i
|
|
|
|
|
|
while (j == i):
|
|
|
- j = randbelow(len(cities) - 3) + 1
|
|
|
+
|
|
|
+ j = randint(1, len(cities) - 2)
|
|
|
|
|
|
temporder = copy.deepcopy(cities)
|
|
|
tempcity = temporder[i]
|
|
@@ -174,7 +175,7 @@ def reinhold_messner(cities, x):
|
|
|
|
|
|
|
|
|
def bad_weather(delta, temp):
|
|
|
- return secrets.SystemRandom().random() < math.exp(delta / temp)
|
|
|
+ return random.SystemRandom().random() < math.exp(delta / temp)
|
|
|
|
|
|
|
|
|
|