print results
This commit is contained in:
parent
76e424c837
commit
32e0a376b3
15
main.py
15
main.py
@ -42,7 +42,7 @@ def tabu_search(initial_solution, n_max):
|
|||||||
cost_best = cost
|
cost_best = cost
|
||||||
tabu = [solution,]
|
tabu = [solution,]
|
||||||
n = 0
|
n = 0
|
||||||
while n <= n_max:
|
while n < n_max:
|
||||||
neighbors_list = []
|
neighbors_list = []
|
||||||
for s in neighbors(solution):
|
for s in neighbors(solution):
|
||||||
if check_validity(s) and s not in tabu:
|
if check_validity(s) and s not in tabu:
|
||||||
@ -61,11 +61,14 @@ def tabu_search(initial_solution, n_max):
|
|||||||
n += 1
|
n += 1
|
||||||
tabu.append(solution)
|
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)
|
return (best, cost_best)
|
||||||
|
|
||||||
print("when not degrading the current solution:")
|
print("tabu search accepting 1 degradation: (find a local optimum)")
|
||||||
print(tabu_search(solution, 0))
|
tabu_search(solution, 1)
|
||||||
print("tabu search accepting 1 degradation:")
|
|
||||||
print(tabu_search(solution, 1))
|
|
||||||
print("tabu search accepting 2 degradations:")
|
print("tabu search accepting 2 degradations:")
|
||||||
print(tabu_search(solution, 2))
|
tabu_search(solution, 2)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user