Generated on Sat Feb 7 2015 02:01:29 for Gecode by doxygen 1.8.9.1
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-12-16 23:11:23 +0100 (Mon, 16 Dec 2013) $ by $Author: tack $
13  * $Revision: 14086 $
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;
117  NodeType t;
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  SetRelType invsrt;
353  switch (srt) {
354  case SRT_SUB: invsrt = SRT_SUP; break;
355  case SRT_SUP: invsrt = SRT_SUB; break;
356  case SRT_LQ: invsrt = SRT_GQ; break;
357  case SRT_LE: invsrt = SRT_GR; break;
358  case SRT_GQ: invsrt = SRT_LQ; break;
359  case SRT_GR: invsrt = SRT_LE; break;
360  case SRT_EQ:
361  case SRT_NQ:
362  case SRT_DISJ:
363  case SRT_CMPL:
364  invsrt = srt;
365  break;
366  }
367  dom(home, s, invsrt, ss, b);
368  }
369  break;
370  case SetExpr::NT_LEXP:
371  {
372  IntVar iv = u.a.x->e.post(home,ICL_DEF);
373  if (neg) {
374  SetVar ic(home,IntSet::empty,
376  rel(home, iv, SRT_CMPL, ic);
377  rel(home,ic,srt,s,b);
378  } else {
379  rel(home,iv,srt,s,b);
380  }
381  }
382  case SetExpr::NT_INTER:
383  {
384  SetVarArgs bs(p+n);
385  int i=0;
386  post(home, SetExpr::NT_INTER, bs, i);
387  SetVar br(home,IntSet::empty,
389  rel(home, SOT_INTER, bs, br);
390  rel(home, br, srt, s, b);
391  }
392  break;
393  case SetExpr::NT_UNION:
394  {
395  SetVarArgs bs(p+n);
396  int i=0;
397  post(home, SetExpr::NT_UNION, bs, i);
398  SetVar br(home,IntSet::empty,
400  rel(home, SOT_UNION, bs, br);
401  rel(home, br, srt, s, b);
402  }
403  break;
404  case SetExpr::NT_DUNION:
405  {
406  SetVarArgs bs(p+n);
407  int i=0;
408  post(home, SetExpr::NT_DUNION, bs, i);
409 
410  if (neg) {
411  SetVar br(home,IntSet::empty,
413  rel(home, SOT_DUNION, bs, br);
414  if (srt == SRT_CMPL)
415  rel(home, br, SRT_EQ, s, b);
416  else if (srt == SRT_EQ)
417  rel(home, br, SRT_CMPL, s, b);
418  else {
419  SetVar bc(home,IntSet::empty,
421  rel(home, br, srt, bc);
422  rel(home, bc, SRT_CMPL, s, b);
423  }
424  } else {
425  SetVar br(home,IntSet::empty,
427  rel(home, SOT_DUNION, bs, br);
428  rel(home, br, srt, s, b);
429  }
430  }
431  break;
432  default:
433  GECODE_NEVER;
434  }
435  }
436 
437  void
438  NNF::post(Home home, NodeType t, SetVarArgs& b, int& i) const {
439  if (this->t != t) {
440  switch (this->t) {
441  case SetExpr::NT_VAR:
442  if (neg) {
443  SetVar xc(home,IntSet::empty,
445  rel(home, xc, SRT_CMPL, u.a.x->x);
446  b[i++]=xc;
447  } else {
448  b[i++]=u.a.x->x;
449  }
450  break;
451  default:
452  {
453  SetVar s(home,IntSet::empty,
455  post(home,SRT_EQ,s);
456  b[i++] = s;
457  }
458  break;
459  }
460  } else {
461  u.b.l->post(home, t, b, i);
462  u.b.r->post(home, t, b, i);
463  }
464  }
465 
466  void
467  NNF::post(Home home, SetRelType srt, const NNF* n) const {
468  if (n->t == SetExpr::NT_VAR && !n->neg) {
469  post(home,srt,n->u.a.x->x);
470  } else if (t == SetExpr::NT_VAR && !neg) {
471  SetRelType n_srt;
472  switch (srt) {
473  case SRT_SUB: n_srt = SRT_SUP; break;
474  case SRT_SUP: n_srt = SRT_SUB; break;
475  default: n_srt = srt;
476  }
477  n->post(home,n_srt,this);
478  } else {
479  SetVar nx(home,IntSet::empty,
481  n->post(home,SRT_EQ,nx);
482  post(home,srt,nx);
483  }
484  }
485 
486  void
487  NNF::post(Home home, BoolVar b, bool pt,
488  SetRelType srt, const NNF* n) const {
489  if (pt) {
490  if (n->t == SetExpr::NT_VAR && !n->neg) {
491  post(home,srt,n->u.a.x->x,b);
492  } else if (t == SetExpr::NT_VAR && !neg) {
493  SetRelType n_srt;
494  switch (srt) {
495  case SRT_SUB: n_srt = SRT_SUP; break;
496  case SRT_SUP: n_srt = SRT_SUB; break;
497  default: n_srt = srt;
498  }
499  n->post(home,b,true,n_srt,this);
500  } else {
501  SetVar nx(home,IntSet::empty,
503  n->post(home,SRT_EQ,nx);
504  post(home,srt,nx,b);
505  }
506  } else if (srt == SRT_EQ) {
507  post(home,b,true,SRT_NQ,n);
508  } else if (srt == SRT_NQ) {
509  post(home,b,true,SRT_EQ,n);
510  } else {
511  BoolVar nb(home,0,1);
512  rel(home,b,IRT_NQ,nb);
513  post(home,nb,true,srt,n);
514  }
515  }
516 
517  NNF*
518  NNF::nnf(Region& r, Node* n, bool neg) {
519  switch (n->t) {
520  case SetExpr::NT_VAR:
521  case SetExpr::NT_CONST:
522  case SetExpr::NT_LEXP:
523  {
524  NNF* x = new (r) NNF;
525  x->t = n->t; x->neg = neg; x->u.a.x = n;
526  if (neg) {
527  x->p = 0; x->n = 1;
528  } else {
529  x->p = 1; x->n = 0;
530  }
531  return x;
532  }
533  case SetExpr::NT_CMPL:
534  return nnf(r,n->l,!neg);
535  case SetExpr::NT_INTER:
536  case SetExpr::NT_UNION:
537  case SetExpr::NT_DUNION:
538  {
539  NodeType t; bool xneg;
540  if (n->t == SetExpr::NT_DUNION) {
541  t = n->t; xneg = neg; neg = false;
542  } else {
543  t = ((n->t == SetExpr::NT_INTER) == neg) ?
545  xneg = false;
546  }
547  NNF* x = new (r) NNF;
548  x->neg = xneg;
549  x->t = t;
550  x->u.b.l = nnf(r,n->l,neg);
551  x->u.b.r = nnf(r,n->r,neg);
552  int p_l, n_l;
553  if ((x->u.b.l->t == t) || (x->u.b.l->t == SetExpr::NT_VAR)) {
554  p_l=x->u.b.l->p; n_l=x->u.b.l->n;
555  } else {
556  p_l=1; n_l=0;
557  }
558  int p_r, n_r;
559  if ((x->u.b.r->t == t) || (x->u.b.r->t == SetExpr::NT_VAR)) {
560  p_r=x->u.b.r->p; n_r=x->u.b.r->n;
561  } else {
562  p_r=1; n_r=0;
563  }
564  x->p = p_l+p_r;
565  x->n = n_l+n_r;
566  return x;
567  }
568  default:
569  GECODE_NEVER;
570  }
571  GECODE_NEVER;
572  return NULL;
573  }
574  }
575 
576  SetExpr::SetExpr(const SetVar& x) : n(new Node) {
577  n->same = 1;
578  n->t = NT_VAR;
579  n->l = NULL;
580  n->r = NULL;
581  n->x = x;
582  }
583 
584  SetExpr::SetExpr(const IntSet& s) : n(new Node) {
585  n->same = 1;
586  n->t = NT_CONST;
587  n->l = NULL;
588  n->r = NULL;
589  n->s = s;
590  }
591 
592  SetExpr::SetExpr(const LinIntExpr& e) : n(new Node) {
593  n->same = 1;
594  n->t = NT_LEXP;
595  n->l = NULL;
596  n->r = NULL;
597  n->e = e;
598  }
599 
601  : n(new Node) {
602  int ls = same(t,l.n->t) ? l.n->same : 1;
603  int rs = same(t,r.n->t) ? r.n->same : 1;
604  n->same = ls+rs;
605  n->t = t;
606  n->l = l.n;
607  n->l->use++;
608  n->r = r.n;
609  n->r->use++;
610  }
611 
613  (void) t;
614  assert(t == NT_CMPL);
615  if (l.n->t == NT_CMPL) {
616  n = l.n->l;
617  n->use++;
618  } else {
619  n = new Node;
620  n->same = 1;
621  n->t = NT_CMPL;
622  n->l = l.n;
623  n->l->use++;
624  n->r = NULL;
625  }
626  }
627 
628  const SetExpr&
630  if (this != &e) {
631  if (n != NULL && n->decrement())
632  delete n;
633  n = e.n;
634  n->use++;
635  }
636  return *this;
637  }
638 
640  if (n != NULL && n->decrement())
641  delete n;
642  }
643 
644  SetExpr::SetExpr(const SetExpr& e) : n(e.n) {
645  n->use++;
646  }
647 
648  SetVar
649  SetExpr::post(Home home) const {
650  Region r(home);
651  SetVar s(home,IntSet::empty,
653  NNF::nnf(r,n,false)->post(home,SRT_EQ,s);
654  return s;
655  }
656 
657  void
658  SetExpr::post(Home home, SetRelType srt, const SetExpr& e) const {
659  Region r(home);
660  return NNF::nnf(r,n,false)->post(home,srt,NNF::nnf(r,e.n,false));
661  }
662  void
663  SetExpr::post(Home home, BoolVar b, bool t,
664  SetRelType srt, const SetExpr& e) const {
665  Region r(home);
666  return NNF::nnf(r,n,false)->post(home,b,t,srt,
667  NNF::nnf(r,e.n,false));
668  }
669 
670  SetExpr
671  operator &(const SetExpr& l, const SetExpr& r) {
672  return SetExpr(l,SetExpr::NT_INTER,r);
673  }
674  SetExpr
675  operator |(const SetExpr& l, const SetExpr& r) {
676  return SetExpr(l,SetExpr::NT_UNION,r);
677  }
678  SetExpr
679  operator +(const SetExpr& l, const SetExpr& r) {
680  return SetExpr(l,SetExpr::NT_DUNION,r);
681  }
682  SetExpr
683  operator -(const SetExpr& e) {
684  return SetExpr(e,SetExpr::NT_CMPL);
685  }
686  SetExpr
687  operator -(const SetExpr& l, const SetExpr& r) {
688  return SetExpr(l,SetExpr::NT_INTER,-r);
689  }
690  SetExpr
691  singleton(const LinIntExpr& e) {
692  return SetExpr(e);
693  }
694 
695  SetExpr
696  inter(const SetVarArgs& x) {
697  if (x.size() == 0)
699  SetExpr r(x[0]);
700  for (int i=1; i<x.size(); i++)
701  r = (r & x[i]);
702  return r;
703  }
704  SetExpr
705  setunion(const SetVarArgs& x) {
706  if (x.size() == 0)
707  return SetExpr(IntSet::empty);
708  SetExpr r(x[0]);
709  for (int i=1; i<x.size(); i++)
710  r = (r | x[i]);
711  return r;
712  }
713  SetExpr
714  setdunion(const SetVarArgs& x) {
715  if (x.size() == 0)
716  return SetExpr(IntSet::empty);
717  SetExpr r(x[0]);
718  for (int i=1; i<x.size(); i++)
719  r = (r + x[i]);
720  return r;
721  }
722 
723  namespace MiniModel {
726  public:
731  SNLE_MAX
732  } t;
737  : t(t0), e(e0) {}
739  virtual IntVar post(Home home, IntVar* ret, IntConLevel) const {
740  IntVar m = result(home,ret);
741  switch (t) {
742  case SNLE_CARD:
743  cardinality(home, e.post(home), m);
744  break;
745  case SNLE_MIN:
746  min(home, e.post(home), m);
747  break;
748  case SNLE_MAX:
749  max(home, e.post(home), m);
750  break;
751  default:
752  GECODE_NEVER;
753  break;
754  }
755  return m;
756  }
757  virtual void post(Home home, IntRelType irt, int c,
758  IntConLevel icl) const {
759  if (t==SNLE_CARD && irt!=IRT_NQ) {
760  switch (irt) {
761  case IRT_LQ:
762  cardinality(home, e.post(home),
763  0U,
764  static_cast<unsigned int>(c));
765  break;
766  case IRT_LE:
767  cardinality(home, e.post(home),
768  0U,
769  static_cast<unsigned int>(c-1));
770  break;
771  case IRT_GQ:
772  cardinality(home, e.post(home),
773  static_cast<unsigned int>(c),
775  break;
776  case IRT_GR:
777  cardinality(home, e.post(home),
778  static_cast<unsigned int>(c+1),
780  break;
781  case IRT_EQ:
782  cardinality(home, e.post(home),
783  static_cast<unsigned int>(c),
784  static_cast<unsigned int>(c));
785  break;
786  default:
787  GECODE_NEVER;
788  }
789  } else if (t==SNLE_MIN && (irt==IRT_GR || irt==IRT_GQ)) {
790  c = (irt==IRT_GQ ? c : c+1);
791  dom(home, e.post(home), SRT_SUB, c, Set::Limits::max);
792  } else if (t==SNLE_MAX && (irt==IRT_LE || irt==IRT_LQ)) {
793  c = (irt==IRT_LQ ? c : c-1);
794  dom(home, e.post(home), SRT_SUB, Set::Limits::min, c);
795  } else {
796  rel(home, post(home,NULL,icl), irt, c);
797  }
798  }
799  virtual void post(Home home, IntRelType irt, int c,
800  BoolVar b, IntConLevel icl) const {
801  if (t==SNLE_MIN && (irt==IRT_GR || irt==IRT_GQ)) {
802  c = (irt==IRT_GQ ? c : c+1);
803  dom(home, e.post(home), SRT_SUB, c, Set::Limits::max, b);
804  } else if (t==SNLE_MAX && (irt==IRT_LE || irt==IRT_LQ)) {
805  c = (irt==IRT_LQ ? c : c-1);
806  dom(home, e.post(home), SRT_SUB, Set::Limits::min, c, b);
807  } else {
808  rel(home, post(home,NULL,icl), irt, c, b);
809  }
810  }
811  };
812  }
813 
814  LinIntExpr
815  cardinality(const SetExpr& e) {
818  }
819  LinIntExpr
820  min(const SetExpr& e) {
823  }
824  LinIntExpr
825  max(const SetExpr& e) {
828  }
829 
830  /*
831  * Posting set expressions
832  *
833  */
834  SetVar
835  expr(Home home, const SetExpr& e) {
836  if (!home.failed())
837  return e.post(home);
839  return x;
840  }
841 
842 
843 }
844 
845 #endif
846 
847 // STATISTICS: minimodel-any
struct Gecode::@534::NNF::@63::@65 a
For atomic nodes.
bool failed(void) const
Check whether corresponding space is failed.
Definition: core.hpp:3446
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:691
SetRelType
Common relation types for sets.
Definition: set.hh:644
IntConLevel
Consistency levels for integer propagators.
Definition: int.hh:937
const SetExpr & operator=(const SetExpr &e)
Assignment operator.
Definition: set-expr.cpp:629
SetExpr operator&(const SetExpr &l, const SetExpr &r)
Intersection of set expressions.
Definition: set-expr.cpp:671
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:906
virtual IntVar post(Home home, IntVar *ret, IntConLevel) const
Post expression.
Definition: set-expr.cpp:739
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:909
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:799
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:908
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:714
struct Gecode::@534::NNF::@63::@64 b
For binary nodes (and, or, eqv)
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)
union Gecode::@534::NNF::@63 u
Union depending on nodetype t.
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:238
Equality ( )
Definition: int.hh:904
IntSet s
Possibly a constant.
Definition: set-expr.cpp:68
IntRelType
Relation types for integers.
Definition: int.hh:903
FloatVal operator+(const FloatVal &x)
Definition: val.hpp:168
NodeType t
Type of expression.
Definition: set-expr.cpp:62
Less or equal ( )
Definition: set.hh:651
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:757
Intersection
Definition: set.hh:664
Less ( )
Definition: int.hh:907
NodeType
Type of set expression.
Definition: minimodel.hh:1072
Integer sets.
Definition: int.hh:171
Less ( )
Definition: set.hh:652
SetExpr setunion(const SetVarArgs &x)
Union of set variables.
Definition: set-expr.cpp:705
Integer valued set expressions.
Definition: set-expr.cpp:725
NodeType t
Type of node.
Definition: set-expr.cpp:117
static const IntSet empty
Empty set.
Definition: int.hh:262
Boolean integer variables.
Definition: int.hh:491
LinIntExpr cardinality(const SetExpr &e)
Cardinality of set expression.
Definition: set-expr.cpp:815
SetExpr inter(const SetVarArgs &x)
Intersection of set variables.
Definition: set-expr.cpp:696
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition: arithmetic.cpp:75
Union.
Definition: set.hh:662
Passing set variables.
Definition: set.hh:490
Greater or equal ( )
Definition: set.hh:653
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:350
#define forceinline
Definition: config.hpp:132
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
Definition: rel.cpp:47
The default consistency for a constraint.
Definition: int.hh:941
unsigned int use
Nodes are reference counted.
Definition: set-expr.cpp:58
Greater ( )
Definition: set.hh:654
Equality ( )
Definition: set.hh:645
Disjoint ( )
Definition: set.hh:649
SetExpr e
The expression.
Definition: set-expr.cpp:734
#define GECODE_MINIMODEL_EXPORT
Definition: minimodel.hh:82
SetExpr operator|(const SetExpr &l, const SetExpr &r)
Union of set expressions.
Definition: set-expr.cpp:675
NNF * r
Right subtree.
Definition: set-expr.cpp:129
Disequality ( )
Definition: set.hh:646
SetNonLinIntExprType
The expression type.
Definition: set-expr.cpp:728
Gecode toplevel namespace
Disequality ( )
Definition: int.hh:905
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:639
#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:736
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:649
int p
Number of positive literals for node type.
Definition: set-expr.cpp:119