Generated on Sat Jun 2 2018 07:17:44 for Gecode by doxygen 1.8.13
neg-bool.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  * Contributing authors:
7  * Samuel Gagnon <samuel.gagnon92@gmail.com>
8  *
9  * Copyright:
10  * Christian Schulte, 2008
11  * Samuel Gagnon, 2018
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 {
39 
40  /*
41  * Negated Boolean views
42  *
43  */
44 
45  /*
46  * Constructors and initialization
47  *
48  */
53  : DerivedView<BoolView>(y) {}
54 
55 
56  /*
57  * Boolean domain tests
58  *
59  */
61  NegBoolView::status(void) const {
62  return x.status();
63  }
64  forceinline bool
65  NegBoolView::zero(void) const {
66  return x.one();
67  }
68  forceinline bool
69  NegBoolView::one(void) const {
70  return x.zero();
71  }
72  forceinline bool
73  NegBoolView::none(void) const {
74  return x.none();
75  }
76 
77 
78  /*
79  * Boolean assignment operations
80  *
81  */
84  return x.one_none(home);
85  }
88  return x.zero_none(home);
89  }
90 
93  return x.one(home);
94  }
97  return x.zero(home);
98  }
99 
100 
101  /*
102  * Value access
103  *
104  */
105  forceinline int
106  NegBoolView::min(void) const {
107  return x.max();
108  }
109  forceinline int
110  NegBoolView::max(void) const {
111  return x.min();
112  }
113  forceinline int
114  NegBoolView::val(void) const {
115  return 1-x.val();
116  }
117 #ifdef GECODE_HAS_CBS
118  forceinline int
119  NegBoolView::baseval(int val) const {
120  return 1-val;
121  }
122 #endif
123 
124 
125  /*
126  * Delta information for advisors
127  *
128  */
129  forceinline int
130  NegBoolView::min(const Delta& d) const {
131  return x.max(d);
132  }
133  forceinline int
134  NegBoolView::max(const Delta& d) const {
135  return x.min(d);
136  }
137  forceinline unsigned int
138  NegBoolView::width(const Delta& d) const {
139  return x.width(d);
140  }
141  forceinline bool
142  NegBoolView::any(const Delta& d) const {
143  return x.any(d);
144  }
145  forceinline bool
147  return BoolView::one(d);
148  }
149  forceinline bool
151  return BoolView::zero(d);
152  }
153 
154 
159  template<>
161  public:
163 
164  ViewRanges(void);
167  ViewRanges(const NegBoolView& x);
169  void init(const NegBoolView& x);
171  };
172 
175 
178  : Iter::Ranges::Singleton(x.min(),x.max()) {}
179 
180  forceinline void
183  }
184 
185 }}
186 
187 // STATISTICS: int-var
bool zero(void) const
Test whether view is assigned to be zero.
Definition: bool.hpp:220
Range iterator for singleton range.
Negated Boolean view.
Definition: view.hpp:1543
int max(void) const
Return maximum of domain.
Definition: neg-bool.hpp:110
unsigned int BoolStatus
Type for status of a Boolean variable.
Definition: var-imp.hpp:484
bool one(void) const
Test whether view is assigned to be one.
Definition: bool.hpp:224
bool any(const Delta &d) const
Test whether arbitrary values got pruned.
Definition: neg-bool.hpp:142
ViewRanges(void)
Default constructor.
int ModEvent
Type for modification events.
Definition: core.hpp:62
int val(void) const
Return assigned value (only if assigned)
Definition: neg-bool.hpp:114
bool zero(void) const
Test whether view is assigned to be zero.
Definition: neg-bool.hpp:65
#define forceinline
Definition: config.hpp:185
Computation spaces.
Definition: core.hpp:1701
void init(const View &x)
Initialize with ranges for view x.
Base-class for derived views.
Definition: view.hpp:230
Range iterator for integer views.
Definition: view.hpp:54
Gecode::IntSet d(v, 7)
int min(void) const
Return minimum of domain.
Definition: neg-bool.hpp:106
ModEvent zero_none(Space &home)
Assign not yet assigned view to zero.
Definition: bool.hpp:238
int max(void) const
Return maximum of domain.
Definition: bool.hpp:66
void init(int min, int max)
Initialize with range min to max.
BoolStatus status(void) const
Return current domain status.
Definition: bool.hpp:58
bool one(void) const
Test whether view is assigned to be one.
Definition: neg-bool.hpp:69
bool none(void) const
Test whether view is not yet assigned.
Definition: neg-bool.hpp:73
BoolStatus status(void) const
Return current domain status.
Definition: neg-bool.hpp:61
int min(void) const
Return minimum of domain.
Definition: bool.hpp:62
NegBoolView(void)
Default constructor.
Definition: neg-bool.hpp:50
Post propagator for SetVar SetOpType SetVar y
Definition: set.hh:765
Generic domain change information to be supplied to advisors.
Definition: core.hpp:203
Post propagator for SetVar x
Definition: set.hh:765
BoolView x
View from which this view is derived.
Definition: view.hpp:238
unsigned int width(const Delta &d) const
Return width of values just pruned.
Definition: neg-bool.hpp:138
unsigned int width(void) const
Return width of domain (distance between maximum and minimum)
Definition: bool.hpp:89
Gecode toplevel namespace
ModEvent zero_none(Space &home)
Assign not yet assigned view to zero.
Definition: neg-bool.hpp:83
ModEvent one_none(Space &home)
Assign not yet assigned view to one.
Definition: bool.hpp:242
bool none(void) const
Test whether view is not yet assigned.
Definition: bool.hpp:228
int val(void) const
Return assigned value (only if assigned)
Definition: bool.hpp:74
ModEvent one_none(Space &home)
Assign not yet assigned view to one.
Definition: neg-bool.hpp:87
bool any(const Delta &d) const
Test whether arbitrary values got pruned.
Definition: bool.hpp:273
Boolean view for Boolean variables.
Definition: view.hpp:1349