How to use OR tool for acheiving Capacitated Vehicle Routing Problem with more than 15 vehicle_capacity?

845 views
Skip to first unread message

reshma rabindranath

unread,
Nov 8, 2018, 4:28:04 AM11/8/18
to or-tools-discuss
I used python code provided in the below link 
https://github.com/google/or-tools/blob/master/examples/python/cvrptw.py for acheiving Capacitated Vehicle Routing Problem with Time Windows using OR tools.

For this  i used latitude and logitude as data["locations"].
For distance calculations,i used "The Haversine Formula" and "horizon" value as 1440.

same like latitude and logitude, i kept values for remaining keys as below.
  data["num_vehicles"] = 20
  data["vehicle_capacity"] = 15
  data["vehicle_speed"] = 5*60/3.6 # Travel speed: 5km/h to convert in m/min
  data["depot"] = 0


For data["demands"], if i use any of values more than 15 the program failed or hanged out.
seems like ["vehicle_capacity"] key is direct propotional to data["demands"] key.


 My vechicle capacity should be static value of 15, my expectation is when i kept as 15, it should be 2 routes or vehicles but actually what happened is program is not responding not even throwing exception.

blind.line

unread,
Nov 9, 2018, 11:18:44 AM11/9/18
to or-tools...@googlegroups.com
The demand is a single quantity. Like a big pallet of stuff all wrapped up in shrinkwrap. The solver doesn't have the common sense to break it up into chunks. So if a demand is 30, and vehicle max capacity is 15, no vehicle can accept that 30-sized load. 

Furthermore, if you want to manually break up 30 into chunks of 1 unit each, you will need to creat 30 "nodes" each at the same location with 1 unit of demand. The solver will visit each node at most one time. 

Hope that helps. 

James
--
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.
For more options, visit https://groups.google.com/d/optout.

reshma rabindranath

unread,
Nov 17, 2018, 12:24:11 AM11/17/18
to or-tools...@googlegroups.com
Hai James, 
  
 Your logic worked for me.  Thanks a lot. 

RESHMA R

Nimish Desai

unread,
Feb 27, 2023, 2:48:31 AM2/27/23
to or-tools-discuss
Hello friends.

I am trying to implement vrptw using or tools. I am pretty new to this. I am using the distance matrix calculated by google and then providing the time window for my locations with demands. the solution returned is always 0. can someone help e out please ?

Laurent Perron

unread,
Feb 27, 2023, 4:14:26 AM2/27/23
to or-tools-discuss
Check that (1) the distance matrix is integral, and (2) that the scale of the numbers is compatible with the time windows. 

Vincent Furnon

unread,
Feb 27, 2023, 4:16:40 AM2/27/23
to or-tools...@googlegroups.com
And to double-check, did you add arc costs to your model ?

Nimish Desai

unread,
Feb 27, 2023, 4:18:15 AM2/27/23
to or-tools...@googlegroups.com
Hello Laurent

Thank you so much for the response. I think what i am struggling with is the data for time matrix and time window. The time mateix returned by google direction matrix api is in seconds. As per the online reference example the time window is defined in units of time.

So if my demot operates from 9 am to 6 pm and if my location with demand operates between 2 pm to 3 pm , what should my time window array look like ?

Any help here will be highly appreciated and helpful.

Regards
Nimish Desai

Nimish Desai

unread,
Feb 27, 2023, 4:21:37 AM2/27/23
to or-tools...@googlegroups.com
Yes I have added the ARC cost. I am 99% sure that my values on time matrix and time window are not the correct units or the time window data i have doesnt make sense. Does the time window need to be calculated with reference to the depot or something?

Laurent Perron

unread,
Feb 27, 2023, 4:43:11 AM2/27/23
to or-tools-discuss

Nimish Desai

unread,
Feb 27, 2023, 10:59:42 AM2/27/23
to or-tools...@googlegroups.com
Hello Laurent

I am still stuck at this point. Can you please please help me on how my timewindow array in seconds unit should look like for below 4 locations as sample ?

Depot working from 9 am to 6 pm
Location 1 working from 14:30 to 17:00
Location 2 working from 10:00 to 14:00
Location 3 working all day 00:00 to 23:59

Thank you for the help in advance 

Nimish Desai

unread,
Feb 28, 2023, 2:26:02 AM2/28/23
to or-tools...@googlegroups.com
Hello friends 

Can you please help me with this question. I guess this is the last point I am stuck at for my final solution.

Regards
Nimish

Laurent Perron

unread,
Feb 28, 2023, 2:34:35 AM2/28/23
to or-tools...@googlegroups.com
(your)

Laurent Perron | Operations Research | lpe...@google.com | (33) 1 42 68 53 00



Le mar. 28 févr. 2023 à 11:33, Laurent Perron <lpe...@google.com> a écrit :
count the second from midnight to you time
Laurent Perron | Operations Research | lpe...@google.com | (33) 1 42 68 53 00



Laurent Perron

unread,
Feb 28, 2023, 2:35:42 AM2/28/23
to or-tools...@googlegroups.com
count the second from midnight to your time

Laurent Perron | Operations Research | lpe...@google.com | (33) 1 42 68 53 00


Message has been deleted

Laurent Perron

unread,
Aug 2, 2023, 5:01:06 PM8/2/23
to or-tools-discuss
Sorry for the spam. 

Le mer. 2 août 2023, 11:59, Waqarmir waqarmir <waqarmirw...@gmail.com> a écrit :

According to my personal experience, organic seeds are better then heirloom seeds. I am also a passionate gardener and I often practice growing vegetables in my garden. I am sharing my experiences on my web page.
--
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.
Reply all
Reply to author
Forward
0 new messages