How to run Jsprit on multiple threads?

791 views
Skip to first unread message

tortabevonas

unread,
Dec 17, 2014, 6:44:22 AM12/17/14
to jsprit-ma...@googlegroups.com
I'm trying to run Jsprit on a 8-core processor, so I think it would benefit from running in multiple threads.
This's how I tried it:

VehicleRoutingAlgorithmBuilder vraBuilder = new VehicleRoutingAlgorithmBuilder(problem, "ac.xml");
vraBuilder.addCoreConstraints();
vraBuilder.setNuOfThreads(8);
vraBuilder.addDefaultCostCalculators();


VehicleRoutingAlgorithm algorithm = vraBuilder.build();

But it still doesn't cause 100% processor load. What am I doing wrong?


Thank you for your help!
Aron

tortabevonas

unread,
Dec 17, 2014, 6:48:05 AM12/17/14
to jsprit-ma...@googlegroups.com
Update: I can see this line in console after starting Jsprit:

jsprit.core.algorithm.io.VehicleRoutingAlgorithms - setup executor-service with 8 threads

But it still runs as slow as on a single thread. How should I achieve full processor usage?

jsprit

unread,
Dec 17, 2014, 7:11:46 AM12/17/14
to jsprit-ma...@googlegroups.com
95 percent of the computation time is spent on re-inserting jobs, i.e. finding the best insertion position. Basically, jsprit goes through every route to find the best insertion position of a job. With the concurrency mode you can only distribute the task to find the best position in an entire routes (you cannot split a route into subroutes). Thus, if you only have one route, only one thread is used no matter how many you configured. If you have 20 routes and configured 4 threads, you can distribute 5 to each thread. Note, that when you use BestInsertion, your problem must be relatively large to gain from concurrent calc (otherwise performance gets worse due to the overhead of distributing). If you use RegretInsertion, I think that you can always gain. But you need to analyse it.



The associated calculations can be done concurrently. However

Am 17.12.14 12:44, schrieb tortabevonas:
--
You received this message because you are subscribed to the Google Groups "jsprit-mailing-list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jsprit-mailing-...@googlegroups.com.
To post to this group, send email to jsprit-ma...@googlegroups.com.
Visit this group at http://groups.google.com/group/jsprit-mailing-list.
For more options, visit https://groups.google.com/d/optout.

tortabevonas

unread,
Dec 17, 2014, 7:20:45 AM12/17/14
to jsprit-ma...@googlegroups.com
Thank you for the informations!

I've tried to use "regretInsertion", but it says that
java.lang.IllegalStateException: currently only 'bestInsertion' is supported

jsprit

unread,
Dec 17, 2014, 7:22:53 AM12/17/14
to jsprit-ma...@googlegroups.com
Do you use v1.5?

Am 17.12.14 13:20, schrieb tortabevonas:
Thank you for the informations!

I've tried to use "regretInsertion", but it says that
java.lang.IllegalStateException: currently only 'bestInsertion' is supported

jsprit

unread,
Dec 17, 2014, 7:26:07 AM12/17/14
to jsprit-ma...@googlegroups.com
Here is an example: https://github.com/jsprit/jsprit/blob/master/jsprit-examples/src/main/java/jsprit/examples/SolomonWithRegretInsertionExample.java

Look for the algorithm file in the input directory to see how it is configured.

It works with v1.5 only.



Am 17.12.14 13:20, schrieb tortabevonas:
Thank you for the informations!

I've tried to use "regretInsertion", but it says that
java.lang.IllegalStateException: currently only 'bestInsertion' is supported

tortabevonas

unread,
Dec 17, 2014, 7:32:02 AM12/17/14
to jsprit-ma...@googlegroups.com
Thank you!
I was using 1.4.1, this's why it didn't work. Now it spins up all the CPU cores. I'll measure if it runs faster.

tortabevonas

unread,
Dec 17, 2014, 7:36:12 AM12/17/14
to jsprit-ma...@googlegroups.com
I found that it didn't run faster when I ran it with regretInsertion

jsprit

unread,
Dec 17, 2014, 7:42:05 AM12/17/14
to jsprit-ma...@googlegroups.com
How many routes do you have in your solution?

Am 17.12.2014 um 13:36 schrieb tortabevonas <tortab...@gmail.com>:

I found that it didn't run faster when I ran it with regretInsertion

--

tortabevonas

unread,
Dec 17, 2014, 8:36:05 AM12/17/14
to jsprit-ma...@googlegroups.com
I had a single route, maybe this's the reason.
In this test I was testing whether it creates a single route for all the deliveries/pickups if the vehicle's capacity makes it possible.
Reply all
Reply to author
Forward
0 new messages