print results

This commit is contained in:
Sam Hadow 2024-10-16 22:12:46 +02:00
parent 76e424c837
commit 32e0a376b3

15
main.py
View File

@ -42,7 +42,7 @@ def tabu_search(initial_solution, n_max):
cost_best = cost
tabu = [solution,]
n = 0
while n <= n_max:
while n < n_max:
neighbors_list = []
for s in neighbors(solution):
if check_validity(s) and s not in tabu:
@ -61,11 +61,14 @@ def tabu_search(initial_solution, n_max):
n += 1
tabu.append(solution)
print("tabu list:")
for e in tabu:
print(e, calculate_cost(e))
print("solution found:")
print(best, cost_best)
return (best, cost_best)
print("when not degrading the current solution:")
print(tabu_search(solution, 0))
print("tabu search accepting 1 degradation:")
print(tabu_search(solution, 1))
print("tabu search accepting 1 degradation: (find a local optimum)")
tabu_search(solution, 1)
print("tabu search accepting 2 degradations:")
print(tabu_search(solution, 2))
tabu_search(solution, 2)