/usr/include/gecode/int/propagator.hpp is in libgecode-dev 5.1.0-2build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 | /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
* Main authors:
* Christian Schulte <schulte@gecode.org>
*
* Copyright:
* Christian Schulte, 2002
*
* Last modified:
* $Date: 2016-06-29 17:28:17 +0200 (Wed, 29 Jun 2016) $ by $Author: schulte $
* $Revision: 15137 $
*
* This file is part of Gecode, the generic constraint
* development environment:
* http://www.gecode.org
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
namespace Gecode { namespace Int {
/**
* \defgroup TaskPropRePat Reified propagator patterns
*
* \ingroup TaskActor
*/
//@{
/**
* \brief Reified unary propagator
*
* Stores single view of type \a View with propagation condition \a pc
* and a Boolean control view of type \a CtrlView.
*
* If the propagation condition \a pc has the value PC_GEN_NONE, no
* subscriptions are created for \a View.
*
*/
template<class View, PropCond pc, class CtrlView>
class ReUnaryPropagator : public Propagator {
protected:
/// Single view
View x0;
/// Boolean control view
CtrlView b;
/// Constructor for cloning \a p
ReUnaryPropagator(Space& home, bool share, ReUnaryPropagator& p);
/// Constructor for rewriting \a p during cloning
ReUnaryPropagator(Space& home, bool share, Propagator& p,
View x0, CtrlView b);
/// Constructor for creation
ReUnaryPropagator(Home home, View x0, CtrlView b);
public:
/// Cost function (defined as low unary)
virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
/// Schedule function
virtual void reschedule(Space& home);
/// Delete propagator and return its size
virtual size_t dispose(Space& home);
};
/**
* \brief Reified binary propagator
*
* Stores two views of type \a View with propagation condition \a pc
* and a Boolean control view of type \a CtrlView.
*
* If the propagation condition \a pc has the value PC_GEN_NONE, no
* subscriptions are created for \a View.
*
*/
template<class View, PropCond pc, class CtrlView>
class ReBinaryPropagator : public Propagator {
protected:
/// Two views
View x0, x1;
/// Boolean control view
CtrlView b;
/// Constructor for cloning \a p
ReBinaryPropagator(Space& home, bool share, ReBinaryPropagator& p);
/// Constructor for rewriting \a p during cloning
ReBinaryPropagator(Space& home, bool share, Propagator& p,
View x0, View x1, CtrlView b);
/// Constructor for creation
ReBinaryPropagator(Home home, View x0, View x1, CtrlView b);
public:
/// Cost function (defined as low binary)
virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
/// Schedule function
virtual void reschedule(Space& home);
/// Delete propagator and return its size
virtual size_t dispose(Space& home);
};
//@}
/**
* \brief Reified mixed binary propagator
*
* Stores two views of type \a View0 and \a View1 with propagation
* conditions \a pc0 and \a pc1 and a Boolean control view of type
* \a CtrlView.
*
* If the propagation conditions \a pc0 or \a pc1 have the values
* PC_GEN_NONE, no subscriptions are created.
*
*/
template<class View0, PropCond pc0, class View1, PropCond pc1,
class CtrlView>
class ReMixBinaryPropagator : public Propagator {
protected:
/// View of type \a View0
View0 x0;
/// View of type \a View1
View1 x1;
/// Boolean control view
CtrlView b;
/// Constructor for cloning \a p
ReMixBinaryPropagator(Space& home, bool share, ReMixBinaryPropagator& p);
/// Constructor for creation
ReMixBinaryPropagator(Home home, View0 x0, View1 x1, CtrlView b);
/// Constructor for rewriting \a p during cloning
ReMixBinaryPropagator(Space& home, bool share, Propagator& p,
View0 x0, View1 x1, CtrlView b);
public:
/// Cost function (defined as low binary)
virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
/// Schedule function
virtual void reschedule(Space& home);
/// Delete propagator and return its size
virtual size_t dispose(Space& home);
};
/*
* Reified unary propagators
*
*/
template<class View, PropCond pc, class CtrlView>
ReUnaryPropagator<View,pc,CtrlView>::ReUnaryPropagator
(Home home, View y0, CtrlView b0)
: Propagator(home), x0(y0), b(b0) {
if (pc != PC_GEN_NONE)
x0.subscribe(home,*this,pc);
b.subscribe(home,*this,Int::PC_INT_VAL);
}
template<class View, PropCond pc, class CtrlView>
forceinline
ReUnaryPropagator<View,pc,CtrlView>::ReUnaryPropagator
(Space& home, bool share, ReUnaryPropagator<View,pc,CtrlView>& p)
: Propagator(home,share,p) {
x0.update(home,share,p.x0);
b.update(home,share,p.b);
}
template<class View, PropCond pc, class CtrlView>
forceinline
ReUnaryPropagator<View,pc,CtrlView>::ReUnaryPropagator
(Space& home, bool share, Propagator& p, View y0, CtrlView b0)
: Propagator(home,share,p) {
x0.update(home,share,y0);
b.update(home,share,b0);
}
template<class View, PropCond pc, class CtrlView>
PropCost
ReUnaryPropagator<View,pc,CtrlView>::cost(const Space&, const ModEventDelta&) const {
return PropCost::unary(PropCost::LO);
}
template<class View, PropCond pc, class CtrlView>
void
ReUnaryPropagator<View,pc,CtrlView>::reschedule(Space& home) {
if (pc != PC_GEN_NONE)
x0.reschedule(home,*this,pc);
b.reschedule(home,*this,Int::PC_INT_VAL);
}
template<class View, PropCond pc, class CtrlView>
forceinline size_t
ReUnaryPropagator<View,pc,CtrlView>::dispose(Space& home) {
if (pc != PC_GEN_NONE)
x0.cancel(home,*this,pc);
b.cancel(home,*this,Int::PC_INT_VAL);
(void) Propagator::dispose(home);
return sizeof(*this);
}
/*
* Reified binary propagators
*
*/
template<class View, PropCond pc, class CtrlView>
ReBinaryPropagator<View,pc,CtrlView>::ReBinaryPropagator
(Home home, View y0, View y1, CtrlView b1)
: Propagator(home), x0(y0), x1(y1), b(b1) {
if (pc != PC_GEN_NONE) {
x0.subscribe(home,*this,pc);
x1.subscribe(home,*this,pc);
}
b.subscribe(home,*this,Int::PC_INT_VAL);
}
template<class View, PropCond pc, class CtrlView>
forceinline
ReBinaryPropagator<View,pc,CtrlView>::ReBinaryPropagator
(Space& home, bool share, ReBinaryPropagator<View,pc,CtrlView>& p)
: Propagator(home,share,p) {
x0.update(home,share,p.x0);
x1.update(home,share,p.x1);
b.update(home,share,p.b);
}
template<class View, PropCond pc, class CtrlView>
forceinline
ReBinaryPropagator<View,pc,CtrlView>::ReBinaryPropagator
(Space& home, bool share, Propagator& p, View y0, View y1, CtrlView b0)
: Propagator(home,share,p) {
x0.update(home,share,y0);
x1.update(home,share,y1);
b.update(home,share,b0);
}
template<class View, PropCond pc, class CtrlView>
PropCost
ReBinaryPropagator<View,pc,CtrlView>::cost(const Space&, const ModEventDelta&) const {
return PropCost::binary(PropCost::LO);
}
template<class View, PropCond pc, class CtrlView>
void
ReBinaryPropagator<View,pc,CtrlView>::reschedule(Space& home) {
if (pc != PC_GEN_NONE) {
x0.reschedule(home,*this,pc);
x1.reschedule(home,*this,pc);
}
b.reschedule(home,*this,Int::PC_INT_VAL);
}
template<class View, PropCond pc, class CtrlView>
forceinline size_t
ReBinaryPropagator<View,pc,CtrlView>::dispose(Space& home) {
if (pc != PC_GEN_NONE) {
x0.cancel(home,*this,pc);
x1.cancel(home,*this,pc);
}
b.cancel(home,*this,Int::PC_INT_VAL);
(void) Propagator::dispose(home);
return sizeof(*this);
}
/*
* Reified mixed binary propagator
*
*/
template<class View0, PropCond pc0, class View1, PropCond pc1,
class CtrlView>
ReMixBinaryPropagator<View0,pc0,View1,pc1,CtrlView>
::ReMixBinaryPropagator(Home home, View0 y0, View1 y1, CtrlView b1)
: Propagator(home), x0(y0), x1(y1), b(b1) {
if (pc0 != PC_GEN_NONE)
x0.subscribe(home,*this,pc0);
if (pc1 != PC_GEN_NONE)
x1.subscribe(home,*this,pc1);
b.subscribe(home,*this,Int::PC_INT_VAL);
}
template<class View0, PropCond pc0, class View1, PropCond pc1,
class CtrlView>
forceinline
ReMixBinaryPropagator<View0,pc0,View1,pc1,CtrlView>::ReMixBinaryPropagator
(Space& home, bool share,
ReMixBinaryPropagator<View0,pc0,View1,pc1,CtrlView>& p)
: Propagator(home,share,p) {
x0.update(home,share,p.x0);
x1.update(home,share,p.x1);
b.update(home,share,p.b);
}
template<class View0, PropCond pc0, class View1, PropCond pc1,
class CtrlView>
forceinline
ReMixBinaryPropagator<View0,pc0,View1,pc1,CtrlView>
::ReMixBinaryPropagator
(Space& home, bool share, Propagator& p, View0 y0, View1 y1, CtrlView b0)
: Propagator(home,share,p) {
x0.update(home,share,y0);
x1.update(home,share,y1);
b.update(home,share,b0);
}
template<class View0, PropCond pc0, class View1, PropCond pc1,
class CtrlView>
PropCost
ReMixBinaryPropagator<View0,pc0,View1,pc1,CtrlView>
::cost(const Space&, const ModEventDelta&) const {
return PropCost::binary(PropCost::LO);
}
template<class View0, PropCond pc0, class View1, PropCond pc1,
class CtrlView>
void
ReMixBinaryPropagator<View0,pc0,View1,pc1,CtrlView>::reschedule(Space& home) {
if (pc0 != PC_GEN_NONE)
x0.reschedule(home,*this,pc0);
if (pc1 != PC_GEN_NONE)
x1.reschedule(home,*this,pc1);
b.reschedule(home,*this,Int::PC_INT_VAL);
}
template<class View0, PropCond pc0, class View1, PropCond pc1,
class CtrlView>
forceinline size_t
ReMixBinaryPropagator<View0,pc0,View1,pc1,CtrlView>::dispose(Space& home) {
if (pc0 != PC_GEN_NONE)
x0.cancel(home,*this,pc0);
if (pc1 != PC_GEN_NONE)
x1.cancel(home,*this,pc1);
b.cancel(home,*this,Int::PC_INT_VAL);
(void) Propagator::dispose(home);
return sizeof(*this);
}
}}
// STATISTICS: int-prop
|