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