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

Function branch

gecode/int/ldsb.cpp:258–306  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

256 using namespace Int::LDSB;
257
258 void
259 branch(Home home, const IntVarArgs& x,
260 IntVarBranch vars, IntValBranch vals,
261 const Symmetries& syms,
262 IntBranchFilter bf,
263 IntVarValPrint vvp) {
264 using namespace Int;
265 if (home.failed()) return;
266 vars.expand(home,x);
267 ViewArray<IntView> xv(home,x);
268 ViewSel<IntView>* vs[1] = {
269 Branch::viewsel(home,vars)
270 };
271 switch (vals.select()) {
272 case IntValBranch::SEL_SPLIT_MIN:
273 case IntValBranch::SEL_SPLIT_MAX:
274 case IntValBranch::SEL_RANGE_MIN:
275 case IntValBranch::SEL_RANGE_MAX:
276 case IntValBranch::SEL_VALUES_MIN:
277 case IntValBranch::SEL_VALUES_MAX:
278 throw LDSBBadValueSelection("Int::LDSB::branch");
279 break;
280 case IntValBranch::SEL_VAL_COMMIT:
281 if (vals.commit())
282 throw LDSBBadValueSelection("Int::LDSB::branch");
283 // If vals.commit() is valid, it means it will commit with
284 // binary branching, which is OK for LDSB, so we
285 // fall through
286 default:
287 // Construct mapping from each variable in the array to its index
288 // in the array.
289 VariableMap variableMap;
290 for (int i = 0 ; i < x.size() ; i++)
291 variableMap[x[i].varimp()] = i;
292
293 // Convert the modelling-level Symmetries object into an array of
294 // SymmetryImp objects.
295 int n = syms.size();
296 SymmetryImp<IntView>** array =
297 static_cast<Space&>(home).alloc<SymmetryImp<IntView>* >(n);
298 for (int i = 0 ; i < n ; i++) {
299 array[i] = createIntSym(home, syms[i], variableMap);
300 }
301
302 postldsbbrancher<IntView,1,int,2>
303 (home,xv,vs,Branch::valselcommit(home,vals),
304 array,n,bf,vvp);
305 }
306 }
307
308 void
309 branch(Home home, const IntVarArgs& x,

Callers

nothing calls this directly

Calls 12

createIntSymFunction · 0.85
INT_VAR_NONEFunction · 0.85
createBoolSymFunction · 0.85
BOOL_VAR_NONEFunction · 0.85
viewselFunction · 0.50
valselcommitFunction · 0.50
failedMethod · 0.45
expandMethod · 0.45
selectMethod · 0.45
commitMethod · 0.45
sizeMethod · 0.45
varimpMethod · 0.45

Tested by

no test coverage detected