Generated on Tue Feb 11 2025 17:33:26 for Gecode by doxygen 1.12.0
rel-op-const-vcc.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 *
6 * Contributing authors:
7 * Gabor Szokoli <szokoli@gecode.org>
8 *
9 * Copyright:
10 * Guido Tack, 2004, 2005
11 *
12 * This file is part of Gecode, the generic constraint
13 * development environment:
14 * http://www.gecode.org
15 *
16 * Permission is hereby granted, free of charge, to any person obtaining
17 * a copy of this software and associated documentation files (the
18 * "Software"), to deal in the Software without restriction, including
19 * without limitation the rights to use, copy, modify, merge, publish,
20 * distribute, sublicense, and/or sell copies of the Software, and to
21 * permit persons to whom the Software is furnished to do so, subject to
22 * the following conditions:
23 *
24 * The above copyright notice and this permission notice shall be
25 * included in all copies or substantial portions of the Software.
26 *
27 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
28 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
29 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
30 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
31 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
32 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
33 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 *
35 */
36
37#include <gecode/set.hh>
38#include <gecode/set/rel.hh>
39#include <gecode/set/rel-op.hh>
40
41namespace Gecode {
42 using namespace Gecode::Set;
43 using namespace Gecode::Set::Rel;
44 using namespace Gecode::Set::RelOp;
45
46 void
48 const IntSet& z) {
49 Set::Limits::check(y, "Set::rel");
50 Set::Limits::check(z, "Set::rel");
51 ConstSetView yv(home, y);
52 ConstSetView zv(home, z);
53
54 if (op==SOT_MINUS) {
55 switch (r) {
56 case SRT_EQ:
57 {
60 IntSet yc(yrc);
61 ConstSetView cy(home, yc);
65 ::post(home,cy,x,zv)));
66 }
67 break;
68 case SRT_LQ: case SRT_LE: case SRT_GQ: case SRT_GR:
69 {
72 IntSet yc(yrc);
73 ConstSetView cy(home, yc);
78 ::post(home,cy,x,tmp)));
79 dom(home,tmp,r,z);
80 }
81 break;
82 case SRT_NQ:
83 {
84 SetVar tmp(home);
87 ::post(home,tmp,zv)));
90 IntSet yc(yrc);
91 ConstSetView cy(home, yc);
95 ::post(home,cy,x,tmp)));
96 }
97 break;
98 case SRT_SUB:
99 {
102 IntSet yc(yrc);
103 ConstSetView cy(home, yc);
106 ::post(home,cy,x,zv)));
107
108 }
109 break;
110 case SRT_SUP:
111 {
112 // z <= tmp
113 SetVar tmp(home,z,Limits::min, Limits::max);
114 SetView xv(x);
115
118 IntSet yc(yrc);
119 ConstSetView cy(home, yc);
120
124 ::post(home,cy,xv,tmp)));
125 }
126 break;
127 case SRT_DISJ:
128 {
129 SetVar tmp(home);
130 SetView tmpv(tmp);
131 IntSetRanges zi(z);
132 GECODE_ME_FAIL( tmpv.excludeI(home, zi));
133
136 IntSet yc(yrc);
137 ConstSetView cy(home, yc);
141 ::post(home,cy,x,tmp)));
142 }
143 break;
144 case SRT_CMPL:
145 {
146 SetView xv(x);
151 ConstSetView>::post(home, yv, cx, zv)));
152 }
153 break;
154 default:
155 throw UnknownRelation("Set::rel");
156 }
157 } else {
158 rel(home, y, op, x, r, z);
159 }
160 }
161
162}
163
164// STATISTICS: set-post
Home class for posting propagators
Definition core.hpp:856
Range iterator for integer sets.
Definition int.hh:292
Integer sets.
Definition int.hh:174
static const IntSet empty
Empty set.
Definition int.hh:283
Exception: Unknown relation passed as argument
Definition exception.hpp:87
Set variables
Definition set.hh:127
Complement set view.
Definition view.hpp:769
Constant view.
Definition view.hpp:186
Range iterator for the greatest lower bound.
Definition var-imp.hpp:359
A complement iterator spezialized for the BndSet limits.
Definition var-imp.hpp:293
Propagator for ternary intersection
Definition rel-op.hh:124
Propagator for the superset of intersection
Definition rel-op.hh:63
Propagator for ternary union
Definition rel-op.hh:154
Propagator for negated equality
Definition rel.hh:268
Set view for set variables
Definition view.hpp:56
ModEvent excludeI(Space &home, I &i)
Remove range sequence described by i from least upper bound.
Definition set.hpp:160
#define GECODE_ES_FAIL(es)
Check whether execution status es is failed, and fail space home.
Definition macros.hpp:103
#define GECODE_ME_FAIL(me)
Check whether modification event me is failed, and fail space home.
Definition macros.hpp:77
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVar x1)
Post propagator for .
Definition rel.cpp:68
SetOpType
Common operations for sets.
Definition set.hh:660
SetRelType
Common relation types for sets.
Definition set.hh:643
@ SOT_MINUS
Difference.
Definition set.hh:664
@ SRT_GQ
Greater or equal ( )
Definition set.hh:652
@ SRT_CMPL
Complement.
Definition set.hh:649
@ SRT_GR
Greater ( )
Definition set.hh:653
@ SRT_LQ
Less or equal ( )
Definition set.hh:650
@ SRT_NQ
Disequality ( )
Definition set.hh:645
@ SRT_LE
Less ( )
Definition set.hh:651
@ SRT_EQ
Equality ( )
Definition set.hh:644
@ SRT_SUP
Superset ( )
Definition set.hh:647
@ SRT_DISJ
Disjoint ( )
Definition set.hh:648
@ SRT_SUB
Subset ( )
Definition set.hh:646
const int min
Smallest allowed integer value.
Definition int.hh:118
const int max
Largest allowed integer value.
Definition int.hh:116
void check(int n, const char *l)
Check whether integer n is in range, otherwise throw overflow exception with information l.
Definition limits.hpp:37
const int min
Smallest allowed integer in integer set.
Definition set.hh:99
const int max
Largest allowed integer in integer set.
Definition set.hh:97
Standard set operation propagators.
Definition rel-op.hh:46
Standard set relation propagators.
Definition rel.hh:45
Finite integer sets.
Definition var-imp.hpp:137
Gecode toplevel namespace
Post propagator for SetVar SetOpType SetVar SetRelType r
Definition set.hh:767
void dom(Home home, FloatVar x, FloatVal n)
Propagates .
Definition dom.cpp:40
Post propagator for SetVar SetOpType SetVar SetRelType SetVar z
Definition set.hh:767
Post propagator for SetVar SetOpType SetVar y
Definition set.hh:767
TFE post(PropagatorGroup g)
Only post functions (but not propagators) from g are considered.
Definition filter.cpp:138
Post propagator for SetVar x
Definition set.hh:767
Post propagator for SetVar SetOpType op
Definition set.hh:767