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

Method choice

examples/radiotherapy.cpp:269–300  ·  view source on GitHub ↗

Return choice

Source from the content-addressed store, hash-verified

267 }
268 /// Return choice
269 virtual Gecode::Choice* choice(Space& home) {
270 done = true;
271 Radiotherapy& rt = static_cast<Radiotherapy&>(home);
272
273 std::cout << "*";
274
275 // Perform nested search for each row
276 bool fail = false;
277 for (int i=0; i<rt.rd.m; i++) {
278 // Create fresh clone for row i
279 Radiotherapy* row = static_cast<Radiotherapy*>(rt.clone());
280
281 // Branch over row i
282 branch(*row, getRow(row, index[i].idx),
283 INT_VAR_NONE(), INT_VAL_SPLIT_MIN());
284 Search::Options o; o.clone = false;
285 if (Radiotherapy* newSol = dfs(row, o) ) {
286 // Found a solution for row i, so try to find one for i+1
287 delete newSol;
288 std::cerr << index[i].idx;
289 } else {
290 // Found no solution for row i, so back to search the N variables
291 fail = true;
292 index[i].weight += 1;
293 if (i && index[i] < index[i-1])
294 std::swap(index[i], index[i-1]);
295 break;
296 }
297 }
298
299 return new Choice(*this, fail);
300 }
301 /// Return choice
302 virtual Choice* choice(const Space&, Archive& e) {
303 bool fail; e >> fail;

Callers

nothing calls this directly

Calls 5

INT_VAR_NONEFunction · 0.85
INT_VAL_SPLIT_MINFunction · 0.85
branchFunction · 0.50
dfsFunction · 0.50
cloneMethod · 0.45

Tested by

no test coverage detected