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

Method GraphColor

examples/graph-color.cpp:338–408  ·  view source on GitHub ↗

The actual model

Source from the content-addressed store, hash-verified

336 };
337 /// The actual model
338 GraphColor(const SizeOptions& opt)
339 : IntMinimizeScript(opt),
340 g(opt.size() == 1 ? g2 : g1),
341 v(*this,g.n_v,0,g.n_v-1),
342 m(*this,0,g.n_v-1) {
343 rel(*this, v, IRT_LQ, m);
344 for (int i = 0; g.e[i] != -1; i += 2)
345 rel(*this, v[g.e[i]], IRT_NQ, v[g.e[i+1]]);
346
347 const int* c = g.c;
348 for (int i = *c++; i--; c++)
349 rel(*this, v[*c], IRT_EQ, i);
350 while (*c != -1) {
351 int n = *c;
352 IntVarArgs x(n); c++;
353 for (int i = n; i--; c++)
354 x[i] = v[*c];
355 distinct(*this, x, opt.ipl());
356 if (opt.model() == MODEL_CLIQUE)
357 rel(*this, m, IRT_GQ, n-1);
358 }
359 // Branching on the number of colors
360 branch(*this, m, INT_VAL_MIN());
361 if (opt.symmetry() == SYMMETRY_NONE) {
362 // Branching without symmetry breaking
363 switch (opt.branching()) {
364 case BRANCH_SIZE:
365 branch(*this, v, INT_VAR_SIZE_MIN(), INT_VAL_MIN());
366 break;
367 case BRANCH_DEGREE:
368 branch(*this, v, tiebreak(INT_VAR_DEGREE_MAX(),INT_VAR_SIZE_MIN()),
369 INT_VAL_MIN());
370 break;
371 case BRANCH_DEGREE_SIZE:
372 branch(*this, v, INT_VAR_DEGREE_SIZE_MAX(), INT_VAL_MIN());
373 break;
374 case BRANCH_AFC_SIZE:
375 branch(*this, v, INT_VAR_AFC_SIZE_MAX(opt.decay()), INT_VAL_MIN());
376 break;
377 case BRANCH_ACTION_SIZE:
378 branch(*this, v, INT_VAR_ACTION_SIZE_MAX(opt.decay()), INT_VAL_MIN());
379 break;
380 }
381 } else { // opt.symmetry() == SYMMETRY_LDSB
382 // Branching while considering value symmetry breaking
383 // (every permutation of color values gives equivalent solutions)
384 Symmetries syms;
385 syms << ValueSymmetry(IntArgs::create(g.n_v,0));
386 switch (opt.branching()) {
387 case BRANCH_SIZE:
388 branch(*this, v, INT_VAR_SIZE_MIN(), INT_VAL_MIN(), syms);
389 break;
390 case BRANCH_DEGREE:
391 branch(*this, v, tiebreak(INT_VAR_DEGREE_MAX(),
392 INT_VAR_SIZE_MIN()),
393 INT_VAL_MIN(), syms);
394 break;
395 case BRANCH_DEGREE_SIZE:

Callers

nothing calls this directly

Calls 15

distinctFunction · 0.85
INT_VAL_MINFunction · 0.85
INT_VAR_SIZE_MINFunction · 0.85
tiebreakFunction · 0.85
INT_VAR_DEGREE_MAXFunction · 0.85
INT_VAR_DEGREE_SIZE_MAXFunction · 0.85
INT_VAR_AFC_SIZE_MAXFunction · 0.85
INT_VAR_ACTION_SIZE_MAXFunction · 0.85
ValueSymmetryFunction · 0.85
modelMethod · 0.80
branchingMethod · 0.80
relFunction · 0.50

Tested by

no test coverage detected