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, 2009 9 * Guido Tack, 2010 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 36#ifndef GECODE_INT_UNARY_HH 37#define GECODE_INT_UNARY_HH 38 39#include <gecode/int/task.hh> 40 41/** 42 * \namespace Gecode::Int::Unary 43 * 44 * The algorithms and data structures follow (mostly): 45 * Petr Vilím, Global Constraints in Int, PhD thesis, 46 * Charles University, Prague, Czech Republic, 2007. 47 * 48 * \brief %Int for unary resources 49 */ 50 51namespace Gecode { namespace Int { namespace Unary { 52 53 /// %Unary (mandatory) task with fixed processing time 54 class ManFixPTask { 55 protected: 56 /// Start time 57 Int::IntView _s; 58 /// Processing time 59 int _p; 60 public: 61 /// \name Constructors and initialization 62 //@{ 63 /// Default constructor 64 ManFixPTask(void); 65 /// Initialize with start time \a s and processing time \a p 66 ManFixPTask(IntVar s, int p); 67 /// Initialize with start time \a s and processing time \a p 68 void init(IntVar s, int p); 69 /// Initialize from task \a t 70 void init(const ManFixPTask& t); 71 //@} 72 73 /// \name Value access 74 //@{ 75 /// Return earliest start time 76 int est(void) const; 77 /// Return earliest completion time 78 int ect(void) const; 79 /// Return latest start time 80 int lst(void) const; 81 /// Return latest completion time 82 int lct(void) const; 83 /// Return minimum processing time 84 int pmin(void) const; 85 /// Return maximum processing time 86 int pmax(void) const; 87 /// Return start time 88 IntVar st(void) const; 89 /// Whether task is mandatory 90 bool mandatory(void) const; 91 /// Whether task is excluded 92 bool excluded(void) const; 93 /// Whether task can still be optional 94 bool optional(void) const; 95 //@} 96 97 /// \name Domain tests 98 //@{ 99 /// Test whether task is assigned 100 bool assigned(void) const; 101 //@} 102 103 /// \name Value update 104 //@{ 105 /// Update earliest start time to \a n 106 ModEvent est(Space& home, int n); 107 /// Update earliest completion time to \a n 108 ModEvent ect(Space& home, int n); 109 /// Update latest start time to \a n 110 ModEvent lst(Space& home, int n); 111 /// Update latest completion time to \a n 112 ModEvent lct(Space& home, int n); 113 /// Update such that task cannot run from \a e to \a l 114 ModEvent norun(Space& home, int e, int l); 115 /// Mark task as mandatory 116 ModEvent mandatory(Space& home); 117 /// Mark task as excluded 118 ModEvent excluded(Space& home); 119 //@} 120 121 /// \name Cloning 122 //@{ 123 /// Update this task to be a clone of task \a t 124 void update(Space& home, ManFixPTask& t); 125 //@} 126 127 /// \name Dependencies 128 //@{ 129 /// Subscribe propagator \a p to task 130 void subscribe(Space& home, Propagator& p, PropCond pc); 131 /// Cancel subscription of propagator \a p for task 132 void cancel(Space& home, Propagator& p, PropCond pc); 133 /// Schedule propagator \a p 134 void reschedule(Space& home, Propagator& p, PropCond pc); 135 //@} 136 137 }; 138 139 /** 140 * \brief Print task in format est:p:lct 141 * \relates ManFixPTask 142 */ 143 template<class Char, class Traits> 144 std::basic_ostream<Char,Traits>& 145 operator <<(std::basic_ostream<Char,Traits>& os, const ManFixPTask& t); 146 147 /// %Unary (mandatory) task with fixed processing, start or end time 148 class ManFixPSETask : public ManFixPTask { 149 protected: 150 /// Task type 151 TaskType _t; 152 public: 153 /// \name Constructors and initialization 154 //@{ 155 /// Default constructor 156 ManFixPSETask(void); 157 /** 158 * \brief Initialize task 159 * 160 * Depending on \a t, \a s is either the end time (if \a t is TT_FIXS) 161 * or the start time of the task, and \a p is the fixed parameter. 162 */ 163 ManFixPSETask(TaskType t, IntVar s, int p); 164 /** 165 * \brief Initialize task 166 * 167 * Depending on \a t, \a s is either the end time (if \a t is FIXS) 168 * or the start time of the task, and \a p is the fixed parameter. 169 */ 170 void init(TaskType t, IntVar s, int p); 171 /// Initialize from task \a t 172 void init(const ManFixPSETask& t); 173 //@} 174 175 /// \name Value access 176 //@{ 177 /// Return earliest start time 178 int est(void) const; 179 /// Return earliest completion time 180 int ect(void) const; 181 /// Return latest start time 182 int lst(void) const; 183 /// Return latest completion time 184 int lct(void) const; 185 /// Return minimum processing time 186 int pmin(void) const; 187 /// Return maximum processing time 188 int pmax(void) const; 189 //@} 190 191 /// \name Value update 192 //@{ 193 /// Update earliest start time to \a n 194 ModEvent est(Space& home, int n); 195 /// Update earliest completion time to \a n 196 ModEvent ect(Space& home, int n); 197 /// Update latest start time to \a n 198 ModEvent lst(Space& home, int n); 199 /// Update latest completion time to \a n 200 ModEvent lct(Space& home, int n); 201 /// Update such that task cannot run from \a e to \a l 202 ModEvent norun(Space& home, int e, int l); 203 //@} 204 205 /// \name Cloning 206 //@{ 207 /// Update this task to be a clone of task \a t 208 void update(Space& home, ManFixPSETask& t); 209 //@} 210 211 }; 212 213 /** 214 * \brief Print task in format est:[p,c]:lct 215 * \relates ManFixPSETask 216 */ 217 template<class Char, class Traits> 218 std::basic_ostream<Char,Traits>& 219 operator <<(std::basic_ostream<Char,Traits>& os, const ManFixPSETask& t); 220 221 /// %Unary optional task with fixed processing time 222 class OptFixPTask : public ManToOptTask<ManFixPTask> { 223 protected: 224 using ManToOptTask<ManFixPTask>::_m; 225 public: 226 /// \name Constructors and initialization 227 //@{ 228 /// Default constructor 229 OptFixPTask(void); 230 /// Initialize with start time \a s, processing time \a p, and mandatory flag \a m 231 OptFixPTask(IntVar s, int p, BoolVar m); 232 /// Initialize with start time \a s, processing time \a p, and mandatory flag \a m 233 void init(IntVar s, int p, BoolVar m); 234 //@} 235 }; 236 237 /** 238 * \brief Print optional task in format est:p:lct:m 239 * \relates OptFixPTask 240 */ 241 template<class Char, class Traits> 242 std::basic_ostream<Char,Traits>& 243 operator <<(std::basic_ostream<Char,Traits>& os, const OptFixPTask& t); 244 245 /// Unary optional task with fixed processing, start or end time 246 class OptFixPSETask : public ManToOptTask<ManFixPSETask> { 247 protected: 248 using ManToOptTask<ManFixPSETask>::_m; 249 public: 250 /// \name Constructors and initialization 251 //@{ 252 /// Default constructor 253 OptFixPSETask(void); 254 /// Initialize with start time \a s, processing time \a p, and mandatory flag \a m 255 OptFixPSETask(TaskType t, IntVar s, int p, BoolVar m); 256 /// Initialize with start time \a s, processing time \a p, and mandatory flag \a m 257 void init(TaskType t, IntVar s, int p, BoolVar m); 258 //@} 259 }; 260 261 /** 262 * \brief Print optional task in format est:p:lct:m 263 * \relates OptFixPSETask 264 */ 265 template<class Char, class Traits> 266 std::basic_ostream<Char,Traits>& 267 operator <<(std::basic_ostream<Char,Traits>& os, const OptFixPSETask& t); 268 269 /// %Unary (mandatory) task with flexible processing time 270 class ManFlexTask { 271 protected: 272 /// Start time 273 Int::IntView _s; 274 /// Processing time 275 Int::IntView _p; 276 /// End time 277 Int::IntView _e; 278 public: 279 /// \name Constructors and initialization 280 //@{ 281 /// Default constructor 282 ManFlexTask(void); 283 /// Initialize with start time \a s, processing time \a p, end time \a e 284 ManFlexTask(IntVar s, IntVar p, IntVar e); 285 /// Initialize with start time \a s, processing time \a p, end time \a e 286 void init(IntVar s, IntVar p, IntVar e); 287 /// Initialize from task \a t 288 void init(const ManFlexTask& t); 289 //@} 290 291 /// \name Value access 292 //@{ 293 /// Return earliest start time 294 int est(void) const; 295 /// Return earliest completion time 296 int ect(void) const; 297 /// Return latest start time 298 int lst(void) const; 299 /// Return latest completion time 300 int lct(void) const; 301 /// Return minimum processing time 302 int pmin(void) const; 303 /// Return maximum processing time 304 int pmax(void) const; 305 /// Return start time 306 IntVar st(void) const; 307 /// Return processing time 308 IntVar p(void) const; 309 /// Return end time 310 IntVar e(void) const; 311 /// Whether task is mandatory 312 bool mandatory(void) const; 313 /// Whether task is excluded 314 bool excluded(void) const; 315 /// Whether task can still be optional 316 bool optional(void) const; 317 //@} 318 319 /// \name Domain tests 320 //@{ 321 /// Test whether task is assigned 322 bool assigned(void) const; 323 //@} 324 325 /// \name Value update 326 //@{ 327 /// Update earliest start time to \a n 328 ModEvent est(Space& home, int n); 329 /// Update earliest completion time to \a n 330 ModEvent ect(Space& home, int n); 331 /// Update latest start time to \a n 332 ModEvent lst(Space& home, int n); 333 /// Update latest completion time to \a n 334 ModEvent lct(Space& home, int n); 335 /// Update such that task cannot run from \a e to \a l 336 ModEvent norun(Space& home, int e, int l); 337 /// Mark task as mandatory 338 ModEvent mandatory(Space& home); 339 /// Mark task as excluded 340 ModEvent excluded(Space& home); 341 //@} 342 343 /// \name Cloning 344 //@{ 345 /// Update this task to be a clone of task \a t 346 void update(Space& home, ManFlexTask& t); 347 //@} 348 349 /// \name Dependencies 350 //@{ 351 /// Subscribe propagator \a p to task 352 void subscribe(Space& home, Propagator& p, PropCond pc); 353 /// Cancel subscription of propagator \a p for task 354 void cancel(Space& home, Propagator& p, PropCond pc); 355 /// Schedule propagator \a p 356 void reschedule(Space& home, Propagator& p, PropCond pc); 357 //@} 358 359 }; 360 361 /** 362 * \brief Print task in format est:lst:pmin:pmax:ect:lct 363 * \relates ManFlexTask 364 */ 365 template<class Char, class Traits> 366 std::basic_ostream<Char,Traits>& 367 operator <<(std::basic_ostream<Char,Traits>& os, const ManFlexTask& t); 368 369 /// %Unary optional task with flexible processing time 370 class OptFlexTask : public ManToOptTask<ManFlexTask> { 371 protected: 372 using ManToOptTask<ManFlexTask>::_m; 373 public: 374 /// \name Constructors and initialization 375 //@{ 376 /// Default constructor 377 OptFlexTask(void); 378 /// Initialize with start time \a s, processing time \a p, end time \a e, and mandatory flag \a m 379 OptFlexTask(IntVar s, IntVar p, IntVar e, BoolVar m); 380 /// Initialize with start time \a s, processing time \a p, end time \a e, and mandatory flag \a m 381 void init(IntVar s, IntVar p, IntVar e, BoolVar m); 382 //@} 383 }; 384 385 /** 386 * \brief Print optional task in format est:lst:pmin:pmax:ect:lct:m 387 * \relates OptFlexTask 388 */ 389 template<class Char, class Traits> 390 std::basic_ostream<Char,Traits>& 391 operator <<(std::basic_ostream<Char,Traits>& os, const OptFlexTask& t); 392 393}}} 394 395#include <gecode/int/unary/task.hpp> 396 397namespace Gecode { namespace Int { namespace Unary { 398 399 /// Forward mandatory fixed task view 400 typedef ManFixPTask ManFixPTaskFwd; 401 402 /// Backward (dual) mandatory fixed task view 403 typedef FwdToBwd<ManFixPTaskFwd> ManFixPTaskBwd; 404 405 /// Forward mandatory fixed task view 406 typedef ManFixPSETask ManFixPSETaskFwd; 407 408 /// Backward (dual) mandatory fixed task view 409 typedef FwdToBwd<ManFixPSETaskFwd> ManFixPSETaskBwd; 410 411 /// Forward optional fixed task view 412 typedef OptFixPTask OptFixPTaskFwd; 413 414 /// Backward (dual) optional fixed task view 415 typedef FwdToBwd<OptFixPTaskFwd> OptFixPTaskBwd; 416 417 /// Forward optional fixed task view 418 typedef OptFixPSETask OptFixPSETaskFwd; 419 420 /// Backward (dual) optional fixed task view 421 typedef FwdToBwd<OptFixPSETaskFwd> OptFixPSETaskBwd; 422 423 /// Forward mandatory flexible task view 424 typedef ManFlexTask ManFlexTaskFwd; 425 426 /// Backward (dual) mandatory flexible task view 427 typedef FwdToBwd<ManFlexTaskFwd> ManFlexTaskBwd; 428 429 /// Forward optional flexible task view 430 typedef OptFlexTask OptFlexTaskFwd; 431 432 /// Backward (dual) optional flexible task view 433 typedef FwdToBwd<OptFlexTaskFwd> OptFlexTaskBwd; 434 435 436 /** 437 * \brief Print backward task view in format est:p:lct 438 * \relates ManFixPTaskBwd 439 */ 440 template<class Char, class Traits> 441 std::basic_ostream<Char,Traits>& 442 operator <<(std::basic_ostream<Char,Traits>& os, const ManFixPTaskBwd& t); 443 444 /** 445 * \brief Print backward task view in format est:p:lct 446 * \relates ManFixPSETaskBwd 447 */ 448 template<class Char, class Traits> 449 std::basic_ostream<Char,Traits>& 450 operator <<(std::basic_ostream<Char,Traits>& os, const ManFixPSETaskBwd& t); 451 452 /** 453 * \brief Print optional backward task view in format est:p:lct:m 454 * \relates OptFixPTaskBwd 455 */ 456 template<class Char, class Traits> 457 std::basic_ostream<Char,Traits>& 458 operator <<(std::basic_ostream<Char,Traits>& os, const OptFixPTaskBwd& t); 459 460 /** 461 * \brief Print optional backward task view in format est:p:lct:m 462 * \relates OptFixPSETaskBwd 463 */ 464 template<class Char, class Traits> 465 std::basic_ostream<Char,Traits>& 466 operator <<(std::basic_ostream<Char,Traits>& os, const OptFixPSETaskBwd& t); 467 468 /** 469 * \brief Print backward task view in format est:lst:pmin:pmax:ect:lct 470 * \relates ManFlexTaskBwd 471 */ 472 template<class Char, class Traits> 473 std::basic_ostream<Char,Traits>& 474 operator <<(std::basic_ostream<Char,Traits>& os, const ManFlexTaskBwd& t); 475 476 /** 477 * \brief Print optional backward task view in format 478 * est:lst:pmin:pmax:ect:lct:m 479 * 480 * \relates OptFlexTaskBwd 481 */ 482 template<class Char, class Traits> 483 std::basic_ostream<Char,Traits>& 484 operator <<(std::basic_ostream<Char,Traits>& os, const OptFlexTaskBwd& t); 485 486}}} 487 488#include <gecode/int/unary/task-view.hpp> 489 490namespace Gecode { namespace Int { 491 492 /// Task view traits for forward task views 493 template<> 494 class TaskViewTraits<Unary::ManFixPTaskFwd> { 495 public: 496 /// The task type 497 typedef Unary::ManFixPTask Task; 498 }; 499 500 /// Task view traits for backward task views 501 template<> 502 class TaskViewTraits<Unary::ManFixPTaskBwd> { 503 public: 504 /// The task type 505 typedef Unary::ManFixPTask Task; 506 }; 507 508 /// Task view traits for forward task views 509 template<> 510 class TaskViewTraits<Unary::ManFixPSETaskFwd> { 511 public: 512 /// The task type 513 typedef Unary::ManFixPSETask Task; 514 }; 515 516 /// Task view traits for backward task views 517 template<> 518 class TaskViewTraits<Unary::ManFixPSETaskBwd> { 519 public: 520 /// The task type 521 typedef Unary::ManFixPSETask Task; 522 }; 523 524 /// Task view traits for forward optional task views 525 template<> 526 class TaskViewTraits<Unary::OptFixPTaskFwd> { 527 public: 528 /// The task type 529 typedef Unary::OptFixPTask Task; 530 }; 531 532 /// Task view traits for backward task views 533 template<> 534 class TaskViewTraits<Unary::OptFixPTaskBwd> { 535 public: 536 /// The task type 537 typedef Unary::OptFixPTask Task; 538 }; 539 540 /// Task view traits for forward optional task views 541 template<> 542 class TaskViewTraits<Unary::OptFixPSETaskFwd> { 543 public: 544 /// The task type 545 typedef Unary::OptFixPSETask Task; 546 }; 547 548 /// Task view traits for backward task views 549 template<> 550 class TaskViewTraits<Unary::OptFixPSETaskBwd> { 551 public: 552 /// The task type 553 typedef Unary::OptFixPSETask Task; 554 }; 555 556 /// Task view traits for forward task views 557 template<> 558 class TaskViewTraits<Unary::ManFlexTaskFwd> { 559 public: 560 /// The task type 561 typedef Unary::ManFlexTask Task; 562 }; 563 564 /// Task view traits for backward task views 565 template<> 566 class TaskViewTraits<Unary::ManFlexTaskBwd> { 567 public: 568 /// The task type 569 typedef Unary::ManFlexTask Task; 570 }; 571 572 /// Task view traits for forward optional task views 573 template<> 574 class TaskViewTraits<Unary::OptFlexTaskFwd> { 575 public: 576 /// The task type 577 typedef Unary::OptFlexTask Task; 578 }; 579 580 /// Task view traits for backward task views 581 template<> 582 class TaskViewTraits<Unary::OptFlexTaskBwd> { 583 public: 584 /// The task type 585 typedef Unary::OptFlexTask Task; 586 }; 587 588 589 /// Task traits for mandatory fixed tasks 590 template<> 591 class TaskTraits<Unary::ManFixPTask> { 592 public: 593 /// The forward task view type 594 typedef Unary::ManFixPTaskFwd TaskViewFwd; 595 /// The backward task view type 596 typedef Unary::ManFixPTaskBwd TaskViewBwd; 597 }; 598 599 /// Task traits for mandatory fixed tasks 600 template<> 601 class TaskTraits<Unary::ManFixPSETask> { 602 public: 603 /// The forward task view type 604 typedef Unary::ManFixPSETaskFwd TaskViewFwd; 605 /// The backward task view type 606 typedef Unary::ManFixPSETaskBwd TaskViewBwd; 607 }; 608 609 /// Task traits for optional fixed tasks 610 template<> 611 class TaskTraits<Unary::OptFixPTask> { 612 public: 613 /// The forward task view type 614 typedef Unary::OptFixPTaskFwd TaskViewFwd; 615 /// The backward task view type 616 typedef Unary::OptFixPTaskBwd TaskViewBwd; 617 /// The corresponding mandatory task 618 typedef Unary::ManFixPTask ManTask; 619 }; 620 621 /// Task traits for optional fixed tasks 622 template<> 623 class TaskTraits<Unary::OptFixPSETask> { 624 public: 625 /// The forward task view type 626 typedef Unary::OptFixPSETaskFwd TaskViewFwd; 627 /// The backward task view type 628 typedef Unary::OptFixPSETaskBwd TaskViewBwd; 629 /// The corresponding mandatory task 630 typedef Unary::ManFixPTask ManTask; 631 }; 632 633 /// Task traits for mandatory flexible tasks 634 template<> 635 class TaskTraits<Unary::ManFlexTask> { 636 public: 637 /// The forward task view type 638 typedef Unary::ManFlexTaskFwd TaskViewFwd; 639 /// The backward task view type 640 typedef Unary::ManFlexTaskBwd TaskViewBwd; 641 }; 642 643 /// Task traits for optional flexible tasks 644 template<> 645 class TaskTraits<Unary::OptFlexTask> { 646 public: 647 /// The forward task view type 648 typedef Unary::OptFlexTaskFwd TaskViewFwd; 649 /// The backward task view type 650 typedef Unary::OptFlexTaskBwd TaskViewBwd; 651 /// The corresponding mandatory task 652 typedef Unary::ManFlexTask ManTask; 653 }; 654 655}} 656 657namespace Gecode { namespace Int { namespace Unary { 658 659 /// Node for an omega tree 660 class OmegaNode { 661 public: 662 /// Processing time for subtree 663 int p; 664 /// Earliest completion time for subtree 665 int ect; 666 /// Initialize node from left child \a l and right child \a r 667 void init(const OmegaNode& l, const OmegaNode& r); 668 /// Update node from left child \a l and right child \a r 669 void update(const OmegaNode& l, const OmegaNode& r); 670 }; 671 672 /// Omega trees for computing ect of task sets 673 template<class TaskView> 674 class OmegaTree : public TaskTree<TaskView,OmegaNode> { 675 protected: 676 using TaskTree<TaskView,OmegaNode>::tasks; 677 using TaskTree<TaskView,OmegaNode>::leaf; 678 using TaskTree<TaskView,OmegaNode>::root; 679 using TaskTree<TaskView,OmegaNode>::init; 680 using TaskTree<TaskView,OmegaNode>::update; 681 public: 682 /// Initialize tree for tasks \a t 683 OmegaTree(Region& r, const TaskViewArray<TaskView>& t); 684 /// Insert task with index \a i 685 void insert(int i); 686 /// Remove task with index \a i 687 void remove(int i); 688 /// Return earliest completion time of all tasks 689 int ect(void) const; 690 /// Return earliest completion time of all tasks but \a i 691 int ect(int i) const; 692 }; 693 694 /// Node for an omega lambda tree 695 class OmegaLambdaNode : public OmegaNode { 696 public: 697 /// Undefined task 698 static const int undef = -1; 699 /// Processing times for subtree 700 int lp; 701 /// Earliest completion times for subtree 702 int lect; 703 /// Node which is responsible for lect 704 int resEct; 705 /// Node which is responsible for lp 706 int resLp; 707 /// Initialize node from left child \a l and right child \a r 708 void init(const OmegaLambdaNode& l, const OmegaLambdaNode& r); 709 /// Update node from left child \a l and right child \a r 710 void update(const OmegaLambdaNode& l, const OmegaLambdaNode& r); 711 }; 712 713 /// Omega-lambda trees for computing ect of task sets 714 template<class TaskView> 715 class OmegaLambdaTree : public TaskTree<TaskView,OmegaLambdaNode> { 716 protected: 717 using TaskTree<TaskView,OmegaLambdaNode>::tasks; 718 using TaskTree<TaskView,OmegaLambdaNode>::leaf; 719 using TaskTree<TaskView,OmegaLambdaNode>::root; 720 using TaskTree<TaskView,OmegaLambdaNode>::init; 721 using TaskTree<TaskView,OmegaLambdaNode>::update; 722 public: 723 /// Initialize tree for tasks \a t with all tasks included, if \a inc is true 724 OmegaLambdaTree(Region& r, const TaskViewArray<TaskView>& t, 725 bool inc=true); 726 /// Shift task with index \a i from omega to lambda 727 void shift(int i); 728 /// Insert task with index \a i to omega 729 void oinsert(int i); 730 /// Insert task with index \a i to lambda 731 void linsert(int i); 732 /// Remove task with index \a i from lambda 733 void lremove(int i); 734 /// Whether has responsible task 735 bool lempty(void) const; 736 /// Return responsible task 737 int responsible(void) const; 738 /// Return earliest completion time of all tasks 739 int ect(void) const; 740 /// Return earliest completion time of all tasks excluding lambda tasks 741 int lect(void) const; 742 }; 743 744}}} 745 746#include <gecode/int/unary/tree.hpp> 747 748namespace Gecode { namespace Int { namespace Unary { 749 750 /// Check mandatory tasks \a t for overload 751 template<class ManTask> 752 ExecStatus overload(TaskArray<ManTask>& t); 753 /// Check optional tasks \a t for overload 754 template<class OptTask, class PL> 755 ExecStatus overload(Space& home, Propagator& p, TaskArray<OptTask>& t); 756 757 /// Perform time-tabling propagation 758 template<class Task> 759 ExecStatus timetabling(Space& home, Propagator& p, TaskArray<Task>& t); 760 761 /// Check tasks \a t for subsumption 762 template<class Task> 763 ExecStatus subsumed(Space& home, Propagator& p, TaskArray<Task>& t); 764 765 /// Propagate detectable precedences 766 template<class ManTask> 767 ExecStatus detectable(Space& home, TaskArray<ManTask>& t); 768 /// Propagate detectable precedences 769 template<class OptTask, class PL> 770 ExecStatus detectable(Space& home, Propagator& p, TaskArray<OptTask>& t); 771 772 /// Propagate not-first and not-last 773 template<class ManTask> 774 ExecStatus notfirstnotlast(Space& home, TaskArray<ManTask>& t); 775 /// Propagate not-first and not-last 776 template<class OptTask, class PL> 777 ExecStatus notfirstnotlast(Space& home, Propagator& p, TaskArray<OptTask>& t); 778 779 /// Propagate by edge-finding 780 template<class Task> 781 ExecStatus edgefinding(Space& home, TaskArray<Task>& t); 782 783 784 /** 785 * \brief %Scheduling propagator for unary resource with mandatory tasks 786 * 787 * Requires \code #include <gecode/int/unary.hh> \endcode 788 * \ingroup FuncIntProp 789 */ 790 template<class ManTask, class PL> 791 class ManProp : public TaskProp<ManTask,PL> { 792 protected: 793 using TaskProp<ManTask,PL>::t; 794 /// Constructor for creation 795 ManProp(Home home, TaskArray<ManTask>& t); 796 /// Constructor for cloning \a p 797 ManProp(Space& home, ManProp& p); 798 public: 799 /// Perform copying during cloning 800 virtual Actor* copy(Space& home); 801 /// Perform propagation 802 virtual ExecStatus propagate(Space& home, const ModEventDelta& med); 803 /// Post propagator that schedules tasks on unary resource 804 static ExecStatus post(Home home, TaskArray<ManTask>& t); 805 }; 806 807 /** 808 * \brief %Scheduling propagator for unary resource with optional tasks 809 * 810 * Requires \code #include <gecode/int/unary.hh> \endcode 811 * \ingroup FuncIntProp 812 */ 813 template<class OptTask, class PL> 814 class OptProp : public TaskProp<OptTask,PL> { 815 protected: 816 using TaskProp<OptTask,PL>::t; 817 /// Constructor for creation 818 OptProp(Home home, TaskArray<OptTask>& t); 819 /// Constructor for cloning \a p 820 OptProp(Space& home, OptProp& p); 821 public: 822 /// Perform copying during cloning 823 virtual Actor* copy(Space& home); 824 /// Perform propagation 825 virtual ExecStatus propagate(Space& home, const ModEventDelta& med); 826 /// Post propagator that schedules tasks on unary resource 827 static ExecStatus post(Home home, TaskArray<OptTask>& t); 828 }; 829 830 /// Post mandatory task propagator according to propagation level 831 template<class ManTask> 832 ExecStatus 833 manpost(Home home, TaskArray<ManTask>& t, IntPropLevel ipl); 834 835 /// Post optional task propagator according to propagation level 836 template<class OptTask> 837 ExecStatus 838 optpost(Home home, TaskArray<OptTask>& t, IntPropLevel ipl); 839 840}}} 841 842#include <gecode/int/unary/overload.hpp> 843#include <gecode/int/unary/time-tabling.hpp> 844#include <gecode/int/unary/subsumption.hpp> 845#include <gecode/int/unary/detectable.hpp> 846#include <gecode/int/unary/not-first-not-last.hpp> 847#include <gecode/int/unary/edge-finding.hpp> 848 849#include <gecode/int/unary/man-prop.hpp> 850#include <gecode/int/unary/opt-prop.hpp> 851#include <gecode/int/unary/post.hpp> 852 853#endif 854 855// STATISTICS: int-prop