Title: Scheduling Using Timed Automata
1SchedulingUsingTimed Automata
Selected Topics in Algorithms and Complexity
(CSE960)
Borzoo Bonakdarpour Wednesday, April 13, 2005
2Based on
- Y. Abdeddaim, O. Maler, Job-shop scheduling using
timed automata, 2001 - Y. Abdeddaim, O. Maler, Scheduling under
uncertainty using timed automata, 2003 - Y. Abdeddaim, O. Maler, Task graph scheduling
using timed automata, 2002 - Krac, Wi, Decidable and undecidable problem in
scheduling analysis using timed automata, 2004
3Outline
- Preliminaries
- Timed automata
- Job-Shop Scheduling
- Job-Shop Scheduling Using Timed Automata
- Scheduling under Uncertainty
- Task Graph Scheduling
- Decidable and Undecidable Problems
- Discussion Future Work
4PART I
5Preliminaries
- Timed automata is traditional finite state
automata equipped with clock variables and timing
constraints. - It has been accepted as the standard formalism
to model real- time programs. - Initially, it was introduced for model checking
and verification, but has been recently used for
program synthesis and scheduling.
6Clock Variables
- For a set X of clocks, the set ? (X) of clock
constraints g is defined by the grammar - g x ? c c ? x x lt c c lt x g ? g
- where x ? X and c ? Q is a rational number.
- A clock valuation is a function v X ? R
- v(x) is the value of clock variable x.
- All clock values increase with the same speed.
- u vY 0 for Y ? X is a clock valuation
for X such that - ?x ? Y v(x) 0
- Agrees with v over the rest of the clocks.
7Timed Automata
- Formally, a timed automaton is a tuple ltV, V0,
VF, X, Egt where - V set of locations,
- V0 set of initial locations,
- VF set of final locations,
- X set of clocks,
- E ? (V ? ? (X) ? 2X ? V ) is a set of
transitions.
lts0, g, ?, s1gt
- The state of a real-time program is a pair (s,
v) such that s is a location and v is a clock
valuation for X.
8Timed Automata (cont.)
- Types of transitions
- Elapse of time (s, v) ? (s, v t1)
t
0
- Location switch (s, v) ? (s', v') where v'
v?0
- A run of the automaton is a finite sequence of
transitions - ? (s0, v0) ? (s1, v1) ? ? (sn, vn)
t1
tn
t2
9Example
s2
s3
s1
s0
Question is s3 reachable via s2?
10PART II
11Job-Shop Scheduling
- M is a set of machines
- Each job J is a triple (k, ?, d) where
- k ? N, the number of tasks
- ? 1..k ? M, assignment of machines to tasks
- d 1..k ? N, duration of every task
- A job-shop specification is a set J J1, J2,
, Jn of jobs - Ji (ki, ?i, di)
- Assumptions
- A job can wait arbitrary amount of time between
two tasks - No preemption
12Schedules
- A feasible schedule for J is a relation S ? J ? K
? T so that - (i, j, t) ? S indicates that job Ji is busy
doing jth task at time t, which satisfies - Ordering (i, j, t) ? S and (i, j', t') ? S then
j lt j' implies t lt t' - Covering No preemption For all i, j the set
t (i, j, t) ? S is nonempty and in the form
r, r d and d ? di(j) - Mutual exclusion (i, j, t) ? S and (i', j', t) ?
S then ?i(j) ? ?i(j') - The length of a schedule is the maximal t over
all (i, j, t) ? S - The optimal job-shop scheduling problem is to
find a minimal length. It is known to be NP-hard.
13Example
- M m1, m2
- J1 (m1, 4), (m2, 5)
- J2 (m1, 3)
14Laziness
- A schedule S is lazy at task j of job i if
immediately before starting that task there an
interval in which both the job and the
corresponding machine are idle.
15Job-shop Timed Automata
- Constructing Job Timed Automaton (Ai) for each
job Ji - One clock that represents the elapse of time for
each task. - Two states for each task j such that ?(j) m
- m indicates that the task is waiting to start on
machine m - m indicates that the task is executing on
machine m - Timing constraints is based on the duration of
tasks
16Example
J1
M m1, m2 J1 (m1, 4), (m2, 5) J2 (m1, 3)
17Job-shop Timed Automata (cont.)
- Constructing mutual exclusion composition (A) of
the job timed automata - An n-tuple q (q1, , qn) ? (M ? M ? f)n is
conflicting if it contains two components qa qb
m ? M - We compose the individual job timed automata such
that in the final timed automaton - Does not contain conflicting states
- Every transition of A satisfies the properties of
Ai for all i
18Example
19Schedules and Runs
- A run ? is complete if it starts at (s, 0) and
ends in f. - Theorem1 If A is a job-shop timed automaton for
J then - For every complete run ? of A, its associated
schedule S? corresponds to a feasible schedule
for J. - For every feasible schedule S for J, there is a
run ? of A such that S? S and if S is non-lazy
so is ?. - Theorem2 The optimal job-shop scheduling problem
can be reduced to the problem of finding the
shortest non-lazy path in a timed automata
20Job-shop Timed Automata (cont.)
- Finding the shortest non-lazy path
- The job-shop timed automaton is acyclic
- Reachability problem for cyclic timed automata is
PSPACE-complete. - Reachability problem for acyclic timed automata
is NP-complete. - There exist efficient algorithms that find the
shortest path in a timed automaton.
21Example
L(S1) 9 L(S2) 12
J2
c2 0
c2 ? 3
f
J1
c2 0
c2 ? 3
m1
f
c1 0
c1 0
c1 0
m1,
m1, f
c1 ? 4
c1 ? 4
c1 ? 4
c2 0
c2 ? 3
c1 0
c1 0
c1 0
c1 0
c2 ? 3
c2 0
c1 ? 5
c1 ? 5
c1 ? 5
c1 ? 5
c2 0
c2 ? 3
22PART III
- SCHEDULING UNDER
- UNCERTAINTY
23Scheduling Under Uncertainty
- The duration of tasks is within an interval l,
u - Example
- J1 (m1, 10) , (m3, 2, 4) , (m4, 5)
- J2 (m2, 2, 8), (m3, 7)
- How can we design a scheduling policy?
- Follow the worst case schedule in both time and
ordering - Follow only the ordering of tasks as soon as a
machine is available. - Design a scheduling strategy.
24Example
(4, 8)
J1 (m1, 10) , (m3, 2, 4) , (m4, 5) J2 (m2,
2, 8), (m3, 7)
25Example
J1 (m1, 10) , (m3, 2, 4) , (m4, 5) J2 (m2,
2, 8), (m3, 7)
26Dynamic Scheduling
- What was the problem?!
- Instead of following a static schedule, whenever
a task terminates, we reschedule the residual
problem. - Example (4, 8) J1 (m1, 10) , (m3, 2, 4) ,
(m4, 5) - J2 (m2, 2, 8, 7)
- After terminations of m2 in J2 after 4 time
- J1 ' (m1, 6) , (m3, 2, 4) , (m4, 5)
- J2' (m3, 7)
27Uncertain Job-shop Automata
- Generate job automata
- Construct mutual exclusion composition
- In the beginning of a run reset a global clock
- Upon termination of a task formulate the residual
problem by calculating the length of runs from
the current state (q, v) to (f, v) using backward
reachability. This can be done in polynomial time
28Optimal Strategies for Timed Automata
h(f, f, ?, ?) 0 h(m4, f, c1, ?) 5 c1 h(m3,
f, ?, c2) 7 c2 h(m4, m3, c1, c2)
29Final Analysis
- Question Is this a game?!
- Theorem The problem of finding optimal
strategies for job-shop scheduling under
uncertainty is solvable using timed automata
reachability algorithms.
30PART VI
31Task Graph Scheduling
- In task graph scheduling, we need to schedule
tasks on a limited number of machines, while
respecting the precedence constraints.
32TGS Using Timed Automata
- Generating the automata for each task
33TGS Using Timed Automata (cont.)
- Constructing chain covers H H1, H2, , Hk of
(P, ?) - Each chain Hi is linearly ordered
- Hi ? Hj ? for all i ? j
- ?i?k Hi P
c1 0 ? p1
c1 0
c1 2
c1 16
c1 0 ? p3
c1 16
c2 0
c2 6
c2 6
c2 0 ? p4
c2 2
c2 0
c3 0 ? p1
c2 2
34TGS Using Timed Automata (cont.)
- Constructing mutual exclusion composition
- Avoid global states with number of active tasks
more the number of available machines - Find the shortest path
35Decidable and Undecidable Problems
- A large class of schedulability problems are
decidable - It has been shown that the schedulability is
undecidable if three conditions hold - The execution times of tasks are uncertain.
- A task can preempt another task.
- A task can announce its completion time.
36Open Problems
- Modeling other types scheduling (minimum
makespan, minimum completion time) using timed
automata - Designing approximation algorithms
37