<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Alexis,<br>
      <br>
      On 15/09/16 01:21, Alexis wrote:<br>
    </div>
    <blockquote
      cite="mid:34e66a7d-dd77-4293-985d-bb5a6e0dbac2@softree.com"
      type="cite">
      <meta http-equiv="Context-Type" content="text/html; charset=utf-8">
      <p>Hi,<br>
      </p>
      <p>With the help of Tobias, I managed to compile CBC standalone in
        VS2015. Inspection of the CPU usage on my machine indicates that
        multithreading seems to work.</p>
      <p>I have a few more questions:</p>
      <p>1 - Does the parameter with -threads indicates the number of
        extra threads? 0 would mean that there is only the master
        thread, essentially no multithreading?<br>
      </p>
    </blockquote>
    Yes.<br>
    <blockquote
      cite="mid:34e66a7d-dd77-4293-985d-bb5a6e0dbac2@softree.com"
      type="cite">
      <p> </p>
      2 - I am not sure I understand at this point the parameter
      threadMode_, but I am going to look more into it.<br>
      <br>
    </blockquote>
    Mostly of secondary importance.  The deterministic option switch on
    by -threads 1nn is important.<br>
    <blockquote
      cite="mid:34e66a7d-dd77-4293-985d-bb5a6e0dbac2@softree.com"
      type="cite"> 3 - More importantly, I am trying to use
      multithreading with my application. Compilation is ok. I am mostly
      wondering about the behavior of the handlers in the multithreading
      settings.<br>
      <br>
      My code is essentially an extended version of
      driver6.cpp/driver4.cpp so I used to have<br>
      <br>
        // Pass to Cbc initialize defaults <br>
        CbcModel modelA(solver1);<br>
        CbcModel * model = &modelA;<br>
        CbcMain0(modelA);<br>
        // Event handler<br>
        MyEventHandler3 eventHandler;<br>
        model->passInEventHandler(&eventHandler);<br>
        /* Now go into code for standalone solver<br>
           Could copy arguments and add -quit at end to be safe<br>
           but this will do<br>
        */<br>
          const char * argv2[]={"driver4","-solve","-quit"};<br>
          CbcMain1(3,argv2,modelA);<br>
      <br>
      Now, I have<br>
      <br>
      <b>    const char * argv2[]={"driver4","-threads, "X",
        "-solve","-quit"};</b><br>
      <b>    CbcMain1(5,argv2,modelA);</b><br>
       <br>
      - Is eventHandler shared between all the threads? Or is there one
      handler (copy) per thread?<br>
    </blockquote>
    I may get this wrong, but ... Normally shared - just one copy - so
    CbcModel pointer is to master. There is option to copy - then points
    to thread CbcModel.<br>
    <blockquote
      cite="mid:34e66a7d-dd77-4293-985d-bb5a6e0dbac2@softree.com"
      type="cite"> - In the first case, is eventHandler thread safe? <br>
    </blockquote>
    Threadsafe for locals.  I would try having copies so each can get
    local CbcModel and global one.  I would use three globals (global
    model, best objective and stopflag) + mutex.  Then if event handler
    wants to do something it grabs mutex, looks at flag - if set
    releases mutex and returns.  If not set then sets it, releases mutex
    and returns saying do something.  If you just want to save a good
    solution then similar.  I have probably got that all wrong.<br>
    <blockquote
      cite="mid:34e66a7d-dd77-4293-985d-bb5a6e0dbac2@softree.com"
      type="cite"> - What would be the best way to get the best solution
      in the tree? Currently, I just have to call<br>
      <br>
      CbcEventHandler::CbcAction <br>
      MyEventHandler3::event(CbcEvent whichEvent)<br>
      {<br>
        // If in sub tree carry on<br>
        if (!model_->parentModel()) {<br>
          if (whichEvent==solution||whichEvent==heuristicSolution) {<br>
            printf("value of solution is
      %g\n",model_->getObjValue());<br>
        } else {<br>
            return noAction; // carry on<br>
        }<br>
      }<br>
    </blockquote>
    <br>
    see above<br>
    <blockquote
      cite="mid:34e66a7d-dd77-4293-985d-bb5a6e0dbac2@softree.com"
      type="cite"> <br>
      Thanks!<br>
      <br>
      Alexis<br>
      <br>
      <div class="moz-signature">-- <br>
        Alexis Guigue, E.I.T., B.Eng., M.A.Sc., Ph.D. <br>
        Software Engineer/Research Engineer <br>
        604-519-6222, ext. 107 <br>
        <br>
        <a moz-do-not-send="true"
href="https://urldefense.proofpoint.com/v2/url?u=http-3A__www.softree.com&d=CwMDaQ&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=js2M0T-3OIMIVDvokcKjokJbk0F8QOCd0mT4FsVFE88&m=JW7jxzBRiPgrJcasWuWrK0kZrU1D4udLWpqagPpVbJc&s=WbbXokSFCnOnYzXBZhD9h4E2A01vgNt2NwPQvBErT8k&e=">Softree
          Technical Systems Inc.</a> <br>
        Engineering an Easier Way <br>
        <br>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Cbc mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Cbc@list.coin-or.org">Cbc@list.coin-or.org</a>
<a class="moz-txt-link-freetext" href="https://urldefense.proofpoint.com/v2/url?u=http-3A__list.coin-2Dor.org_mailman_listinfo_cbc&d=CwICAg&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=js2M0T-3OIMIVDvokcKjokJbk0F8QOCd0mT4FsVFE88&m=JW7jxzBRiPgrJcasWuWrK0kZrU1D4udLWpqagPpVbJc&s=HlOBrUOpfS4_ECFITp9Dm3uUNJz94iQ1OPfrqtmiv2o&e=">https://urldefense.proofpoint.com/v2/url?u=http-3A__list.coin-2Dor.org_mailman_listinfo_cbc&d=CwICAg&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=js2M0T-3OIMIVDvokcKjokJbk0F8QOCd0mT4FsVFE88&m=JW7jxzBRiPgrJcasWuWrK0kZrU1D4udLWpqagPpVbJc&s=HlOBrUOpfS4_ECFITp9Dm3uUNJz94iQ1OPfrqtmiv2o&e=</a> 
</pre>
    </blockquote>
    <p><br>
    </p>
  </body>
</html>