【发布时间】:2020-06-11 06:03:41
【问题描述】:
我正在用 Python 解决 VRPTW
这是从我的坐标获得的时间矩阵:
0 1 2 3 4 5
0 0 1130 1206 635 1072 977 1 1142 0 242 537 608 253 2 1225 156 0 658 645 409 3 808 781 856 0 1014 588 4 1248 686 703 1012 0 720 5 990 441 545 618 426 0
如何为我的客户设置时间窗口。例如。
仓库 - 时间窗口(上午 4:30 至上午 9:30) Loc1 - 时间窗口(上午 5:00 至上午 9:00) Loc2 - 时间窗口(5:00 AM 到 7:00 AM) Loc2 - 时间窗口(5:00 AM 到 7:00 AM) Loc4 - 时间窗口(早上 5:00 到早上 6:00)
def create_data_model():
"""Stores the data for the problem."""
data = {}
data['time_matrix'] = [[0, 1130, 1206, 635, 1072, 977, 1315], [1142, 0, 242, 537, 608, 253, 257], [1225, 156, 0, 658, 645, 409, 105], [808, 781, 856, 0, 1014, 588, 927], [1248, 686, 703, 1012, 0, 720, 664], [990, 441, 545, 618, 426, 0, 506], [1194, 51, 181, 588, 561, 304, 0]]
data['time_windows'] = [
(0, 5), # depot
(7, 12), # 1
(10, 15), # 2
(16, 18), # 3
(10, 13), # 4
(0, 5), # 5
(5, 10) # 6
]
data['num_vehicles'] = 2
data['depot'] = 0
return data
【问题讨论】:
标签: or-tools