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

Function post_all

gecode/int/linear/bool-post.cpp:533–585  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

531
532 template<class View>
533 forceinline void
534 post_all(Home home,
535 Term<BoolView>* t, int n,
536 IntRelType irt, View x, int c) {
537
538 Limits::check(c,"Int::linear");
539
540 long long int d = c;
541
542 eliminate(t,n,d);
543
544 Term<BoolView> *t_p, *t_n;
545 int n_p, n_n, gcd=0;
546 bool unit = normalize<BoolView>(t,n,t_p,n_p,t_n,n_n,gcd);
547
548 rewrite(irt,d);
549
550 c = static_cast<int>(d);
551
552 if (n == 0) {
553 switch (irt) {
554 case IRT_EQ: GECODE_ME_FAIL(x.eq(home,-c)); break;
555 case IRT_NQ: GECODE_ME_FAIL(x.nq(home,-c)); break;
556 case IRT_GQ: GECODE_ME_FAIL(x.lq(home,-c)); break;
557 case IRT_LQ: GECODE_ME_FAIL(x.gq(home,-c)); break;
558 default: GECODE_NEVER;
559 }
560 return;
561 }
562
563 // Check for overflow
564 {
565 long long int sl = static_cast<long long int>(x.max())+c;
566 long long int su = static_cast<long long int>(x.min())+c;
567 for (int i=0; i<n_p; i++)
568 su -= t_p[i].a;
569 for (int i=0; i<n_n; i++)
570 sl += t_n[i].a;
571 Limits::check(sl,"Int::linear");
572 Limits::check(su,"Int::linear");
573 }
574
575 if (unit && (n_n == 0)) {
576 /// All coefficients are 1
577 post_pos_unit(home,t_p,n_p,irt,x,c);
578 } else if (unit && (n_p == 0)) {
579 // All coefficients are -1
580 post_neg_unit(home,t_n,n_n,irt,x,c);
581 } else {
582 // Mixed coefficients
583 post_mixed(home,t_p,n_p,t_n,n_n,irt,x,c);
584 }
585 }
586
587
588 void

Callers 1

postFunction · 0.85

Calls 12

post_pos_unitFunction · 0.85
post_neg_unitFunction · 0.85
post_mixedFunction · 0.85
eliminateFunction · 0.70
rewriteFunction · 0.70
checkFunction · 0.50
eqMethod · 0.45
nqMethod · 0.45
lqMethod · 0.45
gqMethod · 0.45
maxMethod · 0.45
minMethod · 0.45

Tested by

no test coverage detected