task.hpp
Go to the documentation of this file.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 namespace Gecode { namespace Scheduling { namespace Unary {
00039
00040
00041
00042
00043
00044 forceinline
00045 ManFixTask::ManFixTask(void) {}
00046 forceinline
00047 ManFixTask::ManFixTask(IntVar s, int p) : _s(s), _p(p) {}
00048 forceinline void
00049 ManFixTask::init(IntVar s, int p) {
00050 _s=s; _p=p;
00051 }
00052
00053 forceinline int
00054 ManFixTask::est(void) const {
00055 return _s.min();
00056 }
00057 forceinline int
00058 ManFixTask::ect(void) const {
00059 return _s.min()+_p;
00060 }
00061 forceinline int
00062 ManFixTask::lst(void) const {
00063 return _s.max();
00064 }
00065 forceinline int
00066 ManFixTask::lct(void) const {
00067 return _s.max()+_p;
00068 }
00069 forceinline IntVar
00070 ManFixTask::st(void) const {
00071 return _s;
00072 }
00073 forceinline int
00074 ManFixTask::p(void) const {
00075 return _p;
00076 }
00077
00078 forceinline bool
00079 ManFixTask::mandatory(void) const {
00080 return true;
00081 }
00082 forceinline bool
00083 ManFixTask::excluded(void) const {
00084 return false;
00085 }
00086 forceinline bool
00087 ManFixTask::optional(void) const {
00088 return false;
00089 }
00090
00091 forceinline bool
00092 ManFixTask::assigned(void) const {
00093 return _s.assigned();
00094 }
00095
00096 forceinline ModEvent
00097 ManFixTask::est(Space& home, int n) {
00098 return _s.gq(home,n);
00099 }
00100 forceinline ModEvent
00101 ManFixTask::ect(Space& home, int n) {
00102 return _s.gq(home,n-_p);
00103 }
00104 forceinline ModEvent
00105 ManFixTask::lst(Space& home, int n) {
00106 return _s.lq(home,n);
00107 }
00108 forceinline ModEvent
00109 ManFixTask::lct(Space& home, int n) {
00110 return _s.lq(home,n-_p);
00111 }
00112 forceinline ModEvent
00113 ManFixTask::norun(Space& home, int e, int l) {
00114 assert(e <= l);
00115 Iter::Ranges::Singleton r(e-_p+1,l);
00116 return _s.minus_r(home,r,false);
00117 }
00118
00119
00120 forceinline ModEvent
00121 ManFixTask::mandatory(Space&) {
00122 return Int::ME_INT_NONE;
00123 }
00124 forceinline ModEvent
00125 ManFixTask::excluded(Space&) {
00126 return Int::ME_INT_FAILED;
00127 }
00128
00129 forceinline void
00130 ManFixTask::update(Space& home, bool share, ManFixTask& t) {
00131 _s.update(home,share,t._s); _p=t._p;
00132 }
00133
00134 forceinline void
00135 ManFixTask::subscribe(Space& home, Propagator& p, PropCond pc) {
00136 _s.subscribe(home, p, pc);
00137 }
00138 forceinline void
00139 ManFixTask::cancel(Space& home, Propagator& p, PropCond pc) {
00140 _s.cancel(home, p, pc);
00141 }
00142
00143 template<class Char, class Traits>
00144 std::basic_ostream<Char,Traits>&
00145 operator <<(std::basic_ostream<Char,Traits>& os, const ManFixTask& t) {
00146 std::basic_ostringstream<Char,Traits> s;
00147 s.copyfmt(os); s.width(0);
00148 s << t.est() << ':' << t.p() << ':' << t.lct();
00149 return os << s.str();
00150 }
00151
00152
00153
00154
00155
00156
00157 forceinline
00158 OptFixTask::OptFixTask(void) {}
00159 forceinline
00160 OptFixTask::OptFixTask(IntVar s, int p, BoolVar m) {
00161 ManFixTask::init(s,p); _m=m;
00162 }
00163 forceinline void
00164 OptFixTask::init(IntVar s, int p, BoolVar m) {
00165 ManFixTask::init(s,p); _m=m;
00166 }
00167
00168 template<class Char, class Traits>
00169 std::basic_ostream<Char,Traits>&
00170 operator <<(std::basic_ostream<Char,Traits>& os, const OptFixTask& t) {
00171 std::basic_ostringstream<Char,Traits> s;
00172 s.copyfmt(os); s.width(0);
00173 s << t.est() << ':' << t.p() << ':' << t.lct() << ':'
00174 << (t.mandatory() ? '1' : (t.optional() ? '?' : '0'));
00175 return os << s.str();
00176 }
00177
00178 }}}
00179
00180