44 namespace Gecode {
namespace Int {
namespace GCC {
50 bool cf,
bool nolbc) :
52 card_fixed(cf), skip_lbc(nolbc) {
62 card_fixed(p.card_fixed), skip_lbc(p.skip_lbc) {
80 return new (home)
Bnd<Card>(home,share,*
this);
87 int n_k = Card::propagate ? k.size() : 0;
141 int rightmost = nb + 1;
151 for (i = bsize; --
i; ) {
155 hall[
i].
d = lps.sumup(hall[pred].bounds, hall[i].bounds - 1);
162 if (hall[i].
d == 0) {
171 for (i = bsize; i--; ) {
173 if (hall[i].
d == 0) {
193 for (i = 0; i < n; i++) {
195 int x0 = rank[mu[
i]].
min;
196 int y = rank[mu[
i]].
max;
224 if (hall[z].
d <= lps.sumup(hall[y].
bounds, hall[z].
bounds - 1)) {
241 if (--hall[z].
d == 0) {
253 if (hall[x0].h > x0) {
269 if (hall[z].
d == lps.sumup(hall[y].
bounds, hall[z].
bounds - 1)) {
298 for (i = bsize; --
i;)
312 int x0 = rank[mu[
i]].
min;
313 int y = rank[mu[
i]].
max;
315 if ((hall[x0].s <= x0) || (y > hall[x0].s)) {
317 int m = lps.skipNonNullElementsRight(hall[hall[i].newBound].bounds);
324 for (i = 0; i <= nb; i++) {
325 hall[
i].
d = lps.sumup(hall[i].bounds, hall[i + 1].bounds - 1);
326 if (hall[i].
d == 0) {
336 for (i = 1; i <= nb; i++)
337 if (hall[i - 1].
d == 0) {
348 int x0 = rank[nu[
i]].
max;
349 int y = rank[nu[
i]].
min;
357 if (hall[z].
d > lps.sumup(hall[z].
bounds, hall[y].
bounds - 1)) {
359 if (--hall[z].
d == 0) {
365 if (hall[x0].h < x0) {
373 if (hall[z].
d == lps.sumup(hall[z].
bounds, hall[y].
bounds - 1)) {
388 int x0 = rank[nu[
i]].
min;
389 int y = rank[nu[
i]].
max;
390 if ((hall[x0].s <= x0) || (y > hall[x0].s)) {
391 int m = lps.skipNonNullElementsLeft(hall[hall[i].newBound].bounds - 1);
403 int rightmost = nb + 1;
419 for (
int i = bsize; --
i; ) {
420 hall[
i].
h = hall[
i].
t =
i-1;
421 hall[
i].
d = ups.sumup(hall[
i-1].bounds, hall[
i].bounds - 1);
426 for (
int i = 0;
i < n;
i++) {
428 int x0 = rank[mu[
i]].
min;
430 int y = rank[mu[
i]].
max;
449 if (--hall[z].
d == 0) {
465 if (hall[z].
d < ups.sumup(hall[y].
bounds, hall[z].
bounds - 1))
473 if (hall[x0].h > x0) {
496 if (hall[z].
d == ups.sumup(hall[y].
bounds, hall[z].
bounds - 1)) {
510 for (
int i = 0;
i < rightmost;
i++) {
511 hall[
i].
h = hall[
i].
t =
i+1;
512 hall[
i].
d = ups.sumup(hall[
i].bounds, hall[
i+1].bounds - 1);
515 for (
int i = n;
i--; ) {
517 int x0 = rank[nu[
i]].
max;
519 int y = rank[nu[
i]].
min;
524 if (--hall[z].
d == 0) {
540 if (hall[x0].h < x0) {
548 if (hall[z].
d == ups.sumup(hall[z].
bounds, hall[y].
bounds - 1)) {
565 for (
int i=k.
size();
i--;)
571 int* z = r.
alloc<
int>(n_z);
575 if (k[
i].
max() == 0) {
576 z[n_z++] = k[
i].card();
582 for (
int i=x.
size();
i--;) {
586 lps.reinit(); ups.reinit();
605 for (
int i = k.
size();
i--; )
607 bool all_assigned =
true;
609 for (
int i = x.
size();
i--; ) {
619 all_assigned =
false;
622 if (!Card::propagate)
627 if (Card::propagate) {
630 for (
int i = k.
size();
i--; )
636 if (!card_consistent<Card>(x, k))
643 for (
int i = k.
size();
i--; )
646 for (
int i = x.
size();
i--; ) {
657 all_assigned =
false;
664 for (
int i = k.
size();
i--; )
674 int* mu = r.
alloc<
int>(n);
675 int* nu = r.
alloc<
int>(n);
677 for (
int i = n;
i--; )
682 Support::quicksort<int, MaxInc<IntView> >(mu, n, max_inc);
686 Support::quicksort<int, MinInc<IntView> >(nu, n, min_inc);
690 Support::quicksort<Card, MinIdx<Card> >(&k[0], k.size(), min_idx);
692 if (!lps.initialized()) {
693 assert (!ups.initialized());
694 lps.init(home, k,
false);
695 ups.init(home, k,
true);
696 }
else if (Card::propagate) {
699 if (lps.check_update_min(k))
700 lps.init(home, k,
false);
701 if (ups.check_update_max(k))
702 ups.init(home, k,
true);
707 assert(lps.minValue() <= x[nu[0]].min());
724 int min = x[nu[0]].min();
725 int max = x[mu[0]].max() + 1;
726 int last = lps.firstValue + 1;
727 hall[0].bounds = last;
741 if (i < n && min < max) {
744 hall[++nb].bounds = last;
746 rank[nu[
i]].min = nb;
748 min = x[nu[
i]].min();
752 hall[++nb].bounds = last;
754 rank[mu[j]].max = nb;
757 max = x[mu[j]].max() + 1;
762 int rightmost = nb + 1;
763 hall[rightmost].bounds = ups.lastValue + 1 ;
765 if (Card::propagate) {
767 for (
int i = k.
size();
i--; )
768 if (k[
i].
min() != 0) {
774 if (!card_fixed && !skip_lbc)
782 for (
int i = k.
size();
i--; )
784 for (
int i = x.
size();
i--; )
796 for (
int i = k.
size();
i--; )
808 for (
int i=k.
size();
i--; )
810 cardfix =
false;
break;
813 for (
int i=k.
size();
i--; )
814 if (k[
i].
min() != 0) {
815 nolbc =
false;
break;
820 if (isDistinct<Card>(home,x,k))
823 (void)
new (home)
Bnd<Card>(home,x,k,cardfix,nolbc);