MCPcopy Create free account
hub / github.com/Gecode/gecode / run

Method run

gecode/gist/treecanvas.cpp:373–456  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

371 };
372
373 void
374 SearcherThread::run(void) {
375 {
376 if (!node->isOpen())
377 return;
378 t->mutex.lock();
379 emit statusChanged(false);
380
381 unsigned int kids =
382 node->getNumberOfChildNodes(*t->na, t->curBest, t->stats,
383 t->c_d, t->a_d);
384 if (kids == 0 || node->getStatus() == STOP) {
385 t->mutex.unlock();
386 updateCanvas();
387 emit statusChanged(true);
388 return;
389 }
390
391 std::stack<SearchItem> stck;
392 stck.push(SearchItem(node,kids));
393 t->stats.maxDepth =
394 std::max(static_cast<long unsigned int>(t->stats.maxDepth),
395 static_cast<long unsigned int>(depth+stck.size()));
396
397 VisualNode* sol = nullptr;
398 int nodeCount = 0;
399 t->stopSearchFlag = false;
400 while (!stck.empty() && !t->stopSearchFlag) {
401 if (t->refresh > 0 && nodeCount >= t->refresh) {
402 node->dirtyUp(*t->na);
403 updateCanvas();
404 emit statusChanged(false);
405 nodeCount = 0;
406 if (t->refreshPause > 0)
407 msleep(t->refreshPause);
408 }
409 SearchItem& si = stck.top();
410 si.i++;
411 if (si.i == si.noOfChildren) {
412 stck.pop();
413 } else {
414 VisualNode* n = si.n->getChild(*t->na,si.i);
415 if (n->isOpen()) {
416 if (n->getStatus() == UNDETERMINED)
417 nodeCount++;
418 kids = n->getNumberOfChildNodes(*t->na, t->curBest, t->stats,
419 t->c_d, t->a_d);
420 if (t->moveDuringSearch)
421 emit moveToNode(n,false);
422 if (kids == 0) {
423 if (n->getStatus() == SOLVED) {
424 assert(n->hasCopy());
425 emit solution(n->getWorkingSpace());
426 n->purge(*t->na);
427 sol = n;
428 if (!a)
429 break;
430 }

Callers 13

layoutMethod · 0.45
hideFailedMethod · 0.45
labelBranchesMethod · 0.45
unhideAllMethod · 0.45
unstopAllMethod · 0.45
nodeMethod · 0.45
TreeCanvasMethod · 0.45
resetMethod · 0.45
navNextSolMethod · 0.45
exportNodePDFMethod · 0.45
printMethod · 0.45
paintEventMethod · 0.45

Calls 15

SearchItemClass · 0.85
isOpenMethod · 0.80
getNumberOfChildNodesMethod · 0.80
getStatusMethod · 0.80
dirtyUpMethod · 0.80
hasCopyMethod · 0.80
getWorkingSpaceMethod · 0.80
setCurrentNodeMethod · 0.80
maxFunction · 0.50
pushMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected