Generated on Mon Sep 22 2014 12:49:30 for Gecode by doxygen 1.8.7
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  * Last modified:
12  * $Date: 2013-01-22 13:48:12 +0100 (Tue, 22 Jan 2013) $ by $Author: schulte $
13  * $Revision: 13227 $
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 <gecode/minimodel.hh>
41 
42 #ifdef GECODE_HAS_SET_VARS
43 
44 namespace Gecode {
45 
46  namespace {
48  static bool same(SetExpr::NodeType t0, SetExpr::NodeType t1) {
49  return (t0==t1) || (t1==SetExpr::NT_VAR) ||
50  (t1==SetExpr::NT_CONST) || (t1==SetExpr::NT_LEXP);
51  }
52  }
53 
55  class SetExpr::Node {
56  public:
58  unsigned int use;
60  int same;
64  Node *l, *r;
71 
73  Node(void);
76  bool decrement(void);
78  static void* operator new(size_t size);
80  static void operator delete(void* p, size_t size);
81  };
82 
83  /*
84  * Operations for nodes
85  *
86  */
87  SetExpr::Node::Node(void) : use(1) {}
88 
89  void*
90  SetExpr::Node::operator new(size_t size) {
91  return heap.ralloc(size);
92  }
93  void
94  SetExpr::Node::operator delete(void* p, size_t) {
95  heap.rfree(p);
96  }
97 
98  bool
100  if (--use == 0) {
101  if ((l != NULL) && l->decrement())
102  delete l;
103  if ((r != NULL) && r->decrement())
104  delete r;
105  return true;
106  }
107  return false;
108  }
109 
110  namespace {
112  class NNF {
113  public:
114  typedef SetExpr::NodeType NodeType;
115  typedef SetExpr::Node Node;
119  int p;
121  int n;
123  union {
125  struct {
127  NNF* l;
129  NNF* r;
130  } b;
132  struct {
134  Node* x;
135  } a;
136  } u;
138  bool neg;
140  static NNF* nnf(Region& r, Node* n, bool neg);
142  void post(Home home, NodeType t, SetVarArgs& b, int& i) const;
144  void post(Home home, SetRelType srt, SetVar s) const;
146  void post(Home home, SetRelType srt, SetVar s, BoolVar b) const;
148  void post(Home home, SetRelType srt, const NNF* n) const;
150  void post(Home home, BoolVar b, bool t, SetRelType srt,
151  const NNF* n) const;
153  static void* operator new(size_t s, Region& r);
155  static void operator delete(void*);
157  static void operator delete(void*, Region&);
158  };
159 
160  /*
161  * Operations for negation normalform
162  *
163  */
164  forceinline void
165  NNF::operator delete(void*) {}
166 
167  forceinline void
168  NNF::operator delete(void*, Region&) {}
169 
170  forceinline void*
171  NNF::operator new(size_t s, Region& r) {
172  return r.ralloc(s);
173  }
174 
175  void
176  NNF::post(Home home, SetRelType srt, SetVar s) const {
177  switch (t) {
178  case SetExpr::NT_VAR:
179  if (neg) {
180  switch (srt) {
181  case SRT_EQ:
182  rel(home, u.a.x->x, SRT_CMPL, s);
183  break;
184  case SRT_CMPL:
185  rel(home, u.a.x->x, SRT_EQ, s);
186  break;
187  default:
188  SetVar bc(home,IntSet::empty,
190  rel(home, s, SRT_CMPL, bc);
191  rel(home, u.a.x->x, srt, bc);
192  break;
193  }
194  } else
195  rel(home, u.a.x->x, srt, s);
196  break;
197  case SetExpr::NT_CONST:
198  {
199  IntSet ss;
200  if (neg) {
201  IntSetRanges sr(u.a.x->s);
202  Set::RangesCompl<IntSetRanges> src(sr);
203  ss = IntSet(src);
204  } else {
205  ss = u.a.x->s;
206  }
207  switch (srt) {
208  case SRT_SUB: srt = SRT_SUP; break;
209  case SRT_SUP: srt = SRT_SUB; break;
210  default: break;
211  }
212  dom(home, s, srt, ss);
213  }
214  break;
215  case SetExpr::NT_LEXP:
216  {
217  IntVar iv = u.a.x->e.post(home,ICL_DEF);
218  if (neg) {
219  SetVar ic(home,IntSet::empty,
221  rel(home, iv, SRT_CMPL, ic);
222  rel(home,ic,srt,s);
223  } else {
224  rel(home,iv,srt,s);
225  }
226  }
227  break;
228  case SetExpr::NT_INTER:
229  {
230  SetVarArgs bs(p+n);
231  int i=0;
232  post(home, SetExpr::NT_INTER, bs, i);
233  if (i == 2) {
234  rel(home, bs[0], SOT_INTER, bs[1], srt, s);
235  } else {
236  if (srt == SRT_EQ)
237  rel(home, SOT_INTER, bs, s);
238  else {
239  SetVar bc(home,IntSet::empty,
241  rel(home, SOT_INTER, bs, bc);
242  rel(home, bc, srt, s);
243  }
244  }
245  }
246  break;
247  case SetExpr::NT_UNION:
248  {
249  SetVarArgs bs(p+n);
250  int i=0;
251  post(home, SetExpr::NT_UNION, bs, i);
252  if (i == 2) {
253  rel(home, bs[0], SOT_UNION, bs[1], srt, s);
254  } else {
255  if (srt == SRT_EQ)
256  rel(home, SOT_UNION, bs, s);
257  else {
258  SetVar bc(home,IntSet::empty,
260  rel(home, SOT_UNION, bs, bc);
261  rel(home, bc, srt, s);
262  }
263  }
264  }
265  break;
266  case SetExpr::NT_DUNION:
267  {
268  SetVarArgs bs(p+n);
269  int i=0;
270  post(home, SetExpr::NT_DUNION, bs, i);
271 
272  if (i == 2) {
273  if (neg) {
274  if (srt == SRT_CMPL) {
275  rel(home, bs[0], SOT_DUNION, bs[1], srt, s);
276  } else {
277  SetVar bc(home,IntSet::empty,
279  rel(home,s,SRT_CMPL,bc);
280  rel(home, bs[0], SOT_DUNION, bs[1], srt, bc);
281  }
282  } else {
283  rel(home, bs[0], SOT_DUNION, bs[1], srt, s);
284  }
285  } else {
286  if (neg) {
287  if (srt == SRT_CMPL) {
288  rel(home, SOT_DUNION, bs, s);
289  } else {
290  SetVar br(home,IntSet::empty,
292  rel(home, SOT_DUNION, bs, br);
293  if (srt == SRT_EQ)
294  rel(home, br, SRT_CMPL, s);
295  else {
296  SetVar bc(home,IntSet::empty,
298  rel(home, br, srt, bc);
299  rel(home, bc, SRT_CMPL, s);
300  }
301  }
302  } else {
303  if (srt == SRT_EQ)
304  rel(home, SOT_DUNION, bs, s);
305  else {
306  SetVar br(home,IntSet::empty,
308  rel(home, SOT_DUNION, bs, br);
309  rel(home, br, srt, s);
310  }
311  }
312  }
313  }
314  break;
315  default:
316  GECODE_NEVER;
317  }
318  }
319 
320  void
321  NNF::post(Home home, SetRelType srt, SetVar s, BoolVar b) const {
322  switch (t) {
323  case SetExpr::NT_VAR:
324  if (neg) {
325  switch (srt) {
326  case SRT_EQ:
327  rel(home, u.a.x->x, SRT_CMPL, s, b);
328  break;
329  case SRT_CMPL:
330  rel(home, u.a.x->x, SRT_EQ, s, b);
331  break;
332  default:
333  SetVar bc(home,IntSet::empty,
335  rel(home, s, SRT_CMPL, bc);
336  rel(home, u.a.x->x, srt, bc, b);
337  break;
338  }
339  } else
340  rel(home, u.a.x->x, srt, s, b);
341  break;
342  case SetExpr::NT_CONST:
343  {
344  IntSet ss;
345  if (neg) {
346  IntSetRanges sr(u.a.x->s);
347  Set::RangesCompl<IntSetRanges> src(sr);
348  ss = IntSet(src);
349  } else {
350  ss = u.a.x->s;
351  }
352  dom(home, s, srt, ss, b);
353  }
354  break;
355  case SetExpr::NT_LEXP:
356  {
357  IntVar iv = u.a.x->e.post(home,ICL_DEF);
358  if (neg) {
359  SetVar ic(home,IntSet::empty,
361  rel(home, iv, SRT_CMPL, ic);
362  rel(home,ic,srt,s,b);
363  } else {
364  rel(home,iv,srt,s,b);
365  }
366  }
367  case SetExpr::NT_INTER:
368  {
369  SetVarArgs bs(p+n);
370  int i=0;
371  post(home, SetExpr::NT_INTER, bs, i);
372  SetVar br(home,IntSet::empty,
374  rel(home, SOT_INTER, bs, br);
375  rel(home, br, srt, s, b);
376  }
377  break;
378  case SetExpr::NT_UNION:
379  {
380  SetVarArgs bs(p+n);
381  int i=0;
382  post(home, SetExpr::NT_UNION, bs, i);
383  SetVar br(home,IntSet::empty,
385  rel(home, SOT_UNION, bs, br);
386  rel(home, br, srt, s, b);
387  }
388  break;
389  case SetExpr::NT_DUNION:
390  {
391  SetVarArgs bs(p+n);
392  int i=0;
393  post(home, SetExpr::NT_DUNION, bs, i);
394 
395  if (neg) {
396  SetVar br(home,IntSet::empty,
398  rel(home, SOT_DUNION, bs, br);
399  if (srt == SRT_CMPL)
400  rel(home, br, SRT_EQ, s, b);
401  else if (srt == SRT_EQ)
402  rel(home, br, SRT_CMPL, s, b);
403  else {
404  SetVar bc(home,IntSet::empty,
406  rel(home, br, srt, bc);
407  rel(home, bc, SRT_CMPL, s, b);
408  }
409  } else {
410  SetVar br(home,IntSet::empty,
412  rel(home, SOT_DUNION, bs, br);
413  rel(home, br, srt, s, b);
414  }
415  }
416  break;
417  default:
418  GECODE_NEVER;
419  }
420  }
421 
422  void
423  NNF::post(Home home, NodeType t, SetVarArgs& b, int& i) const {
424  if (this->t != t) {
425  switch (this->t) {
426  case SetExpr::NT_VAR:
427  if (neg) {
428  SetVar xc(home,IntSet::empty,
430  rel(home, xc, SRT_CMPL, u.a.x->x);
431  b[i++]=xc;
432  } else {
433  b[i++]=u.a.x->x;
434  }
435  break;
436  default:
437  {
438  SetVar s(home,IntSet::empty,
440  post(home,SRT_EQ,s);
441  b[i++] = s;
442  }
443  break;
444  }
445  } else {
446  u.b.l->post(home, t, b, i);
447  u.b.r->post(home, t, b, i);
448  }
449  }
450 
451  void
452  NNF::post(Home home, SetRelType srt, const NNF* n) const {
453  if (n->t == SetExpr::NT_VAR && !n->neg) {
454  post(home,srt,n->u.a.x->x);
455  } else if (t == SetExpr::NT_VAR && !neg) {
456  SetRelType n_srt;
457  switch (srt) {
458  case SRT_SUB: n_srt = SRT_SUP; break;
459  case SRT_SUP: n_srt = SRT_SUB; break;
460  default: n_srt = srt;
461  }
462  n->post(home,n_srt,this);
463  } else {
464  SetVar nx(home,IntSet::empty,
466  n->post(home,SRT_EQ,nx);
467  post(home,srt,nx);
468  }
469  }
470 
471  void
472  NNF::post(Home home, BoolVar b, bool t,
473  SetRelType srt, const NNF* n) const {
474  if (t) {
475  if (n->t == SetExpr::NT_VAR && !n->neg) {
476  post(home,srt,n->u.a.x->x,b);
477  } else if (t == SetExpr::NT_VAR && !neg) {
478  SetRelType n_srt;
479  switch (srt) {
480  case SRT_SUB: n_srt = SRT_SUP; break;
481  case SRT_SUP: n_srt = SRT_SUB; break;
482  default: n_srt = srt;
483  }
484  n->post(home,b,true,n_srt,this);
485  } else {
486  SetVar nx(home,IntSet::empty,
488  n->post(home,SRT_EQ,nx);
489  post(home,srt,nx,b);
490  }
491  } else if (srt == SRT_EQ) {
492  post(home,b,true,SRT_NQ,n);
493  } else if (srt == SRT_NQ) {
494  post(home,b,true,SRT_EQ,n);
495  } else {
496  BoolVar nb(home,0,1);
497  rel(home,b,IRT_NQ,nb);
498  post(home,nb,true,srt,n);
499  }
500  }
501 
502  NNF*
503  NNF::nnf(Region& r, Node* n, bool neg) {
504  switch (n->t) {
505  case SetExpr::NT_VAR:
506  case SetExpr::NT_CONST:
507  case SetExpr::NT_LEXP:
508  {
509  NNF* x = new (r) NNF;
510  x->t = n->t; x->neg = neg; x->u.a.x = n;
511  if (neg) {
512  x->p = 0; x->n = 1;
513  } else {
514  x->p = 1; x->n = 0;
515  }
516  return x;
517  }
518  case SetExpr::NT_CMPL:
519  return nnf(r,n->l,!neg);
520  case SetExpr::NT_INTER:
521  case SetExpr::NT_UNION:
522  case SetExpr::NT_DUNION:
523  {
524  NodeType t; bool xneg;
525  if (n->t == SetExpr::NT_DUNION) {
526  t = n->t; xneg = neg; neg = false;
527  } else {
528  t = ((n->t == SetExpr::NT_INTER) == neg) ?
530  xneg = false;
531  }
532  NNF* x = new (r) NNF;
533  x->neg = xneg;
534  x->t = t;
535  x->u.b.l = nnf(r,n->l,neg);
536  x->u.b.r = nnf(r,n->r,neg);
537  int p_l, n_l;
538  if ((x->u.b.l->t == t) || (x->u.b.l->t == SetExpr::NT_VAR)) {
539  p_l=x->u.b.l->p; n_l=x->u.b.l->n;
540  } else {
541  p_l=1; n_l=0;
542  }
543  int p_r, n_r;
544  if ((x->u.b.r->t == t) || (x->u.b.r->t == SetExpr::NT_VAR)) {
545  p_r=x->u.b.r->p; n_r=x->u.b.r->n;
546  } else {
547  p_r=1; n_r=0;
548  }
549  x->p = p_l+p_r;
550  x->n = n_l+n_r;
551  return x;
552  }
553  default:
554  GECODE_NEVER;
555  }
556  GECODE_NEVER;
557  return NULL;
558  }
559  }
560 
561  SetExpr::SetExpr(const SetVar& x) : n(new Node) {
562  n->same = 1;
563  n->t = NT_VAR;
564  n->l = NULL;
565  n->r = NULL;
566  n->x = x;
567  }
568 
569  SetExpr::SetExpr(const IntSet& s) : n(new Node) {
570  n->same = 1;
571  n->t = NT_CONST;
572  n->l = NULL;
573  n->r = NULL;
574  n->s = s;
575  }
576 
577  SetExpr::SetExpr(const LinIntExpr& e) : n(new Node) {
578  n->same = 1;
579  n->t = NT_LEXP;
580  n->l = NULL;
581  n->r = NULL;
582  n->e = e;
583  }
584 
586  : n(new Node) {
587  int ls = same(t,l.n->t) ? l.n->same : 1;
588  int rs = same(t,r.n->t) ? r.n->same : 1;
589  n->same = ls+rs;
590  n->t = t;
591  n->l = l.n;
592  n->l->use++;
593  n->r = r.n;
594  n->r->use++;
595  }
596 
598  (void) t;
599  assert(t == NT_CMPL);
600  if (l.n->t == NT_CMPL) {
601  n = l.n->l;
602  n->use++;
603  } else {
604  n = new Node;
605  n->same = 1;
606  n->t = NT_CMPL;
607  n->l = l.n;
608  n->l->use++;
609  n->r = NULL;
610  }
611  }
612 
613  const SetExpr&
615  if (this != &e) {
616  if (n != NULL && n->decrement())
617  delete n;
618  n = e.n;
619  n->use++;
620  }
621  return *this;
622  }
623 
625  if (n != NULL && n->decrement())
626  delete n;
627  }
628 
629  SetExpr::SetExpr(const SetExpr& e) : n(e.n) {
630  n->use++;
631  }
632 
633  SetVar
634  SetExpr::post(Home home) const {
635  Region r(home);
636  SetVar s(home,IntSet::empty,
638  NNF::nnf(r,n,false)->post(home,SRT_EQ,s);
639  return s;
640  }
641 
642  void
643  SetExpr::post(Home home, SetRelType srt, const SetExpr& e) const {
644  Region r(home);
645  return NNF::nnf(r,n,false)->post(home,srt,NNF::nnf(r,e.n,false));
646  }
647  void
648  SetExpr::post(Home home, BoolVar b, bool t,
649  SetRelType srt, const SetExpr& e) const {
650  Region r(home);
651  return NNF::nnf(r,n,false)->post(home,b,t,srt,
652  NNF::nnf(r,e.n,false));
653  }
654 
655  SetExpr
656  operator &(const SetExpr& l, const SetExpr& r) {
657  return SetExpr(l,SetExpr::NT_INTER,r);
658  }
659  SetExpr
660  operator |(const SetExpr& l, const SetExpr& r) {
661  return SetExpr(l,SetExpr::NT_UNION,r);
662  }
663  SetExpr
664  operator +(const SetExpr& l, const SetExpr& r) {
665  return SetExpr(l,SetExpr::NT_DUNION,r);
666  }
667  SetExpr
668  operator -(const SetExpr& e) {
669  return SetExpr(e,SetExpr::NT_CMPL);
670  }
671  SetExpr
672  operator -(const SetExpr& l, const SetExpr& r) {
673  return SetExpr(l,SetExpr::NT_INTER,-r);
674  }
675  SetExpr
676  singleton(const LinIntExpr& e) {
677  return SetExpr(e);
678  }
679 
680  SetExpr
681  inter(const SetVarArgs& x) {
682  if (x.size() == 0)
684  SetExpr r(x[0]);
685  for (int i=1; i<x.size(); i++)
686  r = (r & x[i]);
687  return r;
688  }
689  SetExpr
690  setunion(const SetVarArgs& x) {
691  if (x.size() == 0)
692  return SetExpr(IntSet::empty);
693  SetExpr r(x[0]);
694  for (int i=1; i<x.size(); i++)
695  r = (r | x[i]);
696  return r;
697  }
698  SetExpr
699  setdunion(const SetVarArgs& x) {
700  if (x.size() == 0)
701  return SetExpr(IntSet::empty);
702  SetExpr r(x[0]);
703  for (int i=1; i<x.size(); i++)
704  r = (r + x[i]);
705  return r;
706  }
707 
708  namespace MiniModel {
711  public:
716  SNLE_MAX
717  } t;
722  : t(t0), e(e0) {}
724  virtual IntVar post(Home home, IntVar* ret, IntConLevel) const {
725  IntVar m = result(home,ret);
726  switch (t) {
727  case SNLE_CARD:
728  cardinality(home, e.post(home), m);
729  break;
730  case SNLE_MIN:
731  min(home, e.post(home), m);
732  break;
733  case SNLE_MAX:
734  max(home, e.post(home), m);
735  break;
736  default:
737  GECODE_NEVER;
738  break;
739  }
740  return m;
741  }
742  virtual void post(Home home, IntRelType irt, int c,
743  IntConLevel icl) const {
744  if (t==SNLE_CARD && irt!=IRT_NQ) {
745  switch (irt) {
746  case IRT_LQ:
747  cardinality(home, e.post(home),
748  0U,
749  static_cast<unsigned int>(c));
750  break;
751  case IRT_LE:
752  cardinality(home, e.post(home),
753  0U,
754  static_cast<unsigned int>(c-1));
755  break;
756  case IRT_GQ:
757  cardinality(home, e.post(home),
758  static_cast<unsigned int>(c),
760  break;
761  case IRT_GR:
762  cardinality(home, e.post(home),
763  static_cast<unsigned int>(c+1),
765  break;
766  case IRT_EQ:
767  cardinality(home, e.post(home),
768  static_cast<unsigned int>(c),
769  static_cast<unsigned int>(c));
770  break;
771  default:
772  GECODE_NEVER;
773  }
774  } else if (t==SNLE_MIN && (irt==IRT_GR || irt==IRT_GQ)) {
775  c = (irt==IRT_GQ ? c : c+1);
776  dom(home, e.post(home), SRT_SUB, c, Set::Limits::max);
777  } else if (t==SNLE_MAX && (irt==IRT_LE || irt==IRT_LQ)) {
778  c = (irt==IRT_LQ ? c : c-1);
779  dom(home, e.post(home), SRT_SUB, Set::Limits::min, c);
780  } else {
781  rel(home, post(home,NULL,icl), irt, c);
782  }
783  }
784  virtual void post(Home home, IntRelType irt, int c,
785  BoolVar b, IntConLevel icl) const {
786  if (t==SNLE_MIN && (irt==IRT_GR || irt==IRT_GQ)) {
787  c = (irt==IRT_GQ ? c : c+1);
788  dom(home, e.post(home), SRT_SUB, c, Set::Limits::max, b);
789  } else if (t==SNLE_MAX && (irt==IRT_LE || irt==IRT_LQ)) {
790  c = (irt==IRT_LQ ? c : c-1);
791  dom(home, e.post(home), SRT_SUB, Set::Limits::min, c, b);
792  } else {
793  rel(home, post(home,NULL,icl), irt, c, b);
794  }
795  }
796  };
797  }
798 
799  LinIntExpr
800  cardinality(const SetExpr& e) {
803  }
804  LinIntExpr
805  min(const SetExpr& e) {
808  }
809  LinIntExpr
810  max(const SetExpr& e) {
813  }
814 
815  /*
816  * Posting set expressions
817  *
818  */
819  SetVar
820  expr(Home home, const SetExpr& e) {
821  if (!home.failed())
822  return e.post(home);
824  return x;
825  }
826 
827 
828 }
829 
830 #endif
831 
832 // STATISTICS: minimodel-any
bool failed(void) const
Check whether corresponding space is failed.
Definition: core.hpp:3369
FloatVal operator-(const FloatVal &x)
Definition: val.hpp:172
int same
Number of variables in subtree with same type (for INTER and UNION)
Definition: set-expr.cpp:60
SetExpr singleton(const LinIntExpr &e)
Singleton expression.
Definition: set-expr.cpp:676
SetRelType
Common relation types for sets.
Definition: set.hh:644
IntConLevel
Consistency levels for integer propagators.
Definition: int.hh:935
const SetExpr & operator=(const SetExpr &e)
Assignment operator.
Definition: set-expr.cpp:614
SetExpr operator&(const SetExpr &l, const SetExpr &r)
Intersection of set expressions.
Definition: set-expr.cpp:656
void post(Home home, Term *t, int n, FloatRelType frt, FloatVal c)
Post propagator for linear constraint over floats.
Definition: post.cpp:228
const int min
Smallest allowed integer in integer set.
Definition: set.hh:101
void rfree(void *p)
Free memory block starting at p.
Definition: heap.hpp:355
int size(void) const
Return size of array (number of elements)
Definition: array.hpp:1662
LinIntExpr e
Possibly a linear expression.
Definition: set-expr.cpp:70
bool neg
Is formula negative.
Definition: set-expr.cpp:138
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition: arithmetic.cpp:57
Less or equal ( )
Definition: int.hh:904
virtual IntVar post(Home home, IntVar *ret, IntConLevel) const
Post expression.
Definition: set-expr.cpp:724
void dom(Home home, FloatVar x, FloatVal n)
Propagates .
Definition: dom.cpp:44
Base class for non-linear expressions over integer variables.
Definition: minimodel.hh:107
void * ralloc(size_t s)
Allocate s bytes from heap.
Definition: heap.hpp:341
SetVar x
Possibly a variable.
Definition: set-expr.cpp:66
NNF * l
Left subtree.
Definition: set-expr.cpp:127
Handle to region.
Definition: region.hpp:61
Greater ( )
Definition: int.hh:907
union Gecode::@528::NNF::@60 u
Union depending on nodetype t.
virtual void post(Home home, IntRelType irt, int c, BoolVar b, IntConLevel icl) const
Post reified expression to be in relation irt with c.
Definition: set-expr.cpp:784
Superset ( )
Definition: set.hh:648
Complement.
Definition: set.hh:650
const unsigned int card
Maximum cardinality of an integer set.
Definition: set.hh:103
const int max
Largest allowed integer in integer set.
Definition: set.hh:99
Linear expression.
Definition: minimodel.hh:1075
Greater or equal ( )
Definition: int.hh:906
Set expressions
Definition: minimodel.hh:1069
Node * l
Subexpressions.
Definition: set-expr.cpp:64
Heap heap
The single global heap.
Definition: heap.cpp:49
SetExpr setdunion(const SetVarArgs &x)
Disjoint union of set variables.
Definition: set-expr.cpp:699
Gecode::FloatVal c(-8, 8)
bool same(const ConstView< ViewA > &, const ConstView< ViewB > &)
Test whether two views are the same.
Definition: view.hpp:603
Gecode::IntArgs i(4, 1, 2, 3, 4)
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:238
Equality ( )
Definition: int.hh:902
IntSet s
Possibly a constant.
Definition: set-expr.cpp:68
IntRelType
Relation types for integers.
Definition: int.hh:901
FloatVal operator+(const FloatVal &x)
Definition: val.hpp:168
NodeType t
Type of expression.
Definition: set-expr.cpp:62
struct Gecode::@528::NNF::@60::@62 a
For atomic nodes.
SetExpr(void)
Default constructor.
Definition: set-expr.hpp:48
unsigned int size(I &i)
Size of all ranges of range iterator i.
Node(void)
Default constructor.
Definition: set-expr.cpp:87
Subset ( )
Definition: set.hh:647
virtual void post(Home home, IntRelType irt, int c, IntConLevel icl) const
Post expression to be in relation irt with c.
Definition: set-expr.cpp:742
Intersection
Definition: set.hh:664
Less ( )
Definition: int.hh:905
NodeType
Type of set expression.
Definition: minimodel.hh:1072
Integer sets.
Definition: int.hh:169
SetExpr setunion(const SetVarArgs &x)
Union of set variables.
Definition: set-expr.cpp:690
Integer valued set expressions.
Definition: set-expr.cpp:710
NodeType t
Type of node.
Definition: set-expr.cpp:117
static const IntSet empty
Empty set.
Definition: int.hh:260
Boolean integer variables.
Definition: int.hh:489
LinIntExpr cardinality(const SetExpr &e)
Cardinality of set expression.
Definition: set-expr.cpp:800
SetExpr inter(const SetVarArgs &x)
Intersection of set variables.
Definition: set-expr.cpp:681
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition: arithmetic.cpp:75
struct Gecode::@528::NNF::@60::@61 b
For binary nodes (and, or, eqv)
Union.
Definition: set.hh:662
Passing set variables.
Definition: set.hh:490
BoolVar expr(Home home, const BoolExpr &e, IntConLevel icl)
Post Boolean expression and return its value.
Definition: bool-expr.cpp:632
Set variables
Definition: set.hh:129
Node for set expression
Definition: set-expr.cpp:55
Linear expressions over integer variables.
Definition: minimodel.hh:138
Disjoint union.
Definition: set.hh:663
Integer variables.
Definition: int.hh:348
#define forceinline
Definition: config.hpp:129
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
Definition: rel.cpp:47
The default consistency for a constraint.
Definition: int.hh:939
unsigned int use
Nodes are reference counted.
Definition: set-expr.cpp:58
Equality ( )
Definition: set.hh:645
SetExpr e
The expression.
Definition: set-expr.cpp:719
#define GECODE_MINIMODEL_EXPORT
Definition: minimodel.hh:82
SetExpr operator|(const SetExpr &l, const SetExpr &r)
Union of set expressions.
Definition: set-expr.cpp:660
NNF * r
Right subtree.
Definition: set-expr.cpp:129
Disequality ( )
Definition: set.hh:646
SetNonLinIntExprType
The expression type.
Definition: set-expr.cpp:713
Disequality ( )
Definition: int.hh:903
Node * x
Pointer to corresponding Boolean expression node.
Definition: set-expr.cpp:134
Home class for posting propagators
Definition: core.hpp:717
~SetExpr(void)
Destructor.
Definition: set-expr.cpp:624
#define GECODE_NEVER
Assert that this command is never executed.
Definition: macros.hpp:60
SetNonLinIntExpr(const SetExpr &e0, SetNonLinIntExprType t0)
Constructor.
Definition: set-expr.cpp:721
bool decrement(void)
Decrement reference count and possibly free memory.
Definition: set-expr.cpp:99
SetVar post(Home home) const
Post propagators for expression.
Definition: set-expr.cpp:634
int p
Number of positive literals for node type.
Definition: set-expr.cpp:119