Route planning with capacity

892 views
Skip to first unread message

Ravi

unread,
Sep 1, 2019, 12:58:02 AM9/1/19
to or-tools...@googlegroups.com
Hi All, 

ORTools has an example of how to specify maximum load capacities of vehicles. How can I specify an additional constraint that also specifies the minimum load that a truck needs for it to accept a consignment? 
That is, the total consignment to a truck should *NOT* be less than the minimum that the truck needs to accept a delivery.

Any suggestions?

Thanks! 

Vincent Furnon

unread,
Sep 2, 2019, 4:46:12 AM9/2/19
to or-tools...@googlegroups.com
Hi,
For VRPs:
You could force the lower bound of the cumul of end nodes of non-empty vehicles to be greater than this minimum, but this would make the life of the solver really hard. The alternative would be to use RoutingDimension::SetCumulVarSoftLowerBound on vehicle end nodes (applying a soft cost to vehicles which have not reached the minimum load); note that there is no easy way to put this cost only on non-empty vehicles so the best approach is to offset fixed costs of all vehicles by a value equal to the soft cost of being empty, to make empty vehicles "attractive". 
For PDPs (also applies to VRPs):
You could do something similar, applying RoutingDimension::SetCumulVarSoftLowerBound only to non-start/end nodes; you'd need to make sure you existing penalty costs (to make nodes optional) are high enough to balance soft minimum costs. 
Vincent

--
You received this message because you are subscribed to the Google Groups "or-tools-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to or-tools-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/or-tools-discuss/CAJm4AuUqtN1Lb%3Dko9sDbzE4h%3DykVupQCjBTOfGsmYgukiLSgYQ%40mail.gmail.com.

dhiraj shanbhag

unread,
Dec 16, 2020, 11:05:54 AM12/16/20
to or-tools-discuss
How to put a lower bound on  the cumul of end nodes of non-empty vehicles.
not soft lower bound...Is there a way to put hard lower bound. 
Thanks,

Vincent Furnon

unread,
Dec 16, 2020, 11:19:07 AM12/16/20
to or-tools...@googlegroups.com
Just constrain the cumul variable of the end of a vehicle: set its lower bound directly or add a more elaborate constraint stating next(start)!=end -> cumul(end) > bound (look at the reified version of inequality constraints).

dhiraj shanbhag

unread,
Dec 16, 2020, 9:22:52 PM12/16/20
to or-tools-discuss
I have added this:
 weight_dimension.CumulVar(routing.End(int(veh.index))).SetRange(lower_bound ,max_weight)
but this doesn't seem to work.

Should I add something like you mentioned in routing..solver.
Thanks,

Aravind Reddy

unread,
May 27, 2021, 3:41:47 AM5/27/21
to or-tools-discuss
Did we get any working solution here?

Mizux Seiha

unread,
May 27, 2021, 3:50:02 AM5/27/21
to or-tools-discuss
Did you try this ?

```python
solver = routing.solver()
for vehicle_id in range(manager.GetNumberOfVehicles()):
  end_index = routing.End(vehicle_id)
  solver.Add(weight_dimension.CumulVar(end_index) >= lower_bound * routing.ActiveVehicleVar(vehicle_id))
```

tril...@gmail.com

unread,
Oct 12, 2022, 12:55:45 AM10/12/22
to or-tools-discuss
Hi Vincent  
I am a newbee with ortools. I am trying to set  minimum  load for every acitve vehicles.
Here is my code :
  for vehicle_id in range(data['num_vehicles']):
        index = routing.End(vehicle_id)
        min_capacity =int(data["product_d_capacity"][vehicle_id][0])
        capacity_dimension.SetCumulVarSoftLowerBound(vehicle_id, min_capacity, 100000)
        routing.SetVehicleUsedWhenEmpty(True, vehicle_id)

but  minimum constrant works not correct.
Another approach is: routing.solver().Add(product_d_dimension.CumulVar(routing.End(vehicle_id)) >= (min_capacity * routing.ActiveVehicleVar(vehicle_id))) but very slow and time out after 30p if I use more than 50 nodes.

Can you advise  or any example?
I appreciate your help.

Laurent Perron

unread,
Oct 12, 2022, 1:00:13 AM10/12/22
to or-tools-discuss
Search the mailing list. It is asked very regularly. 

Reply all
Reply to author
Forward
0 new messages