0

I'm doing a school project with VRP. The problem I'm trying to solve is generating routes with multiple points that must be executed in a time window each.

My problem is how to translate the dates (unix timestamp) to time windows in jsprit since the algorithm starts at 0 time. Do I just delta out the time intervals, or is there a best practice I'm missing.

Thanks for any help.

AJ_1310
  • 3,303
  • 3
  • 19
  • 26
  • jsprit is unit agnostic. You could choose to define time in minutes or seconds. You only need a reference point defined (what is time 0?) after which, you can always make your conversion back to a real datetime. As for "Do I just delta out the time intervals" I'm not sure I understand what you are asking. – roganjosh Jul 17 '16 at 12:41
  • Normally on unix timestamp the 0 time is the year 1970. On jsprit time 0 is the start of the algorithm. Time unit is not the problem, the problem is the gap between 0 and the timestamp which is a big number. What i meant by delta is if I had to subtract the current timestamp to all timestamps provided, so that there is no gap. – AJ_1310 Jul 17 '16 at 18:49
  • In that case then yes, we are agreeing on this. You need to find a sensible new unix timestamp to represent zero and then have your time windows defined as an offset from this position, so you _do_ still need to settle on how you want to define the time unit. I think you've over-complicated this in your mind. I solve on a daily basis, with 00:00 being time zero going up to 1439 (mins). If I wanted to solve for a week of 24hr operation, I end on 10080. Then you just restart. – roganjosh Jul 17 '16 at 19:04
  • Ok I think I get what you are saying. Thank you very much for you help. Could you post it as an answer to upvote it? – AJ_1310 Jul 17 '16 at 22:11

1 Answers1

2

Edited.

JSprit is unit agnostic. You choose the units that you wish to work with.

I could choose that my week runs from Monday to Sunday, and I want to define units in terms of minutes. In which case, 9am on Monday morning is time 540 (9*60). Or I could define it in terms of seconds, in which case, that same time is 32400 (9*60*60). It doesn't matter as long as time units are consistent throughout.

A unix timestamp is almost certainly superfluous to the problem. You run a solution at a set time; generally you're looking for a solution to a discrete problem, and you'll run the algorithm at set intervals. This always gives you a datum point in which to take the "abstract" output of jsprit (e.g. arrives at time 678) into a datetime that is relevant to the current problem.

In this way, I could run the algorithm on 19th July for w/c 25th July but know that the solution of arrival time is based on 00:00 on 25th July being "0" and then just add the minutes.

Bottom line: JSprit does not take the time of calling a solution as time 0. It takes time 0 as any point in which you choose to define it in an arbitrary system; midnight on a Sunday, the inauguration of Pope Francis, anything basically :)

roganjosh
  • 12,594
  • 4
  • 29
  • 46