<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=iso-8859-1"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
   {font-family:Calibri;
   panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
   {font-family:Tahoma;
   panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
   {font-family:Consolas;
   panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
   {margin:0cm;
   margin-bottom:.0001pt;
   font-size:12.0pt;
   font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
   {mso-style-priority:99;
   color:blue;
   text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
   {mso-style-priority:99;
   color:purple;
   text-decoration:underline;}
pre
   {mso-style-priority:99;
   mso-style-link:"HTML Vorformatiert Zchn";
   margin:0cm;
   margin-bottom:.0001pt;
   font-size:10.0pt;
   font-family:"Courier New";}
span.HTMLVorformatiertZchn
   {mso-style-name:"HTML Vorformatiert Zchn";
   mso-style-priority:99;
   mso-style-link:"HTML Vorformatiert";
   font-family:Consolas;}
span.E-MailFormatvorlage19
   {mso-style-type:personal-reply;
   font-family:"Calibri","sans-serif";
   color:#1F497D;}
.MsoChpDefault
   {mso-style-type:export-only;}
@page WordSection1
   {size:612.0pt 792.0pt;
   margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
   {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=DE link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>I&#8217;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&#8217;d like to do.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Also, I&#8217;ve no idea what setup is done in CbcMain*, especially CbcMain1 looks quite complex.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>But it&#8217;s great to hear that the main algorithm can be safely used thread-safe, it shouldn&#8217;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.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Regards,<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.5pt;font-family:Consolas;color:#1F497D'>Cornelius Riemenschneider<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.5pt;font-family:Consolas;color:#1F497D'>--<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.5pt;font-family:Consolas;color:#1F497D'>ITscope GmbH<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.5pt;font-family:Consolas;color:#1F497D'>Ludwig-Erhard-Allee 20<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.5pt;font-family:Consolas;color:#1F497D'>76131 Karlsruhe<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.5pt;font-family:Consolas;color:#1F497D'>Email: cornelius.riemenschneider@itscope.de<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.5pt;font-family:Consolas;color:#1F497D'>https://www.itscope.com<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.5pt;font-family:Consolas;color:#1F497D'>Handelsregister: AG Mannheim, HRB 232782<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.5pt;font-family:Consolas;color:#1F497D'>Sitz der Gesellschaft: Karlsruhe<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.5pt;font-family:Consolas;color:#1F497D'>Gesch&#228;ftsf&#252;hrer: Alexander M&#252;nkel, Benjamin Mund, Stefan Reger<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>Von:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> ted@lehigh.edu [mailto:cbc-bounces@list.coin-or.org] <b>Im Auftrag von </b>Ted Ralphs<br><b>Gesendet:</b> Dienstag, 17. Dezember 2013 17:11<br><b>An:</b> John Forrest<br><b>Cc:</b> cbc<br><b>Betreff:</b> Re: [Cbc] Threadsafe usage of Cbc<o:p></o:p></span></p></div><p class=MsoNormal><o:p>&nbsp;</o:p></p><div><div><p class=MsoNormal style='margin-bottom:12.0pt'>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:<br><br><a href="https://projects.coin-or.org/Dip/browser/trunk/Dip/src/DecompModel.cpp#L234">https://projects.coin-or.org/Dip/browser/trunk/Dip/src/DecompModel.cpp#L234</a><o:p></o:p></p></div><p class=MsoNormal>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:<o:p></o:p></p><div><p class=MsoNormal style='margin-bottom:12.0pt'><br><a href="https://projects.coin-or.org/Couenne/browser/trunk/Couenne/src/main/CouenneBab.cpp">https://projects.coin-or.org/Couenne/browser/trunk/Couenne/src/main/CouenneBab.cpp</a><o:p></o:p></p></div><div><p class=MsoNormal>for ideas.<br><br>Cheers,<br><br>Ted<o:p></o:p></p></div></div><div><p class=MsoNormal style='margin-bottom:12.0pt'><o:p>&nbsp;</o:p></p><div><p class=MsoNormal>On Tue, Dec 17, 2013 at 10:34 AM, John Forrest &lt;<a href="mailto:john.forrest@fastercoin.com" target="_blank">john.forrest@fastercoin.com</a>&gt; wrote:<o:p></o:p></p><div><div><p class=MsoNormal>Cornelius,<br><br>static variables were used just because that was the way a main program became callable.&nbsp; 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.<br><br>John Forrest<o:p></o:p></p><div><div><p class=MsoNormal><br><br>On 17/12/13 15:11, Cornelius Riemenschneider wrote:<o:p></o:p></p></div></div></div><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><div><div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Hello,<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>we use CBC via googles or-tools from java in our application.<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Compared to scientific problems, our problems are small and solved by Cbc in &lt;1s (which is great!).<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>As we process requests from users concurrently, we&#8217;d also like to call Cbc concurrently.<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Currently, this is impossible, because Cbc uses the static parameters array in CbcMain0 and CbcMain1 and thus crashes or reads incorrect parameters.<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>One backtrace, for example is:<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>#2 0x00007fb3435bf52b in __libc_message (do_abort=&lt;optimized out&gt;, fmt=&lt;optimized out&gt;) at ../sysdeps/unix/sysv/linux/libc_fatal.c:189<br>#3 0x00007fb3435c8d76 in malloc_printerr (action=3, str=0x7fb3436a1248 &quot;double free or corruption (!prev)&quot;, ptr=&lt;optimized out&gt;) at malloc.c:6283<br>#4 0x00007fb3435cdaac in *__GI___libc_free (mem=&lt;optimized out&gt;) at malloc.c:3738<br>#5 0x00007fb342733f06 in std::string::assign(std::string const&amp;) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6<br>#6 0x00007fb2d652cb7b in establishParams(int&amp;, CbcOrClpParam*) () from libjnilinearsolver.so<br>#7 0x00007fb2d64edc3b in CbcMain0(CbcModel&amp;) () from libjnilinearsolver.so<br>#8 0x00007fb2d6511bec in callCbc(char const*, CbcModel&amp;) () from libjnilinearsolver.so<br>#9 0x00007fb2d64e3fce in operations_research::CBCInterface::Solve(operations_research::MPSolverParameters const&amp;) () from libjnilinearsolver.so<br>#10 0x00007fb2d64cfe45 in operations_research::MPSolver::Solve(operations_research::MPSolverParameters const&amp;) () from libjnilinearsolver.so<br>#11 0x00007fb2d64cff3b in operations_research::MPSolver::Solve() () from libjnilinearsolver.so<br>#12 0x00007fb2d64c91cf in Java_com_google_ortools_linearsolver_mainJNI_MPSolver_1solve_1_1SWIG_10 () from libjnilinearsolver.so<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'># from here on it&#8217;s just the JVM<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>As I don&#8217;t know the code and it&#8217;s hard to read, I can&#8217;t really fix the problem by myself,<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>but wouldn&#8217;t it be better to move parameters inside CbcModel instead of having a static array laying around?<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Andi f that&#8217;s done (or another solution is found), do you know of any thread-safety issues in cbc?<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Keep in mind, we don&#8217;t want Cbc to solve our problem in multiple threads, we just want to be able to solve different problems simultaneous.<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Regards,<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Cornelius Riemenschneider<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>--<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>ITscope GmbH<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Ludwig-Erhard-Allee 20<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>76131 Karlsruhe<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Email: <a href="mailto:cornelius.riemenschneider@itscope.de" target="_blank">cornelius.riemenschneider@itscope.de</a><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><a href="https://www.itscope.com" target="_blank">https://www.itscope.com</a><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Handelsregister: AG Mannheim, HRB 232782<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Sitz der Gesellschaft: Karlsruhe<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Gesch&#228;ftsf&#252;hrer: Alexander M&#252;nkel, Benjamin Mund, Stefan Reger<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;<o:p></o:p></p></div><p class=MsoNormal style='margin-bottom:12.0pt'><o:p>&nbsp;</o:p></p></div></div><pre>_______________________________________________<o:p></o:p></pre><pre>Cbc mailing list<o:p></o:p></pre><pre><a href="mailto:Cbc@list.coin-or.org" target="_blank">Cbc@list.coin-or.org</a><o:p></o:p></pre><pre><a href="http://list.coin-or.org/mailman/listinfo/cbc" target="_blank">http://list.coin-or.org/mailman/listinfo/cbc</a><o:p></o:p></pre></blockquote><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><p class=MsoNormal style='margin-bottom:12.0pt'><br>_______________________________________________<br>Cbc mailing list<br><a href="mailto:Cbc@list.coin-or.org">Cbc@list.coin-or.org</a><br><a href="http://list.coin-or.org/mailman/listinfo/cbc" target="_blank">http://list.coin-or.org/mailman/listinfo/cbc</a><o:p></o:p></p></div><p class=MsoNormal><br><br clear=all><br>-- <br>Dr. Ted Ralphs<br>Associate Professor, Lehigh University<br>(610) 628-1280<br>ted 'at' lehigh 'dot' edu<br><a href="http://coral.ie.lehigh.edu/~ted" target="_blank">coral.ie.lehigh.edu/~ted</a><o:p></o:p></p></div></div></body></html>