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

Method advise

gecode/int/extensional/layered-graph.hpp:436–579  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

434
435 template<class View, class Val, class Degree, class StateIdx>
436 ExecStatus
437 LayeredGraph<View,Val,Degree,StateIdx>::advise(Space& home,
438 Advisor& _a, const Delta& d) {
439 // Check whether state information has already been created
440 if (layers[0].states == nullptr) {
441 State* states = home.alloc<State>(n_states);
442 for (unsigned int i=0; i<n_states; i++)
443 states[i].init();
444 layers[n].states = states;
445 states += layers[n].n_states;
446 for (int i=n; i--; ) {
447 layers[i].states = states;
448 states += layers[i].n_states;
449 for (ValSize j=layers[i].size; j--; ) {
450 Support& s = layers[i].support[j];
451 for (Degree deg=s.n_edges; deg--; ) {
452 i_state(i,s.edges[deg]).o_deg++;
453 o_state(i,s.edges[deg]).i_deg++;
454 }
455 }
456 }
457 }
458
459 Index& a = static_cast<Index&>(_a);
460 const int i = a.i;
461
462 if (layers[i].size <= layers[i].x.size()) {
463 // Propagator has already done everything
464 if (View::modevent(d) == ME_INT_VAL) {
465 a.dispose(home,c);
466 return c.empty() ? ES_NOFIX : ES_FIX;
467 } else {
468 return ES_FIX;
469 }
470 }
471
472 bool i_mod = false;
473 bool o_mod = false;
474
475 if (View::modevent(d) == ME_INT_VAL) {
476 Val n = static_cast<Val>(layers[i].x.val());
477 ValSize j=0;
478 for (; layers[i].support[j].val < n; j++) {
479 Support& s = layers[i].support[j];
480 n_edges -= s.n_edges;
481 // Supported value not any longer in view
482 for (Degree deg=s.n_edges; deg--; ) {
483 // Adapt states
484 o_mod |= i_dec(i,s.edges[deg]);
485 i_mod |= o_dec(i,s.edges[deg]);
486 }
487 }
488 assert(layers[i].support[j].val == n);
489 layers[i].support[0] = layers[i].support[j++];
490 ValSize s=layers[i].size;
491 layers[i].size = 1;
492 for (; j<s; j++) {
493 Support& ls = layers[i].support[j];

Callers

nothing calls this directly

Calls 10

ES_NOFIX_DISPOSEMethod · 0.80
initMethod · 0.45
sizeMethod · 0.45
disposeMethod · 0.45
emptyMethod · 0.45
valMethod · 0.45
anyMethod · 0.45
minMethod · 0.45
maxMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected