Outline

advertisement
Outline
Temporal Plan Execution:
Dynamic Scheduling and
Simple Temporal Networks
•
•
•
•
Review: Constraint -based Interval Planning
Simple Temporal Networks
Temporal Consistency and Scheduling
Execution Under Uncertainty
Brian C. Williams
16.412J/6.834J
March 7th, 2005
1
Simple Spacecraft Problem
Observation-1
Example
Init
pointing
target
instruments
Actions
pC
Observation-2
calibrated
pC
C
px
Ty
Observation-3
Goal
c
py
Observation-4
¬px
…
c
Im
Ix
px
16.410/13: Solved using Graph -based Planners (Blum & Furst )
Partial Order Causal Link Planning
Needed Extensions
(SNLP, UCPOP)
IA
1. Select an open condition
c
2. Choose an op that can achieve it
pA
Link to an existing instance
Add a new instance
pC
C
3. Resolve threats
Im
C
pA
C
pC
TA
S
Im
IA
Time
Resources
F
Utility
c
S
pC
F
c
pA
pC
F
IA
Im
IA
F
Uncertainty
c
pA
Im
IA
F
pC
C
S
¬p C
c
pA
pC
Im
IA
F
TA
¬p C
Based on slides by Dave Smith, NASA Ames
IA
Representing Timing:
Qualitative Temporal Relations [Allen AAAI83]
A before B
A
A meets B
A
TakeImage Pictorially
B
B
TakeImage (?target, ?instr)
contained-by
Status(?instr, Calibrated)
contained-by
Pointing(?target)
meets
Image(?target)
A
A overlaps B
B
A
A contains B
B
Pointing(?target)
A
A=B
contains
B
TakeImage(?target, ?instr)
A
A starts B
meets
Image(?target)
contains
B
Status(?instr, Calibrated)
A
A ends B
Based on slides by Dave Smith, NASA Ames
B
Based on slides by Dave Smith, NASA Ames
A Consistent Complete
Temporal Plan
A Temporal Planning Problem
Turn(A7)
Pointing(Earth)
Pointing(Earth)
meets
meets
Turn(T17)
meets
Past
-8
Image(?target)
meets
meets
Status(Cam2, On)
Past
TakeImage(A7, Cam2)
Future
contains
meets
meets
Status(Cam2, On)
-8
Calibrate(Cam2)
meets
meets
Pointing(T17)
Status(Cam1, Off)
Status(Cam1, Off)
Pointing(A7)
contains
meets
Future
Image(A7)
8
contains
meets
Status(Cam2, Calibrated)
contains
8
CalibrationTarget(T17)
CalibrationTarget(T17)
Based on slides by Dave Smith, NASA Ames
Based on slides by Dave Smith, NASA Ames
A Consistent Complete
Temporal Plan
CBI Planning Algorithm
Choose:
Turn(A7)
Pointing(Earth)
introduce an action & instantiate constraints
coalesce propositions
Propagate temporal constraints
meets
meets
Turn(T17)
meets
TakeImage(A7, Cam2)
-8
contains
meets
Status(Cam2, On)
meets
Calibrate(Cam2)
contains
meets
Status(Cam2, Calibrated)
contains
CalibrationTarget(T17)
Planner Must:
• Check schedulability of candidate plans for correctness.
• Schedule the activities of a complete plan in order to
execute.
Based on slides by Dave Smith, NASA Ames
meets
meets
Pointing(T17)
Status(Cam1, Off)
Past
Pointing(A7)
contains
meets
Image(A7)
Future
8
Relation to Causal Links & Threats
POCL
Examples of CBI Planners
CBI
Zeno (Penberthy)
intervals, no CSP
Causal links:
meets
proposition
action
action
action
Trains (Allen)
meets
proposition
action
Descartes (Joslin)
Threats :
proposition
action
action
proposition
action
IxTeT (Ghallab)
functional rep.
HSTS (Muscettola)
functional rep., activities
EUROPA (Jonsson)
functional rep., activities
Kirk (Williams)
HTN
mutex
threatens
action
proposition
Based on slides by Dave Smith, NASA Ames
action
Based on slides by Dave Smith, NASA Ames
Qualitative Temporal Constraints
Maybe Expressed as Inequalities
Outline
•
•
•
•
extreme least commitment
Review: Constraint -based Interval Planning
Simple Temporal Networks
Temporal Consistency and Scheduling
Execution Under Uncertainty
(Vilain , Kautz 86)
•
•
•
•
•
•
•
X+ < Y­
X+ = Y­
(Y­ < X+) & (X- <
(Y­ < X-) & (X+ <
(X­ = Y-) & (X+ <
(X­ < Y-) & (X+ =
(X­ = Y-) & (X+ =
x before y
x meets y
x overlaps y
x during y
x starts y
x finishes y
x equals y
Y+)
Y+)
Y+)
Y+)
Y+)
Inequalities may be expressed as binary interval relations:
Y- - X+ < [0, +inf]
Generalize to include metric constraints:
Y- - X+ < [lb, ub]
Based on slides by Dave Smith, NASA Ames
Based on slides by Dave Smith, NASA Ames
Metric Time: Temporal CSPS
(Dechter, Meiri, Pearl 91)
TCSP Are Visualized Using
Directed Constraint Graphs
“ Bread should be eaten within a day of baking.”
? 0 < [T +(baking) – T -(eating)] < 1 day
0
1
3
[10,20]
• Xi
continuous variables
interval constraints
• T i ,T ij
{I1, . . . ,In } where Ii = [ai,bi]
2
– T i = (ai £ Xi £ bi) or . . . or (ai £ Xi £ bi)
– T ij = (a1£ Xi - Xj £ b1) or ... or (an £ Xi - Xj £ bn)
Based on slides by Dave Smith, NASA Ames
[30,40]
[60,inf]
[10,20]
< Xi , Ti , T ij >
[20,30]
[40,50]
[60,70]
Based on slides by Dave Smith, NASA Ames
4
Simple Temporal Networks (STNs)
(Dechter, Meiri, Pearl 91)
A Temporal Plan Forms an STN
At most one interval per constraint
• T ij = (aij £ Xi - Xj £ bij )
Delta_V(direction=b, magnitude=200)
[30,40]
[60,inf]
[10,20]
0
Thrust
Goals
1
3
Power
[10,20]
Can’t represent:
• Disjoint activities
2
Sufficient to represent:
• most Allen relations
• simple metric constraints
[20,30]
[40,50]
Attitude
Point(a) Turn(a,b)
Engine
Off
Point(b)
Turn(b,a)
4
Warm Up
Thrust (b, 200)
Off
[60,70]
A Temporal Plan Forms an STN
[1035, 1035]
[0, 300]
Outline
•
•
•
•
[0, + ¥]
[0, + ¥ ]
<0, 0>
Review: Constraint -based Interval Planning
Simple Temporal Networks
Temporal Consistency and Scheduling
Execution Under Uncertainty
[0, 0]
[130,170]
To Query an STN, Map to a
Distance Graph Gd = < V,Ed >
TCSP Queries
(Dechter , Meiri, Pearl, AIJ91)
•
•
• Is the TCSP consistent?
Planning
• What are the feasible times for each Xi? Planning
• What are the feasible durations between Planning
each Xi and Xj ?
• What is a consistent set of times?
• What are the earliest possible times?
• What are the latest possible times?
Scheduling
Scheduling
Edge encodes an upper bound on distance to target from source.
Negative edges are lower bounds.
Xj - Xi £ bij
Xi - Xj £ - aij
T ij = (aij £ Xj - Xi £ bij )
0
[10,20]
1
[30,40]
3
0
20
[40,50]
20
4
2
-60
[60,70]
3
-30
[10,20]
2
40
1
-10
70
50
-40
-10
4
Conjoined Paths Computed using
All Pairs Shortest Path
Gd Induces Constraints
(e.g., Floyd -Warshall, Johnson)
1. for i := 1 to n do dii 0;
2. for i, j := 1 to n do dij aij ;
• Path constraint: i0 =i, i1 = . . ., ik = j
k
X j - Xi £ � ai j -1 ,i j
Initialize distances
j=1
3. for k := 1 to n do
4. for i, j := 1 to n do
5. dij min{dij , dik + dkj };
? Conjoined path constraints result in the shortest path as
bound:
X j - X i £ d ij
Take minimum distance
over all triangles
k
i
where dij is the shortest path from i to j
j
Shortest Paths of Gd
0
0
1
0
20 50 30 70
1 -10
0
2 -40 -30
2
3
4
0
20
Map To STN Minimum Network
-10
0
-10 30
0
2
-30
-10
20
40 20 60
3 -20 -10 20
40
1
50
-40
3
50
4
0
0
0
1 2 3 4
20 50 30 70
3
4
0 0 20 50 30 70
0
3
[60,70]
[0]
[30,40] [10,20]
[50,60]
3 -20 -10 20 0 50
4 -60 -50 -20 -40 0
3 [-30,-20] [-20,-10] [10,20]
2 [-50,-40] [-40,-30]
[0]
4
[-20,-10] [20,30]
[0]
[40,50]
4 [-70,-60] [-60,-50] [-30,-20] [-50,-40]
[0]
STN minimum network
Scheduling: Latest Solution
Node 0 is the reference.
20
2 -40 -30 0 -10 30
3 -20 -10 20 0 50
4 -60 -50 -20 -40 0
40
1
-10
2
-30
-10
20
40 20 60
d-graph
2
1 [-20,-10]
d-graph
No negative cycles: -5 > TA – TA = 0
1 -10 0
[40,50] [20,30]
1 -10 0 40 20 60
2 -40 -30 0 -10 30
Schedulability: Plan Consistency
2
1
[10,20]
70
d-graph
1
0
[0]
-60
4 -60 -50 -20 -40 0
0
0
3
50
-40
4
0
1
2
S1 = (d01, . . . , d0n)
3
4
0 0 20 50 30 70
1 -10 0 40 20 60
2 -40 -30 0 -10 30
0
20
40
1
-10
20
50
-40
3
-60
3 -20 -10 20 0 50
-60
70
4 -60 -50 -20 -40 0
70
d-graph
2
-30
-10
4
Scheduling:
Window of Feasible Values
Scheduling: Earliest Solution
Node 0 is the reference.
0
1
S1 = (-d10, . . . , -dn0)
2
3
4
0 0 20 50 30 70
0
20
40
1
-10
-10
20
1 -10 0 40 20 60
2 -40 -30 0 -10 30
2
-30
50
-40
3
4
-60
3 -20 -10 20 0 50
4 -60 -50 -20 -40 0
70
0
0 0
4
• X3 in [20, 30]
4 -60 -50 -20 -40 0
• X4 in [60, 70]
• X2 in [40, 50]
Solution by Decomposition
• Can assign variables in any order, without backtracking.
2
3
2 -40 -30 0 -10 30
3 -20 -10 20 0 50
Scheduling without Search:
Solution by Decomposition
1
2
Earliest Times d-graph
d-graph
0
1
0 0 20 50 30 70 Latest Times
1 -10 0 40 20 60
• X1 in [10, 20]
3
4
20 50 30 70
• Select value for 1
� 15
[10,20]
• Can assign variables in any order, without backtracking.
0
0 0
1
2
3
4
20 50 30 70
1 -10 0 40 20 60
2 -40 -30 0 -10 30
1 -10 0 40 20 60
2 -40 -30 0 -10 30
3 -20 -10 20
3 -20 -10 20
0 50
• Select value for 1
� 15
[10,20]
0 50
4 -60 -50 -20 -40 0
4 -60 -50 -20 -40 0
d-graph
d-graph
Solution by Decomposition
Solution by Decomposition
• Can assign variables in any order, without backtracking.
• Tighten bound of Y using all selected X: Y ˛ X + |XY|
0
1
2
3
4
0 0 20 50 30 70
1 -10 0 40 20 60
2 -40 -30 0 -10 30
• Select value for 1
� 15
• Select value for 2,
consistent with 1
� 45
[40,50], 15+[30,40]
• Can assign variables in any order, without backtracking.
• Tighten bound of Y using all selected X: Y ˛ X + |XY|
0
1
2
3
4
0 0 20 50 30 70
1 -10 0 40 20 60
2 -40 -30 0 -10 30
3 -20 -10 20 0 50
3 -20 -10 20 0 50
4 -60 -50 -20 -40 0
4 -60 -50 -20 -40 0
d-graph
d-graph
• Select value for 1
� 15
• Select value for 2,
consistent with 1
� 45
[45,50]
Solution by Decomposition
Solution by Decomposition
• Can assign variables in any order, without backtracking.
• Tighten bound of Y using all selected X: Y ˛ X + |XY|
0
1
2
3
4
0 0 20 50 30 70
1 -10 0 40 20 60
2 -40 -30 0 -10 30
• Can assign variables in any order, without backtracking.
• Tighten bound of Y using all selected X: Y ˛ X + |XY|
• Select value for 1
0
� 15
• Select value for 2,
consistent with 1
� 45
1
2
3
4
0 0 20 50 30 70
1 -10 0 40 20 60
2 -40 -30 0 -10 30
[45,50]
• Select value for 1
� 15
• Select value for 2,
consistent with 1
� 45
• Select value for 3,
consistent with 1 & 2
3 -20 -10 20 0 50
3 -20 -10 20 0 50
4 -60 -50 -20 -40 0
4 -60 -50 -20 -40 0
d-graph
d-graph
Solution by Decomposition
Solution by Decomposition
• Can assign variables in any order, without backtracking.
• Tighten bound of Y using all selected X: Y ˛ X + |XY|
0
1
2
3
4
0 0 20 50 30 70
1 -10 0 40 20 60
2 -40 -30 0 -10 30
3 -20 -10 20 0 50
4 -60 -50 -20 -40 0
d-graph
0
� 15
• Select value for 2,
consistent with 1
1
2
3
4
0 0 20 50 30 70
1 -10 0 40 20 60
2 -40 -30 0 -10 30
3 -20 -10 20 0 50
4 -60 -50 -20 -40 0
d-graph
O(N 2)
� 45
• Select value for 3,
consistent with 1 & 2
� 30
• Select value for 4,
consistent with 1,2 & 3
3
4
3 -20 -10 20 0 50
4 -60 -50 -20 -40 0
� 30 [25,30]
� 15
• Select value for 2,
consistent with 1
2
1 -10 0 40 20 60
2 -40 -30 0 -10 30
� 45
• Select value for 3,
consistent with 1 & 2
• Select value for 1
1
0 0 20 50 30 70
• Select value for 1
� 15
• Select value for 2,
consistent with 1
� 45
• Select value for 3,
consistent with 1 & 2
d-graph
Solution by Decomposition
0
[20,30], 15+[10,20],45+[ -20,-10]
• Can assign variables in any order, without backtracking.
• Tighten bound of Y using all selected X: Y ˛ X + |XY|
• Select value for 1
• Can assign variables in any order, without backtracking.
• Tighten bound of Y using all selected X: Y ˛ X + |XY|
� 30
� 30 [25,30]
Outline
•
•
•
•
Review: Constraint -based Interval Planning
Simple Temporal Networks
Temporal Consistency and Scheduling
Execution Under Uncertainty
Executing Flexible Temporal Plans
[Muscettola, Morris, Pell et al.]
Handling delays and fluctuations in task duration:
• Least commitment temporal plans leave room to adapt.
EXECUTIVE
Issues in Flexible Execution
1. How do we minimize execution latency?
2. How do we schedule at execution time?
CONTROLLED SYSTEM
Flexible execution adapts through dynamic scheduling.
• Assigns time to event when executed.
Time Propagation Can Be Costly
Time Propagation Can Be Costly
EXECUTIVE
EXECUTIVE
CONTROLLED SYSTEM
CONTROLLED SYSTEM
Time Propagation Can Be Costly
Time Propagation Can Be Costly
EXECUTIVE
EXECUTIVE
CONTROLLED SYSTEM
CONTROLLED SYSTEM
Time Propagation Can Be Costly
Time Propagation Can Be Costly
EXECUTIVE
EXECUTIVE
CONTROLLED SYSTEM
CONTROLLED SYSTEM
Issues in Flexible Execution
Compile to Efficient Network
1. How do we minimize execution latency?
� Propagate through a small set of neighboring constraints.
2. How do we schedule at execution time?
EXECUTIVE
CONTROLLED SYSTEM
Compile to Efficient Network
Compile to Efficient Network
EXECUTIVE
EXECUTIVE
CONTROLLED SYSTEM
CONTROLLED SYSTEM
Issues in Flexible Execution
Issues in Flexible Execution
1. How do we minimize execution latency?
� Propagate through a small set of
neighboring constraints.
1. How do we minimize execution latency?
� Propagate through a small set of neighboring constraints.
2. How do we schedule at execution time?
2. How do we schedule at execution time?
� Through decomposition?
Dynamic Scheduling
by Decomposition
Dynamic Scheduling
by Decomposition
• Compute APSP graph
• Decomposition enables assignment without search
11
10
[0,10]
B
[1,1]
A
D
[0,10]
C
A
10
-1
B
0
1
0
-2
D
0
A
0
C
[2,2]
10
2
Equivalent Distance Graph
Representation
Simple Example
Assignment by Decomposition
• Select executable timepoint and assign
• Propagate assignment to neighbors
1
-1
10
-1
B
1
A
D
-2
<0,10>
t=0
0
A
0
1
1
-1
Equivalent All Pairs Shortest
Paths (APSP) Representation
Assignment by Decomposition
• Select executable timepoint and assign
• Propagate assignment to neighbors
<0,0>
0
A
-2
0
C
10
<0,10>
-2
11
t=3
-1
B
<2,11>
1
1
-1
D
-2
C
2
D
10
2
Equivalent Distance Graph
Representation
-2
10
D
-2
10
-1
B
0
C
2
11
10
1
C
10
-1
B
0
<0,10>
-2
2
<2,11>
Assignment by Decomposition
• Select executable timepoint and assign
• Propagate assignment to neighbors
But C now has to be
executed at t =2, which
is already in the past!
Solution:
• Assignments must
monotonically
increase in value.
11
t=3
10
<0,0>
� First execute all
APSP neighbors
with negative delays.
0
A
0
1
1
-1
Execute an event when enabled and active
• Enabled - APSP Predecessors are completed
– Predecessor – a destination of a negative edge
that starts at event.
• Active
-1
B
Dispatching Execution Controller
D
- Current time within bound of task.
<4,4>
-2
C
2
<2,2>
10
-2
Dispatching Execution Controller
Initially:
• E = Time points w/o predecessors
• S = {}
Repeat:
1. Wait until current_time has advanced st
EXECUTIVE
a. Some TP in E is active
b. All time points in E are still enabled.
2. Set TP’s execution time to current_time.
3. Add TP to S.
4. Propagate time of execution to TP’s APSP immediate neighbors.
5. Add to A, all immediate neighbors that became enabled.
a. TPx enabled if all negative edges starting at TPx have their
destination in S.
Propagation Example
S = {A}
Propagation is Focused
• Propagate forward along positive edges to
tighten upper bounds.
– forward prop along negative edges is useless.
• Propagate backward along negative edges to
tighten lower bounds.
–Backward prop along positive edges useless.
Propagation Example
S = {A}
11
<0,0>
A
10
-1
0
9
11
<1,10>
B
-1
<0,0>
1
1 -1
D
0
-2
C
2
-2
A
10
-1
9
B
-1
1
1 -1
D
-2
C
2
-2
Propagation Example
Propagation Example
S = {A}
S = {A}
11
<1,10>
<0,0>
A
10
-1
0
11
<1,10>
B
-1
<0,0>
1
1 -1
D
A
0
-2
C
9
-1
D
-2
C
2
<0,9>
-2
Propagation Example
<2,11>
1
1 -1
9
2
<0,9>
-2
B
10
-1
Reducing Execution Latency
S = {A}
Filtering:
Execution time is:
E= {C}
• some edges are redundant
• worst case O(n )
• remove redundant edges
• best case
11
<1,10>
<0,0>
A
10
-1
0
9
O(n )
B
-1
1
1 -1
11
<2,11>
10
D
C
<0,9>
-2
<0,0>
2
0
A
0
Edge Domination
–The thread running through A-B-C is always just as fast or faster than the thread running through A-C
-1
1
-1
1
D
<2,11>
-2
C
10
• BC upper-dominates AC if in
every consistent execution,
TB + b(B,C) £ T A + b(A,C)
t=3
B
-2
<0,10>
2
-2
Edge Domination
• AB lower-dominates AC if in
every consistent execution,
TB - b(A,B) ‡ TC - b(A,C)
A
B
C
A
B
– Enablement of node A is always determined by thread running through A-B-C
C
• Edge Dominance
• Edge Dominance
– Eliminate edge that is redundant due to the triangle inequality AB + BC = AC
– Eliminate edge that is redundant due to the
triangle inequality AB + BC = AC
150
A
150
B
-100
80
-50
A
80
-20
C
-50
• Edge Dominance
A
B
-100
80
-50
80
-20
C
-50
An Example of Edge Filtering
• Start off with the APSP network
B
1 -1
C
-2
C
An Example of Edge Filtering
• Start at A-B-C triangle
11
0
C
150
B
-100
9
-20
– Eliminate edge that is redundant due to the
triangle inequality AB + BC = AC
150
A
A
100
• Edge Dominance
– Eliminate edge that is redundant due to the triangle inequality AB + BC = AC
10
-1
B
-100
100
11
-1
1
-2
D
2
A
10
-1
0
9
B
1 -1
C
-2
-1
1
-2
2
D
An Example of Edge Filtering
• Look at B-D-C triangle
An Example of Edge Filtering
• Look at B-D-C triangle
11
11
B
-1
A
0
1 -1
1
-2
C
9
B
-1
D
-1
A
0
-1
1
-2
C
9
2
1 -1
D
2
-2
An Example of Edge Filtering
• Look at D-A-B triangle
An Example of Edge Filtering
• Look at D-A-C triangle
11
11
B
-1
A
0
1 -1
1
C
9
B
-1
D
2
• Look at B-C-D triangle
0
9
C
1 -1
-1
1
C
D
2
An Example of Edge Filtering
• Look at B-C-D triangle
B
1 -1
0
9
An Example of Edge Filtering
A
A
B
-1
1
D
2
A
0
9
1 -1
C
-1
1
D
An Example of Edge Filtering
• Resulting network has less edges than the
original
A
9
C
0
1
• Node Contraction
– Collapse two events with fixed time between
them
D
-1
-1
B
|LB|
10
-1
B
A
1
B
Additional Filtering
0
1
0
-2
C
10
D
A
|AL|
2
Additional Filtering
• Node Contraction
– Collapse two events with fixed time between
them
An Example of Node Contraction
• Resulting network has less edges than the
original
A
9
0
|LB|
|BL|
|LA|
L
C
1
1
B
D
-1
-1
B
9
A
|BL|
Avoiding Intermediate
Graph Explosion
Problem:
• APSP consumes O(n2) space.
Solution:
• Interleave process of APSP construction
with edge elimination
– Never have to build whole APSP graph
CBD
0
AL
Goals and Environment Constraints
Temporal
Planner
Temporal
Network
Solver
Projective
Task Expansion
Temporal Plan
Dynamic Scheduling
and Task Dispatch
Modes
Goals
Model-based Programming
& Task Execution
Observations
Task
Dispatch
Commands
Reactive
Task Expansion
Download