JSprit Algorithm soft and hard time windows

1.8k Views Asked by At

I have list of services with time windows. Is it possible to configure JSprit in way that some time windows must be met (hard time windows) while other are configured to be soft time windows?

Thanks in advance for help

1

There are 1 best solutions below

0
On

Hard time windows can be implemented by assigning a time window to a service via Service.Builder. By default, services do not have any time windows. Soft time windows can be considered by implementing core.problem.constraint.SoftActivityConstraint

https://github.com/jsprit/jsprit/blob/master/jsprit-core/src/main/java/jsprit/core/problem/constraint/SoftActivityConstraint.java

Here, you can penalize "late" arrivals. Keep in mind that the insertion of a new activity does not only have a local impact, i.e. on the two neighboring activities, but it can have an impact on the whole route since it shifts all subsequent activities. This, in turn, can yield additional penalties that need to be considered as well. To evaluate this in constant time, you require some sort of approximation of the global impact. Once you add the soft constraint, you need to account for it in your objective function as well (see for example and its respective code examples to see how this works).