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

Method next

gecode/search/seq/bab.hpp:60–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58
59 template<class Tracer>
60 forceinline Space*
61 BAB<Tracer>::next(void) {
62 /*
63 * The engine maintains the following invariant:
64 * - If the current space (cur) is not nullptr, the path always points
65 * to exactly that space.
66 * - If the current space (cur) is nullptr, the path always points
67 * to the next space (if there is any).
68 *
69 * This invariant is needed so that no-goods can be extracted properly
70 * when the engine is stopped or has found a solution.
71 *
72 * An additional invariant maintained by the engine is:
73 * For all nodes stored at a depth less than mark, there
74 * is no guarantee of betterness. For those above the mark,
75 * betterness is guaranteed.
76 *
77 */
78 start();
79 while (true) {
80 if (stop(opt))
81 return nullptr;
82 // Recompute and add constraint if necessary
83 while (cur == nullptr) {
84 if (path.empty())
85 return nullptr;
86 cur = path.recompute(d,opt.a_d,*this,*best,mark,tracer);
87 if (cur != nullptr)
88 break;
89 path.next();
90 }
91 node++;
92 SearchTracer::EdgeInfo ei;
93 if (tracer && (path.entries() > 0)) {
94 typename Path<Tracer>::Edge& top = path.top();
95 ei.init(tracer.wid(), top.nid(), top.truealt(), *cur, *top.choice());
96 }
97 unsigned int nid = tracer.nid();
98 switch (cur->status(*this)) {
99 case SS_FAILED:
100 if (tracer) {
101 SearchTracer::NodeInfo ni(SearchTracer::NodeType::FAILED,
102 tracer.wid(), nid, *cur);
103 tracer.node(ei,ni);
104 }
105 fail++;
106 delete cur;
107 cur = nullptr;
108 path.next();
109 break;
110 case SS_SOLVED:
111 {
112 if (tracer) {
113 SearchTracer::NodeInfo ni(SearchTracer::NodeType::SOLVED,
114 tracer.wid(), nid, *cur);
115 tracer.node(ei,ni);
116 }
117 // Deletes all pending branchers

Callers

nothing calls this directly

Calls 14

stopFunction · 0.85
emptyMethod · 0.45
recomputeMethod · 0.45
entriesMethod · 0.45
initMethod · 0.45
widMethod · 0.45
nidMethod · 0.45
truealtMethod · 0.45
choiceMethod · 0.45
statusMethod · 0.45
nodeMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected