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 class ManFixPTask : public Unary::ManFixPTask {
00063 protected:
00065 int _c;
00066 public:
00068
00069
00070 ManFixPTask(void);
00072 ManFixPTask(IntVar s, int p, int c);
00074 void init(IntVar s, int p, int c);
00076 void init(const ManFixPTask& t);
00078
00080
00081
00082 int c(void) const;
00084 double e(void) const;
00086
00088
00089
00090 void update(Space& home, bool share, ManFixPTask& t);
00092
00093 };
00094
00099 template<class Char, class Traits>
00100 std::basic_ostream<Char,Traits>&
00101 operator <<(std::basic_ostream<Char,Traits>& os, const ManFixPTask& t);
00102
00104 class ManFixPSETask : public Unary::ManFixPSETask {
00105 protected:
00107 int _c;
00108 public:
00110
00111
00112 ManFixPSETask(void);
00120 ManFixPSETask(TaskType t, IntVar s, int p, int c);
00128 void init(TaskType t, IntVar s, int p, int c);
00130 void init(const ManFixPSETask& t);
00132
00134
00135
00136 int c(void) const;
00138 double e(void) const;
00140
00142
00143
00144 void update(Space& home, bool share, ManFixPSETask& t);
00146
00147 };
00148
00153 template<class Char, class Traits>
00154 std::basic_ostream<Char,Traits>&
00155 operator <<(std::basic_ostream<Char,Traits>& os, const ManFixPSETask& t);
00156
00158 class ManFlexTask : public Unary::ManFlexTask {
00159 protected:
00161 int _c;
00162 public:
00164
00165
00166 ManFlexTask(void);
00168 ManFlexTask(IntVar s, IntVar p, IntVar e, int c);
00170 void init(IntVar s, IntVar p, IntVar e, int c);
00172 void init(const ManFlexTask& t);
00174
00176
00177
00178 int c(void) const;
00180 double e(void) const;
00182
00184
00185
00186 void update(Space& home, bool share, ManFlexTask& t);
00188
00189 };
00190
00195 template<class Char, class Traits>
00196 std::basic_ostream<Char,Traits>&
00197 operator <<(std::basic_ostream<Char,Traits>& os, const ManFlexTask& t);
00198
00199
00201 class OptFixPTask : public ManToOptTask<ManFixPTask> {
00202 protected:
00203 using ManToOptTask<ManFixPTask>::_m;
00204 public:
00206
00207
00208 OptFixPTask(void);
00210 OptFixPTask(IntVar s, int p, int c, BoolVar m);
00212 void init(IntVar s, int p, int c, BoolVar m);
00214
00215 operator Unary::OptFixPTask (void);
00216 };
00217
00222 template<class Char, class Traits>
00223 std::basic_ostream<Char,Traits>&
00224 operator <<(std::basic_ostream<Char,Traits>& os, const OptFixPTask& t);
00225
00227 class OptFixPSETask : public ManToOptTask<ManFixPSETask> {
00228 protected:
00229 using ManToOptTask<ManFixPSETask>::_m;
00230 public:
00232
00233
00234 OptFixPSETask(void);
00236 OptFixPSETask(TaskType t, IntVar s, int p, int c, BoolVar m);
00238 void init(TaskType t, IntVar s, int p, int c, BoolVar m);
00240
00241 operator Unary::OptFixPSETask (void);
00242 };
00243
00248 template<class Char, class Traits>
00249 std::basic_ostream<Char,Traits>&
00250 operator <<(std::basic_ostream<Char,Traits>& os, const OptFixPSETask& t);
00251
00253 class OptFlexTask : public ManToOptTask<ManFlexTask> {
00254 protected:
00255 using ManToOptTask<ManFlexTask>::_m;
00256 public:
00258
00259
00260 OptFlexTask(void);
00262 OptFlexTask(IntVar s, IntVar p, IntVar e, int c, BoolVar m);
00264 void init(IntVar s, IntVar p, IntVar e, int c, BoolVar m);
00266
00267 operator Unary::OptFlexTask (void);
00268 };
00269
00274 template<class Char, class Traits>
00275 std::basic_ostream<Char,Traits>&
00276 operator <<(std::basic_ostream<Char,Traits>& os, const OptFlexTask& t);
00277
00278 }}}
00279
00280 #include <gecode/int/cumulative/task.hpp>
00281
00282 namespace Gecode { namespace Int { namespace Cumulative {
00283
00285 typedef ManFixPTask ManFixPTaskFwd;
00286
00288 typedef FwdToBwd<ManFixPTaskFwd> ManFixPTaskBwd;
00289
00291 typedef ManFixPSETask ManFixPSETaskFwd;
00292
00294 typedef FwdToBwd<ManFixPSETaskFwd> ManFixPSETaskBwd;
00295
00297 typedef OptFixPTask OptFixPTaskFwd;
00298
00300 typedef FwdToBwd<OptFixPTaskFwd> OptFixPTaskBwd;
00301
00303 typedef OptFixPSETask OptFixPSETaskFwd;
00304
00306 typedef FwdToBwd<OptFixPSETaskFwd> OptFixPSETaskBwd;
00307
00309 typedef ManFlexTask ManFlexTaskFwd;
00310
00312 typedef FwdToBwd<ManFlexTaskFwd> ManFlexTaskBwd;
00313
00315 typedef OptFlexTask OptFlexTaskFwd;
00316
00318 typedef FwdToBwd<OptFlexTaskFwd> OptFlexTaskBwd;
00319
00320
00325 template<class Char, class Traits>
00326 std::basic_ostream<Char,Traits>&
00327 operator <<(std::basic_ostream<Char,Traits>& os, const ManFixPTaskBwd& t);
00328
00333 template<class Char, class Traits>
00334 std::basic_ostream<Char,Traits>&
00335 operator <<(std::basic_ostream<Char,Traits>& os, const ManFixPSETaskBwd& t);
00336
00341 template<class Char, class Traits>
00342 std::basic_ostream<Char,Traits>&
00343 operator <<(std::basic_ostream<Char,Traits>& os, const OptFixPTaskBwd& t);
00344
00349 template<class Char, class Traits>
00350 std::basic_ostream<Char,Traits>&
00351 operator <<(std::basic_ostream<Char,Traits>& os, const OptFixPSETaskBwd& t);
00352
00353 }}}
00354
00355 #include <gecode/int/cumulative/task-view.hpp>
00356
00357 namespace Gecode { namespace Int {
00358
00360 template<>
00361 class TaskViewTraits<Cumulative::ManFixPTaskFwd> {
00362 public:
00364 typedef Cumulative::ManFixPTask Task;
00365 };
00366
00368 template<>
00369 class TaskViewTraits<Cumulative::ManFixPTaskBwd> {
00370 public:
00372 typedef Cumulative::ManFixPTask Task;
00373 };
00374
00376 template<>
00377 class TaskViewTraits<Cumulative::ManFixPSETaskFwd> {
00378 public:
00380 typedef Cumulative::ManFixPSETask Task;
00381 };
00382
00384 template<>
00385 class TaskViewTraits<Cumulative::ManFixPSETaskBwd> {
00386 public:
00388 typedef Cumulative::ManFixPSETask Task;
00389 };
00390
00392 template<>
00393 class TaskViewTraits<Cumulative::OptFixPTaskFwd> {
00394 public:
00396 typedef Cumulative::OptFixPTask Task;
00397 };
00398
00400 template<>
00401 class TaskViewTraits<Cumulative::OptFixPTaskBwd> {
00402 public:
00404 typedef Cumulative::OptFixPTask Task;
00405 };
00406
00408 template<>
00409 class TaskViewTraits<Cumulative::OptFixPSETaskFwd> {
00410 public:
00412 typedef Cumulative::OptFixPSETask Task;
00413 };
00414
00416 template<>
00417 class TaskViewTraits<Cumulative::OptFixPSETaskBwd> {
00418 public:
00420 typedef Cumulative::OptFixPSETask Task;
00421 };
00422
00424 template<>
00425 class TaskViewTraits<Cumulative::ManFlexTaskFwd> {
00426 public:
00428 typedef Cumulative::ManFlexTask Task;
00429 };
00430
00432 template<>
00433 class TaskViewTraits<Cumulative::ManFlexTaskBwd> {
00434 public:
00436 typedef Cumulative::ManFlexTask Task;
00437 };
00438
00440 template<>
00441 class TaskViewTraits<Cumulative::OptFlexTaskFwd> {
00442 public:
00444 typedef Cumulative::OptFlexTask Task;
00445 };
00446
00448 template<>
00449 class TaskViewTraits<Cumulative::OptFlexTaskBwd> {
00450 public:
00452 typedef Cumulative::OptFlexTask Task;
00453 };
00454
00455
00457 template<>
00458 class TaskTraits<Cumulative::ManFixPTask> {
00459 public:
00461 typedef Cumulative::ManFixPTaskFwd TaskViewFwd;
00463 typedef Cumulative::ManFixPTaskBwd TaskViewBwd;
00465 typedef Unary::ManFixPTask UnaryTask;
00466 };
00467
00469 template<>
00470 class TaskTraits<Cumulative::ManFixPSETask> {
00471 public:
00473 typedef Cumulative::ManFixPSETaskFwd TaskViewFwd;
00475 typedef Cumulative::ManFixPSETaskBwd TaskViewBwd;
00477 typedef Unary::ManFixPSETask UnaryTask;
00478 };
00479
00481 template<>
00482 class TaskTraits<Cumulative::OptFixPTask> {
00483 public:
00485 typedef Cumulative::OptFixPTaskFwd TaskViewFwd;
00487 typedef Cumulative::OptFixPTaskBwd TaskViewBwd;
00489 typedef Cumulative::ManFixPTask ManTask;
00491 typedef Unary::OptFixPTask UnaryTask;
00492 };
00493
00495 template<>
00496 class TaskTraits<Cumulative::OptFixPSETask> {
00497 public:
00499 typedef Cumulative::OptFixPSETaskFwd TaskViewFwd;
00501 typedef Cumulative::OptFixPSETaskBwd TaskViewBwd;
00503 typedef Cumulative::ManFixPSETask ManTask;
00505 typedef Unary::OptFixPSETask UnaryTask;
00506 };
00507
00509 template<>
00510 class TaskTraits<Cumulative::ManFlexTask> {
00511 public:
00513 typedef Cumulative::ManFlexTaskFwd TaskViewFwd;
00515 typedef Cumulative::ManFlexTaskBwd TaskViewBwd;
00517 typedef Unary::ManFlexTask UnaryTask;
00518 };
00519
00521 template<>
00522 class TaskTraits<Cumulative::OptFlexTask> {
00523 public:
00525 typedef Cumulative::OptFlexTaskFwd TaskViewFwd;
00527 typedef Cumulative::OptFlexTaskBwd TaskViewBwd;
00529 typedef Cumulative::ManFlexTask ManTask;
00531 typedef Unary::OptFlexTask UnaryTask;
00532 };
00533
00534 }}
00535
00536 namespace Gecode { namespace Int { namespace Cumulative {
00537
00539 class OmegaNode {
00540 public:
00542 double e;
00544 double env;
00546 void init(const OmegaNode& l, const OmegaNode& r);
00548 void update(const OmegaNode& l, const OmegaNode& r);
00549 };
00550
00552 template<class TaskView>
00553 class OmegaTree : public TaskTree<TaskView,OmegaNode> {
00554 protected:
00555 using TaskTree<TaskView,OmegaNode>::tasks;
00556 using TaskTree<TaskView,OmegaNode>::leaf;
00557 using TaskTree<TaskView,OmegaNode>::root;
00558 using TaskTree<TaskView,OmegaNode>::init;
00559 using TaskTree<TaskView,OmegaNode>::update;
00561 int c;
00562 public:
00564 OmegaTree(Region& r, int c, const TaskViewArray<TaskView>& t);
00566 void insert(int i);
00568 void remove(int i);
00570 double env(void) const;
00571 };
00572
00574 class ExtOmegaNode : public OmegaNode {
00575 public:
00577 double cenv;
00579 void init(const ExtOmegaNode& l, const ExtOmegaNode& r);
00581 void update(const ExtOmegaNode& l, const ExtOmegaNode& r);
00582 };
00583
00585 template<class TaskView>
00586 class ExtOmegaTree : public TaskTree<TaskView,ExtOmegaNode> {
00587 protected:
00588 using TaskTree<TaskView,ExtOmegaNode>::tasks;
00589 using TaskTree<TaskView,ExtOmegaNode>::leaf;
00590 using TaskTree<TaskView,ExtOmegaNode>::root;
00591 using TaskTree<TaskView,ExtOmegaNode>::init;
00592 using TaskTree<TaskView,ExtOmegaNode>::update;
00593 using TaskTree<TaskView,ExtOmegaNode>::node;
00594 using TaskTree<TaskView,ExtOmegaNode>::n_leaf;
00595 using TaskTree<TaskView,ExtOmegaNode>::n_left;
00596 using TaskTree<TaskView,ExtOmegaNode>::left;
00597 using TaskTree<TaskView,ExtOmegaNode>::n_right;
00598 using TaskTree<TaskView,ExtOmegaNode>::right;
00599 using TaskTree<TaskView,ExtOmegaNode>::n_root;
00600 using TaskTree<TaskView,ExtOmegaNode>::n_parent;
00601 using TaskTree<TaskView,ExtOmegaNode>::n_nodes;
00602 using TaskTree<TaskView,ExtOmegaNode>::_leaf;
00604 int c, ci;
00605 public:
00607 template<class Node>
00608 ExtOmegaTree(Region& r, int c, const TaskTree<TaskView,Node>& t);
00610 void init(int ci);
00612 double env(int i);
00613 };
00614
00615
00617 class OmegaLambdaNode : public OmegaNode {
00618 public:
00620 static const int undef = -1;
00622 double le;
00624 double lenv;
00626 int resLe;
00628 int resLenv;
00630 void init(const OmegaLambdaNode& l, const OmegaLambdaNode& r);
00632 void update(const OmegaLambdaNode& l, const OmegaLambdaNode& r);
00633 };
00634
00636 template<class TaskView>
00637 class OmegaLambdaTree : public TaskTree<TaskView,OmegaLambdaNode> {
00638 protected:
00639 using TaskTree<TaskView,OmegaLambdaNode>::tasks;
00640 using TaskTree<TaskView,OmegaLambdaNode>::leaf;
00641 using TaskTree<TaskView,OmegaLambdaNode>::root;
00642 using TaskTree<TaskView,OmegaLambdaNode>::init;
00643 using TaskTree<TaskView,OmegaLambdaNode>::update;
00645 int c;
00646 public:
00648 OmegaLambdaTree(Region& r, int c, const TaskViewArray<TaskView>& t);
00650 void shift(int i);
00652 void lremove(int i);
00654 bool lempty(void) const;
00656 int responsible(void) const;
00658 double env(void) const;
00660 double lenv(void) const;
00661 };
00662
00663 }}}
00664
00665 #include <gecode/int/cumulative/tree.hpp>
00666
00667 namespace Gecode { namespace Int { namespace Cumulative {
00668
00670 template<class Task, class Cap>
00671 ExecStatus basic(Space& home, bool& subsumed, Cap c, TaskArray<Task>& t);
00672
00674 template<class ManTask>
00675 ExecStatus overload(Space& home, int c, TaskArray<ManTask>& t);
00676
00678 template<class Task>
00679 ExecStatus edgefinding(Space& home, int c, TaskArray<Task>& t);
00680
00687 template<class ManTask, class Cap>
00688 class ManProp : public TaskProp<ManTask,Int::PC_INT_DOM> {
00689 protected:
00690 using TaskProp<ManTask,Int::PC_INT_DOM>::t;
00692 Cap c;
00694 ManProp(Home home, Cap c, TaskArray<ManTask>& t);
00696 ManProp(Space& home, bool shared, ManProp& p);
00697 public:
00699 virtual Actor* copy(Space& home, bool share);
00701 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00703 static ExecStatus post(Home home, Cap c, TaskArray<ManTask>& t);
00705 virtual size_t dispose(Space& home);
00706 };
00707
00714 template<class OptTask, class Cap>
00715 class OptProp : public TaskProp<OptTask,Int::PC_INT_DOM> {
00716 protected:
00717 using TaskProp<OptTask,Int::PC_INT_DOM>::t;
00719 Cap c;
00721 OptProp(Home home, Cap c, TaskArray<OptTask>& t);
00723 OptProp(Space& home, bool shared, OptProp& p);
00724 public:
00726 virtual Actor* copy(Space& home, bool share);
00728 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00730 static ExecStatus post(Home home, Cap c, TaskArray<OptTask>& t);
00732 virtual size_t dispose(Space& home);
00733 };
00734
00735 }}}
00736
00737 #include <gecode/int/cumulative/basic.hpp>
00738 #include <gecode/int/cumulative/overload.hpp>
00739 #include <gecode/int/cumulative/edge-finding.hpp>
00740 #include <gecode/int/cumulative/man-prop.hpp>
00741 #include <gecode/int/cumulative/opt-prop.hpp>
00742
00743 #endif
00744
00745