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

Method next

gecode/search/seq/rbs.cpp:55–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53 }
54
55 Space*
56 RBS::next(void) {
57 if (restart) {
58 restart = false;
59 sslr++;
60 NoGoods& ng = e->nogoods();
61 // Reset number of no-goods found
62 ng.ng(0);
63 MetaInfo mi(stop->m_stat.restart,MetaInfo::RR_SOL,sslr,e->statistics().fail,last,ng);
64 bool r = master->master(mi);
65 stop->m_stat.nogood += ng.ng();
66 if (master->status(stop->m_stat) == SS_FAILED) {
67 stop->update(e->statistics());
68 delete master;
69 master = nullptr;
70 e->reset(nullptr);
71 return nullptr;
72 } else if (r) {
73 stop->update(e->statistics());
74 Space* slave = master;
75 master = master->clone();
76 complete = slave->slave(mi);
77 e->reset(slave);
78 sslr = 0;
79 stop->m_stat.restart++;
80 }
81 }
82 while (true) {
83 Space* n = e->next();
84 if (n != nullptr) {
85 // The engine found a solution
86 restart = true;
87 delete last;
88 last = n->clone();
89 return n;
90 } else if ( (!complete && !e->stopped()) ||
91 (e->stopped() && stop->enginestopped()) ) {
92 // The engine must perform a true restart
93 // The number of the restart has been incremented in the stop object
94 if (!complete && !e->stopped())
95 stop->m_stat.restart++;
96 sslr = 0;
97 NoGoods& ng = e->nogoods();
98 ng.ng(0);
99 MetaInfo mi(stop->m_stat.restart,e->stopped() ? MetaInfo::RR_LIM : MetaInfo::RR_CMPL,sslr,e->statistics().fail,last,ng);
100 (void) master->master(mi);
101 stop->m_stat.nogood += ng.ng();
102 unsigned long long int nl = ++(*co);
103 stop->limit(e->statistics(),nl);
104 if (master->status(stop->m_stat) == SS_FAILED)
105 return nullptr;
106 Space* slave = master;
107 master = master->clone();
108 complete = slave->slave(mi);
109 e->reset(slave);
110 } else {
111 return nullptr;
112 }

Callers

nothing calls this directly

Calls 12

ngMethod · 0.80
enginestoppedMethod · 0.80
nogoodsMethod · 0.45
statisticsMethod · 0.45
masterMethod · 0.45
statusMethod · 0.45
updateMethod · 0.45
resetMethod · 0.45
cloneMethod · 0.45
slaveMethod · 0.45
stoppedMethod · 0.45
limitMethod · 0.45

Tested by

no test coverage detected