scheduling using timed automata

37
Scheduling Using Timed Automata Borzoo Bonakdarpour Wednesday, April 13, 2005 Selected Topics in Algorithms and Complexity (CSE960)

Upload: olisa

Post on 10-Jan-2016

61 views

Category:

Documents


1 download

DESCRIPTION

Selected Topics in Algorithms and Complexity (CSE960). Scheduling Using Timed Automata. Borzoo Bonakdarpour Wednesday, April 13, 2005. Based on. Y. Abdeddaim, O. Maler, Job-shop scheduling using timed automata , 2001 - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Scheduling Using Timed Automata

SchedulingUsing

Timed Automata

Borzoo BonakdarpourWednesday, April 13, 2005

Selected Topics in

Algorithms and Complexity (CSE960)

Page 2: Scheduling Using Timed Automata

Based on

1. Y. Abdeddaim, O. Maler, Job-shop scheduling using timed automata, 2001

2. Y. Abdeddaim, O. Maler, Scheduling under uncertainty using timed automata, 2003

3. Y. Abdeddaim, O. Maler, Task graph scheduling using timed automata, 2002

4. Krac, Wi, Decidable and undecidable problem in scheduling analysis using timed automata, 2004

Page 3: Scheduling Using Timed Automata

Outline

• 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

Page 4: Scheduling Using Timed Automata

TIMED AUTOMATA

PART I

Page 5: Scheduling Using Timed Automata

Preliminaries

• Timed automata is traditional finite state automataequipped 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.

Page 6: Scheduling Using Timed Automata

Clock 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 < c | c < x | g gwhere 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 = v[Y := 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.

Page 7: Scheduling Using Timed Automata

Timed Automata

• Formally, a timed automaton is a tuple <V, V0, VF, X, E> 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.

s0

g, []s1

• 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.

<s0, g, , s1> :

Page 8: Scheduling Using Timed Automata

Timed Automata (cont.)

• Types of transitions:

– Elapse of time: (s, v) (s, v + t1)

s0

x = 3y = 1

s0

x = 4y = 2

t = 1

s0x = 3y = 1

s1x = 0

y = 1.2

[x := 0]

– Location switch: (s, v) (s', v') where v' = v[:=0]0

t

• A run of the automaton is a finite sequence of transitions:

= (s0, v0) (s1, v1) … (sn, vn)t1 tnt2

Page 9: Scheduling Using Timed Automata

Example

s2

s3s1s0

y := 0

(y = 1)? (x < 1)?

(x > 1)?(x < 1)?

Question: is s3 reachable via s2?

Page 10: Scheduling Using Timed Automata

JOB-SHOP SCHEDULING

PART II

Page 11: Scheduling Using Timed Automata

Job-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

Page 12: Scheduling Using Timed Automata

Schedules

• 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 < j' implies t < 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.

Page 13: Scheduling Using Timed Automata

Example

• M = {m1, m2}

• J1 = (m1, 4), (m2, 5)

• J2 = (m1, 3)

12

m1

m2

J1J2

J1(b)

9

m1

m2

J1 J2

J1

(a)

Page 14: Scheduling Using Timed Automata

Laziness

• 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.

J1

J2

m1 m2

m1 m2

J3

m1

(a)

J1

J2

m1 m2

m1 m2

J3

m1

(b)

Page 15: Scheduling Using Timed Automata

Job-shop Timed Automata

1. 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

Page 16: Scheduling Using Timed Automata

Example

m1

M = {m1, m2}

J1 = (m1, 4), (m2, 5)

J2 = (m1, 3)

m1

c1 := 0

m2

c1 4

m2

c1 := 0

f

c1 5

J1

m1

m1

c2 := 0

f

c2 3

J2

Page 17: Scheduling Using Timed Automata

2. 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

Job-shop Timed Automata (cont.)

Page 18: Scheduling Using Timed Automata

Example

m1

m1

c1 := 0

m2

c1 4

m2

c1 := 0

f

c1 5

J1

m1m1

c2 := 0f

c2 3J2

m1, m1 m1, m1 m1, f

m1m1, m1, m1 m1, f

m2, m1 m2, m1 m2, f

m1m2, m2, m1 m2, f

m1f, m2, f f, f

c2 := 0 c2 3

c1 := 0 c1 := 0

c1 4

c1 := 0

c1 5

c2 := 0 c2 3

c1 4

c1 := 0

c1 5c2 := 0 c2 3

c2 3c2 := 0

c1 5

c1 := 0

Page 19: Scheduling Using Timed Automata

Schedules 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

Page 20: Scheduling Using Timed Automata

3. 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.

Job-shop Timed Automata (cont.)

Page 21: Scheduling Using Timed Automata

Example

m1

m1

c1 := 0

m2

c1 4

m2

c1 := 0

f

c1 5

J1

m1m1

c2 := 0f

c2 3J2

m1, m1 m1, m1 m1, f

m1m1, m1, f

m2, m1 m2, m1 m2, f

m1m2, m2, m1 m2, f

m1f, f, m1 f, f

c2 := 0 c2 3

c1 := 0 c1 := 0

c1 4

c1 := 0

c1 5

c2 := 0 c2 3

c1 4

c1 := 0

c1 5c2 := 0 c2 3

c2 3c2 := 0

c1 5

c1 := 0

L(S1) = 9

L(S2) = 12

Page 22: Scheduling Using Timed Automata

SCHEDULING UNDER

UNCERTAINTY

PART III

Page 23: Scheduling Using Timed Automata

Scheduling 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.

Page 24: Scheduling Using Timed Automata

Example

J1 = (m1, 10) , (m3, [2, 4]) , (m4, 5)

J2 = (m2, [2, 8]), (m3, 7)

21

m1 m3

J1

J2

(b)

m4

m2 m3

10(2, 8)

21

m1 m3

J1

J2

(a)

m4

m2 m3

10 14

8

(4, 8)

19

m1 m3

J1

J2

(c)

m4

m2 m3

10

Page 25: Scheduling Using Timed Automata

Example

J1 = (m1, 10) , (m3, [2, 4]) , (m4, 5)J2 = (m2, [2, 8]), (m3, 7)

(4, 4)

20

m1 m3

J2

J1

(c)

m4

m2 m3

10

21

m1 m3

J2

J1

(b)

m4

m2 m3

10

Page 26: Scheduling Using Timed Automata

Dynamic 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)

