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

Method getNumberOfChildNodes

gecode/gist/spacenode.cpp:297–366  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

295
296
297 int
298 SpaceNode::getNumberOfChildNodes(NodeAllocator& na,
299 BestNode* curBest, Statistics& stats,
300 int c_d, int a_d) {
301 int kids = 0;
302 if (isUndetermined()) {
303 stats.undetermined--;
304 acquireSpace(na, curBest, c_d, a_d);
305 QVector<QString> labels;
306 switch (static_cast<Space*>(Support::funmark(copy))->status(stats)) {
307 case SS_FAILED:
308 {
309 purge(na);
310 kids = 0;
311 setHasOpenChildren(false);
312 setHasSolvedChildren(false);
313 setHasFailedChildren(true);
314 setStatus(FAILED);
315 stats.failures++;
316 SpaceNode* p = getParent(na);
317 if (p != nullptr)
318 p->closeChild(na, true, false);
319 }
320 break;
321 case SS_SOLVED:
322 {
323 // Deletes all pending branchers
324 (void) static_cast<Space*>(Support::funmark(copy))->choice();
325 kids = 0;
326 setStatus(SOLVED);
327 setHasOpenChildren(false);
328 setHasSolvedChildren(true);
329 setHasFailedChildren(false);
330 stats.solutions++;
331 if (curBest != nullptr) {
332 curBest->s = this;
333 }
334 SpaceNode* p = getParent(na);
335 if (p != nullptr)
336 p->closeChild(na, false, true);
337 }
338 break;
339 case SS_BRANCH:
340 {
341 Space* s = static_cast<Space*>(Support::funmark(copy));
342 choice = s->choice();
343 kids = choice->alternatives();
344 setHasOpenChildren(true);
345 if (dynamic_cast<const StopChoice*>(choice)) {
346 setStatus(STOP);
347 } else {
348 setStatus(BRANCH);
349 stats.choices++;
350 }
351 stats.undetermined += kids;
352 for (int i=0; i<kids; i++) {
353 std::ostringstream oss;
354 s->print(*choice,i,oss);

Callers 2

runMethod · 0.80
inspectCurrentNodeMethod · 0.80

Calls 9

funmarkFunction · 0.85
purgeFunction · 0.85
closeChildMethod · 0.80
alternativesMethod · 0.80
changedStatusMethod · 0.80
statusMethod · 0.45
choiceMethod · 0.45
printMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected