time-tabling.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 namespace Gecode { namespace Int { namespace Unary {
00037
00038 template<class Task>
00039 ExecStatus
00040 timetabling(Space& home, Propagator& p, TaskArray<Task>& t) {
00041 Region r;
00042
00043 bool assigned;
00044 if (Event* e = Event::events(r,t,assigned)) {
00045
00046 bool free = true;
00047
00048 Support::BitSet<Region> tasks(r,static_cast<unsigned int>(t.size()));
00049
00050
00051 do {
00052
00053 int time = e->time();
00054
00055
00056 for ( ; (e->type() == Event::LRT) && (e->time() == time); e++)
00057 if (t[e->idx()].mandatory()) {
00058 tasks.set(static_cast<unsigned int>(e->idx()));
00059 free = true;
00060 }
00061
00062
00063 for ( ; (e->type() == Event::LCT) && (e->time() == time); e++)
00064 tasks.clear(static_cast<unsigned int>(e->idx()));
00065
00066
00067 for ( ; (e->type() == Event::EST) && (e->time() == time); e++)
00068 tasks.set(static_cast<unsigned int>(e->idx()));
00069
00070
00071 for ( ; (e->type() == Event::ZRO) && (e->time() == time); e++)
00072 if (!free)
00073 return ES_FAILED;
00074
00075
00076 int nrstime = time;
00077
00078 for ( ; (e->type() == Event::ERT) && (e->time() == time); e++)
00079 if (t[e->idx()].mandatory()) {
00080 tasks.clear(static_cast<unsigned int>(e->idx()));
00081 if (!free)
00082 return ES_FAILED;
00083 free = false;
00084 nrstime = time+1;
00085 } else if (t[e->idx()].optional() && !free) {
00086 GECODE_ME_CHECK(t[e->idx()].excluded(home));
00087 }
00088
00089 if (!free)
00090 for (Iter::Values::BitSet<Support::BitSet<Region> > j(tasks);
00091 j(); ++j)
00092
00093 if (t[j.val()].mandatory())
00094 GECODE_ME_CHECK(t[j.val()].norun(home, nrstime, e->time() - 1));
00095
00096 } while (e->type() != Event::END);
00097 }
00098
00099 if (assigned)
00100 return home.ES_SUBSUMED(p);
00101
00102 return ES_NOFIX;
00103 }
00104
00105 }}}
00106
00107