this repo has no description
1/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */ 2/* 3 * Main authors: 4 * Christian Schulte <schulte@gecode.org> 5 * Guido Tack <tack@gecode.org> 6 * 7 * Copyright: 8 * Christian Schulte, 2002 9 * Guido Tack, 2004 10 * 11 * This file is part of Gecode, the generic constraint 12 * development environment: 13 * http://www.gecode.org 14 * 15 * Permission is hereby granted, free of charge, to any person obtaining 16 * a copy of this software and associated documentation files (the 17 * "Software"), to deal in the Software without restriction, including 18 * without limitation the rights to use, copy, modify, merge, publish, 19 * distribute, sublicense, and/or sell copies of the Software, and to 20 * permit persons to whom the Software is furnished to do so, subject to 21 * the following conditions: 22 * 23 * The above copyright notice and this permission notice shall be 24 * included in all copies or substantial portions of the Software. 25 * 26 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 27 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 28 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 29 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 30 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 31 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 32 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 33 * 34 */ 35 36namespace Gecode { 37 38 /** 39 * \defgroup TaskPropPat Propagator patterns 40 * 41 * \ingroup TaskActor 42 */ 43 44 //@{ 45 /** 46 * \brief Unary propagator 47 * 48 * Stores a single view of type \a View with propagation condition \a pc. 49 * 50 * If the propagation condition \a pc has the value PC_GEN_NONE, no 51 * subscriptions are created. 52 * 53 */ 54 template<class View, PropCond pc> 55 class UnaryPropagator : public Propagator { 56 protected: 57 /// Single view 58 View x0; 59 /// Constructor for cloning \a p 60 UnaryPropagator(Space& home, UnaryPropagator& p); 61 /// Constructor for rewriting \a p during cloning 62 UnaryPropagator(Space& home, Propagator& p, View x0); 63 /// Constructor for creation 64 UnaryPropagator(Home home, View x0); 65 public: 66 /// Cost function (defined as PC_UNARY_LO) 67 virtual PropCost cost(const Space& home, const ModEventDelta& med) const; 68 /// Schedule function 69 virtual void reschedule(Space& home); 70 /// Delete propagator and return its size 71 virtual size_t dispose(Space& home); 72 }; 73 74 /** 75 * \brief Binary propagator 76 * 77 * Stores two views of type \a View with propagation condition \a pc. 78 * 79 * If the propagation condition \a pc has the value PC_GEN_NONE, no 80 * subscriptions are created. 81 * 82 */ 83 template<class View, PropCond pc> 84 class BinaryPropagator : public Propagator { 85 protected: 86 /// Two views 87 View x0, x1; 88 /// Constructor for cloning \a p 89 BinaryPropagator(Space& home, BinaryPropagator& p); 90 /// Constructor for creation 91 BinaryPropagator(Home home, View x0, View x1); 92 /// Constructor for rewriting \a p during cloning 93 BinaryPropagator(Space& home, Propagator& p, View x0, View x1); 94 public: 95 /// Cost function (defined as low binary) 96 virtual PropCost cost(const Space& home, const ModEventDelta& med) const; 97 /// Schedule function 98 virtual void reschedule(Space& home); 99 /// Delete propagator and return its size 100 virtual size_t dispose(Space& home); 101 }; 102 103 /** 104 * \brief Ternary propagator 105 * 106 * Stores three views of type \a View with propagation condition \a pc. 107 * 108 * If the propagation condition \a pc has the value PC_GEN_NONE, no 109 * subscriptions are created. 110 * 111 */ 112 template<class View, PropCond pc> 113 class TernaryPropagator : public Propagator { 114 protected: 115 /// Three views 116 View x0, x1, x2; 117 /// Constructor for cloning \a p 118 TernaryPropagator(Space& home, TernaryPropagator& p); 119 /// Constructor for creation 120 TernaryPropagator(Home home, View x0, View x1, View x2); 121 /// Constructor for rewriting \a p during cloning 122 TernaryPropagator(Space& home, Propagator& p, View x0, View x1, View x2); 123 public: 124 /// Cost function (defined as low ternary) 125 virtual PropCost cost(const Space& home, const ModEventDelta& med) const; 126 /// Schedule function 127 virtual void reschedule(Space& home); 128 /// Delete propagator and return its size 129 virtual size_t dispose(Space& home); 130 }; 131 132 /** 133 * \brief n-ary propagator 134 * 135 * Stores array of views of type \a View with propagation condition \a pc. 136 * 137 * If the propagation condition \a pc has the value PC_GEN_NONE, no 138 * subscriptions are created. 139 * 140 */ 141 template<class View, PropCond pc> 142 class NaryPropagator : public Propagator { 143 protected: 144 /// Array of views 145 ViewArray<View> x; 146 /// Constructor for cloning \a p 147 NaryPropagator(Space& home, NaryPropagator& p); 148 /// Constructor for rewriting \a p during cloning 149 NaryPropagator(Space& home, Propagator& p, ViewArray<View>& x); 150 /// Constructor for creation 151 NaryPropagator(Home home, ViewArray<View>& x); 152 public: 153 /// Cost function (defined as low linear) 154 virtual PropCost cost(const Space& home, const ModEventDelta& med) const; 155 /// Schedule function 156 virtual void reschedule(Space& home); 157 /// Delete propagator and return its size 158 virtual size_t dispose(Space& home); 159 }; 160 161 /** 162 * \brief (n+1)-ary propagator 163 * 164 * Stores array of views and single view of type \a View with propagation 165 * condition \a pc. 166 * 167 * If the propagation condition \a pc has the value PC_GEN_NONE, no 168 * subscriptions are created. 169 * 170 */ 171 template<class View, PropCond pc> 172 class NaryOnePropagator : public Propagator { 173 protected: 174 /// Array of views 175 ViewArray<View> x; 176 /// Single view 177 View y; 178 /// Constructor for cloning \a p 179 NaryOnePropagator(Space& home, NaryOnePropagator& p); 180 /// Constructor for rewriting \a p during cloning 181 NaryOnePropagator(Space& home, Propagator& p, ViewArray<View>& x, View y); 182 /// Constructor for creation 183 NaryOnePropagator(Home home, ViewArray<View>& x, View y); 184 public: 185 /// Cost function (defined as low linear) 186 virtual PropCost cost(const Space& home, const ModEventDelta& med) const; 187 /// Schedule function 188 virtual void reschedule(Space& home); 189 /// Delete propagator and return its size 190 virtual size_t dispose(Space& home); 191 }; 192 193 /** 194 * \brief Mixed binary propagator 195 * 196 * Stores two views of type \a View0 and \a View1 with propagation 197 * conditions \a pc0 and \a pc1. 198 * 199 * If the propagation conditions \a pc0 or \a pc1 have the values 200 * PC_GEN_NONE, no subscriptions are created. 201 * 202 */ 203 template<class View0, PropCond pc0, class View1, PropCond pc1> 204 class MixBinaryPropagator : public Propagator { 205 protected: 206 /// View of type \a View0 207 View0 x0; 208 /// View of type \a View1 209 View1 x1; 210 /// Constructor for cloning 211 MixBinaryPropagator(Space& home, MixBinaryPropagator& p); 212 /// Constructor for creation 213 MixBinaryPropagator(Home home, View0 x0, View1 x1); 214 /// Constructor for rewriting \a p during cloning 215 MixBinaryPropagator(Space& home, Propagator& p, View0 x0, View1 x1); 216 public: 217 /// Cost function (defined as low binary) 218 virtual PropCost cost(const Space& home, const ModEventDelta& med) const; 219 /// Schedule function 220 virtual void reschedule(Space& home); 221 /// Delete propagator and return its size 222 virtual size_t dispose(Space& home); 223 }; 224 225 /** 226 * \brief Mixed ternary propagator 227 * 228 * Stores three views of type \a View0, \a View1, and \a View2 229 * with propagation conditions \a pc0, \a pc1, and \a pc2. 230 * 231 * If the propagation conditions \a pc0, \a pc1, \a pc2 have the values 232 * PC_GEN_NONE, no subscriptions are created. 233 * 234 */ 235 template<class View0, PropCond pc0, class View1, PropCond pc1, 236 class View2, PropCond pc2> 237 class MixTernaryPropagator : public Propagator { 238 protected: 239 /// View of type \a View0 240 View0 x0; 241 /// View of type \a View1 242 View1 x1; 243 /// View of type \a View2 244 View2 x2; 245 /// Constructor for cloning 246 MixTernaryPropagator(Space& home, MixTernaryPropagator& p); 247 /// Constructor for creation 248 MixTernaryPropagator(Home home, View0 x0, View1 x1, View2 x2); 249 /// Constructor for rewriting \a p during cloning 250 MixTernaryPropagator(Space& home, Propagator& p, 251 View0 x0, View1 x1, View2 x2); 252 public: 253 /// Cost function (defined as low ternary) 254 virtual PropCost cost(const Space& home, const ModEventDelta& med) const; 255 /// Schedule function 256 virtual void reschedule(Space& home); 257 /// Delete propagator and return its size 258 virtual size_t dispose(Space& home); 259 }; 260 261 /** 262 * \brief Mixed (n+1)-ary propagator 263 * 264 * Stores array of views of type \a View0 with propagation condition \a pc0 265 * and a single view of type \a View1 with propagation condition \a pc1. 266 * 267 * If the propagation conditions \a pc0 or \a pc1 have the values 268 * PC_GEN_NONE, no subscriptions are created. 269 * 270 */ 271 template<class View0, PropCond pc0, class View1, PropCond pc1> 272 class MixNaryOnePropagator : public Propagator { 273 protected: 274 /// Array of views 275 ViewArray<View0> x; 276 /// Single view 277 View1 y; 278 /// Constructor for cloning \a p 279 MixNaryOnePropagator(Space& home, MixNaryOnePropagator& p); 280 /// Constructor for creation 281 MixNaryOnePropagator(Home home, ViewArray<View0>& x, View1 y); 282 /// Constructor for rewriting \a p during cloning 283 MixNaryOnePropagator(Space& home, Propagator& p, 284 ViewArray<View0>& x, View1 y); 285 public: 286 /// Cost function (defined as low linear) 287 virtual PropCost cost(const Space& home, const ModEventDelta& med) const; 288 /// Schedule function 289 virtual void reschedule(Space& home); 290 /// Delete propagator and return its size 291 virtual size_t dispose(Space& home); 292 }; 293 //@} 294 295 296 /* 297 * Unary propagators 298 * 299 */ 300 301 template<class View, PropCond pc> 302 UnaryPropagator<View,pc>::UnaryPropagator(Home home, View y0) 303 : Propagator(home), x0(y0) { 304 if (pc != PC_GEN_NONE) 305 x0.subscribe(home,*this,pc); 306 } 307 308 template<class View, PropCond pc> 309 forceinline 310 UnaryPropagator<View,pc>::UnaryPropagator 311 (Space& home, UnaryPropagator<View,pc>& p) 312 : Propagator(home,p) { 313 x0.update(home,p.x0); 314 } 315 316 template<class View, PropCond pc> 317 forceinline 318 UnaryPropagator<View,pc>::UnaryPropagator 319 (Space& home, Propagator& p, View y0) 320 : Propagator(home,p) { 321 x0.update(home,y0); 322 } 323 324 template<class View, PropCond pc> 325 PropCost 326 UnaryPropagator<View,pc>::cost(const Space&, const ModEventDelta&) const { 327 return PropCost::unary(PropCost::LO); 328 } 329 330 template<class View, PropCond pc> 331 void 332 UnaryPropagator<View,pc>::reschedule(Space& home) { 333 if (pc != PC_GEN_NONE) 334 x0.reschedule(home,*this,pc); 335 } 336 337 template<class View, PropCond pc> 338 forceinline size_t 339 UnaryPropagator<View,pc>::dispose(Space& home) { 340 if (pc != PC_GEN_NONE) 341 x0.cancel(home,*this,pc); 342 (void) Propagator::dispose(home); 343 return sizeof(*this); 344 } 345 346 347 /* 348 * Binary propagators 349 * 350 */ 351 352 template<class View, PropCond pc> 353 BinaryPropagator<View,pc>::BinaryPropagator(Home home, View y0, View y1) 354 : Propagator(home), x0(y0), x1(y1) { 355 if (pc != PC_GEN_NONE) { 356 x0.subscribe(home,*this,pc); 357 x1.subscribe(home,*this,pc); 358 } 359 } 360 361 template<class View, PropCond pc> 362 forceinline 363 BinaryPropagator<View,pc>::BinaryPropagator 364 (Space& home, BinaryPropagator<View,pc>& p) 365 : Propagator(home,p) { 366 x0.update(home,p.x0); 367 x1.update(home,p.x1); 368 } 369 370 template<class View, PropCond pc> 371 forceinline 372 BinaryPropagator<View,pc>::BinaryPropagator 373 (Space& home, Propagator& p, View y0, View y1) 374 : Propagator(home,p) { 375 x0.update(home,y0); 376 x1.update(home,y1); 377 } 378 379 template<class View, PropCond pc> 380 PropCost 381 BinaryPropagator<View,pc>::cost(const Space&, const ModEventDelta&) const { 382 return PropCost::binary(PropCost::LO); 383 } 384 385 template<class View, PropCond pc> 386 void 387 BinaryPropagator<View,pc>::reschedule(Space& home) { 388 if (pc != PC_GEN_NONE) { 389 x0.reschedule(home,*this,pc); 390 x1.reschedule(home,*this,pc); 391 } 392 } 393 394 template<class View, PropCond pc> 395 forceinline size_t 396 BinaryPropagator<View,pc>::dispose(Space& home) { 397 if (pc != PC_GEN_NONE) { 398 x0.cancel(home,*this,pc); 399 x1.cancel(home,*this,pc); 400 } 401 (void) Propagator::dispose(home); 402 return sizeof(*this); 403 } 404 405 /* 406 * Ternary propagators 407 * 408 */ 409 410 template<class View, PropCond pc> 411 TernaryPropagator<View,pc>::TernaryPropagator 412 (Home home, View y0, View y1, View y2) 413 : Propagator(home), x0(y0), x1(y1), x2(y2) { 414 if (pc != PC_GEN_NONE) { 415 x0.subscribe(home,*this,pc); 416 x1.subscribe(home,*this,pc); 417 x2.subscribe(home,*this,pc); 418 } 419 } 420 421 template<class View, PropCond pc> 422 forceinline 423 TernaryPropagator<View,pc>::TernaryPropagator 424 (Space& home, TernaryPropagator<View,pc>& p) 425 : Propagator(home,p) { 426 x0.update(home,p.x0); 427 x1.update(home,p.x1); 428 x2.update(home,p.x2); 429 } 430 431 template<class View, PropCond pc> 432 forceinline 433 TernaryPropagator<View,pc>::TernaryPropagator 434 (Space& home, Propagator& p, View y0, View y1, View y2) 435 : Propagator(home,p) { 436 x0.update(home,y0); 437 x1.update(home,y1); 438 x2.update(home,y2); 439 } 440 441 template<class View, PropCond pc> 442 PropCost 443 TernaryPropagator<View,pc>::cost(const Space&, const ModEventDelta&) const { 444 return PropCost::ternary(PropCost::LO); 445 } 446 447 template<class View, PropCond pc> 448 void 449 TernaryPropagator<View,pc>::reschedule(Space& home) { 450 if (pc != PC_GEN_NONE) { 451 x0.reschedule(home,*this,pc); 452 x1.reschedule(home,*this,pc); 453 x2.reschedule(home,*this,pc); 454 } 455 } 456 457 template<class View, PropCond pc> 458 forceinline size_t 459 TernaryPropagator<View,pc>::dispose(Space& home) { 460 if (pc != PC_GEN_NONE) { 461 x0.cancel(home,*this,pc); 462 x1.cancel(home,*this,pc); 463 x2.cancel(home,*this,pc); 464 } 465 (void) Propagator::dispose(home); 466 return sizeof(*this); 467 } 468 469 /* 470 * Nary propagators 471 * 472 */ 473 474 template<class View, PropCond pc> 475 NaryPropagator<View,pc>::NaryPropagator 476 (Home home, ViewArray<View>& y) 477 : Propagator(home), x(y) { 478 if (pc != PC_GEN_NONE) 479 x.subscribe(home,*this,pc); 480 } 481 482 template<class View, PropCond pc> 483 forceinline 484 NaryPropagator<View,pc>::NaryPropagator 485 (Space& home, NaryPropagator<View,pc>& p) 486 : Propagator(home,p) { 487 x.update(home,p.x); 488 } 489 490 template<class View, PropCond pc> 491 forceinline 492 NaryPropagator<View,pc>::NaryPropagator 493 (Space& home, Propagator& p, ViewArray<View>& x0) 494 : Propagator(home,p) { 495 x.update(home,x0); 496 } 497 498 template<class View, PropCond pc> 499 PropCost 500 NaryPropagator<View,pc>::cost(const Space&, const ModEventDelta&) const { 501 return PropCost::linear(PropCost::LO,x.size()); 502 } 503 504 template<class View, PropCond pc> 505 void 506 NaryPropagator<View,pc>::reschedule(Space& home) { 507 if (pc != PC_GEN_NONE) 508 x.reschedule(home,*this,pc); 509 } 510 511 template<class View, PropCond pc> 512 forceinline size_t 513 NaryPropagator<View,pc>::dispose(Space& home) { 514 if (pc != PC_GEN_NONE) 515 x.cancel(home,*this,pc); 516 (void) Propagator::dispose(home); 517 return sizeof(*this); 518 } 519 520 /* 521 * NaryOne (one additional variable) propagators 522 * 523 */ 524 525 template<class View, PropCond pc> 526 NaryOnePropagator<View,pc>::NaryOnePropagator 527 (Home home, ViewArray<View>& x0, View y0) 528 : Propagator(home), x(x0), y(y0) { 529 if (pc != PC_GEN_NONE) { 530 x.subscribe(home,*this,pc); 531 y.subscribe(home,*this,pc); 532 } 533 } 534 535 template<class View, PropCond pc> 536 forceinline 537 NaryOnePropagator<View,pc>::NaryOnePropagator 538 (Space& home, NaryOnePropagator<View,pc>& p) 539 : Propagator(home,p) { 540 x.update(home,p.x); 541 y.update(home,p.y); 542 } 543 544 template<class View, PropCond pc> 545 forceinline 546 NaryOnePropagator<View,pc>::NaryOnePropagator 547 (Space& home, Propagator& p, ViewArray<View>& x0, View y0) 548 : Propagator(home,p) { 549 x.update(home,x0); 550 y.update(home,y0); 551 } 552 553 template<class View, PropCond pc> 554 PropCost 555 NaryOnePropagator<View,pc>::cost(const Space&, const ModEventDelta&) const { 556 return PropCost::linear(PropCost::LO,x.size()+1); 557 } 558 559 template<class View, PropCond pc> 560 void 561 NaryOnePropagator<View,pc>::reschedule(Space& home) { 562 if (pc != PC_GEN_NONE) { 563 x.reschedule(home,*this,pc); 564 y.reschedule(home,*this,pc); 565 } 566 } 567 568 template<class View, PropCond pc> 569 forceinline size_t 570 NaryOnePropagator<View,pc>::dispose(Space& home) { 571 if (pc != PC_GEN_NONE) { 572 x.cancel(home,*this,pc); 573 y.cancel(home,*this,pc); 574 } 575 (void) Propagator::dispose(home); 576 return sizeof(*this); 577 } 578 579 /* 580 * Mixed binary propagators 581 * 582 */ 583 584 template<class View0, PropCond pc0, class View1, PropCond pc1> 585 MixBinaryPropagator<View0,pc0,View1,pc1>::MixBinaryPropagator 586 (Home home, View0 y0, View1 y1) 587 : Propagator(home), x0(y0), x1(y1) { 588 if (pc0 != PC_GEN_NONE) 589 x0.subscribe(home,*this,pc0); 590 if (pc1 != PC_GEN_NONE) 591 x1.subscribe(home,*this,pc1); 592 } 593 594 template<class View0, PropCond pc0, class View1, PropCond pc1> 595 forceinline 596 MixBinaryPropagator<View0,pc0,View1,pc1>::MixBinaryPropagator 597 (Space& home, MixBinaryPropagator<View0,pc0,View1,pc1>& p) 598 : Propagator(home,p) { 599 x0.update(home,p.x0); 600 x1.update(home,p.x1); 601 } 602 603 template<class View0, PropCond pc0, class View1, PropCond pc1> 604 forceinline 605 MixBinaryPropagator<View0,pc0,View1,pc1>::MixBinaryPropagator 606 (Space& home, Propagator& p, View0 y0, View1 y1) 607 : Propagator(home,p) { 608 x0.update(home,y0); 609 x1.update(home,y1); 610 } 611 612 template<class View0, PropCond pc0, class View1, PropCond pc1> 613 PropCost 614 MixBinaryPropagator<View0,pc0,View1,pc1>::cost(const Space&, 615 const ModEventDelta&) const { 616 return PropCost::binary(PropCost::LO); 617 } 618 619 template<class View0, PropCond pc0, class View1, PropCond pc1> 620 void 621 MixBinaryPropagator<View0,pc0,View1,pc1>::reschedule(Space& home) { 622 if (pc0 != PC_GEN_NONE) 623 x0.reschedule(home,*this,pc0); 624 if (pc1 != PC_GEN_NONE) 625 x1.reschedule(home,*this,pc1); 626 } 627 628 template<class View0, PropCond pc0, class View1, PropCond pc1> 629 forceinline size_t 630 MixBinaryPropagator<View0,pc0,View1,pc1>::dispose(Space& home) { 631 if (pc0 != PC_GEN_NONE) 632 x0.cancel(home,*this,pc0); 633 if (pc1 != PC_GEN_NONE) 634 x1.cancel(home,*this,pc1); 635 (void) Propagator::dispose(home); 636 return sizeof(*this); 637 } 638 639 /* 640 * Mixed ternary propagators 641 * 642 */ 643 644 template<class View0, PropCond pc0, class View1, PropCond pc1, 645 class View2, PropCond pc2> 646 MixTernaryPropagator<View0,pc0,View1,pc1,View2,pc2>:: 647 MixTernaryPropagator(Home home, View0 y0, View1 y1, View2 y2) 648 : Propagator(home), x0(y0), x1(y1), x2(y2) { 649 if (pc0 != PC_GEN_NONE) 650 x0.subscribe(home,*this,pc0); 651 if (pc1 != PC_GEN_NONE) 652 x1.subscribe(home,*this,pc1); 653 if (pc2 != PC_GEN_NONE) 654 x2.subscribe(home,*this,pc2); 655 } 656 657 template<class View0, PropCond pc0, class View1, PropCond pc1, 658 class View2, PropCond pc2> 659 forceinline 660 MixTernaryPropagator<View0,pc0,View1,pc1,View2,pc2>:: 661 MixTernaryPropagator(Space& home, 662 MixTernaryPropagator<View0,pc0,View1,pc1, 663 View2,pc2>& p) 664 : Propagator(home,p) { 665 x0.update(home,p.x0); 666 x1.update(home,p.x1); 667 x2.update(home,p.x2); 668 } 669 670 template<class View0, PropCond pc0, class View1, PropCond pc1, 671 class View2, PropCond pc2> 672 forceinline 673 MixTernaryPropagator<View0,pc0,View1,pc1,View2,pc2>::MixTernaryPropagator 674 (Space& home, Propagator& p, View0 y0, View1 y1, View2 y2) 675 : Propagator(home,p) { 676 x0.update(home,y0); 677 x1.update(home,y1); 678 x2.update(home,y2); 679 } 680 681 template<class View0, PropCond pc0, class View1, PropCond pc1, 682 class View2, PropCond pc2> 683 PropCost 684 MixTernaryPropagator<View0,pc0,View1,pc1,View2,pc2>:: 685 cost(const Space&, const ModEventDelta&) const { 686 return PropCost::ternary(PropCost::LO); 687 } 688 689 template<class View0, PropCond pc0, class View1, PropCond pc1, 690 class View2, PropCond pc2> 691 void 692 MixTernaryPropagator<View0,pc0,View1,pc1,View2,pc2>::reschedule(Space& home) { 693 if (pc0 != PC_GEN_NONE) 694 x0.reschedule(home,*this,pc0); 695 if (pc1 != PC_GEN_NONE) 696 x1.reschedule(home,*this,pc1); 697 if (pc2 != PC_GEN_NONE) 698 x2.reschedule(home,*this,pc2); 699 } 700 701 template<class View0, PropCond pc0, class View1, PropCond pc1, 702 class View2, PropCond pc2> 703 forceinline size_t 704 MixTernaryPropagator<View0,pc0,View1,pc1,View2,pc2>::dispose(Space& home) { 705 if (pc0 != PC_GEN_NONE) 706 x0.cancel(home,*this,pc0); 707 if (pc1 != PC_GEN_NONE) 708 x1.cancel(home,*this,pc1); 709 if (pc2 != PC_GEN_NONE) 710 x2.cancel(home,*this,pc2); 711 (void) Propagator::dispose(home); 712 return sizeof(*this); 713 } 714 715 /* 716 * MixNaryOne (one additional variable) propagators 717 * 718 */ 719 720 template<class View0, PropCond pc0, class View1, PropCond pc1> 721 MixNaryOnePropagator<View0,pc0,View1,pc1>::MixNaryOnePropagator 722 (Home home, ViewArray<View0>& x0, View1 y0) 723 : Propagator(home), x(x0), y(y0) { 724 if (pc0 != PC_GEN_NONE) 725 x.subscribe(home,*this,pc0); 726 if (pc1 != PC_GEN_NONE) 727 y.subscribe(home,*this,pc1); 728 } 729 730 template<class View0, PropCond pc0, class View1, PropCond pc1> 731 forceinline 732 MixNaryOnePropagator<View0,pc0,View1,pc1>::MixNaryOnePropagator 733 (Space& home, MixNaryOnePropagator<View0,pc0,View1,pc1>& p) 734 : Propagator(home,p) { 735 x.update(home,p.x); 736 y.update(home,p.y); 737 } 738 739 template<class View0, PropCond pc0, class View1, PropCond pc1> 740 forceinline 741 MixNaryOnePropagator<View0,pc0,View1,pc1>::MixNaryOnePropagator 742 (Space& home, Propagator& p, ViewArray<View0>& x0, View1 y0) 743 : Propagator(home,p) { 744 x.update(home,x0); 745 y.update(home,y0); 746 } 747 748 template<class View0, PropCond pc0, class View1, PropCond pc1> 749 PropCost 750 MixNaryOnePropagator<View0,pc0,View1,pc1>::cost(const Space&, 751 const ModEventDelta&) const { 752 return PropCost::linear(PropCost::LO,x.size()+1); 753 } 754 755 template<class View0, PropCond pc0, class View1, PropCond pc1> 756 void 757 MixNaryOnePropagator<View0,pc0,View1,pc1>::reschedule(Space& home) { 758 if (pc0 != PC_GEN_NONE) 759 x.reschedule(home,*this,pc0); 760 if (pc1 != PC_GEN_NONE) 761 y.reschedule(home,*this,pc1); 762 } 763 764 template<class View0, PropCond pc0, class View1, PropCond pc1> 765 forceinline size_t 766 MixNaryOnePropagator<View0,pc0,View1,pc1>::dispose(Space& home) { 767 if (pc0 != PC_GEN_NONE) 768 x.cancel(home,*this,pc0); 769 if (pc1 != PC_GEN_NONE) 770 y.cancel(home,*this,pc1); 771 (void) Propagator::dispose(home); 772 return sizeof(*this); 773 } 774 775} 776 777// STATISTICS: kernel-prop