00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #ifndef __GECODE_INT_CUMULATIVE_HH__
00041 #define __GECODE_INT_CUMULATIVE_HH__
00042
00043 #include <gecode/int/task.hh>
00044 #include <gecode/int/unary.hh>
00045
00059 namespace Gecode { namespace Int { namespace Cumulative {
00060
00062 void mul_check(long long int x, long long int y);
00063
00065 void mul_check(long long int x, long long int y, long long int z);
00066
00067 }}}
00068
00069 #include <gecode/int/cumulative/limits.hpp>
00070
00071 namespace Gecode { namespace Int { namespace Cumulative {
00072
00074 class ManFixPTask : public Unary::ManFixPTask {
00075 protected:
00077 int _c;
00078 public:
00080
00081
00082 ManFixPTask(void);
00084 ManFixPTask(IntVar s, int p, int c);
00086 void init(IntVar s, int p, int c);
00088 void init(const ManFixPTask& t);
00090
00092
00093
00094 int c(void) const;
00096 long long int e(void) const;
00098
00100
00101
00102 void update(Space& home, bool share, ManFixPTask& t);
00104
00105 };
00106
00111 template<class Char, class Traits>
00112 std::basic_ostream<Char,Traits>&
00113 operator <<(std::basic_ostream<Char,Traits>& os, const ManFixPTask& t);
00114
00116 class ManFixPSETask : public Unary::ManFixPSETask {
00117 protected:
00119 int _c;
00120 public:
00122
00123
00124 ManFixPSETask(void);
00132 ManFixPSETask(TaskType t, IntVar s, int p, int c);
00140 void init(TaskType t, IntVar s, int p, int c);
00142 void init(const ManFixPSETask& t);
00144
00146
00147
00148 int c(void) const;
00150 long long int e(void) const;
00152
00154
00155
00156 void update(Space& home, bool share, ManFixPSETask& t);
00158
00159 };
00160
00165 template<class Char, class Traits>
00166 std::basic_ostream<Char,Traits>&
00167 operator <<(std::basic_ostream<Char,Traits>& os, const ManFixPSETask& t);
00168
00170 class ManFlexTask : public Unary::ManFlexTask {
00171 protected:
00173 int _c;
00174 public:
00176
00177
00178 ManFlexTask(void);
00180 ManFlexTask(IntVar s, IntVar p, IntVar e, int c);
00182 void init(IntVar s, IntVar p, IntVar e, int c);
00184 void init(const ManFlexTask& t);
00186
00188
00189
00190 int c(void) const;
00192 long long int e(void) const;
00194
00196
00197
00198 void update(Space& home, bool share, ManFlexTask& t);
00200
00201 };
00202
00207 template<class Char, class Traits>
00208 std::basic_ostream<Char,Traits>&
00209 operator <<(std::basic_ostream<Char,Traits>& os, const ManFlexTask& t);
00210
00211
00213 class OptFixPTask : public ManToOptTask<ManFixPTask> {
00214 protected:
00215 using ManToOptTask<ManFixPTask>::_m;
00216 public:
00218
00219
00220 OptFixPTask(void);
00222 OptFixPTask(IntVar s, int p, int c, BoolVar m);
00224 void init(IntVar s, int p, int c, BoolVar m);
00226
00227 operator Unary::OptFixPTask (void);
00228 };
00229
00234 template<class Char, class Traits>
00235 std::basic_ostream<Char,Traits>&
00236 operator <<(std::basic_ostream<Char,Traits>& os, const OptFixPTask& t);
00237
00239 class OptFixPSETask : public ManToOptTask<ManFixPSETask> {
00240 protected:
00241 using ManToOptTask<ManFixPSETask>::_m;
00242 public:
00244
00245
00246 OptFixPSETask(void);
00248 OptFixPSETask(TaskType t, IntVar s, int p, int c, BoolVar m);
00250 void init(TaskType t, IntVar s, int p, int c, BoolVar m);
00252
00253 operator Unary::OptFixPSETask (void);
00254 };
00255
00260 template<class Char, class Traits>
00261 std::basic_ostream<Char,Traits>&
00262 operator <<(std::basic_ostream<Char,Traits>& os, const OptFixPSETask& t);
00263
00265 class OptFlexTask : public ManToOptTask<ManFlexTask> {
00266 protected:
00267 using ManToOptTask<ManFlexTask>::_m;
00268 public:
00270
00271
00272 OptFlexTask(void);
00274 OptFlexTask(IntVar s, IntVar p, IntVar e, int c, BoolVar m);
00276 void init(IntVar s, IntVar p, IntVar e, int c, BoolVar m);
00278
00279 operator Unary::OptFlexTask (void);
00280 };
00281
00286 template<class Char, class Traits>
00287 std::basic_ostream<Char,Traits>&
00288 operator <<(std::basic_ostream<Char,Traits>& os, const OptFlexTask& t);
00289
00290 }}}
00291
00292 #include <gecode/int/cumulative/task.hpp>
00293
00294 namespace Gecode { namespace Int { namespace Cumulative {
00295
00297 typedef ManFixPTask ManFixPTaskFwd;
00298
00300 typedef FwdToBwd<ManFixPTaskFwd> ManFixPTaskBwd;
00301
00303 typedef ManFixPSETask ManFixPSETaskFwd;
00304
00306 typedef FwdToBwd<ManFixPSETaskFwd> ManFixPSETaskBwd;
00307
00309 typedef OptFixPTask OptFixPTaskFwd;
00310
00312 typedef FwdToBwd<OptFixPTaskFwd> OptFixPTaskBwd;
00313
00315 typedef OptFixPSETask OptFixPSETaskFwd;
00316
00318 typedef FwdToBwd<OptFixPSETaskFwd> OptFixPSETaskBwd;
00319
00321 typedef ManFlexTask ManFlexTaskFwd;
00322
00324 typedef FwdToBwd<ManFlexTaskFwd> ManFlexTaskBwd;
00325
00327 typedef OptFlexTask OptFlexTaskFwd;
00328
00330 typedef FwdToBwd<OptFlexTaskFwd> OptFlexTaskBwd;
00331
00332
00337 template<class Char, class Traits>
00338 std::basic_ostream<Char,Traits>&
00339 operator <<(std::basic_ostream<Char,Traits>& os, const ManFixPTaskBwd& t);
00340
00345 template<class Char, class Traits>
00346 std::basic_ostream<Char,Traits>&
00347 operator <<(std::basic_ostream<Char,Traits>& os, const ManFixPSETaskBwd& t);
00348
00353 template<class Char, class Traits>
00354 std::basic_ostream<Char,Traits>&
00355 operator <<(std::basic_ostream<Char,Traits>& os, const OptFixPTaskBwd& t);
00356
00361 template<class Char, class Traits>
00362 std::basic_ostream<Char,Traits>&
00363 operator <<(std::basic_ostream<Char,Traits>& os, const OptFixPSETaskBwd& t);
00364
00365 }}}
00366
00367 #include <gecode/int/cumulative/task-view.hpp>
00368
00369 namespace Gecode { namespace Int {
00370
00372 template<>
00373 class TaskViewTraits<Cumulative::ManFixPTaskFwd> {
00374 public:
00376 typedef Cumulative::ManFixPTask Task;
00377 };
00378
00380 template<>
00381 class TaskViewTraits<Cumulative::ManFixPTaskBwd> {
00382 public:
00384 typedef Cumulative::ManFixPTask Task;
00385 };
00386
00388 template<>
00389 class TaskViewTraits<Cumulative::ManFixPSETaskFwd> {
00390 public:
00392 typedef Cumulative::ManFixPSETask Task;
00393 };
00394
00396 template<>
00397 class TaskViewTraits<Cumulative::ManFixPSETaskBwd> {
00398 public:
00400 typedef Cumulative::ManFixPSETask Task;
00401 };
00402
00404 template<>
00405 class TaskViewTraits<Cumulative::OptFixPTaskFwd> {
00406 public:
00408 typedef Cumulative::OptFixPTask Task;
00409 };
00410
00412 template<>
00413 class TaskViewTraits<Cumulative::OptFixPTaskBwd> {
00414 public:
00416 typedef Cumulative::OptFixPTask Task;
00417 };
00418
00420 template<>
00421 class TaskViewTraits<Cumulative::OptFixPSETaskFwd> {
00422 public:
00424 typedef Cumulative::OptFixPSETask Task;
00425 };
00426
00428 template<>
00429 class TaskViewTraits<Cumulative::OptFixPSETaskBwd> {
00430 public:
00432 typedef Cumulative::OptFixPSETask Task;
00433 };
00434
00436 template<>
00437 class TaskViewTraits<Cumulative::ManFlexTaskFwd> {
00438 public:
00440 typedef Cumulative::ManFlexTask Task;
00441 };
00442
00444 template<>
00445 class TaskViewTraits<Cumulative::ManFlexTaskBwd> {
00446 public:
00448 typedef Cumulative::ManFlexTask Task;
00449 };
00450
00452 template<>
00453 class TaskViewTraits<Cumulative::OptFlexTaskFwd> {
00454 public:
00456 typedef Cumulative::OptFlexTask Task;
00457 };
00458
00460 template<>
00461 class TaskViewTraits<Cumulative::OptFlexTaskBwd> {
00462 public:
00464 typedef Cumulative::OptFlexTask Task;
00465 };
00466
00467
00469 template<>
00470 class TaskTraits<Cumulative::ManFixPTask> {
00471 public:
00473 typedef Cumulative::ManFixPTaskFwd TaskViewFwd;
00475 typedef Cumulative::ManFixPTaskBwd TaskViewBwd;
00477 typedef Unary::ManFixPTask UnaryTask;
00478 };
00479
00481 template<>
00482 class TaskTraits<Cumulative::ManFixPSETask> {
00483 public:
00485 typedef Cumulative::ManFixPSETaskFwd TaskViewFwd;
00487 typedef Cumulative::ManFixPSETaskBwd TaskViewBwd;
00489 typedef Unary::ManFixPSETask UnaryTask;
00490 };
00491
00493 template<>
00494 class TaskTraits<Cumulative::OptFixPTask> {
00495 public:
00497 typedef Cumulative::OptFixPTaskFwd TaskViewFwd;
00499 typedef Cumulative::OptFixPTaskBwd TaskViewBwd;
00501 typedef Cumulative::ManFixPTask ManTask;
00503 typedef Unary::OptFixPTask UnaryTask;
00504 };
00505
00507 template<>
00508 class TaskTraits<Cumulative::OptFixPSETask> {
00509 public:
00511 typedef Cumulative::OptFixPSETaskFwd TaskViewFwd;
00513 typedef Cumulative::OptFixPSETaskBwd TaskViewBwd;
00515 typedef Cumulative::ManFixPSETask ManTask;
00517 typedef Unary::OptFixPSETask UnaryTask;
00518 };
00519
00521 template<>
00522 class TaskTraits<Cumulative::ManFlexTask> {
00523 public:
00525 typedef Cumulative::ManFlexTaskFwd TaskViewFwd;
00527 typedef Cumulative::ManFlexTaskBwd TaskViewBwd;
00529 typedef Unary::ManFlexTask UnaryTask;
00530 };
00531
00533 template<>
00534 class TaskTraits<Cumulative::OptFlexTask> {
00535 public:
00537 typedef Cumulative::OptFlexTaskFwd TaskViewFwd;
00539 typedef Cumulative::OptFlexTaskBwd TaskViewBwd;
00541 typedef Cumulative::ManFlexTask ManTask;
00543 typedef Unary::OptFlexTask UnaryTask;
00544 };
00545
00546 }}
00547
00548 namespace Gecode { namespace Int { namespace Cumulative {
00549
00551 class OmegaNode {
00552 public:
00554 long long int e;
00556 long long int env;
00558 void init(const OmegaNode& l, const OmegaNode& r);
00560 void update(const OmegaNode& l, const OmegaNode& r);
00561 };
00562
00564 template<class TaskView>
00565 class OmegaTree : public TaskTree<TaskView,OmegaNode> {
00566 protected:
00567 using TaskTree<TaskView,OmegaNode>::tasks;
00568 using TaskTree<TaskView,OmegaNode>::leaf;
00569 using TaskTree<TaskView,OmegaNode>::root;
00570 using TaskTree<TaskView,OmegaNode>::init;
00571 using TaskTree<TaskView,OmegaNode>::update;
00573 int c;
00574 public:
00576 OmegaTree(Region& r, int c, const TaskViewArray<TaskView>& t);
00578 void insert(int i);
00580 void remove(int i);
00582 long long int env(void) const;
00583 };
00584
00586 class ExtOmegaNode : public OmegaNode {
00587 public:
00589 long long int cenv;
00591 void init(const ExtOmegaNode& l, const ExtOmegaNode& r);
00593 void update(const ExtOmegaNode& l, const ExtOmegaNode& r);
00594 };
00595
00597 template<class TaskView>
00598 class ExtOmegaTree : public TaskTree<TaskView,ExtOmegaNode> {
00599 protected:
00600 using TaskTree<TaskView,ExtOmegaNode>::tasks;
00601 using TaskTree<TaskView,ExtOmegaNode>::leaf;
00602 using TaskTree<TaskView,ExtOmegaNode>::root;
00603 using TaskTree<TaskView,ExtOmegaNode>::init;
00604 using TaskTree<TaskView,ExtOmegaNode>::update;
00605 using TaskTree<TaskView,ExtOmegaNode>::node;
00606 using TaskTree<TaskView,ExtOmegaNode>::n_leaf;
00607 using TaskTree<TaskView,ExtOmegaNode>::n_left;
00608 using TaskTree<TaskView,ExtOmegaNode>::left;
00609 using TaskTree<TaskView,ExtOmegaNode>::n_right;
00610 using TaskTree<TaskView,ExtOmegaNode>::right;
00611 using TaskTree<TaskView,ExtOmegaNode>::n_root;
00612 using TaskTree<TaskView,ExtOmegaNode>::n_parent;
00613 using TaskTree<TaskView,ExtOmegaNode>::n_nodes;
00614 using TaskTree<TaskView,ExtOmegaNode>::_leaf;
00616 int c, ci;
00617 public:
00619 template<class Node>
00620 ExtOmegaTree(Region& r, int c, const TaskTree<TaskView,Node>& t);
00622 void init(int ci);
00624 long long int env(int i);
00625 };
00626
00627
00629 class OmegaLambdaNode : public OmegaNode {
00630 public:
00632 static const int undef = -1;
00634 long long int le;
00636 long long int lenv;
00638 int resLe;
00640 int resLenv;
00642 void init(const OmegaLambdaNode& l, const OmegaLambdaNode& r);
00644 void update(const OmegaLambdaNode& l, const OmegaLambdaNode& r);
00645 };
00646
00648 template<class TaskView>
00649 class OmegaLambdaTree : public TaskTree<TaskView,OmegaLambdaNode> {
00650 protected:
00651 using TaskTree<TaskView,OmegaLambdaNode>::tasks;
00652 using TaskTree<TaskView,OmegaLambdaNode>::leaf;
00653 using TaskTree<TaskView,OmegaLambdaNode>::root;
00654 using TaskTree<TaskView,OmegaLambdaNode>::init;
00655 using TaskTree<TaskView,OmegaLambdaNode>::update;
00657 int c;
00658 public:
00660 OmegaLambdaTree(Region& r, int c, const TaskViewArray<TaskView>& t);
00662 void shift(int i);
00664 void lremove(int i);
00666 bool lempty(void) const;
00668 int responsible(void) const;
00670 long long int env(void) const;
00672 long long int lenv(void) const;
00673 };
00674
00675 }}}
00676
00677 #include <gecode/int/cumulative/tree.hpp>
00678
00679 namespace Gecode { namespace Int { namespace Cumulative {
00680
00682 template<class Task>
00683 ExecStatus
00684 subsumed(Space& home, Propagator& p, int c, TaskArray<Task>& t);
00685
00687 template<class ManTask>
00688 ExecStatus overload(Space& home, int c, TaskArray<ManTask>& t);
00689
00691 template<class Task, class Cap>
00692 ExecStatus timetabling(Space& home, Propagator& p, Cap c,
00693 TaskArray<Task>& t);
00694
00696 template<class Task>
00697 ExecStatus edgefinding(Space& home, int c, TaskArray<Task>& t);
00698
00705 template<class ManTask, class Cap, class PL>
00706 class ManProp : public TaskProp<ManTask,PL> {
00707 protected:
00708 using TaskProp<ManTask,PL>::t;
00710 Cap c;
00712 ManProp(Home home, Cap c, TaskArray<ManTask>& t);
00714 ManProp(Space& home, bool shared, ManProp& p);
00715 public:
00717 virtual Actor* copy(Space& home, bool share);
00719 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00721 static ExecStatus post(Home home, Cap c, TaskArray<ManTask>& t);
00723 virtual size_t dispose(Space& home);
00724 };
00725
00732 template<class OptTask, class Cap, class PL>
00733 class OptProp : public TaskProp<OptTask,PL> {
00734 protected:
00735 using TaskProp<OptTask,PL>::t;
00737 Cap c;
00739 OptProp(Home home, Cap c, TaskArray<OptTask>& t);
00741 OptProp(Space& home, bool shared, OptProp& p);
00742 public:
00744 virtual Actor* copy(Space& home, bool share);
00746 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00748 static ExecStatus post(Home home, Cap c, TaskArray<OptTask>& t);
00750 virtual size_t dispose(Space& home);
00751 };
00752
00754 template<class ManTask, class Cap>
00755 ExecStatus
00756 cmanpost(Home home, Cap c, TaskArray<ManTask>& t, IntPropLevel ipl);
00757
00759 template<class OptTask, class Cap>
00760 ExecStatus
00761 coptpost(Home home, Cap c, TaskArray<OptTask>& t, IntPropLevel ipl);
00762
00763 }}}
00764
00765 #include <gecode/int/cumulative/time-tabling.hpp>
00766 #include <gecode/int/cumulative/subsumption.hpp>
00767 #include <gecode/int/cumulative/overload.hpp>
00768 #include <gecode/int/cumulative/edge-finding.hpp>
00769 #include <gecode/int/cumulative/man-prop.hpp>
00770 #include <gecode/int/cumulative/opt-prop.hpp>
00771 #include <gecode/int/cumulative/post.hpp>
00772
00773 #endif
00774
00775