-
Notifications
You must be signed in to change notification settings - Fork 4
/
vrpSchedule.py
24 lines (19 loc) · 1.03 KB
/
vrpSchedule.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
import json
import vrp
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("-v","--verbose",help="increase output verbosity",action="store_true")
parser.add_argument("-o","--orders",type=argparse.FileType('r'),help="orders to be scheduled as a json file")
parser.add_argument("-t","--trucks",type=argparse.FileType('r'),help="trucks to be scheduled as a json file")
parser.add_argument("-i","--iterations",type=int,nargs='?',const=1000,default=1000,help="number of iterations to run (defaults to 1000)")
args = parser.parse_args()
orders = json.load(args.orders)
trucks = json.load(args.trucks)
schedule = vrp.RandomOptimizer(trucks,orders,args.iterations,args.verbose)
if args.verbose:
print('schedule passes validation? ', vrp.SimpleScheduleValidator(schedule,orders))
vrp.PrettyPrintSimulatedSchedule(schedule)
print('total cost of schedule: $',schedule['totalCost'])
print('total time of schedule: ',schedule['requiredTime'],'h')
with open('data/schedule.json','w') as outfile:
json.dump(schedule,outfile)