<div dir="ltr"><div>Hi again,<br><br></div>I was able to make this work by modifying Cbc&#39;s source code. Essentially it boils down to creating a (virtual) cloning method for CbcModel and using the cloning method instead of the copy constructor when forking in CbcThreads.cpp.<br>

<br>As I think the changes are tiny, I would appreciate if they could be made standard. I&#39;m coping a diff below, referred to CbcModel stable/2.7.<br><br>Pietro<br><div><div><br><br>Index: CbcModel.cpp<br>===================================================================<br>

--- CbcModel.cpp    (revision 1966)<br>+++ CbcModel.cpp    (working copy)<br>@@ -4875,6 +4875,13 @@<br>     return ;<br> }<br> <br>+// Cloning method<br>+<br>+CbcModel *CbcModel::clone (bool cloneHandler) {<br>+  return new CbcModel (*this, cloneHandler);<br>

+}<br>+<br>+<br> // Copy constructor.<br> <br> CbcModel::CbcModel(const CbcModel &amp; rhs, bool cloneHandler)<br>Index: CbcThread.cpp<br>===================================================================<br>--- CbcThread.cpp    (revision 1966)<br>

+++ CbcThread.cpp    (working copy)<br>@@ -569,7 +569,8 @@<br>         CbcStrategy * saveStrategy = model.strategy();<br>         model.setStrategy(NULL);<br>         for (int i = 0; i &lt; numberThreads_; i++) {<br>-            threadModel_[i] = new CbcModel(model, true);<br>

+          //threadModel_[i] = new CbcModel(model, true);<br>+        threadModel_[i] = model. clone (true);<br>             threadModel_[i]-&gt;synchronizeHandlers(1);<br> #ifdef COIN_HAS_CLP<br>             // Solver may need to know about model<br>

Index: CbcModel.hpp<br>===================================================================<br>--- CbcModel.hpp    (revision 1966)<br>+++ CbcModel.hpp    (working copy)<br>@@ -1837,6 +1837,9 @@<br>     */<br>     CbcModel(const CbcModel &amp; rhs, bool cloneHandler = false);<br>

 <br>+    /** Clone */<br>+  virtual CbcModel *clone (bool cloneHandler);<br>+<br>     /// Assignment operator<br>     CbcModel &amp; operator=(const CbcModel&amp; rhs);<br> <br><br></div></div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Fri, Oct 4, 2013 at 12:54 AM, Pietro Belotti <span dir="ltr">&lt;<a href="mailto:petr.7b6@gmail.com" target="_blank">petr.7b6@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div><div><div>Hello.<br><br></div>I have implemented a BB by deriving a myModel class from CbcModel. The main difference is in the ::checkSolution() method, which is specialized to the model. <br><br>The sequential version seems to work just fine. The multi-thread version, instead, does not: while everything works fine in the root node and the right solution check is run, in CbcThread.cpp:573, the new CbcModels that run the threads are created using the copy constructor of the original CbcModel, and hence during the BB the original (and invalid for my problem) checkSolution() method is used.<br>

<br></div>Is there a clean way to make the threads use myModel objects rather than CbcModels?<br><br>Thanks,<br></div>Pietro<br></div>
</blockquote></div><br></div>