Generated on Thu Apr 5 2018 19:44:19 for Gecode by doxygen 1.8.13
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$ by $Author$
11  * $Revision$
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,p), is(p.is) {
87  }
88 
89  template<class View, ReifyMode rm>
90  Actor*
92  return new (home) ReIntSet(home,*this);
93  }
94 
95  template<class View, ReifyMode rm>
98  IntSetRanges i_is(is);
99  if (b.one()) {
100  if (rm != RM_PMI)
101  GECODE_ME_CHECK(x0.inter_r(home,i_is,false));
102  return home.ES_SUBSUMED(*this);
103  }
104  if (b.zero()) {
105  if (rm != RM_IMP)
106  GECODE_ME_CHECK(x0.minus_r(home,i_is,false));
107  return home.ES_SUBSUMED(*this);
108  }
109 
110  {
111  ViewRanges<View> i_x(x0);
112 
113  switch (Iter::Ranges::compare(i_x,i_is)) {
115  if (rm != RM_IMP)
116  GECODE_ME_CHECK(b.one_none(home));
117  return home.ES_SUBSUMED(*this);
119  if (rm != RM_PMI)
120  GECODE_ME_CHECK(b.zero_none(home));
121  return home.ES_SUBSUMED(*this);
123  break;
124  default: GECODE_NEVER;
125  }
126  }
127  return ES_FIX;
128  }
129 
130 }}}
131 
132 // STATISTICS: int-prop
133 
virtual size_t dispose(Space &home)
Delete propagator and return its size.
Definition: set.hpp:50
bool zero(void) const
Test whether view is assigned to be zero.
Definition: bool.hpp:214
Inverse implication for reification.
Definition: int.hh:848
Range iterator for integer sets.
Definition: int.hh:272
ExecStatus ES_SUBSUMED(Propagator &p)
Definition: core.hpp:3433
ReIntSet(Space &home, ReIntSet &p)
Constructor for cloning p.
Definition: set.hpp:85
Actor must always be disposed.
Definition: core.hpp:554
bool one(void) const
Test whether view is assigned to be one.
Definition: bool.hpp:218
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.
#define forceinline
Definition: config.hpp:182
Propagation has computed fixpoint.
Definition: core.hpp:469
Computation spaces.
Definition: core.hpp:1668
int min(int i) const
Return minimum of range at position i.
Definition: int-set-1.hpp:115
Base-class for both propagators and branchers.
Definition: core.hpp:620
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 max(int i) const
Return maximum of range at position i.
Definition: int-set-1.hpp:121
const Gecode::PropCond PC_INT_DOM
Propagate when domain changes.
Definition: var-type.hpp:100
Integer sets.
Definition: int.hh:174
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
Definition: macros.hpp:56
struct Gecode::@585::NNF::@62::@63 b
For binary nodes (and, or, eqv)
void ignore(Actor &a, ActorProperty p, bool duplicate=false)
Ignore actor property.
Definition: core.hpp:3944
ExecStatus
Definition: core.hpp:464
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Definition: set.hpp:91
Post propagator for SetVar x
Definition: set.hh:769
Execution is okay.
Definition: core.hpp:468
int ranges(void) const
Return number of ranges of the specification.
Definition: int-set-1.hpp:134
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
Gecode toplevel namespace
Implication for reification.
Definition: int.hh:841
ModEvent one_none(Space &home)
Assign not yet assigned view to one.
Definition: bool.hpp:236
int ModEventDelta
Modification event deltas.
Definition: core.hpp:91
Home class for posting propagators
Definition: core.hpp:846
#define GECODE_NEVER
Assert that this command is never executed.
Definition: macros.hpp:60
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition: set.hpp:97
Boolean view for Boolean variables.
Definition: view.hpp:1329