-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
29 lines (23 loc) · 1 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
import os
import glob
import argparse
import time
from VRPTW import *
def arguments() -> argparse.Namespace:
parser = argparse.ArgumentParser(description='Solving VRPTW with algorithms')
parser.add_argument('problem_file', type=str, help='Problem file (in Solomon format)')
return parser.parse_args()
if __name__ == '__main__':
args = arguments()
if not os.path.exists('solutions'):
os.mkdir('solutions')
assert os.path.exists(args.problem_file), "Problem file doesn't exist"
problem = SolomonFormatParser(args.problem_file).get_problem()
print(problem)
solution = IteratedLocalSearch(problem).execute()
with open(f"""solutions/{args.problem_file.split(os.sep)[-1].split(".")[0]}-ILS.sol""", 'w') as f:
f.write(problem.print_canonical(solution))
print('\nCalculating optimal route using Genetic Algorithm .... \n')
print(problem)
problem = SolomonFormatParser(args.problem_file).get_problem()
solution = GASearch(problem).execute(args.problem_file)