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

Method getSubStrategy

contribs/qecode/Strategy.cc:139–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

137}
138
139Strategy Strategy::getSubStrategy(vector<int> position) {
140 if (position.empty()) return *this;
141 int deg = degree();
142 if (deg == 0) {
143 cout<<"Did not find substrategy"<<endl;
144 return Strategy::Dummy();
145 }
146 for (int i=0;i<deg;i++) {
147 Strategy child=getChild(i);
148 bool ok=true;
149 if (child.values().size() == 0) {
150 ok = false;
151 }
152 for (int j=0;(j<child.values().size()) && ok;j++) {
153 if (child.value(j) != position[j]) ok=false;
154 }
155 if (ok) {
156 position.erase(position.begin(),position.begin() + (child.values().size()));
157 return child.getSubStrategy(position);
158 }
159 }
160 cout<<"Did not find substrategy"<<endl;
161 return Strategy::Dummy();
162}
163
164void Strategy::attach(Strategy child) {
165 if (child.isDummy()) {

Callers 1

returnWorkMethod · 0.80

Calls 6

degreeFunction · 0.85
valuesMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45
valueMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected