Time window preference optimization

I’ve got jsprit working on a pickup/delivery problem, but I’d like it to give priority to hitting a target time rather than picking the first solution it finds in the given time window. For example, say a customer says they want a delivery at 5:00 but they are available from 4:00-6:00. How would I set this up so 5:00 (or times closer to 5:00) would be preferred over other portions of the time window?

Hi @d3501,

It seems to me that you will need a soft activity constraint, in which you reward the insertion of an activity if it hits its target time.

There are two others things you might need to take care of:

  1. You will need to set the objective function accordingly;

  2. In the soft activity constraint, you might also need to check all the downstream activities, because the insertion of newAct will shift the arriving times of them.

Best regards,

1 Like

Hi @stefan,

It seems to me this can be related to soft time windows: the target time (window) 5:00 can be regarded as the hard time window, and 4:00 - 6:00 can be regarded as soft time window.

And it will allow the service to start before its hard time window start time.

What do you think?

Best regards,

Hello He,
Thanks for your answers. It really helps!
Well, I also think that this is related to soft time windows. I think that 4-6 is hard here, and there is this preferred time window like 4:55 - 5:05 or so. Delivery within 4:55-5:05 does not come with additional costs, however delivering outside this but within 4-6 it comes with increasing costs depending on how far it is from the preferred time window? But as you already put it in your answer, it is currently not that easy to consider this consistently in jsprit. Or do you have a reasonable solution for this?

@d3501: the algorithm does not pick the first time it finds, but it is a little more than this. It picks a time that contributes to a good overall solution.

Best, Stefan