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 #ifndef __GECODE_SCHEDULING_UNARY_HH__
00039 #define __GECODE_SCHEDULING_UNARY_HH__
00040
00041 #include <gecode/scheduling/task.hh>
00042
00053 namespace Gecode { namespace Scheduling { namespace Unary {
00054
00056 class ManFixTask {
00057 protected:
00059 Int::IntView _s;
00061 int _p;
00062 public:
00064
00065
00066 ManFixTask(void);
00068 ManFixTask(IntVar s, int p);
00070 void init(IntVar s, int p);
00072
00074
00075
00076 int est(void) const;
00078 int ect(void) const;
00080 int lst(void) const;
00082 int lct(void) const;
00084 IntVar st(void) const;
00086 int p(void) const;
00088
00090
00091
00092 bool assigned(void) const;
00094
00096
00097
00098 ModEvent est(Space& home, int n);
00100 ModEvent ect(Space& home, int n);
00102 ModEvent lst(Space& home, int n);
00104 ModEvent lct(Space& home, int n);
00106
00108
00109
00110 void update(Space& home, bool share, ManFixTask& t);
00112
00114
00115
00116 void subscribe(Space& home, Propagator& p);
00118 void cancel(Space& home, Propagator& p);
00120
00121 };
00122
00127 template<class Char, class Traits>
00128 std::basic_ostream<Char,Traits>&
00129 operator <<(std::basic_ostream<Char,Traits>& os, const ManFixTask& t);
00130
00131
00133 class OptFixTask : public ManToOptTask<ManFixTask> {
00134 protected:
00135 using ManToOptTask<ManFixTask>::_m;
00136 public:
00138
00139
00140 OptFixTask(void);
00142 OptFixTask(IntVar s, int p, BoolVar m);
00144 void init(IntVar s, int p, BoolVar m);
00146 };
00147
00152 template<class Char, class Traits>
00153 std::basic_ostream<Char,Traits>&
00154 operator <<(std::basic_ostream<Char,Traits>& os, const OptFixTask& t);
00155
00156 }}}
00157
00158 #include <gecode/scheduling/unary/task.hpp>
00159
00160 namespace Gecode { namespace Scheduling { namespace Unary {
00161
00163 typedef ManFixTask ManFixTaskFwd;
00164
00166 typedef FwdToBwd<ManFixTaskFwd> ManFixTaskBwd;
00167
00169 typedef OptFixTask OptFixTaskFwd;
00170
00172 typedef FwdToBwd<OptFixTaskFwd> OptFixTaskBwd;
00173
00174
00179 template<class Char, class Traits>
00180 std::basic_ostream<Char,Traits>&
00181 operator <<(std::basic_ostream<Char,Traits>& os, const ManFixTaskBwd& t);
00182
00187 template<class Char, class Traits>
00188 std::basic_ostream<Char,Traits>&
00189 operator <<(std::basic_ostream<Char,Traits>& os, const OptFixTaskBwd& t);
00190
00191 }}}
00192
00193 #include <gecode/scheduling/unary/task-view.hpp>
00194
00195 namespace Gecode { namespace Scheduling {
00196
00198 template<>
00199 class TaskViewTraits<Unary::ManFixTaskFwd> {
00200 public:
00202 typedef Unary::ManFixTask Task;
00203 };
00204
00206 template<>
00207 class TaskViewTraits<Unary::ManFixTaskBwd> {
00208 public:
00210 typedef Unary::ManFixTask Task;
00211 };
00212
00214 template<>
00215 class TaskViewTraits<Unary::OptFixTaskFwd> {
00216 public:
00218 typedef Unary::OptFixTask Task;
00219 };
00220
00222 template<>
00223 class TaskViewTraits<Unary::OptFixTaskBwd> {
00224 public:
00226 typedef Unary::OptFixTask Task;
00227 };
00228
00229
00231 template<>
00232 class TaskTraits<Unary::ManFixTask> {
00233 public:
00235 typedef Unary::ManFixTaskFwd TaskViewFwd;
00237 typedef Unary::ManFixTaskBwd TaskViewBwd;
00238 };
00239
00241 template<>
00242 class TaskTraits<Unary::OptFixTask> {
00243 public:
00245 typedef Unary::OptFixTaskFwd TaskViewFwd;
00247 typedef Unary::OptFixTaskBwd TaskViewBwd;
00249 typedef Unary::ManFixTask ManTask;
00250 };
00251
00252 }}
00253
00254 namespace Gecode { namespace Scheduling { namespace Unary {
00255
00257 class OmegaNode {
00258 public:
00260 int p;
00262 int ect;
00264 void init(const OmegaNode& l, const OmegaNode& r);
00266 void update(const OmegaNode& l, const OmegaNode& r);
00267 };
00268
00270 template<class TaskView>
00271 class OmegaTree : public TaskTree<TaskView,OmegaNode> {
00272 protected:
00273 using TaskTree<TaskView,OmegaNode>::tasks;
00274 using TaskTree<TaskView,OmegaNode>::leaf;
00275 using TaskTree<TaskView,OmegaNode>::root;
00276 using TaskTree<TaskView,OmegaNode>::init;
00277 using TaskTree<TaskView,OmegaNode>::update;
00278 public:
00280 OmegaTree(Region& r, const TaskViewArray<TaskView>& t);
00282 void insert(int i);
00284 void remove(int i);
00286 int ect(void) const;
00288 int ect(int i) const;
00289 };
00290
00292 class OmegaLambdaNode : public OmegaNode {
00293 public:
00295 static const int undef = -1;
00297 int lp;
00299 int lect;
00301 int res;
00303 void init(const OmegaLambdaNode& l, const OmegaLambdaNode& r);
00305 void update(const OmegaLambdaNode& l, const OmegaLambdaNode& r);
00306 };
00307
00309 template<class TaskView>
00310 class OmegaLambdaTree : public TaskTree<TaskView,OmegaLambdaNode> {
00311 protected:
00312 using TaskTree<TaskView,OmegaLambdaNode>::tasks;
00313 using TaskTree<TaskView,OmegaLambdaNode>::leaf;
00314 using TaskTree<TaskView,OmegaLambdaNode>::root;
00315 using TaskTree<TaskView,OmegaLambdaNode>::init;
00316 using TaskTree<TaskView,OmegaLambdaNode>::update;
00317 public:
00319 OmegaLambdaTree(Region& r, const TaskViewArray<TaskView>& t,
00320 bool inc=true);
00322 void shift(int i);
00324 void oinsert(int i);
00326 void linsert(int i);
00328 void lremove(int i);
00330 bool lempty(void) const;
00332 int responsible(void) const;
00334 int ect(void) const;
00336 int lect(void) const;
00337 };
00338
00339 }}}
00340
00341 #include <gecode/scheduling/unary/tree.hpp>
00342
00343 namespace Gecode { namespace Scheduling { namespace Unary {
00344
00346 template<class ManTask>
00347 ExecStatus overload(Space& home, TaskArray<ManTask>& t);
00349 template<class OptTask>
00350 ExecStatus overload(Space& home, Propagator& p, TaskArray<OptTask>& t);
00351
00353 template<class Task>
00354 ExecStatus subsumed(Space& home, Propagator& p, TaskArray<Task>& t);
00355
00357 template<class ManTask>
00358 ExecStatus detectable(Space& home, TaskArray<ManTask>& t);
00360 template<class OptTask>
00361 ExecStatus detectable(Space& home, Propagator& p, TaskArray<OptTask>& t);
00362
00364 template<class ManTask>
00365 ExecStatus notfirstnotlast(Space& home, TaskArray<ManTask>& t);
00367 template<class OptTask>
00368 ExecStatus notfirstnotlast(Space& home, Propagator& p, TaskArray<OptTask>& t);
00369
00371 template<class Task>
00372 ExecStatus edgefinding(Space& home, TaskArray<Task>& t);
00373
00374
00381 template<class ManTask>
00382 class ManProp : public TaskProp<ManTask> {
00383 protected:
00384 using TaskProp<ManTask>::t;
00386 ManProp(Home home, TaskArray<ManTask>& t);
00388 ManProp(Space& home, bool shared, ManProp& p);
00389 public:
00391 virtual Actor* copy(Space& home, bool share);
00393 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00395 static ExecStatus post(Home home, TaskArray<ManTask>& t);
00396 };
00397
00404 template<class OptTask>
00405 class OptProp : public TaskProp<OptTask> {
00406 protected:
00407 using TaskProp<OptTask>::t;
00409 OptProp(Home home, TaskArray<OptTask>& t);
00411 OptProp(Space& home, bool shared, OptProp& p);
00412 public:
00414 virtual Actor* copy(Space& home, bool share);
00416 virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00418 static ExecStatus post(Home home, TaskArray<OptTask>& t);
00419 };
00420
00421 }}}
00422
00423 #include <gecode/scheduling/unary/overload.hpp>
00424 #include <gecode/scheduling/unary/subsumption.hpp>
00425 #include <gecode/scheduling/unary/detectable.hpp>
00426 #include <gecode/scheduling/unary/not-first-not-last.hpp>
00427 #include <gecode/scheduling/unary/edge-finding.hpp>
00428
00429 #include <gecode/scheduling/unary/man-prop.hpp>
00430 #include <gecode/scheduling/unary/opt-prop.hpp>
00431
00432 #endif
00433
00434