Create a vehicle for each day


We are testing Jsprit and are really amazed about the possibilies, really nice job.

I have a complex situation where we have 20 vehicles and 200 jobs.

We get a solution in about 40 seconds with 1500 iterations. I think that is acceptable.

Now the problem we have is the same 20 vehicles with 200 jobs, but now for 30 days.

What we do is create a vehicle for each user for each day, so now we have 600 vehicles.

The same run for 200 jobs is so slow i cant give you the exact result but
after hours it was on 256 iterations and i cancelled the solution. The
200 jobs can be done in 2 days, i know that it should be better that the
user only selects 2 days, but that is not what they do. In my head it
is simple, but i understand that for the algoritme every vehicle is used
for calculation. Are we doing something wrong, is there a better way
too configure this ?

I really would not prefer to run 1 day, then remove jobs which are assigned and then run for the next day,
etc until there are no jobs. This is never optimal for the complete date selection.


Did you have some particular constraints, as TimeWindows, Capacity or Precedance ?

Setting a hard number of vehicles is not a good approach, because you enforce the algorithm to try the fill each one.
Which is not a good idea in term of computation time.

Define your vehicle fleet as an infinite one will improve the solve speed (vrpBuilder.setFleetSize(FleetSize.INFINITE))
It will let the algorithm define the number of vehicle and only consider the generated ones. If you want to limit the global number of vehicles, I think a HardConstraint could do that.


Thanks for you reply. Our vehicles have skills / different shifts by setting setEarliestStart and setLatestArrival, also Initial Services that already are scheduled manualy. So the setting you are reffering to can not be set unfortunately. What i am trying now is setting setEarliestStart and setLatestArrival for a period of 30 days, and then add services for the shifts the driver is not working with location id set to Home. Any suggestions ?

I’m not sure I understand your problem well, can you just confirm my assumptions, or help me were I’ve made a wrong assumption:
You have 20 vehicles that are available to run once per day for 30 days
Then you have 200 different jobs for each of the 30 days
Now we have 30 separate VRP problems, and you are talking about one big VRP problem, so I guess there must be some overlap - like if you can’t finish a specific days jobs, it can be delayed to the next day?

Hello, we fixed the problem bij not creating a vehicle for each day, but create 1 vehicle which has jobs with home location for the time they are not working. This is performing very well. Thanks for you replies.


Nice solution :slight_smile:!