[Cbc] Threadsafe usage of Cbc

Cornelius Riemenschneider cri at itscope.de
Tue Dec 17 11:58:58 EST 2013


I?d rather like to avoid that, because we use or-tools for getting Cbc in our java project, and fiddling with or-tools internals is not something we?d like to do.

Also, I?ve no idea what setup is done in CbcMain*, especially CbcMain1 looks quite complex.

But it?s great to hear that the main algorithm can be safely used thread-safe, it shouldn?t be that hard to allocate the parameters either in CbcModel or just directly from the heap in CbcMain0 to pass them via an argument into CbcMain1.

 

Regards,

Cornelius Riemenschneider

--

ITscope GmbH

Ludwig-Erhard-Allee 20

76131 Karlsruhe

Email: cornelius.riemenschneider at itscope.de

https://www.itscope.com

Handelsregister: AG Mannheim, HRB 232782

Sitz der Gesellschaft: Karlsruhe

Geschäftsführer: Alexander Münkel, Benjamin Mund, Stefan Reger

 

Von: ted at lehigh.edu [mailto:cbc-bounces at list.coin-or.org] Im Auftrag von Ted Ralphs
Gesendet: Dienstag, 17. Dezember 2013 17:11
An: John Forrest
Cc: cbc
Betreff: Re: [Cbc] Threadsafe usage of Cbc


 

We just recently ran into exactly the same issue calling Cbc to solve individual subproblems in parallel within our decomposition framework (DIP). Rather than calling CbcMain*, we are now just directly calling the branchAndBound of CbcModel and it seems to be working fine, though I haven't looked into how the performance compares. John can probably say what the difference is between the two methods of calling Cbc. For example, see the code starting here:

https://projects.coin-or.org/Dip/browser/trunk/Dip/src/DecompModel.cpp#L234


This is also how Cbc is called within Couenne (and probably Bonmin as well). I believe Couenne was also successfully using Cbc in parallel. Couenne probably does this a bit more smartly (in terms of setting parameters, etc.). You can poke around this file:


https://projects.coin-or.org/Couenne/browser/trunk/Couenne/src/main/CouenneBab.cpp


for ideas.

Cheers,

Ted



 

On Tue, Dec 17, 2013 at 10:34 AM, John Forrest <john.forrest at fastercoin.com> wrote:

Cornelius,

static variables were used just because that was the way a main program became callable.  Some work was started a few years ago to improve - I will have another look to see what minimum work needs to be done to make CbcMain0/1 calls threadsafe.

John Forrest



On 17/12/13 15:11, Cornelius Riemenschneider wrote:




Hello,

we use CBC via googles or-tools from java in our application.

Compared to scientific problems, our problems are small and solved by Cbc in <1s (which is great!).

As we process requests from users concurrently, we?d also like to call Cbc concurrently.

Currently, this is impossible, because Cbc uses the static parameters array in CbcMain0 and CbcMain1 and thus crashes or reads incorrect parameters.

One backtrace, for example is:

 

#2 0x00007fb3435bf52b in __libc_message (do_abort=<optimized out>, fmt=<optimized out>) at ../sysdeps/unix/sysv/linux/libc_fatal.c:189
#3 0x00007fb3435c8d76 in malloc_printerr (action=3, str=0x7fb3436a1248 "double free or corruption (!prev)", ptr=<optimized out>) at malloc.c:6283
#4 0x00007fb3435cdaac in *__GI___libc_free (mem=<optimized out>) at malloc.c:3738
#5 0x00007fb342733f06 in std::string::assign(std::string const&) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#6 0x00007fb2d652cb7b in establishParams(int&, CbcOrClpParam*) () from libjnilinearsolver.so
#7 0x00007fb2d64edc3b in CbcMain0(CbcModel&) () from libjnilinearsolver.so
#8 0x00007fb2d6511bec in callCbc(char const*, CbcModel&) () from libjnilinearsolver.so
#9 0x00007fb2d64e3fce in operations_research::CBCInterface::Solve(operations_research::MPSolverParameters const&) () from libjnilinearsolver.so
#10 0x00007fb2d64cfe45 in operations_research::MPSolver::Solve(operations_research::MPSolverParameters const&) () from libjnilinearsolver.so
#11 0x00007fb2d64cff3b in operations_research::MPSolver::Solve() () from libjnilinearsolver.so
#12 0x00007fb2d64c91cf in Java_com_google_ortools_linearsolver_mainJNI_MPSolver_1solve_1_1SWIG_10 () from libjnilinearsolver.so

# from here on it?s just the JVM

 

As I don?t know the code and it?s hard to read, I can?t really fix the problem by myself,

but wouldn?t it be better to move parameters inside CbcModel instead of having a static array laying around?

 

Andi f that?s done (or another solution is found), do you know of any thread-safety issues in cbc?

Keep in mind, we don?t want Cbc to solve our problem in multiple threads, we just want to be able to solve different problems simultaneous.

 

Regards,

Cornelius Riemenschneider

--

ITscope GmbH

Ludwig-Erhard-Allee 20

76131 Karlsruhe

Email: cornelius.riemenschneider at itscope.de

https://www.itscope.com

Handelsregister: AG Mannheim, HRB 232782

Sitz der Gesellschaft: Karlsruhe

Geschäftsführer: Alexander Münkel, Benjamin Mund, Stefan Reger

 


 



_______________________________________________

Cbc mailing list

Cbc at list.coin-or.org

http://list.coin-or.org/mailman/listinfo/cbc

 



_______________________________________________
Cbc mailing list
Cbc at list.coin-or.org
http://list.coin-or.org/mailman/listinfo/cbc





-- 
Dr. Ted Ralphs
Associate Professor, Lehigh University
(610) 628-1280
ted 'at' lehigh 'dot' edu
coral.ie.lehigh.edu/~ted


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/cbc/attachments/20131217/2519e8fe/attachment.html>


More information about the Cbc mailing list