-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_all_datasets.py
More file actions
42 lines (41 loc) · 1.22 KB
/
Copy pathtest_all_datasets.py
File metadata and controls
42 lines (41 loc) · 1.22 KB
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
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import os
import time
import pandas as pd
from solver import *
from sol_representation import *
if __name__ == "__main__":
datasets = [
'datasetA','datasetB', 'datasetC',
'datasetD','datasetE','datasetF',
'datasetG', 'datasetH', 'datasetI',
'datasetJ', 'dataset_small'
]
solver = Solver22()
f = open(
os.path.join(".", "results", f"{solver.name}_summary.csv"),
"a"
)
for dataset in datasets:
df_items = pd.read_csv(
os.path.join(".", "data", dataset, "items.csv"),
)
df_vehicles = pd.read_csv(
os.path.join(".", "data", dataset, "vehicles.csv"),
)
sol_file_name = f"{solver.name}_{dataset}_sol.csv"
# measure execution time
start = time.time()
solver.solve(df_items, df_vehicles, sol_file_name)
stop = time.time()
# read dataframe solution
df_sol = pd.read_csv(
os.path.join("results", sol_file_name),
)
try:
of = sol_check(df_sol, df_vehicles, df_items)
except Exception as e:
of = -1
f.write(f"{dataset},{(stop - start):.2f},{of}\n")
f.close()