Initial Routes without Initial Routes


I have a problem and I hope you can help me with it :slight_smile:

I have a fleet of vehicles working for multiple days. For example I have a vehicle from 540 (540 minutes so 9 Oclock on the first day) to 8220 ( 1020 minutes (17 oclock) after 5 days (so 5 x 1440))
Now I have services that are from 0(+ 1440 * i) to 1440(+ 1440 * i) ( so 0 oclock to 24 oclock) on each day so they could be planed on every time of the day. This is not logical so I wanted to insert into the problem “at home” jobs, that are on each time between the working time of the vehicle. This services have also a custom skill “vehiclename” so only this vehicle can make this service.

So far so good. In my tests the planed routes don´t have everytime this “at home” services planed. Also if I make the timewindow for the “normal” services not from 0 to 1440 but from 500 to 1000 it doesn´t help. Somehow the algorithm thinks it would be better to wait from 1000 to 1900 on the location of the last services instead of driving to the “at home” job.

So somehow I need to tell the algorithm, that these “at home” services are better. For examle they have no costs or something like that.

To my question:

I actually thought about putting some kind of capacity in services and vehicles. So maybe I could give normal services less or more size then to the “at home” services. But would be the use of capacity and size right? Does the size of an service change the mind of the algorithm? And if yes, how? If I have 2 services on the same location and one of the services has a bigger size then the other and they would both fill the vehicle so much, that the other will not match: What service would the algorithm take?

Would there be another option to make this services “fixed”?

If you ask yourself, why I do not use initial routes: It don´t fits to my problem ^^ The “at home” services are not completly fix. There could be a service that goes multiple days. So the route is either with a “at home” service at night, or with a service that goes multiple days with ajusted servicetime and routingcosts (the driving to the services costs for a 2 day service 3 ways) But this is an other problem :stuck_out_tongue:

I hope you can understand me :stuck_out_tongue:


Hello again :slight_smile:

I tested a little bit with the capacity and I think that it don´t fits to my problem. Services that are nearer and have a bigger size dimension will be ignored. The nearest are the first that will be used. But…

I am a little bit further with my problem. I used the following functions

VehicleTypeImpl.Builder vehicleTypeBuilder = VehicleTypeImpl.Builder.newInstance(“vehicleType”).setCostPerDistance(50.0).setCostPerServiceTime(0.0).setCostPerWaitingTime(50.0);

So I tell the algorithm, that driving and waiting costs the same and more then working on a service. This looks good. In my benchmarks nearly all “at home” services are planed. nearly…

For the beginning of the iterations it looks like that the “at home” services are not planed, but from iteration to iteration more of them are in the solution so I think, that for the vrp is optimal(or better) with them then without these services. For example: With 100 iterations there where 10 “at home” services unplaned, with 400 where 5 “at home” services unplaned and with "1000 all where planed or 1-2 not.

My problem is now: I create the algorithm with the “from scratch method”:

algorithm = Jsprit.Builder.newInstance(problem)
.setProperty(Jsprit.Parameter.THREADS, threats + “”)
.setProperty(Jsprit.Parameter.VEHICLE_SWITCH, “false”)

I think by default, it is a random ruin used. The problem would be that it can be that some corners of the vrp will not be ruined. So even if I make 1000 or 2000 iterations it can be, that these “at home” services are unplaned.
My question now is: Excists a strategy that can guarantiee that every point of the problem is touched? I have a little problem with all the strategies that are in .setProperty(Jsprit.Strategy…)
I don´t understand all the strategys that can be used there and I can´t find any documentation for what problems that strategy is the best.

Maybe you can explain me them or give me a hint, where I can find infos about the different strategys. I found a page where you talk about the xml file, but you also don´t explain for what problems what configuration is better.

Hi @patrick_wisniewski19,

Have you tried the priority feature? It might help solve your problem to keep the “at home” jobs assigned.

Regarding the strategies, you can find the descriptions on random ruin, radial ruin and best insertion here on an earlier version of the “Meta-Heuristic” page. For regret insertion, the “WHATS_NEW” page under “2014-12-12 new release v1.5” (search for it and scroll down). For worst ruin and cluster ruin, I am afraid I cannot find any explicit description, and the best I can find is again the “WHATS_NEW” page under “2015-03-12 new release v1.6”.

Alternatively, you can directly go to their respective class pages, most of those pages contain description for the specific strategy - I say most, because, again, worst ruin and cluster ruin class pages don’t have the correct description for them.

Best regards,

Ok. Let us open a wiki page for strategies being used by Jsprit and we can all work at a reasonable description.

Should we put this here?


Hello again.

I have a question about the priorities. Does the highest priority mean, that this services are planed first, then come the normal priority and then the lowest ones? If yes this would fit very good to my problem.

So I will try it. Do I have to update for the newest Jsprit version, right?

Yes, this would be very nice if we could discribe somehow the ruin methods and wich of them fit better wo wich problem.

Hi @patrick_wisniewski19,

If you take a look at the implementation, you will find that, for best insertion, the jobs to be inserted are sorted based on their priority for half of the time - due to


For regret insertion, it is not achieved that way. What is done in regret insertion is that, in the score function, the difference between the cost of the best alternative and that of the second best is multiplied by

(4 - unassignedJob.getPriority())

In general I think you are right, because in both cases jobs with higher priority tend to be inserted first.

Best regards,


Actualy I am making benchmarks testing different count of iterations and different strategys.
Is the creation of the inital solution also updatet to the priorities? Is some initial solution strategy better for this problem?