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

Method recompute

gecode/gist/spacenode.cpp:63–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61 BestNode::BestNode(SpaceNode* s0) : s(s0) {}
62
63 int
64 SpaceNode::recompute(NodeAllocator& na,
65 BestNode* curBest, int c_d, int a_d) {
66 int rdist = 0;
67
68 if (copy == nullptr) {
69 SpaceNode* curNode = this;
70 SpaceNode* lastFixpoint = nullptr;
71
72 lastFixpoint = curNode;
73
74 std::stack<Branch> stck;
75
76 int idx = getIndex(na);
77 while (curNode->copy == nullptr) {
78 SpaceNode* parent = curNode->getParent(na);
79 int parentIdx = curNode->getParent();
80 int alternative = curNode->getAlternative(na);
81
82 SpaceNode* ownBest = na.best(idx);
83 Branch b(alternative, parent->choice,
84 curBest == nullptr ? nullptr : ownBest);
85 stck.push(b);
86
87 curNode = parent;
88 idx = parentIdx;
89 rdist++;
90 }
91
92 Space* curSpace;
93 if (Support::marked(curNode->copy)) {
94 curSpace = static_cast<Space*>(Support::unmark(curNode->copy));
95 curNode->copy = nullptr;
96 a_d = -1;
97 } else {
98 curSpace = curNode->copy->clone();
99 curNode->setDistance(0);
100 }
101
102 SpaceNode* lastBest = nullptr;
103 SpaceNode* middleNode = curNode;
104 int curDist = 0;
105
106 while (!stck.empty()) {
107 if (a_d >= 0 &&
108 curDist > a_d &&
109 curDist == rdist / 2) {
110 if (curSpace->status() == SS_FAILED) {
111 copy = static_cast<Space*>(Support::mark(curSpace));
112 return rdist;
113 } else {
114 middleNode->copy = curSpace->clone();
115 }
116 }
117 Branch b = stck.top(); stck.pop();
118
119 if(middleNode == lastFixpoint) {
120 curSpace->status();

Callers

nothing calls this directly

Calls 15

markedFunction · 0.85
unmarkFunction · 0.85
markFunction · 0.85
funmarkFunction · 0.85
getParentMethod · 0.80
getAlternativeMethod · 0.80
setDistanceMethod · 0.80
acquireSpaceMethod · 0.80
dfsFunction · 0.70
bestMethod · 0.45
pushMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected