Pickup and Deliveries Constraint

18 views
Skip to first unread message

Sirine Belguith

unread,
Jul 23, 2024, 1:17:27 PM (2 days ago) Jul 23
to or-tools...@googlegroups.com
I'm solving the VRPTW problem with pickup and delivery.   Each vehicle is capable of doing delivery, pickup, or both at once.
     # Add Pickup and Delivery constraints.
for node_index in range(1, len(data['demands'])):
    if data['demands'][node_index] > 0 or data['deliveries'][node_index] > 0:
        pickup_index = manager.NodeToIndex(node_index)
        delivery_index = manager.NodeToIndex(node_index)
        # Add Pickup and Delivery constraints.
        routing.AddPickupAndDelivery(pickup_index, delivery_index)
        routing.solver().Add(routing.VehicleVar(pickup_index) == routing.VehicleVar(delivery_index))
        routing.solver().Add(time_dimension.CumulVar(pickup_index) <= time_dimension.CumulVar(delivery_index))

What is the constraint that ensures equal pickup and delivery for each trip and that every pickup has a delivery for every vehicle tour?   
Reply all
Reply to author
Forward
0 new messages