forked from sabinoroselli/VRP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
interface.py
112 lines (91 loc) · 3.7 KB
/
interface.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
from MonoMod import modello
from ComSat import Compositional
from support_functions import list_unknown,list_missing,data_analyzer,data_printer
from multiprocessing import Pool,cpu_count
def instance_writer(instance,method):
if method == 'CA':
feasibility, optimum, solving_time, len_prev_routes = Compositional(instance)
generation_time = 'None'
elif method == 'S' or method == 'O':
feasibility, optimum, generation_time, solving_time = modello(instance,method)
len_prev_routes = 'None'
else:
raise ValueError('WRONG METHOD')
with open('data_storage.txt','a+') as write_file:
write_file.write('{},{},{},{},{},{},{},{},{},{} \n'.format(
method,
feasibility,
optimum,
instance.split('_')[1],
instance.split('_')[2],
instance.split('_')[3],
instance.split('_')[4],
generation_time,
solving_time,
len_prev_routes
)
)
return instance,method,feasibility,solving_time
###################### HERE IS WHERE THE ACTUAL TESTING STARTS ######################
# the specific problem instance i am solving
# problem = 'MM_1535_50_20_5'
# problem = 'MMM_1535_0_15_5_bis'
# print(problem)
#solving method can be optimization 'O' or satisfiability 'S' or compositional algorithm 'CA'
# modello(problem,'S')
# Compositional(problem)
#### SEQUENTIAL EXECUTION #####
# for NVJ in [35610]:#[1535,2547,3568]:
# for edge_reduction in [0,25,50]:
# for Big_Num in [30, 40, 50, 60]: # [15,20,25,30]:
# for SEED in range(5, 10):
# instance_writer('MM_{}_{}_{}_{}'.format(NVJ,edge_reduction,Big_Num,SEED), 'CA')
missing_instances = list_missing('unknown_instances')
# for i in missing_instances:
# # instance_writer(i,'CA')
# print(i)
# print(len(missing_instances))
## PARALLEL EXECUTION ####
# instances = [
# ( 'MM_{}_{}_{}_{}'.format(NVJ,edge_reduction,Big_Num,SEED), 'CA')
# for NVJ in [35912,351115]
# for edge_reduction in [0,25,50]
# for Big_Num in [40,70,100,150,200,300]
# for SEED in range(5,10)
# ]
#
# nprocs = cpu_count()
# print('available cores: ', nprocs)
#
# pool = Pool(processes=nprocs)
#
# multi_result = [pool.apply_async(instance_writer, inp) for inp in missing_instances]
#
# result = [x for p in multi_result for x in p.get()]
# for i in result:
# print(i)
# instances = [
# ( 'MM_{}_{}_{}_{}'.format(NVJ,edge_reduction,Big_Num,SEED), 'S')
# for NVJ in [1535, 2547]
# for edge_reduction in [0, 25, 50]
# for Big_Num in [20, 25, 30, 40, 50, 60]
# for SEED in range(5, 10)
# ]
#
#
# nprocs = cpu_count()
# print('available cores: ', nprocs)
#
# pool = Pool(processes=nprocs)
#
# multi_result = [pool.apply_async(instance_writer, inp) for inp in instances]
#
# result = [x for p in multi_result for x in p.get()]
# for i in result:
# print(i)
################ DATA ANALYSIS ######################
whatever = data_analyzer('data_for_evaluation')
for i in whatever:
print(i,whatever[i])
# print(i)
data_printer(whatever)