Initial VehicleRoute without fixed vehicle, is it possible?

Hi everybody.

First a big thank you to Stefan for this extremly useful and well designed Project! We use it since some months now for the route planning of aid organizations.

My current problem is to use service routes with initial stations and leave selction of the best vehicle to the optimizer.
That is, we have the trunk of route with stations start, 1,2,…,end. During optimization more jobs are added, while keeping the order of the initial stations.
With the help of the existing examples i figured out how to do with addInitialVehicleRoute.

But with addInitialVehicleRoute I have to create a route with a fixed vehicle and this vehicle will not be changed anymore even if there would be a better choice cost-wise.In our use case, the choice of vehicle don’t matters, its important that the initial jobs stay together, the vehicle should just be the most cost effectice.

I try to use VehicleImpl.NoVehicle but it throws an exeption in addInitialVehicleRoute() since it dont have a vehicleIdentifier.

Is it possible?


Hi Thomue,

Thanks for your kind words.

I understand your use case and also find this feature very important. I already implemented this such that one can model arbitrary dependencies of type “in_sequence”, “in_direct_sequence” and “in_same_route” between activites and jobs (with and without an a priori assignment vehicles) . However, after long internal pro and contra discussions we have decided to keep this code closed source (for now). Thus, this feature is only available via our commercial API and is documented here.


Hi Stefan,

thank you for your answer. I wasn’t aware that there is a commercial API with extended capabilties. I will have a closer look at it. Anyway, currently it is also helpful to just know that this is not possible with the open source project.
jsprit is really high quality and its obvious you put a lot of time and effort into it.I hope you can get something back in terms of money too.
I assume if one uses the commercial API, there is no way to integrate own code, like constraints, strategies, own discance matrices, a.o., right?


Hello Thomas,


Here you get more info about the commercial API. To a certain extend, you can define your business specific constraints. Distance and travel time matrices are calculated with the GraphHopper Matrix API based on OSM. Let me know if you need more information, and if you want to try it, I can provide you with a free trial subscription of whatever subscription you like.

All the best,