Generated on Thu Apr 5 2018 19:44:19 for Gecode by doxygen 1.8.13
bool-int.hpp
Go to the documentation of this file.
1 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /*
3  * Main authors:
4  * Christian Schulte <schulte@gecode.org>
5  * Tias Guns <tias.guns@cs.kuleuven.be>
6  *
7  * Copyright:
8  * Christian Schulte, 2006
9  * Tias Guns, 2009
10  *
11  * Last modified:
12  * $Date$ by $Author$
13  * $Revision$
14  *
15  * This file is part of Gecode, the generic constraint
16  * development environment:
17  * http://www.gecode.org
18  *
19  * Permission is hereby granted, free of charge, to any person obtaining
20  * a copy of this software and associated documentation files (the
21  * "Software"), to deal in the Software without restriction, including
22  * without limitation the rights to use, copy, modify, merge, publish,
23  * distribute, sublicense, and/or sell copies of the Software, and to
24  * permit persons to whom the Software is furnished to do so, subject to
25  * the following conditions:
26  *
27  * The above copyright notice and this permission notice shall be
28  * included in all copies or substantial portions of the Software.
29  *
30  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
32  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
33  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
34  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
35  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
36  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37  *
38  */
39 
40 #include <algorithm>
41 
42 #include <gecode/int/bool.hh>
43 
44 namespace Gecode { namespace Int { namespace Linear {
45 
46  /*
47  * Baseclass for integer Boolean sum using dependencies
48  *
49  */
50  template<class VX>
53  int n_s, int c0)
54  : Propagator(home), co(home), x(x0), n_as(n_s), n_hs(n_s), c(c0) {
55  Advisor* a = new (home) Advisor(home,*this,co);
56  for (int i=n_as; i--; )
57  x[i].subscribe(home,*a);
58  }
59 
60  template<class VX>
61  forceinline void
63  if (n_as != n_hs) {
64  // Remove views for which no more subscriptions exist
65  int n_x = x.size();
66  for (int i=n_hs; i--; )
67  if (!x[i].none()) {
68  x[i]=x[--n_hs]; x[n_hs]=x[--n_x];
69  }
70  x.size(n_x);
71  }
72  assert(n_as == n_hs);
73  // Remove assigned yet unsubscribed views
74  {
75  int n_x = x.size();
76  for (int i=n_x-1; i>=n_hs; i--)
77  if (x[i].one()) {
78  c--; x[i]=x[--n_x];
79  } else if (x[i].zero()) {
80  x[i]=x[--n_x];
81  }
82  x.size(n_x);
83  }
84  }
85 
86  template<class VX>
89  : Propagator(home,p), n_as(p.n_as), n_hs(n_as) {
90  p.normalize();
91  c=p.c;
92  co.update(home,p.co);
93  x.update(home,p.x);
94  }
95 
96  template<class VX>
97  PropCost
98  LinBoolInt<VX>::cost(const Space&, const ModEventDelta&) const {
100  }
101 
102  template<class VX>
103  forceinline size_t
105  Advisors<Advisor> as(co);
106  for (int i=n_hs; i--; )
107  x[i].cancel(home,as.advisor());
108  co.dispose(home);
109  (void) Propagator::dispose(home);
110  return sizeof(*this);
111  }
112 
113  /*
114  * Greater or equal propagator (integer rhs)
115  *
116  */
117  template<class VX>
120  : LinBoolInt<VX>(home,x,c+1,c) {}
121 
122  template<class VX>
125  : LinBoolInt<VX>(home,p) {}
126 
127  template<class VX>
128  Actor*
130  return new (home) GqBoolInt<VX>(home,*this);
131  }
132 
133  template<class VX>
134  ExecStatus
136  // Check whether propagator is running
137  if (n_as == 0)
138  return ES_FIX;
139 
140  if (VX::one(d)) {
141  c--; goto check;
142  }
143  if (c+1 < n_as)
144  goto check;
145  // Find a new subscription
146  for (int i = x.size()-1; i>=n_hs; i--)
147  if (x[i].none()) {
148  std::swap(x[i],x[n_hs]);
149  x[n_hs++].subscribe(home,a);
150  x.size(i+1);
151  return ES_FIX;
152  } else if (x[i].one()) {
153  c--;
154  if (c+1 < n_as) {
155  x.size(i);
156  assert(n_hs <= x.size());
157  goto check;
158  }
159  }
160  // No view left for subscription
161  x.size(n_hs);
162  check:
163  // Do not update subscription
164  n_as--;
165  int n = x.size()-n_hs+n_as;
166  if ((n < c) && !disabled())
167  return ES_FAILED;
168  if ((c <= 0) || (c == n))
169  return ES_NOFIX;
170  else
171  return ES_FIX;
172  }
173 
174  template<class VX>
175  void
177  int n = x.size()-n_hs+n_as;
178  if ((c <= 0) || (c >= n))
179  VX::schedule(home,*this,ME_INT_VAL);
180  }
181 
182  template<class VX>
183  ExecStatus
185  // Check for failure due to a disabled propagator
186  if (x.size() - n_hs + n_as < c)
187  return ES_FAILED;
188  if (c > 0) {
189  assert((n_as == c) && (x.size() == n_hs));
190  // Signal that propagator is running
191  n_as = 0;
192  // All views must be one to satisfy inequality
193  for (int i=n_hs; i--; )
194  if (x[i].none())
195  GECODE_ME_CHECK(x[i].one_none(home));
196  }
197  return home.ES_SUBSUMED(*this);
198  }
199 
200  template<class VX>
201  ExecStatus
203  // Eliminate assigned views
204  int n_x = x.size();
205  for (int i=n_x; i--; )
206  if (x[i].zero()) {
207  x[i] = x[--n_x];
208  } else if (x[i].one()) {
209  x[i] = x[--n_x]; c--;
210  }
211  x.size(n_x);
212  // RHS too large
213  if (n_x < c)
214  return ES_FAILED;
215  // Whatever the x[i] take for values, the inequality is subsumed
216  if (c <= 0)
217  return ES_OK;
218  // Use Boolean disjunction for this special case
219  if (c == 1)
220  return Bool::NaryOrTrue<VX>::post(home,x);
221  // All views must be one to satisfy inequality
222  if (c == n_x) {
223  for (int i=n_x; i--; )
224  GECODE_ME_CHECK(x[i].one_none(home));
225  return ES_OK;
226  }
227  // This is the needed invariant as c+1 subscriptions must be created
228  assert(n_x > c);
229  (void) new (home) GqBoolInt<VX>(home,x,c);
230  return ES_OK;
231  }
232 
233 
234 
235 
236  /*
237  * Equal propagator (integer rhs)
238  *
239  */
240  template<class VX>
243  : LinBoolInt<VX>(home,x,std::max(c,x.size()-c)+1,c) {}
244 
245  template<class VX>
248  : LinBoolInt<VX>(home,p) {}
249 
250  template<class VX>
251  Actor*
253  return new (home) EqBoolInt<VX>(home,*this);
254  }
255 
256  template<class VX>
257  ExecStatus
259  // Check whether propagator is running
260  if (n_as == 0)
261  return ES_FIX;
262 
263  if (VX::one(d))
264  c--;
265  if ((c+1 < n_as) && (x.size()-n_hs < c))
266  goto check;
267  // Find a new subscription
268  for (int i = x.size()-1; i>=n_hs; i--)
269  if (x[i].none()) {
270  std::swap(x[i],x[n_hs]);
271  x[n_hs++].subscribe(home,a);
272  x.size(i+1);
273  return ES_FIX;
274  } else if (x[i].one()) {
275  c--;
276  }
277  // No view left for subscription
278  x.size(n_hs);
279  check:
280  // Do not update subscription
281  n_as--;
282  int n = x.size()-n_hs+n_as;
283  if (((c < 0) || (c > n)) && !disabled())
284  return ES_FAILED;
285  if ((c == 0) || (c == n))
286  return ES_NOFIX;
287  else
288  return ES_FIX;
289  }
290 
291  template<class VX>
292  void
294  int n = x.size()-n_hs+n_as;
295  if ((c <= 0) || (c >= n))
296  VX::schedule(home,*this,ME_INT_VAL);
297  }
298 
299  template<class VX>
300  ExecStatus
302  // Check for failure due to being disabled before
303  if ((c < 0) || (c > x.size()-n_hs+n_as))
304  return ES_FAILED;
305 
306  assert(x.size() == n_hs);
307  // Signal that propagator is running
308  n_as = 0;
309  if (c == 0) {
310  // All views must be zero to satisfy equality
311  for (int i=n_hs; i--; )
312  if (x[i].none())
313  GECODE_ME_CHECK(x[i].zero_none(home));
314  } else {
315  // All views must be one to satisfy equality
316  for (int i=n_hs; i--; )
317  if (x[i].none())
318  GECODE_ME_CHECK(x[i].one_none(home));
319  }
320  return home.ES_SUBSUMED(*this);
321  }
322 
323  template<class VX>
324  ExecStatus
326  // Eliminate assigned views
327  int n_x = x.size();
328  for (int i=n_x; i--; )
329  if (x[i].zero()) {
330  x[i] = x[--n_x];
331  } else if (x[i].one()) {
332  x[i] = x[--n_x]; c--;
333  }
334  x.size(n_x);
335  // RHS too small or too large
336  if ((c < 0) || (c > n_x))
337  return ES_FAILED;
338  // All views must be zero to satisfy equality
339  if (c == 0) {
340  for (int i=n_x; i--; )
341  GECODE_ME_CHECK(x[i].zero_none(home));
342  return ES_OK;
343  }
344  // All views must be one to satisfy equality
345  if (c == n_x) {
346  for (int i=n_x; i--; )
347  GECODE_ME_CHECK(x[i].one_none(home));
348  return ES_OK;
349  }
350  (void) new (home) EqBoolInt<VX>(home,x,c);
351  return ES_OK;
352  }
353 
354 
355  /*
356  * Integer disequal to Boolean sum
357  *
358  */
359 
360  template<class VX>
363  : BinaryPropagator<VX,PC_INT_VAL>(home,
364  b[b.size()-2],
365  b[b.size()-1]), x(b), c(c0) {
366  assert(x.size() >= 2);
367  x.size(x.size()-2);
368  }
369 
370  template<class VX>
371  forceinline size_t
374  return sizeof(*this);
375  }
376 
377  template<class VX>
380  : BinaryPropagator<VX,PC_INT_VAL>(home,p), x(home,p.x.size()) {
381  // Eliminate all zeros and ones in original and update
382  int n = p.x.size();
383  int p_c = p.c;
384  for (int i=n; i--; )
385  if (p.x[i].zero()) {
386  n--; p.x[i]=p.x[n]; x[i]=x[n];
387  } else if (p.x[i].one()) {
388  n--; p_c--; p.x[i]=p.x[n]; x[i]=x[n];
389  } else {
390  x[i].update(home,p.x[i]);
391  }
392  c = p_c; p.c = p_c;
393  x.size(n); p.x.size(n);
394  }
395 
396  template<class VX>
399  int n = x.size();
400  for (int i=n; i--; )
401  if (x[i].one()) {
402  x[i]=x[--n]; c--;
403  } else if (x[i].zero()) {
404  x[i]=x[--n];
405  }
406  x.size(n);
407  if ((n < c) || (c < 0))
408  return ES_OK;
409  if (n == 0)
410  return (c == 0) ? ES_FAILED : ES_OK;
411  if (n == 1) {
412  if (c == 1) {
413  GECODE_ME_CHECK(x[0].zero_none(home));
414  } else {
415  GECODE_ME_CHECK(x[0].one_none(home));
416  }
417  return ES_OK;
418  }
419  (void) new (home) NqBoolInt(home,x,c);
420  return ES_OK;
421  }
422 
423  template<class VX>
424  Actor*
426  return new (home) NqBoolInt<VX>(home,*this);
427  }
428 
429  template<class VX>
430  PropCost
431  NqBoolInt<VX>::cost(const Space&, const ModEventDelta&) const {
432  return PropCost::linear(PropCost::LO, x.size());
433  }
434 
435  template<class VX>
436  forceinline bool
438  if (y.one())
439  c--;
440  int n = x.size();
441  for (int i=n; i--; )
442  if (x[i].one()) {
443  c--; x[i]=x[--n];
444  } else if (x[i].zero()) {
445  x[i] = x[--n];
446  } else {
447  // New unassigned view found
448  assert(!x[i].zero() && !x[i].one());
449  // Move to y and subscribe
450  y=x[i]; x[i]=x[--n];
451  x.size(n);
452  y.subscribe(home,*this,PC_INT_VAL,false);
453  return true;
454  }
455  // All views have been assigned!
456  x.size(0);
457  return false;
458  }
459 
460  template<class VX>
461  ExecStatus
463  bool s0 = true;
464  if (x0.zero() || x0.one())
465  s0 = resubscribe(home,x0);
466  bool s1 = true;
467  if (x1.zero() || x1.one())
468  s1 = resubscribe(home,x1);
469  int n = x.size() + s0 + s1;
470  if ((n < c) || (c < 0))
471  return home.ES_SUBSUMED(*this);
472  if (n == 0)
473  return (c == 0) ? ES_FAILED : home.ES_SUBSUMED(*this);
474  if (n == 1) {
475  if (s0) {
476  if (c == 1) {
477  GECODE_ME_CHECK(x0.zero_none(home));
478  } else {
479  GECODE_ME_CHECK(x0.one_none(home));
480  }
481  } else {
482  assert(s1);
483  if (c == 1) {
484  GECODE_ME_CHECK(x1.zero_none(home));
485  } else {
486  GECODE_ME_CHECK(x1.one_none(home));
487  }
488  }
489  return home.ES_SUBSUMED(*this);
490  }
491  return ES_FIX;
492  }
493 
494  /*
495  * Baseclass for reified integer Boolean sum
496  *
497  */
498  template<class VX, class VB>
501  int c0, VB b0)
502  : Propagator(home), co(home), x(x0), n_s(x.size()), c(c0), b(b0) {
503  x.subscribe(home,*new (home) Advisor(home,*this,co));
504  b.subscribe(home,*this,PC_BOOL_VAL);
505  }
506 
507  template<class VX, class VB>
508  forceinline void
510  if (n_s != x.size()) {
511  int n_x = x.size();
512  for (int i=n_x; i--; )
513  if (!x[i].none())
514  x[i] = x[--n_x];
515  x.size(n_x);
516  assert(x.size() == n_s);
517  }
518  }
519 
520  template<class VX, class VB>
523  : Propagator(home,p), n_s(p.n_s), c(p.c) {
524  p.normalize();
525  co.update(home,p.co);
526  x.update(home,p.x);
527  b.update(home,p.b);
528  }
529 
530  template<class VX, class VB>
531  forceinline size_t
533  Advisors<Advisor> as(co);
534  x.cancel(home,as.advisor());
535  co.dispose(home);
536  b.cancel(home,*this,PC_BOOL_VAL);
537  (void) Propagator::dispose(home);
538  return sizeof(*this);
539  }
540 
541  template<class VX, class VB>
542  PropCost
545  }
546 
547  template<>
550  public:
555  NegBoolView y(x); return y;
556  }
557  };
558 
559  template<>
562  public:
564  typedef BoolView NegView;
567  return x.base();
568  }
569  };
570 
571 
572  /*
573  * Reified greater or equal propagator (integer rhs)
574  *
575  */
576  template<class VX, class VB, ReifyMode rm>
579  : ReLinBoolInt<VX,VB>(home,x,c,b) {}
580 
581  template<class VX, class VB, ReifyMode rm>
584  : ReLinBoolInt<VX,VB>(home,p) {}
585 
586  template<class VX, class VB, ReifyMode rm>
587  Actor*
589  return new (home) ReGqBoolInt<VX,VB,rm>(home,*this);
590  }
591 
592  template<class VX, class VB, ReifyMode rm>
593  ExecStatus
595  if (VX::one(d))
596  c--;
597  n_s--;
598  if ((n_s < c) || (c <= 0))
599  return ES_NOFIX;
600  else
601  return ES_FIX;
602  }
603 
604  template<class VX, class VB, ReifyMode rm>
605  void
607  b.reschedule(home,*this,PC_BOOL_VAL);
608  if ((n_s < c) || (c <= 0))
609  VX::schedule(home,*this,ME_BOOL_VAL);
610  }
611 
612  template<class VX, class VB, ReifyMode rm>
613  ExecStatus
615  if (b.none()) {
616  if (c <= 0) {
617  if (rm != RM_IMP)
618  GECODE_ME_CHECK(b.one_none(home));
619  } else {
620  if (rm != RM_PMI)
621  GECODE_ME_CHECK(b.zero_none(home));
622  }
623  } else {
624  normalize();
625  if (b.one()) {
626  if (rm != RM_PMI)
627  GECODE_REWRITE(*this,(GqBoolInt<VX>::post(home(*this),x,c)));
628  } else {
629  if (rm != RM_IMP) {
631  for (int i=x.size(); i--; )
632  nx[i]=BoolNegTraits<VX>::neg(x[i]);
634  ::post(home(*this),nx,x.size()-c+1));
635  }
636  }
637  }
638  return home.ES_SUBSUMED(*this);
639  }
640 
641  template<class VX, class VB, ReifyMode rm>
642  ExecStatus
644  assert(!b.assigned()); // checked before posting
645 
646  // Eliminate assigned views
647  int n_x = x.size();
648  for (int i=n_x; i--; )
649  if (x[i].zero()) {
650  x[i] = x[--n_x];
651  } else if (x[i].one()) {
652  x[i] = x[--n_x]; c--;
653  }
654  x.size(n_x);
655  if (n_x < c) {
656  // RHS too large
657  if (rm != RM_PMI)
658  GECODE_ME_CHECK(b.zero_none(home));
659  } else if (c <= 0) {
660  // Whatever the x[i] take for values, the inequality is subsumed
661  if (rm != RM_IMP)
662  GECODE_ME_CHECK(b.one_none(home));
663  } else if ((c == 1) && (rm == RM_EQV)) {
664  // Equivalent to Boolean disjunction
665  return Bool::NaryOr<VX,VB>::post(home,x,b);
666  } else if ((c == n_x) && (rm == RM_EQV)) {
667  // Equivalent to Boolean conjunction, transform to Boolean disjunction
669  for (int i=n_x; i--; )
670  nx[i]=BoolNegTraits<VX>::neg(x[i]);
671  return Bool::NaryOr
672  <typename BoolNegTraits<VX>::NegView,
674  ::post(home,nx,BoolNegTraits<VB>::neg(b));
675  } else {
676  (void) new (home) ReGqBoolInt<VX,VB,rm>(home,x,c,b);
677  }
678  return ES_OK;
679  }
680 
681  /*
682  * Reified equal propagator (integer rhs)
683  *
684  */
685  template<class VX, class VB, ReifyMode rm>
688  : ReLinBoolInt<VX,VB>(home,x,c,b) {}
689 
690  template<class VX, class VB, ReifyMode rm>
693  : ReLinBoolInt<VX,VB>(home,p) {}
694 
695  template<class VX, class VB, ReifyMode rm>
696  Actor*
698  return new (home) ReEqBoolInt<VX,VB,rm>(home,*this);
699  }
700 
701  template<class VX, class VB, ReifyMode rm>
702  ExecStatus
704  if (VX::one(d))
705  c--;
706  n_s--;
707 
708  if ((c < 0) || (c > n_s) || (n_s == 0))
709  return ES_NOFIX;
710  else
711  return ES_FIX;
712  }
713 
714  template<class VX, class VB, ReifyMode rm>
715  void
717  b.reschedule(home,*this,PC_BOOL_VAL);
718  if ((c < 0) || (c > n_s) || (n_s == 0))
719  VX::schedule(home,*this,ME_BOOL_VAL);
720  }
721 
722  template<class VX, class VB, ReifyMode rm>
723  ExecStatus
725  if (b.none()) {
726  if ((c == 0) && (n_s == 0)) {
727  if (rm != RM_IMP)
728  GECODE_ME_CHECK(b.one_none(home));
729  } else {
730  if (rm != RM_PMI)
731  GECODE_ME_CHECK(b.zero_none(home));
732  }
733  } else {
734  normalize();
735  if (b.one()) {
736  if (rm != RM_PMI)
737  GECODE_REWRITE(*this,(EqBoolInt<VX>::post(home(*this),x,c)));
738  } else {
739  if (rm != RM_IMP)
740  GECODE_REWRITE(*this,(NqBoolInt<VX>::post(home(*this),x,c)));
741  }
742  }
743  return home.ES_SUBSUMED(*this);
744  }
745 
746  template<class VX, class VB, ReifyMode rm>
747  ExecStatus
749  assert(!b.assigned()); // checked before posting
750 
751  // Eliminate assigned views
752  int n_x = x.size();
753  for (int i=n_x; i--; )
754  if (x[i].zero()) {
755  x[i] = x[--n_x];
756  } else if (x[i].one()) {
757  x[i] = x[--n_x]; c--;
758  }
759  x.size(n_x);
760  if ((n_x < c) || (c < 0)) {
761  // RHS too large
762  if (rm != RM_PMI)
763  GECODE_ME_CHECK(b.zero_none(home));
764  } else if ((c == 0) && (n_x == 0)) {
765  // all variables set, and c == 0: equality
766  if (rm != RM_IMP)
767  GECODE_ME_CHECK(b.one_none(home));
768  } else if ((c == 0) && (rm == RM_EQV)) {
769  // Equivalent to Boolean disjunction
771  ::post(home,x,BoolNegTraits<VB>::neg(b));
772  } else if ((c == n_x) && (rm == RM_EQV)) {
773  // Equivalent to Boolean conjunction, transform to Boolean disjunction
775  for (int i=n_x; i--; )
776  nx[i]=BoolNegTraits<VX>::neg(x[i]);
777  return Bool::NaryOr
778  <typename BoolNegTraits<VX>::NegView,
780  ::post(home,nx,BoolNegTraits<VB>::neg(b));
781  } else {
782  (void) new (home) ReEqBoolInt<VX,VB,rm>(home,x,c,b);
783  }
784  return ES_OK;
785  }
786 
787 
788 }}}
789 
790 // STATISTICS: int-prop
791 
virtual ExecStatus advise(Space &home, Advisor &a, const Delta &d)
Give advice to propagator.
Definition: bool-int.hpp:703
ViewArray< VX > x
Boolean views.
Definition: linear.hh:796
View base(void) const
Return view from which this view is derived.
Definition: view.hpp:561
#define GECODE_REWRITE(prop, post)
Rewrite propagator by executing post function.
Definition: macros.hpp:120
Inverse implication for reification.
Definition: int.hh:848
static PropCost linear(PropCost::Mod m, unsigned int n)
Linear complexity for modifier pcm and size measure n.
Definition: core.hpp:4643
void update(Space &home, ViewArray< View > &a)
Update array to be a clone of array a.
Definition: array.hpp:1375
ExecStatus ES_SUBSUMED(Propagator &p)
Definition: core.hpp:3433
int n_s
Number of subscriptions.
Definition: linear.hh:927
NqBoolInt(Home home, ViewArray< VX > &b, int c)
Constructor for posting.
Definition: bool-int.hpp:362
virtual ExecStatus advise(Space &home, Advisor &a, const Delta &d)
Give advice to propagator.
Definition: bool-int.hpp:258
Negated Boolean view.
Definition: view.hpp:1519
bool one(const Gecode::FloatValArgs &a)
Check whether has only one coefficients.
Definition: linear.cpp:50
void cancel(Space &home, Propagator &p, IntSet &y)
Definition: rel.hpp:85
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition: bool-int.hpp:104
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as high unary)
Definition: bool-int.hpp:98
Baseclass for integer Boolean sum.
Definition: linear.hh:791
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition: arithmetic.cpp:53
static ExecStatus post(Home home, ViewArray< VX > &x, int c, VB b)
Post propagator for .
Definition: bool-int.hpp:643
static ExecStatus post(Home home, ViewArray< VX > &x, int c, VB b)
Post propagator for .
Definition: bool-int.hpp:748
static ExecStatus post(Home home, ViewArray< VX > &x, int c)
Post propagator for .
Definition: bool-int.hpp:325
Propagator for integer disequal to Boolean sum (cardinality)
Definition: linear.hh:887
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: bool-int.hpp:724
virtual ExecStatus advise(Space &home, Advisor &a, const Delta &d)
Give advice to propagator.
Definition: bool-int.hpp:135
ReLinBoolInt(Space &home, ReLinBoolInt &p)
Constructor for cloning p.
Definition: bool-int.hpp:522
Base-class for propagators.
Definition: core.hpp:1016
Base-class for advisors.
Definition: core.hpp:1218
virtual void reschedule(Space &home)
Schedule function.
Definition: bool-int.hpp:716
void subscribe(Space &home, Propagator &p, PropCond pc, bool schedule=true)
Subscribe propagator p with propagation condition pc to variable.
Definition: array.hpp:1388
Definition: flatzinc.cpp:56
virtual void reschedule(Space &home)
Schedule function.
Definition: bool-int.hpp:293
Class to iterate over advisors of a council.
Definition: core.hpp:157
#define forceinline
Definition: config.hpp:182
Propagation has computed fixpoint.
Definition: core.hpp:469
static PropCost unary(PropCost::Mod m)
Single variable for modifier pcm.
Definition: core.hpp:4660
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition: bool-int.hpp:532
Computation spaces.
Definition: core.hpp:1668
virtual Actor * copy(Space &home)
Create copy during cloning.
Definition: bool-int.hpp:129
Base-class for both propagators and branchers.
Definition: core.hpp:620
virtual Actor * copy(Space &home)
Create copy during cloning.
Definition: bool-int.hpp:252
Gecode::IntSet d(v, 7)
Council< Advisor > co
Council for single advisor.
Definition: linear.hh:923
Gecode::FloatVal c(-8, 8)
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:236
Gecode::IntArgs i(4, 1, 2, 3, 4)
virtual void reschedule(Space &home)
Schedule function.
Definition: bool-int.hpp:606
GqBoolInt(Space &home, GqBoolInt &p)
Constructor for cloning p.
Definition: bool-int.hpp:124
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:238
int n_as
Number of active subscriptions.
Definition: linear.hh:798
Execution has resulted in failure.
Definition: core.hpp:466
Binary propagator.
Definition: pattern.hpp:88
Propagator for integer less or equal to Boolean sum (cardinality)
Definition: linear.hh:855
Propagator for integer equal to Boolean sum (cardinality)
Definition: linear.hh:823
const Gecode::ModEvent ME_INT_VAL
Domain operation has resulted in a value (assigned variable)
Definition: var-type.hpp:56
void subscribe(Space &home, Propagator &p, IntSet &y)
Definition: rel.hpp:75
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: bool-int.hpp:462
int c
Righthandside.
Definition: linear.hh:802
size_t size
The size of the propagator (used during subsumption)
Definition: core.hpp:1029
bool disabled(void) const
Whether propagator is currently disabled.
Definition: core.hpp:3358
static ExecStatus post(Home home, ViewArray< VX > &x, int c)
Post propagator for .
Definition: bool-int.hpp:202
bool resubscribe(Space &home, VX &y)
Update subscription.
Definition: bool-int.hpp:437
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: bool-int.hpp:301
Expensive.
Definition: core.hpp:506
void normalize(void)
Normalize by removing unused views.
Definition: bool-int.hpp:509
virtual Actor * copy(Space &home)
Create copy during cloning.
Definition: bool-int.hpp:697
ReEqBoolInt(Space &home, ReEqBoolInt &p)
Constructor for cloning p.
Definition: bool-int.hpp:692
Propagator for reified integer less or equal to Boolean sum (cardinality)
Definition: linear.hh:959
void normalize(void)
Normalize by removing unused views.
Definition: bool-int.hpp:62
void cancel(Space &home, Propagator &p, PropCond pc)
Cancel subscription of propagator p with propagation condition pc to all views.
Definition: array.hpp:1396
Propagator for reified integer equal to Boolean sum (cardinality)
Definition: linear.hh:991
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
Definition: macros.hpp:56
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: bool-int.hpp:614
Baseclass for reified integer Boolean sum.
Definition: linear.hh:920
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition: bool-int.hpp:425
void check(const FloatVal &n, const char *l)
Check whether float n is a valid number, otherwise throw out of limits exception with information l...
Definition: limits.hpp:48
struct Gecode::@585::NNF::@62::@63 b
For binary nodes (and, or, eqv)
static NegBoolView neg(BoolView x)
Return negated View.
Definition: bool-int.hpp:554
Post propagator for SetVar SetOpType SetVar y
Definition: set.hh:769
static ExecStatus post(Home home, ViewArray< VX > &b, int c)
Post propagator for .
Definition: bool-int.hpp:398
virtual void reschedule(Space &home)
Schedule function.
Definition: bool-int.hpp:176
ReGqBoolInt(Space &home, ReGqBoolInt &p)
Constructor for cloning p.
Definition: bool-int.hpp:583
NegBoolView NegView
The negated view.
Definition: bool-int.hpp:552
Generic domain change information to be supplied to advisors.
Definition: core.hpp:205
Traits for Boolean negation view.
Definition: linear.hh:950
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: bool-int.hpp:184
struct Gecode::@585::NNF::@62::@64 a
For atomic nodes.
virtual size_t dispose(Space &home)
Delete actor and return its size.
Definition: core.hpp:3172
Propagation cost.
Definition: core.hpp:478
friend class Advisor
Definition: core.hpp:1020
Boolean n-ary disjunction propagator.
Definition: bool.hh:359
ExecStatus
Definition: core.hpp:464
LinBoolInt(Space &home, LinBoolInt &p)
Constructor for cloning p.
Definition: bool-int.hpp:88
Post propagator for SetVar x
Definition: set.hh:769
Execution is okay.
Definition: core.hpp:468
virtual ExecStatus advise(Space &home, Advisor &a, const Delta &d)
Give advice to propagator.
Definition: bool-int.hpp:594
Propagation has not computed fixpoint.
Definition: core.hpp:467
Council< Advisor > co
Council for managing single advisor.
Definition: linear.hh:794
int n_hs
Number of views that have or had subscriptions.
Definition: linear.hh:800
static ExecStatus post(Home home, ViewArray< BV > &b)
Post propagator .
Definition: or.hpp:667
ViewArray< VX > x
Views not yet subscribed to.
Definition: linear.hh:892
static ExecStatus post(Home home, ViewArray< VX > &x, VY y)
Post propagator .
Definition: or.hpp:773
Gecode toplevel namespace
Implication for reification.
Definition: int.hh:841
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition: bool-int.hpp:372
static BoolView neg(NegBoolView x)
Return negated View.
Definition: bool-int.hpp:566
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as high unary)
Definition: bool-int.hpp:543
int ModEventDelta
Modification event deltas.
Definition: core.hpp:91
int size(void) const
Return size of array (number of elements)
Definition: array.hpp:1203
Home class for posting propagators
Definition: core.hpp:846
virtual Actor * copy(Space &home)
Create copy during cloning.
Definition: bool-int.hpp:588
A & advisor(void) const
Return advisor.
Definition: core.hpp:3880
VB b
Control variable.
Definition: linear.hh:931
int c
Righthandside.
Definition: linear.hh:894
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as low linear)
Definition: bool-int.hpp:431
Equivalence for reification (default)
Definition: int.hh:834
IntRelType swap(IntRelType irt)
Return swapped relation type of irt.
Definition: irt.hpp:41
const Gecode::PropCond PC_INT_VAL
Propagate when a view becomes assigned (single value)
Definition: var-type.hpp:82
EqBoolInt(Space &home, EqBoolInt &p)
Constructor for cloning p.
Definition: bool-int.hpp:247
const Gecode::PropCond PC_BOOL_VAL
Propagate when a view becomes assigned (single value)
Definition: var-type.hpp:126
const Gecode::ModEvent ME_BOOL_VAL
Domain operation has resulted in a value (assigned variable)
Definition: var-type.hpp:116
Boolean view for Boolean variables.
Definition: view.hpp:1329
ViewArray< VX > x
Views.
Definition: linear.hh:925