MCPcopy Create free account
hub / github.com/Gecode/gecode / timetabling

Function timetabling

gecode/int/unary/time-tabling.hpp:39–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37
38 template<class Task>
39 ExecStatus
40 timetabling(Space& home, Propagator& p, TaskArray<Task>& t) {
41 Region r;
42
43 bool assigned;
44 if (Event* e = Event::events(r,t,assigned)) {
45 // Whether resource is free
46 bool free = true;
47 // Set of current but not required tasks
48 Support::BitSet<Region> tasks(r,static_cast<unsigned int>(t.size()));
49
50 // Process events
51 do {
52 // Current time
53 int time = e->time();
54
55 // Process events for completion of required part
56 for ( ; (e->type() == Event::LRT) && (e->time() == time); e++)
57 if (t[e->idx()].mandatory()) {
58 tasks.set(static_cast<unsigned int>(e->idx()));
59 free = true;
60 }
61
62 // Process events for completion of task
63 for ( ; (e->type() == Event::LCT) && (e->time() == time); e++)
64 tasks.clear(static_cast<unsigned int>(e->idx()));
65
66 // Process events for start of task
67 for ( ; (e->type() == Event::EST) && (e->time() == time); e++)
68 tasks.set(static_cast<unsigned int>(e->idx()));
69
70 // Process events for zero-length task
71 for ( ; (e->type() == Event::ZRO) && (e->time() == time); e++)
72 if (!free)
73 return ES_FAILED;
74
75 // Norun start time
76 int nrstime = time;
77 // Process events for start of required part
78 for ( ; (e->type() == Event::ERT) && (e->time() == time); e++)
79 if (t[e->idx()].mandatory()) {
80 tasks.clear(static_cast<unsigned int>(e->idx()));
81 if (!free)
82 return ES_FAILED;
83 free = false;
84 nrstime = time+1;
85 } else if (t[e->idx()].optional() && !free) {
86 GECODE_ME_CHECK(t[e->idx()].excluded(home));
87 }
88
89 if (!free)
90 for (Iter::Values::BitSet<Support::BitSet<Region> > j(tasks);
91 j(); ++j)
92 // Task j cannot run from time to next time - 1
93 if (t[j.val()].mandatory())
94 GECODE_ME_CHECK(t[j.val()].norun(home, nrstime, e->time() - 1));
95
96 } while (e->type() != Event::END);

Callers 4

propagateMethod · 0.85
propagateMethod · 0.85
propagateMethod · 0.85
propagateMethod · 0.85

Calls 13

jFunction · 0.85
ES_SUBSUMEDMethod · 0.80
sizeMethod · 0.45
timeMethod · 0.45
typeMethod · 0.45
mandatoryMethod · 0.45
idxMethod · 0.45
setMethod · 0.45
clearMethod · 0.45
optionalMethod · 0.45
excludedMethod · 0.45
valMethod · 0.45

Tested by

no test coverage detected