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

Method next

gecode/search/seq/dfs.hpp:77–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75
76 template<class Tracer>
77 forceinline Space*
78 DFS<Tracer>::next(void) {
79 /*
80 * The engine maintains the following invariant:
81 * - If the current space (cur) is not nullptr, the path always points
82 * to exactly that space.
83 * - If the current space (cur) is nullptr, the path always points
84 * to the next space (if there is any).
85 *
86 * This invariant is needed so that no-goods can be extracted properly
87 * when the engine is stopped or has found a solution.
88 *
89 */
90 start();
91 while (true) {
92 if (stop(opt))
93 return nullptr;
94 while (cur == nullptr) {
95 if (path.empty())
96 return nullptr;
97 cur = path.recompute(d,opt.a_d,*this,tracer);
98 if (cur != nullptr)
99 break;
100 path.next();
101 }
102 node++;
103 SearchTracer::EdgeInfo ei;
104 if (tracer && (path.entries() > 0)) {
105 typename Path<Tracer>::Edge& top = path.top();
106 ei.init(tracer.wid(), top.nid(), top.truealt(), *cur, *top.choice());
107 }
108 unsigned int nid = tracer.nid();
109 switch (cur->status(*this)) {
110 case SS_FAILED:
111 if (tracer) {
112 SearchTracer::NodeInfo ni(SearchTracer::NodeType::FAILED,
113 tracer.wid(), nid, *cur);
114 tracer.node(ei,ni);
115 }
116 fail++;
117 delete cur;
118 cur = nullptr;
119 path.next();
120 break;
121 case SS_SOLVED:
122 {
123 if (tracer) {
124 SearchTracer::NodeInfo ni(SearchTracer::NodeType::SOLVED,
125 tracer.wid(), nid, *cur);
126 tracer.node(ei,ni);
127 }
128 // Deletes all pending branchers
129 (void) cur->choice();
130 Space* s = cur;
131 cur = nullptr;
132 path.next();
133 return s;
134 }

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