如何定义相对到达时间?

时间:2019-12-13 14:17:02

标签: or-tools

我想相对于索引为stop_index2的另一个停靠点的到达时间来约束索引为stop_index1的停靠点的到达时间。应根据直接行驶时间direct和de回系数detour来定义约束条件:

在Python中(不包括时间时间维度的创建):

n_stops = 11
n_vehicles = 3
ix_depot = 0

index_manager = pywrapcp.RoutingIndexManager(n_stops, n_vehicles, ix_depot)
routing_model = pywrapcp.RoutingModel(index_manager)
cpsolver = routing_model.solver()

ix1 = index_manager.NodeToIndex(1)
ix2 = index_manager.NodeToIndex(2)

factor = 0.8
direct = 1000
cpsolver.Add(time_dimension.CumulVar(ix2) < int(time_dimension.CumulVar(ix1) + factor * direct))

assignment = routing_model.Solve()
print(assignment.Value(routing_model.VehicleVar(stop_index)))

这是推荐的方法吗?

0 个答案:

没有答案