Generated on Wed Jan 24 2018 21:22:26 for Gecode by doxygen 1.8.13
eq.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  *
6  * Copyright:
7  * Christian Schulte, 2004
8  *
9  * Last modified:
10  * $Date: 2016-11-08 17:23:24 +0100 (Tue, 08 Nov 2016) $ by $Author: schulte $
11  * $Revision: 15253 $
12  *
13  * This file is part of Gecode, the generic constraint
14  * development environment:
15  * http://www.gecode.org
16  *
17  * Permission is hereby granted, free of charge, to any person obtaining
18  * a copy of this software and associated documentation files (the
19  * "Software"), to deal in the Software without restriction, including
20  * without limitation the rights to use, copy, modify, merge, publish,
21  * distribute, sublicense, and/or sell copies of the Software, and to
22  * permit persons to whom the Software is furnished to do so, subject to
23  * the following conditions:
24  *
25  * The above copyright notice and this permission notice shall be
26  * included in all copies or substantial portions of the Software.
27  *
28  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
32  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
33  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
34  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35  *
36  */
37 
38 namespace Gecode { namespace Int { namespace Rel {
39 
40  /*
41  * Binary value propagation equality
42  *
43  */
44 
45  template<class View0, class View1>
47  EqVal<View0,View1>::EqVal(Home home, View0 x0, View1 x1)
48  : MixBinaryPropagator<View0,PC_INT_VAL,View1,PC_INT_VAL>(home,x0,x1) {}
49 
50  template<class View0, class View1>
52  EqVal<View0,View1>::post(Home home, View0 x0, View1 x1){
53  if (x0.assigned()) {
54  GECODE_ME_CHECK(x1.eq(home,x0.val()));
55  } else if (x1.assigned()) {
56  GECODE_ME_CHECK(x0.eq(home,x1.val()));
57  } else if (!same(x0,x1)) {
58  (void) new (home) EqVal<View0,View1>(home,x0,x1);
59  }
60  return ES_OK;
61  }
62 
63  template<class View0, class View1>
66  : MixBinaryPropagator<View0,PC_INT_VAL,View1,PC_INT_VAL>(home,share,p) {}
67 
68  template<class View0, class View1>
71  View0 x0, View1 x1)
72  : MixBinaryPropagator<View0,PC_INT_VAL,View1,PC_INT_VAL>(home,share,p,
73  x0,x1) {}
74 
75  template<class View0, class View1>
76  Actor*
77  EqVal<View0,View1>::copy(Space& home, bool share) {
78  return new (home) EqVal<View0,View1>(home,share,*this);
79  }
80 
81  template<class View0, class View1>
82  PropCost
85  }
86 
87  template<class View0, class View1>
90  if (x0.assigned()) {
91  GECODE_ME_CHECK(x1.eq(home,x0.val()));
92  } else {
93  assert(x1.assigned());
94  GECODE_ME_CHECK(x0.eq(home,x1.val()));
95  }
96  return home.ES_SUBSUMED(*this);
97  }
98 
99 
100  /*
101  * Binary bounds consistent equality
102  *
103  */
104 
105  template<class View0, class View1>
107  EqBnd<View0,View1>::EqBnd(Home home, View0 x0, View1 x1)
108  : MixBinaryPropagator<View0,PC_INT_BND,View1,PC_INT_BND>(home,x0,x1) {}
109 
110  template<class View0, class View1>
111  ExecStatus
112  EqBnd<View0,View1>::post(Home home, View0 x0, View1 x1){
113  if (x0.assigned()) {
114  GECODE_ME_CHECK(x1.eq(home,x0.val()));
115  } else if (x1.assigned()) {
116  GECODE_ME_CHECK(x0.eq(home,x1.val()));
117  } else if (!same(x0,x1)) {
118  GECODE_ME_CHECK(x0.lq(home,x1.max()));
119  GECODE_ME_CHECK(x1.lq(home,x0.max()));
120  GECODE_ME_CHECK(x0.gq(home,x1.min()));
121  GECODE_ME_CHECK(x1.gq(home,x0.min()));
122  (void) new (home) EqBnd<View0,View1>(home,x0,x1);
123  }
124  return ES_OK;
125  }
126 
127  template<class View0, class View1>
130  : MixBinaryPropagator<View0,PC_INT_BND,View1,PC_INT_BND>(home,share,p) {}
131 
132  template<class View0, class View1>
135  View0 x0, View1 x1)
136  : MixBinaryPropagator<View0,PC_INT_BND,View1,PC_INT_BND>(home,share,p,
137  x0,x1) {}
138 
139  template<class View0, class View1>
140  Actor*
141  EqBnd<View0,View1>::copy(Space& home, bool share) {
142  return new (home) EqBnd<View0,View1>(home,share,*this);
143  }
144 
145  template<class View0, class View1>
146  ExecStatus
148  if (x0.assigned()) {
149  GECODE_ME_CHECK(x1.eq(home,x0.val()));
150  } else if (x1.assigned()) {
151  GECODE_ME_CHECK(x0.eq(home,x1.val()));
152  } else {
153  do {
154  GECODE_ME_CHECK(x0.gq(home,x1.min()));
155  GECODE_ME_CHECK(x1.gq(home,x0.min()));
156  } while (x0.min() != x1.min());
157  do {
158  GECODE_ME_CHECK(x0.lq(home,x1.max()));
159  GECODE_ME_CHECK(x1.lq(home,x0.max()));
160  } while (x0.max() != x1.max());
161  if (!x0.assigned())
162  return ES_FIX;
163  }
164  assert(x0.assigned() && x1.assigned());
165  return home.ES_SUBSUMED(*this);
166  }
167 
168  /*
169  * Binary domain consistent equality
170  *
171  */
172 
173  template<class View0, class View1>
175  EqDom<View0,View1>::EqDom(Home home, View0 x0, View1 x1)
176  : MixBinaryPropagator<View0,PC_INT_DOM,View1,PC_INT_DOM>(home,x0,x1) {}
177 
178  template<class View0, class View1>
179  ExecStatus
180  EqDom<View0,View1>::post(Home home, View0 x0, View1 x1){
181  if (x0.assigned()) {
182  GECODE_ME_CHECK(x1.eq(home,x0.val()));
183  } else if (x1.assigned()) {
184  GECODE_ME_CHECK(x0.eq(home,x1.val()));
185  } else if (!same(x0,x1)) {
186  GECODE_ME_CHECK(x0.lq(home,x1.max()));
187  GECODE_ME_CHECK(x1.lq(home,x0.max()));
188  GECODE_ME_CHECK(x0.gq(home,x1.min()));
189  GECODE_ME_CHECK(x1.gq(home,x0.min()));
190  (void) new (home) EqDom<View0,View1>(home,x0,x1);
191  }
192  return ES_OK;
193  }
194 
195 
196  template<class View0, class View1>
199  : MixBinaryPropagator<View0,PC_INT_DOM,View1,PC_INT_DOM>(home,share,p) {}
200 
201  template<class View0, class View1>
204  View0 x0, View1 x1)
205  : MixBinaryPropagator<View0,PC_INT_DOM,View1,PC_INT_DOM>(home,share,p,
206  x0,x1) {}
207 
208  template<class View0, class View1>
209  Actor*
210  EqDom<View0,View1>::copy(Space& home, bool share) {
211  return new (home) EqDom<View0,View1>(home,share,*this);
212  }
213 
214  template<class View0, class View1>
215  PropCost
217  if ((View0::me(med) == ME_INT_VAL) || (View1::me(med) == ME_INT_VAL))
219  else if ((View0::me(med) == ME_INT_DOM) || (View1::me(med) == ME_INT_DOM))
221  else
223  }
224 
225  template<class View0, class View1>
226  ExecStatus
228  if (x0.assigned()) {
229  GECODE_ME_CHECK(x1.eq(home,x0.val()));
230  return home.ES_SUBSUMED(*this);
231  }
232  if (x1.assigned()) {
233  GECODE_ME_CHECK(x0.eq(home,x1.val()));
234  return home.ES_SUBSUMED(*this);
235  }
236  if ((View0::me(med) != ME_INT_DOM) && (View1::me(med) != ME_INT_DOM)) {
237  do {
238  GECODE_ME_CHECK(x0.gq(home,x1.min()));
239  GECODE_ME_CHECK(x1.gq(home,x0.min()));
240  } while (x0.min() != x1.min());
241  do {
242  GECODE_ME_CHECK(x0.lq(home,x1.max()));
243  GECODE_ME_CHECK(x1.lq(home,x0.max()));
244  } while (x0.max() != x1.max());
245  if (x0.assigned())
246  return home.ES_SUBSUMED(*this);
247  if (x0.range() && x1.range())
248  return ES_FIX;
249  return home.ES_FIX_PARTIAL(*this,View0::med(ME_INT_DOM));
250  }
251  ViewRanges<View0> r0(x0);
252  GECODE_ME_CHECK(x1.inter_r(home,r0,shared(x0,x1)));
253  ViewRanges<View1> r1(x1);
254  GECODE_ME_CHECK(x0.narrow_r(home,r1,shared(x0,x1)));
255  if (x0.assigned())
256  return home.ES_SUBSUMED(*this);
257  return ES_FIX;
258  }
259 
260 
261 
262  /*
263  * Nary domain consistent equality
264  *
265  */
266 
267  template<class View>
270  : NaryPropagator<View,PC_INT_DOM>(home,x) {}
271 
272  template<class View>
273  ExecStatus
275  x.unique(home);
276  if (x.size() == 2) {
277  return EqDom<View,View>::post(home,x[0],x[1]);
278  } else if (x.size() > 2) {
279  int l = x[0].min();
280  int u = x[0].max();
281  for (int i=x.size(); i-- > 1; ) {
282  l = std::max(l,x[i].min());
283  u = std::min(u,x[i].max());
284  }
285  for (int i=x.size(); i--; ) {
286  GECODE_ME_CHECK(x[i].gq(home,l));
287  GECODE_ME_CHECK(x[i].lq(home,u));
288  }
289  (void) new (home) NaryEqDom<View>(home,x);
290  }
291  return ES_OK;
292  }
293 
294  template<class View>
297  : NaryPropagator<View,PC_INT_DOM>(home,share,p) {}
298 
299  template<class View>
300  Actor*
301  NaryEqDom<View>::copy(Space& home, bool share) {
302  return new (home) NaryEqDom<View>(home,share,*this);
303  }
304 
305  template<class View>
306  PropCost
308  if (View::me(med) == ME_INT_VAL)
310  else
311  return PropCost::linear((View::me(med) == ME_INT_DOM) ?
312  PropCost::LO : PropCost::HI, x.size());
313  }
314 
315  template<class View>
316  ExecStatus
318  assert(x.size() > 2);
319 
320  ModEvent me = View::me(med);
321  if (me == ME_INT_VAL) {
322  // One of the variables is assigned
323  for (int i = 0; ; i++)
324  if (x[i].assigned()) {
325  int n = x[i].val();
326  x.move_lst(i);
327  for (int j = x.size(); j--; )
328  GECODE_ME_CHECK(x[j].eq(home,n));
329  return home.ES_SUBSUMED(*this);
330  }
331  GECODE_NEVER;
332  }
333 
334  if (me == ME_INT_BND) {
335  {
336  // One of the mins has changed
337  int mn = x[0].min();
338  restart_min:
339  for (int i = x.size(); i--; ) {
340  GECODE_ME_CHECK(x[i].gq(home,mn));
341  if (mn < x[i].min()) {
342  mn = x[i].min();
343  goto restart_min;
344  }
345  }
346  }
347  {
348  // One of the maxs has changed
349  int mx = x[0].max();
350  restart_max:
351  for (int i = x.size(); i--; ) {
352  GECODE_ME_CHECK(x[i].lq(home,mx));
353  if (mx > x[i].max()) {
354  mx = x[i].max();
355  goto restart_max;
356  }
357  }
358  }
359  if (x[0].assigned())
360  return home.ES_SUBSUMED(*this);
361  return home.ES_FIX_PARTIAL(*this,View::med(ME_INT_DOM));
362  }
363 
364  int n = x.size();
365 
366  Region re(home);
368  for (int i = n; i--; ) {
369  ViewRanges<View> i_xi(x[i]);
370  i_x[i] = i_xi;
371  }
372  Iter::Ranges::NaryInter r(re,i_x,n);
373 
374  if (!r())
375  return ES_FAILED;
376  ++r;
377  if (!r()) {
378  r.reset();
379  for (int i = n; i--; ) {
380  GECODE_ME_CHECK(x[i].gq(home,r.min()));
381  GECODE_ME_CHECK(x[i].lq(home,r.max()));
382  }
383  } else {
384  for (int i = n; i--; ) {
385  r.reset();
386  GECODE_ME_CHECK(x[i].narrow_r(home,r,false));
387  }
388  }
389  return ES_FIX;
390  }
391 
392 
393 
394  /*
395  * Nary bound consistent equality
396  *
397  */
398 
399  template<class View>
402  : NaryPropagator<View,PC_INT_BND>(home,x) {}
403 
404  template<class View>
405  ExecStatus
407  x.unique(home);
408  if (x.size() == 2) {
409  return EqBnd<View,View>::post(home,x[0],x[1]);
410  } else if (x.size() > 2) {
411  int l = x[0].min();
412  int u = x[0].max();
413  for (int i=x.size(); i-- > 1; ) {
414  l = std::max(l,x[i].min());
415  u = std::min(u,x[i].max());
416  }
417  for (int i=x.size(); i--; ) {
418  GECODE_ME_CHECK(x[i].gq(home,l));
419  GECODE_ME_CHECK(x[i].lq(home,u));
420  }
421  (void) new (home) NaryEqBnd<View>(home,x);
422  }
423  return ES_OK;
424  }
425 
426  template<class View>
429  : NaryPropagator<View,PC_INT_BND>(home,share,p) {}
430 
431  template<class View>
432  Actor*
433  NaryEqBnd<View>::copy(Space& home, bool share) {
434  return new (home) NaryEqBnd<View>(home,share,*this);
435  }
436 
437  template<class View>
438  PropCost
440  if (View::me(med) == ME_INT_VAL)
442  else
443  return PropCost::linear(PropCost::LO, x.size());
444  }
445 
446  template<class View>
447  ExecStatus
449  assert(x.size() > 2);
450  if (View::me(med) == ME_INT_VAL) {
451  // One of the variables is assigned
452  for (int i = 0; ; i++)
453  if (x[i].assigned()) {
454  int n = x[i].val();
455  x.move_lst(i);
456  for (int j = x.size(); j--; )
457  GECODE_ME_CHECK(x[j].eq(home,n));
458  return home.ES_SUBSUMED(*this);
459  }
460  GECODE_NEVER;
461  }
462 
463  int mn = x[0].min();
464  restart_min:
465  for (int i = x.size(); i--; ) {
466  GECODE_ME_CHECK(x[i].gq(home,mn));
467  if (mn < x[i].min()) {
468  mn = x[i].min();
469  goto restart_min;
470  }
471  }
472  int mx = x[0].max();
473  restart_max:
474  for (int i = x.size(); i--; ) {
475  GECODE_ME_CHECK(x[i].lq(home,mx));
476  if (mx > x[i].max()) {
477  mx = x[i].max();
478  goto restart_max;
479  }
480  }
481  return x[0].assigned() ? home.ES_SUBSUMED(*this) : ES_FIX;
482  }
483 
484 
485 
486  /*
487  * Reified domain consistent equality
488  *
489  */
490 
491  template<class View, class CtrlView, ReifyMode rm>
493  ReEqDom<View,CtrlView,rm>::ReEqDom(Home home, View x0, View x1, CtrlView b)
494  : ReBinaryPropagator<View,PC_INT_DOM,CtrlView>(home,x0,x1,b) {}
495 
496  template<class View, class CtrlView, ReifyMode rm>
497  ExecStatus
498  ReEqDom<View,CtrlView,rm>::post(Home home, View x0, View x1, CtrlView b) {
499  if (b.one()) {
500  if (rm == RM_PMI)
501  return ES_OK;
502  return EqDom<View,View>::post(home,x0,x1);
503  }
504  if (b.zero()) {
505  if (rm == RM_IMP)
506  return ES_OK;
507  return Nq<View,View>::post(home,x0,x1);
508  }
509  if (!same(x0,x1)) {
510  (void) new (home) ReEqDom(home,x0,x1,b);
511  } else if (rm != RM_IMP) {
512  GECODE_ME_CHECK(b.one(home));
513  }
514  return ES_OK;
515  }
516 
517 
518  template<class View, class CtrlView, ReifyMode rm>
521  : ReBinaryPropagator<View,PC_INT_DOM,CtrlView>(home,share,p) {}
522 
523  template<class View, class CtrlView, ReifyMode rm>
524  Actor*
526  return new (home) ReEqDom<View,CtrlView,rm>(home,share,*this);
527  }
528 
529  template<class View, class CtrlView, ReifyMode rm>
530  ExecStatus
532  if (b.one()) {
533  if (rm == RM_PMI)
534  return home.ES_SUBSUMED(*this);
535  GECODE_REWRITE(*this,(EqDom<View,View>::post(home(*this),x0,x1)));
536  }
537  if (b.zero()) {
538  if (rm == RM_IMP)
539  return home.ES_SUBSUMED(*this);
540  GECODE_REWRITE(*this,(Nq<View,View>::post(home(*this),x0,x1)));
541  }
542  switch (rtest_eq_dom(x0,x1)) {
543  case RT_TRUE:
544  if (rm != RM_IMP)
545  GECODE_ME_CHECK(b.one_none(home));
546  break;
547  case RT_FALSE:
548  if (rm != RM_PMI)
549  GECODE_ME_CHECK(b.zero_none(home));
550  break;
551  case RT_MAYBE:
552  return ES_FIX;
553  default: GECODE_NEVER;
554  }
555  return home.ES_SUBSUMED(*this);
556  }
557 
558 
559 
560  /*
561  * Reified bounds consistent equality
562  *
563  */
564 
565  template<class View, class CtrlView, ReifyMode rm>
567  ReEqBnd<View,CtrlView,rm>::ReEqBnd(Home home, View x0, View x1, CtrlView b)
568  : ReBinaryPropagator<View,PC_INT_BND,CtrlView>(home,x0,x1,b) {}
569 
570  template<class View, class CtrlView, ReifyMode rm>
571  ExecStatus
572  ReEqBnd<View,CtrlView,rm>::post(Home home, View x0, View x1, CtrlView b){
573  if (b.one()) {
574  if (rm == RM_PMI)
575  return ES_OK;
576  return EqBnd<View,View>::post(home,x0,x1);
577  }
578  if (b.zero()) {
579  if (rm == RM_IMP)
580  return ES_OK;
581  return Nq<View,View>::post(home,x0,x1);
582  }
583  if (!same(x0,x1)) {
584  (void) new (home) ReEqBnd(home,x0,x1,b);
585  } else if (rm != RM_IMP) {
586  GECODE_ME_CHECK(b.one(home));
587  }
588  return ES_OK;
589  }
590 
591 
592  template<class View, class CtrlView, ReifyMode rm>
595  : ReBinaryPropagator<View,PC_INT_BND,CtrlView>(home,share,p) {}
596 
597  template<class View, class CtrlView, ReifyMode rm>
598  Actor*
600  return new (home) ReEqBnd<View,CtrlView,rm>(home,share,*this);
601  }
602 
603  template<class View, class CtrlView, ReifyMode rm>
604  ExecStatus
606  if (b.one()) {
607  if (rm == RM_PMI)
608  return home.ES_SUBSUMED(*this);
609  GECODE_REWRITE(*this,(EqBnd<View,View>::post(home(*this),x0,x1)));
610  }
611  if (b.zero()) {
612  if (rm == RM_IMP)
613  return home.ES_SUBSUMED(*this);
614  GECODE_REWRITE(*this,(Nq<View,View>::post(home(*this),x0,x1)));
615  }
616  switch (rtest_eq_bnd(x0,x1)) {
617  case RT_TRUE:
618  if (rm != RM_IMP)
619  GECODE_ME_CHECK(b.one_none(home));
620  break;
621  case RT_FALSE:
622  if (rm != RM_PMI)
623  GECODE_ME_CHECK(b.zero_none(home));
624  break;
625  case RT_MAYBE:
626  return ES_FIX;
627  default: GECODE_NEVER;
628  }
629  return home.ES_SUBSUMED(*this);
630  }
631 
632 
633 
634 
635  /*
636  * Reified domain consistent equality (one variable)
637  *
638  */
639 
640  template<class View, class CtrlView, ReifyMode rm>
643  (Home home, View x, int c0, CtrlView b)
645 
646  template<class View, class CtrlView, ReifyMode rm>
647  ExecStatus
648  ReEqDomInt<View,CtrlView,rm>::post(Home home, View x, int c, CtrlView b) {
649  if (b.one()) {
650  if (rm != RM_PMI)
651  GECODE_ME_CHECK(x.eq(home,c));
652  } else if (b.zero()) {
653  if (rm != RM_IMP)
654  GECODE_ME_CHECK(x.nq(home,c));
655  } else if (x.assigned()) {
656  assert(b.none());
657  if (x.val() == c) {
658  if (rm != RM_IMP)
659  GECODE_ME_CHECK(b.one_none(home));
660  } else {
661  if (rm != RM_PMI)
662  GECODE_ME_CHECK(b.zero_none(home));
663  }
664  } else {
665  (void) new (home) ReEqDomInt(home,x,c,b);
666  }
667  return ES_OK;
668  }
669 
670 
671  template<class View, class CtrlView, ReifyMode rm>
674  ReEqDomInt& p)
675  : ReUnaryPropagator<View,PC_INT_DOM,CtrlView>(home,share,p), c(p.c) {}
676 
677  template<class View, class CtrlView, ReifyMode rm>
678  Actor*
680  return new (home) ReEqDomInt<View,CtrlView,rm>(home,share,*this);
681  }
682 
683  template<class View, class CtrlView, ReifyMode rm>
684  ExecStatus
686  if (b.one()) {
687  if (rm != RM_PMI)
688  GECODE_ME_CHECK(x0.eq(home,c));
689  } else if (b.zero()) {
690  if (rm != RM_IMP)
691  GECODE_ME_CHECK(x0.nq(home,c));
692  } else {
693  switch (rtest_eq_dom(x0,c)) {
694  case RT_TRUE:
695  if (rm != RM_IMP)
696  GECODE_ME_CHECK(b.one_none(home));
697  break;
698  case RT_FALSE:
699  if (rm != RM_PMI)
700  GECODE_ME_CHECK(b.zero_none(home));
701  break;
702  case RT_MAYBE:
703  return ES_FIX;
704  default: GECODE_NEVER;
705  }
706  }
707  return home.ES_SUBSUMED(*this);
708  }
709 
710 
711 
712 
713  /*
714  * Reified bounds consistent equality (one variable)
715  *
716  */
717 
718  template<class View, class CtrlView, ReifyMode rm>
721  (Home home, View x, int c0, CtrlView b)
723 
724  template<class View, class CtrlView, ReifyMode rm>
725  ExecStatus
726  ReEqBndInt<View,CtrlView,rm>::post(Home home, View x, int c, CtrlView b) {
727  if (b.one()) {
728  if (rm != RM_PMI)
729  GECODE_ME_CHECK(x.eq(home,c));
730  } else if (b.zero()) {
731  if (rm != RM_IMP)
732  GECODE_ME_CHECK(x.nq(home,c));
733  } else if (x.assigned()) {
734  assert(b.none());
735  if (x.val() == c) {
736  if (rm != RM_IMP)
737  GECODE_ME_CHECK(b.one_none(home));
738  } else {
739  if (rm != RM_PMI)
740  GECODE_ME_CHECK(b.zero_none(home));
741  }
742  } else {
743  (void) new (home) ReEqBndInt(home,x,c,b);
744  }
745  return ES_OK;
746  }
747 
748 
749  template<class View, class CtrlView, ReifyMode rm>
752  : ReUnaryPropagator<View,PC_INT_BND,CtrlView>(home,share,p), c(p.c) {}
753 
754  template<class View, class CtrlView, ReifyMode rm>
755  Actor*
757  return new (home) ReEqBndInt<View,CtrlView,rm>(home,share,*this);
758  }
759 
760  template<class View, class CtrlView, ReifyMode rm>
761  ExecStatus
763  if (b.one()) {
764  if (rm != RM_PMI)
765  GECODE_ME_CHECK(x0.eq(home,c));
766  } else if (b.zero()) {
767  if (rm != RM_IMP)
768  GECODE_ME_CHECK(x0.nq(home,c));
769  } else {
770  switch (rtest_eq_bnd(x0,c)) {
771  case RT_TRUE:
772  if (rm != RM_IMP)
773  GECODE_ME_CHECK(b.one_none(home));
774  break;
775  case RT_FALSE:
776  if (rm != RM_PMI)
777  GECODE_ME_CHECK(b.zero_none(home));
778  break;
779  case RT_MAYBE:
780  return ES_FIX;
781  default: GECODE_NEVER;
782  }
783  }
784  return home.ES_SUBSUMED(*this);
785  }
786 
787 }}}
788 
789 // STATISTICS: int-prop
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: eq.hpp:317
#define GECODE_REWRITE(prop, post)
Rewrite propagator by executing post function.
Definition: macros.hpp:120
Relation may hold or not.
Definition: view.hpp:1616
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: eq.hpp:227
int c
Integer constant to check.
Definition: rel.hh:435
static ExecStatus post(Home home, V0 x0, V1 x1)
Post propagator .
Definition: nq.hpp:53
ReEqDomInt(Space &home, bool share, ReEqDomInt &p)
Constructor for cloning p.
Definition: eq.hpp:673
NNF * l
Left subtree.
Definition: bool-expr.cpp:244
Inverse implication for reification.
Definition: int.hh:850
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
Definition: eq.hpp:525
union Gecode::@579::NNF::@61 u
Union depending on nodetype t.
static ExecStatus post(Home home, ViewArray< View > &x)
Post bounds consistent propagator .
Definition: eq.hpp:406
static PropCost linear(PropCost::Mod m, unsigned int n)
Linear complexity for modifier pcm and size measure n.
Definition: core.hpp:4841
Binary domain consistent equality propagator.
Definition: rel.hh:71
ExecStatus ES_SUBSUMED(Propagator &p)
Definition: core.hpp:3614
const FloatNum max
Largest allowed float value.
Definition: float.hh:848
RelTest rtest_eq_dom(VX x, VY y)
Test whether views x and y are equal (use full domain information)
Definition: rel-test.hpp:69
Binary value propagation equality propagator.
Definition: rel.hh:107
T * alloc(long unsigned int n)
Allocate block of n objects of type T from region.
Definition: region.hpp:326
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition: arithmetic.cpp:53
Reified binary propagator.
Definition: propagator.hpp:91
static ExecStatus post(Home home, View0 x0, View1 x1)
Post domain consistent propagator .
Definition: eq.hpp:180
int ModEvent
Type for modification events.
Definition: core.hpp:142
ViewArray< View > x
Array of views.
Definition: propagator.hpp:152
Base-class for propagators.
Definition: core.hpp:1092
NaryEqDom(Space &home, bool share, NaryEqDom< View > &p)
Constructor for cloning p.
Definition: eq.hpp:296
Handle to region.
Definition: region.hpp:61
n-ary domain consistent equality propagator
Definition: rel.hh:168
Propagation has computed fixpoint.
Definition: core.hpp:545
static PropCost unary(PropCost::Mod m)
Single variable for modifier pcm.
Definition: core.hpp:4858
static ExecStatus post(Home home, View x, int c, CtrlView b)
Post bounds consistent propagator .
Definition: eq.hpp:726
void unique(const Space &home)
Remove all duplicate views from array (changes element order)
Definition: array.hpp:1505
Computation spaces.
Definition: core.hpp:1748
static ExecStatus post(Home home, View x0, View x1, CtrlView b)
Post bounds consistent propagator .
Definition: eq.hpp:572
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
Definition: eq.hpp:77
Base-class for both propagators and branchers.
Definition: core.hpp:696
EqBnd(Space &home, bool share, EqBnd< View0, View1 > &p)
Constructor for cloning p.
Definition: eq.hpp:129
Range iterator for integer views.
Definition: view.hpp:54
static ExecStatus post(Home home, View0 x0, View1 x1)
Post bounds consistent propagator .
Definition: eq.hpp:112
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: eq.hpp:685
int c
Integer constant to check.
Definition: rel.hh:408
int max(void) const
Return largest value of range.
bool same(const CachedView< View > &x, const CachedView< View > &y)
Definition: cached.hpp:389
Gecode::FloatVal c(-8, 8)
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
Definition: eq.hpp:141
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:236
const FloatNum min
Smallest allowed float value.
Definition: float.hh:850
Gecode::IntArgs i(4, 1, 2, 3, 4)
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
Definition: eq.hpp:301
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
Definition: eq.hpp:433
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:238
void reset(void)
Reset iterator to start.
EqVal(Space &home, bool share, EqVal< View0, View1 > &p)
Constructor for cloning p.
Definition: eq.hpp:65
Execution has resulted in failure.
Definition: core.hpp:542
Relation does not hold.
Definition: view.hpp:1615
const Gecode::PropCond PC_INT_BND
Propagate when minimum or maximum of a view changes.
Definition: var-type.hpp:91
const Gecode::ModEvent ME_INT_VAL
Domain operation has resulted in a value (assigned variable)
Definition: var-type.hpp:56
Reified binary domain consistent equality propagator.
Definition: rel.hh:350
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
Definition: eq.hpp:210
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: eq.hpp:762
ModEventDelta med
A set of modification events (used during propagation)
Definition: core.hpp:1103
ReEqBndInt(Space &home, bool share, ReEqBndInt &p)
Constructor for cloning p.
Definition: eq.hpp:751
struct Gecode::@579::NNF::@61::@62 b
For binary nodes (and, or, eqv)
Binary bounds consistent equality propagator.
Definition: rel.hh:137
const Gecode::PropCond PC_INT_DOM
Propagate when domain changes.
Definition: var-type.hpp:100
const Gecode::ModEvent ME_INT_BND
Domain operation has changed the minimum or maximum of the domain.
Definition: var-type.hpp:65
Reified binary bounds consistent equality propagator.
Definition: rel.hh:376
n-ary propagator
Definition: propagator.hpp:149
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
Definition: eq.hpp:756
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
Definition: eq.hpp:599
EqDom(Space &home, bool share, EqDom< View0, View1 > &p)
Constructor for cloning p.
Definition: eq.hpp:198
Expensive.
Definition: core.hpp:582
static ExecStatus post(Home home, View x0, View x1, CtrlView b)
Post domain consistent propagator .
Definition: eq.hpp:498
View arrays.
Definition: array.hpp:234
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: eq.hpp:147
static ExecStatus post(Home home, View0 x0, View1 x1)
Post value propagation propagator .
Definition: eq.hpp:52
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function.
Definition: eq.hpp:439
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
Definition: macros.hpp:56
int min(void) const
Return smallest value of range.
ExecStatus ES_FIX_PARTIAL(Propagator &p, const ModEventDelta &med)
Propagator p has computed partial fixpoint
Definition: core.hpp:3620
RelTest rtest_eq_bnd(VX x, VY y)
Test whether views x and y are equal (use bounds information)
Definition: rel-test.hpp:47
static ExecStatus post(Home home, View x, int c, CtrlView b)
Post domain consistent propagator .
Definition: eq.hpp:648
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: eq.hpp:531
Post propagator for SetVar SetOpType SetVar SetRelType r
Definition: set.hh:784
Reified bounds consistent equality with integer propagator.
Definition: rel.hh:429
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition: arithmetic.cpp:71
Mixed binary propagator.
Definition: propagator.hpp:213
Range iterator for intersection of iterators.
Propagation cost.
Definition: core.hpp:554
const Gecode::ModEvent ME_INT_DOM
Domain operation has changed the domain.
Definition: var-type.hpp:72
ExecStatus
Definition: core.hpp:540
bool assigned(View x, int v)
Whether x is assigned to value v.
Definition: single.hpp:47
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: eq.hpp:448
#define forceinline
Definition: config.hpp:173
Binary disequality propagator.
Definition: rel.hh:464
Post propagator for SetVar x
Definition: set.hh:784
Execution is okay.
Definition: core.hpp:544
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function.
Definition: eq.hpp:216
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: eq.hpp:89
NaryEqBnd(Space &home, bool share, NaryEqBnd< View > &p)
Constructor for cloning p.
Definition: eq.hpp:428
n-ary bounds consistent equality propagator
Definition: rel.hh:200
bool shared(const ConstView< ViewA > &, const ConstView< ViewB > &)
Test whether views share same variable.
Definition: view.hpp:702
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function.
Definition: eq.hpp:307
ReEqBnd(Space &home, bool share, ReEqBnd &p)
Constructor for cloning p.
Definition: eq.hpp:594
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function: low unary.
Definition: eq.hpp:83
Gecode toplevel namespace
Implication for reification.
Definition: int.hh:843
static ExecStatus post(Home home, ViewArray< View > &x)
Post domain consistent propagator .
Definition: eq.hpp:274
int size(void) const
Return size of array (number of elements)
Definition: array.hpp:1215
int ModEventDelta
Modification event deltas.
Definition: core.hpp:169
Reified domain consistent equality with integer propagator.
Definition: rel.hh:402
Home class for posting propagators
Definition: core.hpp:922
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
Definition: eq.hpp:679
static PropCost binary(PropCost::Mod m)
Two variables for modifier pcm.
Definition: core.hpp:4854
#define GECODE_NEVER
Assert that this command is never executed.
Definition: macros.hpp:60
Relation does hold.
Definition: view.hpp:1617
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: eq.hpp:605
const Gecode::PropCond PC_INT_VAL
Propagate when a view becomes assigned (single value)
Definition: var-type.hpp:82
ReEqDom(Space &home, bool share, ReEqDom &p)
Constructor for cloning p.
Definition: eq.hpp:520