Page 27: Scheduling Using Timed Automata

Uncertain Job-shop Automata1. Generate job automata

2. Construct mutual exclusion composition

3. In the beginning of a run reset a global clock

4. 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:

h(f, v) = 0

h(q, v) = min {t + h(q', v'): (q, v) (q, v+t1) (q', v')t 0

Page 28: Scheduling Using Timed Automata

Optimal 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) =

min{7-c2+h(m4, f, c1+7- c2, )

5-c1+h(f, m3, , c2+5- c1)

min{7 c1 if c2 c1 2

5 c1 if c2 c1 2

Page 29: Scheduling Using Timed Automata

Final 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.

Page 30: Scheduling Using Timed Automata

TASK GRAPH SCHEDULING

PART VI

Page 31: Scheduling Using Timed Automata

Task Graph Scheduling

• In task graph scheduling, we need to schedule tasks on a limited number of machines, while respecting the precedence constraints.

P1

P6 P4P3

P7 P5

P216 2

2

2

16

8

6

Page 32: Scheduling Using Timed Automata

TGS Using Timed Automata

1. Generating the automata for each task

p1

p1

c1 := 0

p1

c1 = 1

p3

p1

c3 := 0 p1

p1

c3 = 6

p2

p2

c2 := 0

p2

c2 = 16

Page 33: Scheduling Using Timed Automata

TGS Using Timed Automata (cont.)

2. Constructing chain covers H = {H1, H2, …, Hk} of (P, )– Each chain Hi is linearly ordered– Hi Hj = for all i j ik Hi = P

p2p2

c1 := 0 c1 = 16p6 p6 p7

p7 fc1 = 2 c1 = 16c1 := 0 p1 c1 := 0 p3

p1p1

c2 := 0 c2 = 2p3 p3 p5

p5

f

c2 = 6 c2 = 6c2 := 0 c2 := 0 p4

p4p4

c3 := 0 p1 c2 = 2

f

Page 34: Scheduling Using Timed Automata

TGS Using Timed Automata (cont.)

3. Constructing mutual exclusion composition

– Avoid global states with number of active tasks more the number of available machines

4. Find the shortest path

Page 35: Scheduling Using Timed Automata

Decidable and Undecidable Problems

• A large class of schedulability problems are decidable

• It has been shown that the schedulability is undecidable if three conditions hold:

1. The execution times of tasks are uncertain.

2. A task can preempt another task.

3. A task can announce its completion time.

Page 36: Scheduling Using Timed Automata

Open Problems

• Modeling other types scheduling (minimum makespan, minimum completion time) using timed automata

• Designing approximation algorithms

Page 37: Scheduling Using Timed Automata

Questions & Comments