Generated on Sat Jun 2 2018 07:17:44 for Gecode by doxygen 1.8.13
set-expr.cpp
Go to the documentation of this file.
1 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /*
3  * Main authors:
4  * Guido Tack <tack@gecode.org>
5  * Christian Schulte <schulte@gecode.org>
6  *
7  * Copyright:
8  * Guido Tack, 2010
9  * Christian Schulte, 2004
10  *
11  * This file is part of Gecode, the generic constraint
12  * development environment:
13  * http://www.gecode.org
14  *
15  * Permission is hereby granted, free of charge, to any person obtaining
16  * a copy of this software and associated documentation files (the
17  * "Software"), to deal in the Software without restriction, including
18  * without limitation the rights to use, copy, modify, merge, publish,
19  * distribute, sublicense, and/or sell copies of the Software, and to
20  * permit persons to whom the Software is furnished to do so, subject to
21  * the following conditions:
22  *
23  * The above copyright notice and this permission notice shall be
24  * included in all copies or substantial portions of the Software.
25  *
26  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
29  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
30  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
31  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
32  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33  *
34  */
35 
36 #include <gecode/minimodel.hh>
37 
38 #ifdef GECODE_HAS_SET_VARS
39 
40 namespace Gecode {
41 
42  namespace {
44  static bool same(SetExpr::NodeType t0, SetExpr::NodeType t1) {
45  return (t0==t1) || (t1==SetExpr::NT_VAR) ||
46  (t1==SetExpr::NT_CONST) || (t1==SetExpr::NT_LEXP);
47  }
48  }
49 
51  class SetExpr::Node {
52  public:
54  unsigned int use;
56  int same;
60  Node *l, *r;
67 
69  Node(void);
72  bool decrement(void);
74  static void* operator new(size_t size);
76  static void operator delete(void* p, size_t size);
77  };
78 
79  /*
80  * Operations for nodes
81  *
82  */
83  SetExpr::Node::Node(void) : use(1) {}
84 
85  void*
86  SetExpr::Node::operator new(size_t size) {
87  return heap.ralloc(size);
88  }
89  void
90  SetExpr::Node::operator delete(void* p, size_t) {
91  heap.rfree(p);
92  }
93 
94  bool
96  if (--use == 0) {
97  if ((l != NULL) && l->decrement())
98  delete l;
99  if ((r != NULL) && r->decrement())
100  delete r;
101  return true;
102  }
103  return false;
104  }
105 
106  namespace {
108  class NNF {
109  public:
110  typedef SetExpr::NodeType NodeType;
111  typedef SetExpr::Node Node;
113  NodeType t;
115  int p;
117  int n;
119  union {
121  struct {
123  NNF* l;
125  NNF* r;
126  } b;
128  struct {
130  Node* x;
131  } a;
132  } u;
134  bool neg;
136  static NNF* nnf(Region& r, Node* n, bool neg);
138  void post(Home home, NodeType t, SetVarArgs& b, int& i) const;
140  void post(Home home, SetRelType srt, SetVar s) const;
142  void post(Home home, SetRelType srt, SetVar s, BoolVar b) const;
144  void post(Home home, SetRelType srt, const NNF* n) const;
146  void post(Home home, BoolVar b, bool t, SetRelType srt,
147  const NNF* n) const;
149  static void* operator new(size_t s, Region& r);
151  static void operator delete(void*);
153  static void operator delete(void*, Region&);
154  };
155 
156  /*
157  * Operations for negation normalform
158  *
159  */
160  forceinline void
161  NNF::operator delete(void*) {}
162 
163  forceinline void
164  NNF::operator delete(void*, Region&) {}
165 
166  forceinline void*
167  NNF::operator new(size_t s, Region& r) {
168  return r.ralloc(s);
169  }
170 
171  void
172  NNF::post(Home home, SetRelType srt, SetVar s) const {
173  switch (t) {
174  case SetExpr::NT_VAR:
175  if (neg) {
176  switch (srt) {
177  case SRT_EQ:
178  rel(home, u.a.x->x, SRT_CMPL, s);
179  break;
180  case SRT_CMPL:
181  rel(home, u.a.x->x, SRT_EQ, s);
182  break;
183  default:
184  SetVar bc(home,IntSet::empty,
186  rel(home, s, SRT_CMPL, bc);
187  rel(home, u.a.x->x, srt, bc);
188  break;
189  }
190  } else
191  rel(home, u.a.x->x, srt, s);
192  break;
193  case SetExpr::NT_CONST:
194  {
195  IntSet ss;
196  if (neg) {
197  IntSetRanges sr(u.a.x->s);
198  Set::RangesCompl<IntSetRanges> src(sr);
199  ss = IntSet(src);
200  } else {
201  ss = u.a.x->s;
202  }
203  switch (srt) {
204  case SRT_SUB: srt = SRT_SUP; break;
205  case SRT_SUP: srt = SRT_SUB; break;
206  default: break;
207  }
208  dom(home, s, srt, ss);
209  }
210  break;
211  case SetExpr::NT_LEXP:
212  {
213  IntVar iv = u.a.x->e.post(home,IPL_DEF);
214  if (neg) {
215  SetVar ic(home,IntSet::empty,
217  rel(home, iv, SRT_CMPL, ic);
218  rel(home,ic,srt,s);
219  } else {
220  rel(home,iv,srt,s);
221  }
222  }
223  break;
224  case SetExpr::NT_INTER:
225  {
226  SetVarArgs bs(p+n);
227  int i=0;
228  post(home, SetExpr::NT_INTER, bs, i);
229  if (i == 2) {
230  rel(home, bs[0], SOT_INTER, bs[1], srt, s);
231  } else {
232  if (srt == SRT_EQ)
233  rel(home, SOT_INTER, bs, s);
234  else {
235  SetVar bc(home,IntSet::empty,
237  rel(home, SOT_INTER, bs, bc);
238  rel(home, bc, srt, s);
239  }
240  }
241  }
242  break;
243  case SetExpr::NT_UNION:
244  {
245  SetVarArgs bs(p+n);
246  int i=0;
247  post(home, SetExpr::NT_UNION, bs, i);
248  if (i == 2) {
249  rel(home, bs[0], SOT_UNION, bs[1], srt, s);
250  } else {
251  if (srt == SRT_EQ)
252  rel(home, SOT_UNION, bs, s);
253  else {
254  SetVar bc(home,IntSet::empty,
256  rel(home, SOT_UNION, bs, bc);
257  rel(home, bc, srt, s);
258  }
259  }
260  }
261  break;
262  case SetExpr::NT_DUNION:
263  {
264  SetVarArgs bs(p+n);
265  int i=0;
266  post(home, SetExpr::NT_DUNION, bs, i);
267 
268  if (i == 2) {
269  if (neg) {
270  if (srt == SRT_CMPL) {
271  rel(home, bs[0], SOT_DUNION, bs[1], srt, s);
272  } else {
273  SetVar bc(home,IntSet::empty,
275  rel(home,s,SRT_CMPL,bc);
276  rel(home, bs[0], SOT_DUNION, bs[1], srt, bc);
277  }
278  } else {
279  rel(home, bs[0], SOT_DUNION, bs[1], srt, s);
280  }
281  } else {
282  if (neg) {
283  if (srt == SRT_CMPL) {
284  rel(home, SOT_DUNION, bs, s);
285  } else {
286  SetVar br(home,IntSet::empty,
288  rel(home, SOT_DUNION, bs, br);
289  if (srt == SRT_EQ)
290  rel(home, br, SRT_CMPL, s);
291  else {
292  SetVar bc(home,IntSet::empty,
294  rel(home, br, srt, bc);
295  rel(home, bc, SRT_CMPL, s);
296  }
297  }
298  } else {
299  if (srt == SRT_EQ)
300  rel(home, SOT_DUNION, bs, s);
301  else {
302  SetVar br(home,IntSet::empty,
304  rel(home, SOT_DUNION, bs, br);
305  rel(home, br, srt, s);
306  }
307  }
308  }
309  }
310  break;
311  default:
312  GECODE_NEVER;
313  }
314  }
315 
316  void
317  NNF::post(Home home, SetRelType srt, SetVar s, BoolVar b) const {
318  switch (t) {
319  case SetExpr::NT_VAR:
320  if (neg) {
321  switch (srt) {
322  case SRT_EQ:
323  rel(home, u.a.x->x, SRT_CMPL, s, b);
324  break;
325  case SRT_CMPL:
326  rel(home, u.a.x->x, SRT_EQ, s, b);
327  break;
328  default:
329  SetVar bc(home,IntSet::empty,
331  rel(home, s, SRT_CMPL, bc);
332  rel(home, u.a.x->x, srt, bc, b);
333  break;
334  }
335  } else
336  rel(home, u.a.x->x, srt, s, b);
337  break;
338  case SetExpr::NT_CONST:
339  {
340  IntSet ss;
341  if (neg) {
342  IntSetRanges sr(u.a.x->s);
343  Set::RangesCompl<IntSetRanges> src(sr);
344  ss = IntSet(src);
345  } else {
346  ss = u.a.x->s;
347  }
348  SetRelType invsrt;
349  switch (srt) {
350  case SRT_SUB: invsrt = SRT_SUP; break;
351  case SRT_SUP: invsrt = SRT_SUB; break;
352  case SRT_LQ: invsrt = SRT_GQ; break;
353  case SRT_LE: invsrt = SRT_GR; break;
354  case SRT_GQ: invsrt = SRT_LQ; break;
355  case SRT_GR: invsrt = SRT_LE; break;
356  case SRT_EQ:
357  case SRT_NQ:
358  case SRT_DISJ:
359  case SRT_CMPL:
360  invsrt = srt;
361  break;
362  default:
363  invsrt = srt;
364  GECODE_NEVER;
365  }
366  dom(home, s, invsrt, ss, b);
367  }
368  break;
369  case SetExpr::NT_LEXP:
370  {
371  IntVar iv = u.a.x->e.post(home,IPL_DEF);
372  if (neg) {
373  SetVar ic(home,IntSet::empty,
375  rel(home, iv, SRT_CMPL, ic);
376  rel(home,ic,srt,s,b);
377  } else {
378  rel(home,iv,srt,s,b);
379  }
380  }
381  case SetExpr::NT_INTER:
382  {
383  SetVarArgs bs(p+n);
384  int i=0;
385  post(home, SetExpr::NT_INTER, bs, i);
386  SetVar br(home,IntSet::empty,
388  rel(home, SOT_INTER, bs, br);
389  rel(home, br, srt, s, b);
390  }
391  break;
392  case SetExpr::NT_UNION:
393  {
394  SetVarArgs bs(p+n);
395  int i=0;
396  post(home, SetExpr::NT_UNION, bs, i);
397  SetVar br(home,IntSet::empty,
399  rel(home, SOT_UNION, bs, br);
400  rel(home, br, srt, s, b);
401  }
402  break;
403  case SetExpr::NT_DUNION:
404  {
405  SetVarArgs bs(p+n);
406  int i=0;
407  post(home, SetExpr::NT_DUNION, bs, i);
408 
409  if (neg) {
410  SetVar br(home,IntSet::empty,
412  rel(home, SOT_DUNION, bs, br);
413  if (srt == SRT_CMPL)
414  rel(home, br, SRT_EQ, s, b);
415  else if (srt == SRT_EQ)
416  rel(home, br, SRT_CMPL, s, b);
417  else {
418  SetVar bc(home,IntSet::empty,
420  rel(home, br, srt, bc);
421  rel(home, bc, SRT_CMPL, s, b);
422  }
423  } else {
424  SetVar br(home,IntSet::empty,
426  rel(home, SOT_DUNION, bs, br);
427  rel(home, br, srt, s, b);
428  }
429  }
430  break;
431  default:
432  GECODE_NEVER;
433  }
434  }
435 
436  void
437  NNF::post(Home home, NodeType t, SetVarArgs& b, int& i) const {
438  if (this->t != t) {
439  switch (this->t) {
440  case SetExpr::NT_VAR:
441  if (neg) {
442  SetVar xc(home,IntSet::empty,
444  rel(home, xc, SRT_CMPL, u.a.x->x);
445  b[i++]=xc;
446  } else {
447  b[i++]=u.a.x->x;
448  }
449  break;
450  default:
451  {
452  SetVar s(home,IntSet::empty,
454  post(home,SRT_EQ,s);
455  b[i++] = s;
456  }
457  break;
458  }
459  } else {
460  u.b.l->post(home, t, b, i);
461  u.b.r->post(home, t, b, i);
462  }
463  }
464 
465  void
466  NNF::post(Home home, SetRelType srt, const NNF* n) const {
467  if (n->t == SetExpr::NT_VAR && !n->neg) {
468  post(home,srt,n->u.a.x->x);
469  } else if (t == SetExpr::NT_VAR && !neg) {
470  SetRelType n_srt;
471  switch (srt) {
472  case SRT_SUB: n_srt = SRT_SUP; break;
473  case SRT_SUP: n_srt = SRT_SUB; break;
474  default: n_srt = srt;
475  }
476  n->post(home,n_srt,this);
477  } else {
478  SetVar nx(home,IntSet::empty,
480  n->post(home,SRT_EQ,nx);
481  post(home,srt,nx);
482  }
483  }
484 
485  void
486  NNF::post(Home home, BoolVar b, bool pt,
487  SetRelType srt, const NNF* n) const {
488  if (pt) {
489  if (n->t == SetExpr::NT_VAR && !n->neg) {
490  post(home,srt,n->u.a.x->x,b);
491  } else if (t == SetExpr::NT_VAR && !neg) {
492  SetRelType n_srt;
493  switch (srt) {
494  case SRT_SUB: n_srt = SRT_SUP; break;
495  case SRT_SUP: n_srt = SRT_SUB; break;
496  default: n_srt = srt;
497  }
498  n->post(home,b,true,n_srt,this);
499  } else {
500  SetVar nx(home,IntSet::empty,
502  n->post(home,SRT_EQ,nx);
503  post(home,srt,nx,b);
504  }
505  } else if (srt == SRT_EQ) {
506  post(home,b,true,SRT_NQ,n);
507  } else if (srt == SRT_NQ) {
508  post(home,b,true,SRT_EQ,n);
509  } else {
510  BoolVar nb(home,0,1);
511  rel(home,b,IRT_NQ,nb);
512  post(home,nb,true,srt,n);
513  }
514  }
515 
516  NNF*
517  NNF::nnf(Region& r, Node* n, bool neg) {
518  switch (n->t) {
519  case SetExpr::NT_VAR:
520  case SetExpr::NT_CONST:
521  case SetExpr::NT_LEXP:
522  {
523  NNF* x = new (r) NNF;
524  x->t = n->t; x->neg = neg; x->u.a.x = n;
525  if (neg) {
526  x->p = 0; x->n = 1;
527  } else {
528  x->p = 1; x->n = 0;
529  }
530  return x;
531  }
532  case SetExpr::NT_CMPL:
533  return nnf(r,n->l,!neg);
534  case SetExpr::NT_INTER:
535  case SetExpr::NT_UNION:
536  case SetExpr::NT_DUNION:
537  {
538  NodeType t; bool xneg;
539  if (n->t == SetExpr::NT_DUNION) {
540  t = n->t; xneg = neg; neg = false;
541  } else {
542  t = ((n->t == SetExpr::NT_INTER) == neg) ?
544  xneg = false;
545  }
546  NNF* x = new (r) NNF;
547  x->neg = xneg;
548  x->t = t;
549  x->u.b.l = nnf(r,n->l,neg);
550  x->u.b.r = nnf(r,n->r,neg);
551  int p_l, n_l;
552  if ((x->u.b.l->t == t) || (x->u.b.l->t == SetExpr::NT_VAR)) {
553  p_l=x->u.b.l->p; n_l=x->u.b.l->n;
554  } else {
555  p_l=1; n_l=0;
556  }
557  int p_r, n_r;
558  if ((x->u.b.r->t == t) || (x->u.b.r->t == SetExpr::NT_VAR)) {
559  p_r=x->u.b.r->p; n_r=x->u.b.r->n;
560  } else {
561  p_r=1; n_r=0;
562  }
563  x->p = p_l+p_r;
564  x->n = n_l+n_r;
565  return x;
566  }
567  default:
568  GECODE_NEVER;
569  }
570  GECODE_NEVER;
571  return NULL;
572  }
573  }
574 
575  SetExpr::SetExpr(const SetVar& x) : n(new Node) {
576  n->same = 1;
577  n->t = NT_VAR;
578  n->l = NULL;
579  n->r = NULL;
580  n->x = x;
581  }
582 
583  SetExpr::SetExpr(const IntSet& s) : n(new Node) {
584  n->same = 1;
585  n->t = NT_CONST;
586  n->l = NULL;
587  n->r = NULL;
588  n->s = s;
589  }
590 
591  SetExpr::SetExpr(const LinIntExpr& e) : n(new Node) {
592  n->same = 1;
593  n->t = NT_LEXP;
594  n->l = NULL;
595  n->r = NULL;
596  n->e = e;
597  }
598 
600  : n(new Node) {
601  int ls = same(t,l.n->t) ? l.n->same : 1;
602  int rs = same(t,r.n->t) ? r.n->same : 1;
603  n->same = ls+rs;
604  n->t = t;
605  n->l = l.n;
606  n->l->use++;
607  n->r = r.n;
608  n->r->use++;
609  }
610 
612  (void) t;
613  assert(t == NT_CMPL);
614  if (l.n->t == NT_CMPL) {
615  n = l.n->l;
616  n->use++;
617  } else {
618  n = new Node;
619  n->same = 1;
620  n->t = NT_CMPL;
621  n->l = l.n;
622  n->l->use++;
623  n->r = NULL;
624  }
625  }
626 
627  const SetExpr&
629  if (this != &e) {
630  if (n != NULL && n->decrement())
631  delete n;
632  n = e.n;
633  n->use++;
634  }
635  return *this;
636  }
637 
639  if (n != NULL && n->decrement())
640  delete n;
641  }
642 
643  SetExpr::SetExpr(const SetExpr& e) : n(e.n) {
644  n->use++;
645  }
646 
647  SetVar
648  SetExpr::post(Home home) const {
649  Region r;
650  SetVar s(home,IntSet::empty,
652  NNF::nnf(r,n,false)->post(home,SRT_EQ,s);
653  return s;
654  }
655 
656  void
657  SetExpr::post(Home home, SetRelType srt, const SetExpr& e) const {
658  Region r;
659  return NNF::nnf(r,n,false)->post(home,srt,NNF::nnf(r,e.n,false));
660  }
661  void
662  SetExpr::post(Home home, BoolVar b, bool t,
663  SetRelType srt, const SetExpr& e) const {
664  Region r;
665  return NNF::nnf(r,n,false)->post(home,b,t,srt,
666  NNF::nnf(r,e.n,false));
667  }
668 
669  SetExpr
670  operator &(const SetExpr& l, const SetExpr& r) {
671  return SetExpr(l,SetExpr::NT_INTER,r);
672  }
673  SetExpr
674  operator |(const SetExpr& l, const SetExpr& r) {
675  return SetExpr(l,SetExpr::NT_UNION,r);
676  }
677  SetExpr
678  operator +(const SetExpr& l, const SetExpr& r) {
679  return SetExpr(l,SetExpr::NT_DUNION,r);
680  }
681  SetExpr
682  operator -(const SetExpr& e) {
683  return SetExpr(e,SetExpr::NT_CMPL);
684  }
685  SetExpr
686  operator -(const SetExpr& l, const SetExpr& r) {
687  return SetExpr(l,SetExpr::NT_INTER,-r);
688  }
689  SetExpr
690  singleton(const LinIntExpr& e) {
691  return SetExpr(e);
692  }
693 
694  SetExpr
695  inter(const SetVarArgs& x) {
696  if (x.size() == 0)
698  SetExpr r(x[0]);
699  for (int i=1; i<x.size(); i++)
700  r = (r & x[i]);
701  return r;
702  }
703  SetExpr
704  setunion(const SetVarArgs& x) {
705  if (x.size() == 0)
706  return SetExpr(IntSet::empty);
707  SetExpr r(x[0]);
708  for (int i=1; i<x.size(); i++)
709  r = (r | x[i]);
710  return r;
711  }
712  SetExpr
713  setdunion(const SetVarArgs& x) {
714  if (x.size() == 0)
715  return SetExpr(IntSet::empty);
716  SetExpr r(x[0]);
717  for (int i=1; i<x.size(); i++)
718  r = (r + x[i]);
719  return r;
720  }
721 
722  namespace MiniModel {
725  public:
730  SNLE_MAX
731  } t;
736  : t(t0), e(e0) {}
738  virtual IntVar post(Home home, IntVar* ret, IntPropLevel) const {
739  IntVar m = result(home,ret);
740  switch (t) {
741  case SNLE_CARD:
742  cardinality(home, e.post(home), m);
743  break;
744  case SNLE_MIN:
745  min(home, e.post(home), m);
746  break;
747  case SNLE_MAX:
748  max(home, e.post(home), m);
749  break;
750  default:
751  GECODE_NEVER;
752  break;
753  }
754  return m;
755  }
756  virtual void post(Home home, IntRelType irt, int c,
757  IntPropLevel ipl) const {
758  if (t==SNLE_CARD && irt!=IRT_NQ) {
759  switch (irt) {
760  case IRT_LQ:
761  cardinality(home, e.post(home),
762  0U,
763  static_cast<unsigned int>(c));
764  break;
765  case IRT_LE:
766  cardinality(home, e.post(home),
767  0U,
768  static_cast<unsigned int>(c-1));
769  break;
770  case IRT_GQ:
771  cardinality(home, e.post(home),
772  static_cast<unsigned int>(c),
774  break;
775  case IRT_GR:
776  cardinality(home, e.post(home),
777  static_cast<unsigned int>(c+1),
779  break;
780  case IRT_EQ:
781  cardinality(home, e.post(home),
782  static_cast<unsigned int>(c),
783  static_cast<unsigned int>(c));
784  break;
785  default:
786  GECODE_NEVER;
787  }
788  } else if (t==SNLE_MIN && (irt==IRT_GR || irt==IRT_GQ)) {
789  c = (irt==IRT_GQ ? c : c+1);
790  dom(home, e.post(home), SRT_SUB, c, Set::Limits::max);
791  } else if (t==SNLE_MAX && (irt==IRT_LE || irt==IRT_LQ)) {
792  c = (irt==IRT_LQ ? c : c-1);
793  dom(home, e.post(home), SRT_SUB, Set::Limits::min, c);
794  } else {
795  rel(home, post(home,NULL,ipl), irt, c);
796  }
797  }
798  virtual void post(Home home, IntRelType irt, int c,
799  BoolVar b, IntPropLevel ipl) const {
800  if (t==SNLE_MIN && (irt==IRT_GR || irt==IRT_GQ)) {
801  c = (irt==IRT_GQ ? c : c+1);
802  dom(home, e.post(home), SRT_SUB, c, Set::Limits::max, b);
803  } else if (t==SNLE_MAX && (irt==IRT_LE || irt==IRT_LQ)) {
804  c = (irt==IRT_LQ ? c : c-1);
805  dom(home, e.post(home), SRT_SUB, Set::Limits::min, c, b);
806  } else {
807  rel(home, post(home,NULL,ipl), irt, c, b);
808  }
809  }
810  };
811  }
812 
813  LinIntExpr
814  cardinality(const SetExpr& e) {
817  }
818  LinIntExpr
819  min(const SetExpr& e) {
822  }
823  LinIntExpr
824  max(const SetExpr& e) {
827  }
828 
829  /*
830  * Posting set expressions
831  *
832  */
833  SetVar
834  expr(Home home, const SetExpr& e) {
835  PostInfo pi(home);
836  if (!home.failed())
837  return e.post(home);
839  return x;
840  }
841 
842 
843 }
844 
845 #endif
846 
847 // STATISTICS: minimodel-any
FloatVal operator-(const FloatVal &x)
Definition: val.hpp:168
int same
Number of variables in subtree with same type (for INTER and UNION)
Definition: set-expr.cpp:56
SetExpr singleton(const LinIntExpr &e)
Singleton expression.
Definition: set-expr.cpp:690
SetRelType
Common relation types for sets.
Definition: set.hh:641
const SetExpr & operator=(const SetExpr &e)
Assignment operator.
Definition: set-expr.cpp:628
int size(void) const
Return size of array (number of elements)
Definition: array.hpp:1653
void post(Home home, Term *t, int n, FloatRelType frt, FloatVal c)
Post propagator for linear constraint over floats.
Definition: post.cpp:238
const int min
Smallest allowed integer in integer set.
Definition: set.hh:99
SetExpr operator&(const SetExpr &l, const SetExpr &r)
Intersection of set expressions.
Definition: set-expr.cpp:670
void rfree(void *p)
Free memory block starting at p.
Definition: heap.hpp:371
LinIntExpr e
Possibly a linear expression.
Definition: set-expr.cpp:66
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition: arithmetic.cpp:49
Less or equal ( )
Definition: int.hh:903
virtual void post(Home home, IntRelType irt, int c, BoolVar b, IntPropLevel ipl) const
Post reified expression to be in relation irt with c.
Definition: set-expr.cpp:798
void dom(Home home, FloatVar x, FloatVal n)
Propagates .
Definition: dom.cpp:40
Base class for non-linear expressions over integer variables.
Definition: minimodel.hh:109
void * ralloc(size_t s)
Allocate s bytes from heap.
Definition: heap.hpp:357
SetVar x
Possibly a variable.
Definition: set-expr.cpp:62
NNF * l
Left subtree.
Definition: set-expr.cpp:123
Handle to region.
Definition: region.hpp:53
Greater ( )
Definition: int.hh:906
Superset ( )
Definition: set.hh:645
virtual void post(Home home, IntRelType irt, int c, IntPropLevel ipl) const
Post expression to be in relation irt with c.
Definition: set-expr.cpp:756
Complement.
Definition: set.hh:647
#define forceinline
Definition: config.hpp:185
const unsigned int card
Maximum cardinality of an integer set.
Definition: set.hh:101
const int max
Largest allowed integer in integer set.
Definition: set.hh:97
Linear expression.
Definition: minimodel.hh:1066
Greater or equal ( )
Definition: int.hh:905
Set expressions
Definition: minimodel.hh:1060
Node * l
Subexpressions.
Definition: set-expr.cpp:60
SetExpr setdunion(const SetVarArgs &x)
Disjoint union of set variables.
Definition: set-expr.cpp:713
Gecode::FloatVal c(-8, 8)
bool same(const ConstView< ViewA > &, const ConstView< ViewB > &)
Test whether two views are the same.
Definition: view.hpp:676
Gecode::IntArgs i(4, 1, 2, 3, 4)
IntRelType neg(IntRelType irt)
Return negated relation type of irt.
Definition: irt.hpp:52
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:234
Equality ( )
Definition: int.hh:901
IntSet s
Possibly a constant.
Definition: set-expr.cpp:64
struct Gecode::@604::NNF::@68::@70 a
For atomic nodes.
IntRelType
Relation types for integers.
Definition: int.hh:900
FloatVal operator+(const FloatVal &x)
Definition: val.hpp:164
struct Gecode::@604::NNF::@68::@69 b
For binary nodes (and, or, eqv)
NodeType t
Type of expression.
Definition: set-expr.cpp:58
Less or equal ( )
Definition: set.hh:648
Class to set group information when a post function is executed.
Definition: core.hpp:945
virtual IntVar post(Home home, IntVar *ret, IntPropLevel) const
Post expression.
Definition: set-expr.cpp:738
Simple propagation levels.
Definition: int.hh:951
SetExpr(void)
Default constructor.
Definition: set-expr.hpp:44
bool failed(void) const
Check whether corresponding space is failed.
Definition: core.hpp:3967
unsigned int size(I &i)
Size of all ranges of range iterator i.
Node(void)
Default constructor.
Definition: set-expr.cpp:83
Subset ( )
Definition: set.hh:644
Intersection
Definition: set.hh:661
Less ( )
Definition: int.hh:904
NodeType
Type of set expression.
Definition: minimodel.hh:1063
Integer sets.
Definition: int.hh:170
const int * pi[]
Definition: photo.cpp:14262
Less ( )
Definition: set.hh:649
SetExpr setunion(const SetVarArgs &x)
Union of set variables.
Definition: set-expr.cpp:704
Integer valued set expressions.
Definition: set-expr.cpp:724
NodeType t
Type of node.
Definition: set-expr.cpp:113
static const IntSet empty
Empty set.
Definition: int.hh:259
BoolVar expr(Home home, const BoolExpr &e, IntPropLevel ipl)
Post Boolean expression and return its value.
Definition: bool-expr.cpp:628
Boolean integer variables.
Definition: int.hh:488
LinIntExpr cardinality(const SetExpr &e)
Cardinality of set expression.
Definition: set-expr.cpp:814
Post propagator for SetVar SetOpType SetVar SetRelType r
Definition: set.hh:765
SetExpr inter(const SetVarArgs &x)
Intersection of set variables.
Definition: set-expr.cpp:695
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition: arithmetic.cpp:67
IntPropLevel
Propagation levels for integer propagators.
Definition: int.hh:949
Union.
Definition: set.hh:659
Passing set variables.
Definition: set.hh:488
Greater or equal ( )
Definition: set.hh:650
Set variables
Definition: set.hh:127
Node for set expression
Definition: set-expr.cpp:51
Linear expressions over integer variables.
Definition: minimodel.hh:140
Disjoint union.
Definition: set.hh:660
Integer variables.
Definition: int.hh:347
Heap heap
The single global heap.
Definition: heap.cpp:44
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
Definition: rel.cpp:43
union Gecode::@604::NNF::@68 u
Union depending on nodetype t.
unsigned int use
Nodes are reference counted.
Definition: set-expr.cpp:54
Greater ( )
Definition: set.hh:651
Equality ( )
Definition: set.hh:642
Disjoint ( )
Definition: set.hh:646
SetExpr e
The expression.
Definition: set-expr.cpp:733
Post propagator for SetVar x
Definition: set.hh:765
#define GECODE_MINIMODEL_EXPORT
Definition: minimodel.hh:78
SetExpr operator|(const SetExpr &l, const SetExpr &r)
Union of set expressions.
Definition: set-expr.cpp:674
Disequality ( )
Definition: set.hh:643
SetNonLinIntExprType
The expression type.
Definition: set-expr.cpp:727
Gecode toplevel namespace
Disequality ( )
Definition: int.hh:902
Home class for posting propagators
Definition: core.hpp:853
~SetExpr(void)
Destructor.
Definition: set-expr.cpp:638
#define GECODE_NEVER
Assert that this command is never executed.
Definition: macros.hpp:56
SetNonLinIntExpr(const SetExpr &e0, SetNonLinIntExprType t0)
Constructor.
Definition: set-expr.cpp:735
bool decrement(void)
Decrement reference count and possibly free memory.
Definition: set-expr.cpp:95
SetVar post(Home home) const
Post propagators for expression.
Definition: set-expr.cpp:648
int p
Number of positive literals for node type.
Definition: set-expr.cpp:115