-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
56 lines (41 loc) · 1.85 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import tabu_search
import obj_function
import load_data
import numpy as np
import timeit
import random
import sys
if __name__ == "__main__":
tabu = [1, 10, 100, 350, 600, 1000]
for i in range(4):
# BEGIN - Parameters for algorithm
file_name = 'pcb.txt'
point_number = 10
number_of_tools = 3
t_min = 3
number_of_iterations = 1000000
tabu_list_length = tabu[i]
type_of_neighborhood = 4
seed = None
# END - Parameters for algorithm
init_solution = np.arange(1, point_number + 1)
#np.random.shuffle(init_solution)
OF = obj_function.ObjectiveFun(file_name, t_min, point_number, number_of_tools)
TS = tabu_search.TabuSearch(file_name, init_solution, number_of_iterations, tabu_list_length,
type_of_neighborhood, t_min, point_number, number_of_tools, seed)
start = timeit.default_timer()
TS.run()
stop = timeit.default_timer()
print("*****************************************")
# print("Initial solution: \n" + str(init_solution))
print("Initial objective function value: " + "{0:.2f}".format(OF.obj_function(init_solution)))
print("-----------------------------------------")
# print("Best solution: \n" + str(TS.solution) + "\n")
# print("Best real solution: \n" + str(OF.real_permutation(TS.solution)) + "\n")
print("Best objective function value: " + "{0:.2f}".format(TS.objective_fun_value))
print("Time of execution: " + "{0:.2f}".format(stop - start) + " seconds")
print("*****************************************\n")
TS.save_objective_fun_value_plots()
print("Record successfully saved to records.csv file!")
print("Figures saved to Fig/ directory!")
# TS.show_objective_fun_value_plots()