[Cbc] CbcEventHandler in multithreading
Alexis
aguigue at softree.com
Wed Sep 14 20:21:13 EDT 2016
Hi,
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.
I have a few more questions:
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?
2 - I am not sure I understand at this point the parameter threadMode_,
but I am going to look more into it.
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.
My code is essentially an extended version of driver6.cpp/driver4.cpp so
I used to have
// Pass to Cbc initialize defaults
CbcModel modelA(solver1);
CbcModel * model = &modelA;
CbcMain0(modelA);
// Event handler
MyEventHandler3 eventHandler;
model->passInEventHandler(&eventHandler);
/* Now go into code for standalone solver
Could copy arguments and add -quit at end to be safe
but this will do
*/
const char * argv2[]={"driver4","-solve","-quit"};
CbcMain1(3,argv2,modelA);
Now, I have
* const char * argv2[]={"driver4","-threads, "X", "-solve","-quit"};*
* CbcMain1(5,argv2,modelA);*
- Is eventHandler shared between all the threads? Or is there one
handler (copy) per thread?
- In the first case, is eventHandler thread safe?
- What would be the best way to get the best solution in the tree?
Currently, I just have to call
CbcEventHandler::CbcAction
MyEventHandler3::event(CbcEvent whichEvent)
{
// If in sub tree carry on
if (!model_->parentModel()) {
if (whichEvent==solution||whichEvent==heuristicSolution) {
printf("value of solution is %g\n",model_->getObjValue());
} else {
return noAction; // carry on
}
}
Thanks!
Alexis
--
Alexis Guigue, E.I.T., B.Eng., M.A.Sc., Ph.D.
Software Engineer/Research Engineer
604-519-6222, ext. 107
Softree Technical Systems Inc. <http://www.softree.com>
Engineering an Easier Way
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/cbc/attachments/20160914/5a3c21a4/attachment.html>
More information about the Cbc
mailing list