Tuesday, 12 October 2021

Google OR tools: How to add multiple dimension constraints(Width, length, height) to Capacitated Vehicle Routing Problem (CVRP)?

I am new to OR tools and trying to add weight and volume (height, length, width separately) constraints in the capacitated vehicle routing problem. The main idea of not using the volume constraint directly is because, for example, consider a truck of dimensions 10x10x10 and an item of dimensions 12x1x1. However, practically the volume of the item is less than the volume of the truck, it is not possible to ship this product in the truck. Hence, I want to consider length, width, and height separately. The subtle issue while handling the width and length constraints is that the item can be placed vertically or horizontally. I want the algorithm to consider this as well. Any help would be appreciated.

Working CVRP code with single capacity constraint:

def demand_callback(from_index):
    """Returns the demand of the node."""
    # Convert from routing variable Index to demands NodeIndex.
    from_node = manager.IndexToNode(from_index)
    return data['demands'][from_node]

demand_callback_index = routing.RegisterUnaryTransitCallback(
    demand_callback)
routing.AddDimensionWithVehicleCapacity(
    demand_callback_index,
    0,  # null capacity slack
    data['vehicle_capacities'],  # vehicle maximum capacities
    True,  # start cumul to zero
    'Capacity')

To this above working solution, i want to add dimension constraint.

Reference: OR-Tools: CVRP



from Google OR tools: How to add multiple dimension constraints(Width, length, height) to Capacitated Vehicle Routing Problem (CVRP)?

No comments:

Post a Comment