Generated on Thu Jul 21 2022 00:00:00 for Gecode by doxygen 1.9.5
set.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 * This file is part of Gecode, the generic constraint
10 * development environment:
11 * http://www.gecode.org
12 *
13 * Permission is hereby granted, free of charge, to any person obtaining
14 * a copy of this software and associated documentation files (the
15 * "Software"), to deal in the Software without restriction, including
16 * without limitation the rights to use, copy, modify, merge, publish,
17 * distribute, sublicense, and/or sell copies of the Software, and to
18 * permit persons to whom the Software is furnished to do so, subject to
19 * the following conditions:
20 *
21 * The above copyright notice and this permission notice shall be
22 * included in all copies or substantial portions of the Software.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 *
32 */
33
34namespace Gecode { namespace Int { namespace Dom {
35
36 template<class View, ReifyMode rm>
39 (Home home, View x, const IntSet& s, BoolView b)
40 : ReUnaryPropagator<View,PC_INT_DOM,BoolView>(home,x,b), is(s) {
41 home.notice(*this,AP_DISPOSE);
42 }
43
44 template<class View, ReifyMode rm>
45 forceinline size_t
47 home.ignore(*this,AP_DISPOSE);
48 is.~IntSet();
50 return sizeof(*this);
51 }
52
53 template<class View, ReifyMode rm>
55 ReIntSet<View,rm>::post(Home home, View x, const IntSet& s, BoolView b) {
56 if (s.ranges() == 0) {
57 if (rm == RM_PMI)
58 return ES_OK;
59 GECODE_ME_CHECK(b.zero(home));
60 } else if (s.ranges() == 1) {
61 return ReRange<View,rm>::post(home,x,s.min(),s.max(),b);
62 } else if (b.one()) {
63 if (rm == RM_PMI)
64 return ES_OK;
65 IntSetRanges i_is(s);
66 GECODE_ME_CHECK(x.inter_r(home,i_is,false));
67 } else if (b.zero()) {
68 if (rm == RM_IMP)
69 return ES_OK;
70 IntSetRanges i_is(s);
71 GECODE_ME_CHECK(x.minus_r(home,i_is,false));
72 } else {
73 (void) new (home) ReIntSet<View,rm>(home,x,s,b);
74 }
75 return ES_OK;
76 }
77
78
79 template<class View, ReifyMode rm>
82 : ReUnaryPropagator<View,PC_INT_DOM,BoolView>(home,p), is(p.is) {
83 }
84
85 template<class View, ReifyMode rm>
86 Actor*
88 return new (home) ReIntSet(home,*this);
89 }
90
91 template<class View, ReifyMode rm>
94 IntSetRanges i_is(is);
95 if (b.one()) {
96 if (rm != RM_PMI)
97 GECODE_ME_CHECK(x0.inter_r(home,i_is,false));
98 return home.ES_SUBSUMED(*this);
99 }
100 if (b.zero()) {
101 if (rm != RM_IMP)
102 GECODE_ME_CHECK(x0.minus_r(home,i_is,false));
103 return home.ES_SUBSUMED(*this);
104 }
105
106 {
107 ViewRanges<View> i_x(x0);
108
109 switch (Iter::Ranges::compare(i_x,i_is)) {
111 if (rm != RM_IMP)
112 GECODE_ME_CHECK(b.one_none(home));
113 return home.ES_SUBSUMED(*this);
115 if (rm != RM_PMI)
116 GECODE_ME_CHECK(b.zero_none(home));
117 return home.ES_SUBSUMED(*this);
119 break;
120 default: GECODE_NEVER;
121 }
122 }
123 return ES_FIX;
124 }
125
126}}}
127
128// STATISTICS: int-prop
129
struct Gecode::@603::NNF::@65::@66 b
For binary nodes (and, or, eqv)
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:232
Base-class for both propagators and branchers.
Definition: core.hpp:628
Home class for posting propagators
Definition: core.hpp:856
void notice(Actor &a, ActorProperty p, bool duplicate=false)
Notice actor property.
Definition: core.hpp:3219
Range iterator for integer sets.
Definition: int.hh:292
Integer sets.
Definition: int.hh:174
int min(int i) const
Return minimum of range at position i.
Definition: int-set-1.hpp:152
int max(int i) const
Return maximum of range at position i.
Definition: int-set-1.hpp:158
int ranges(void) const
Return number of ranges of the specification.
Definition: int-set-1.hpp:171
Boolean view for Boolean variables.
Definition: view.hpp:1380
Reified domain dom-propagator.
Definition: dom.hh:84
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: set.hpp:93
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition: set.hpp:87
ReIntSet(Space &home, ReIntSet &p)
Constructor for cloning p.
Definition: set.hpp:81
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition: set.hpp:46
static ExecStatus post(Home home, View x, const IntSet &s, BoolView b)
Post propagator for .
Definition: set.hpp:55
static ExecStatus post(Home home, View x, int min, int max, BoolView b)
Post propagator for .
Definition: range.hpp:46
Reified unary propagator.
Definition: propagator.hpp:54
Range iterator for integer views.
Definition: view.hpp:54
Computation spaces.
Definition: core.hpp:1742
ExecStatus ES_SUBSUMED(Propagator &p)
Definition: core.hpp:3563
void ignore(Actor &a, ActorProperty p, bool duplicate=false)
Ignore actor property.
Definition: core.hpp:4074
int ModEventDelta
Modification event deltas.
Definition: core.hpp:89
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
Definition: macros.hpp:52
@ AP_DISPOSE
Actor must always be disposed.
Definition: core.hpp:562
@ RM_IMP
Implication for reification.
Definition: int.hh:862
@ RM_PMI
Inverse implication for reification.
Definition: int.hh:869
const Gecode::PropCond PC_INT_DOM
Propagate when domain changes.
Definition: var-type.hpp:100
@ CS_NONE
Neither of the above.
@ CS_SUBSET
First is subset of second iterator.
@ CS_DISJOINT
Intersection is empty.
CompareStatus compare(I &i, J &j)
Check whether range iterator i is a subset of j, or whether they are disjoint.
Gecode toplevel namespace
ExecStatus
Definition: core.hpp:472
@ ES_OK
Execution is okay.
Definition: core.hpp:476
@ ES_FIX
Propagation has computed fixpoint.
Definition: core.hpp:477
Post propagator for SetVar x
Definition: set.hh:767
#define forceinline
Definition: config.hpp:194
#define GECODE_NEVER
Assert that this command is never executed.
Definition: macros.hpp:56