Planning and Optimization
D7. M&S: Generic Algorithm and Heuristic Properties
Gabriele R¨oger and Thomas Keller
Universit¨at Basel
November 7, 2018
Generic Algorithm Heuristic Properties Summary
Content of this Course
Planning
Classical
Tasks Progression/
Regression Complexity Heuristics
Probabilistic
MDPs Uninformed Search
Heuristic Search Monte-Carlo
Methods
Generic Algorithm Heuristic Properties Summary
Content of this Course: Heuristics
Heuristics
Delete Relaxation
Abstraction
Abstractions in General
Pattern Databases
Merge &
Shrink Landmarks
Potential Heuristics Cost Partitioning
Generic Algorithm Heuristic Properties Summary
Generic Algorithm
Generic Algorithm Heuristic Properties Summary
Content of this Course: Merge & Shrink
Merge & Shrink
Synchronized Product Merge & Shrink Algorithm
Heuristic Properties Strategies Label Reduction
Generic Algorithm Heuristic Properties Summary
Generic Merge-and-shrink Abstractions: Outline
Using the results from the previous chapter, we can develop the ideas of ageneric abstraction computation procedurethat takes all state variables into account:
Initialization step: Compute all abstract transition systems for atomic projections to form the initial abstraction collection.
Merge steps: Combine two abstract systems in the collection by replacing them with their synchronized product. (Stop once only one transition system is left.)
Shrink steps: If the abstractions in the collection are too large to compute their synchronized product, make them smaller by abstracting them further (applying an arbitrary abstraction to them).
We explain these steps with our running example.
Generic Algorithm Heuristic Properties Summary
Back to the Running Example
LRR LLL LLR
LRL
ALR
ALL
BLL
BRL
ARL
ARR
BRR
BLR
RRR RRL
RLR
RLL
Logistics problem with one package, two trucks, two locations:
state variablepackage: {L,R,A,B} state variabletruck A:{L,R}
state variabletruck B:{L,R}
Generic Algorithm Heuristic Properties Summary
Initialization Step: Atomic Projection for Package
Tπ{package}:
L
A
B
R
M???
PAL DAL
M???
DAR PAR
M???
PBR DBR
M???
DBL PBL
Generic Algorithm Heuristic Properties Summary
Initialization Step: Atomic Projection for Truck A
Tπ{truck A}:
L R
PAL,DAL,MB??, PB?,DB?
MALR
MARL
PAR,DAR,MB??, PB?,DB?
Generic Algorithm Heuristic Properties Summary
Initialization Step: Atomic Projection for Truck B
Tπ{truck B}:
L R
PBL,DBL,MA??, PA?,DA?
MBLR
MBRL
PBR,DBR,MA??, PA?,DA?
current collection: {Tπ{package},Tπ{truck A},Tπ{truck B}}
Generic Algorithm Heuristic Properties Summary
First Merge Step
T1 :=Tπ{package}⊗ Tπ{truck A}:
LL LR
AL AR
BL BR
RL RR
MALR MARL
MALR MARL
MALR MARL
MALR MARL PAL
DAL
PADARR
PBR DBL DBR
PBL
PBL DBL
DBR PBR
MB?? MB??
MB?? MB??
MB?? MB??
MB?? MB??
current collection: {T1,Tπ{truck B}}
Generic Algorithm Heuristic Properties Summary
Need to Simplify?
If we have sufficient memory available, we can now compute T1⊗ Tπ{truck B}, which would recover the complete transition system of the task.
However, to illustrate the general idea, let us assume that we do not have sufficient memory for this product.
More specifically, we will assume that after each product operation we need to reduce the result transition system to four states to obey memory constraints.
So we need to reduce T1 to four states. We have a lot of leeway in deciding how exactly to abstractT1.
In this example, we simply use an abstraction that leads to a good result in the end.
Generic Algorithm Heuristic Properties Summary
First Shrink Step
T2 := some abstraction of T1
LL LR
AL AR
BL BR
RL RR
MALR MARL
MALR MARL
MALR MARL
MALR MARL PAL
DAL
PADARR
PBR DBL DBR
PBL
PBL DBL
DBR PBR
MB?? MB??
MB?? MB??
MB?? MB??
MB?? MB??
current collection: {T2,Tπ{truck B}}
Generic Algorithm Heuristic Properties Summary
First Shrink Step
T2 := some abstraction of T1
LL LR
AL AR
BL BR
RL RR
MALR MARL
MALR MARL
MALR MARL
MALR MARL PAL
DAL
PADARR
PBR DBL DBR
PBL
PBL DBL
DBR PBR
MB?? MB??
MB?? MB??
MB?? MB??
MB?? MB??
current collection: {T2,Tπ{truck B}}
Generic Algorithm Heuristic Properties Summary
First Shrink Step
T2 := some abstraction of T1
LL LR
AL AR
BL BR
R
MALR MARL
MALR MARL
MALR MARL PAL
DAL
DAR PAR
DBRPBR DBL
PBL
PBL DBL
DBR PBR MB??
MB?? MB??
MB??
MB??
M???
MB??
current collection: {T2,Tπ{truck B}}
Generic Algorithm Heuristic Properties Summary
First Shrink Step
T2 := some abstraction of T1
LL LR
AL AR
AL AR
BL BR
R
MALR MARL
MALR MARL
MALR MARL PAL
DAL
DAR PAR
DBRPBR DBL
PBL
PBL DBL
DBR PBR MB??
MB?? MB??
MB??
MB??
M???
MB??
current collection: {T2,Tπ{truck B}}
Generic Algorithm Heuristic Properties Summary
First Shrink Step
T2 := some abstraction of T1
LL LR
A
BL BR
R
MALR MARL
MALR MARL PAL
DAL
DAR PAR
DBRPBR DBL
PBL
PBL DBL
DBR PBR MB??
M???
MB??
MB??
M???
MB??
current collection: {T2,Tπ{truck B}}
Generic Algorithm Heuristic Properties Summary
First Shrink Step
T2 := some abstraction of T1
LL LR
A
BL BR
BL BR
R
MALR MARL
MALR MARL PAL
DAL
DAR PAR
DBRPBR DBL
PBL
PBL DBL
DBR PBR MB??
M???
MB??
MB??
M???
MB??
current collection: {T2,Tπ{truck B}}
Generic Algorithm Heuristic Properties Summary
First Shrink Step
T2 := some abstraction of T1
LL LR
A
B
R
MALR MARL
PAL DAL
DAR PAR
PBR DBL DBR
PBL PBL DBL MB??
M???
MB??
M???
M???
current collection: {T2,Tπ{truck B}}
Generic Algorithm Heuristic Properties Summary
First Shrink Step
T2 := some abstraction of T1
LL LR
A A
B B
R
MALR MARL
PAL DAL
DAR PAR
PBR DBL DBR
PBL PBL DBL MB??
M???
MB??
M???
M???
current collection: {T2,Tπ{truck B}}
Generic Algorithm Heuristic Properties Summary
First Shrink Step
T2 := some abstraction of T1
LL LR I R
MALR MARL MB??
MB??
D?R M???
P?R M???
PBL DBL P?L D?L
current collection: {T2,Tπ{truck B}}
Generic Algorithm Heuristic Properties Summary
First Shrink Step
T2 := some abstraction of T1
LL LR I R
MALR MARL MB??
MB??
D?R M???
P?R M???
PBL DBL P?L D?L
current collection: {T2,Tπ{truck B}}
Generic Algorithm Heuristic Properties Summary
Second Merge Step
T3 :=T2⊗ Tπ{truck B}:
LRL
LRR
LLL
LLR
IL
IR
RL
RR
MBLR MBRL
MBLR MBRL
MBLR MBRL
MBLR MBRL DAR
PAR
D?R P?R P?L
D?L
PAL DAL MALR MARL MALR MARL
PBL DBL
MA??
MA?? MA??
MA??
current collection: {T3}
Generic Algorithm Heuristic Properties Summary
Another Shrink Step?
Normally we could stop now and use the distances in the final abstract transition system as our heuristic function.
However, if there were further state variables to integrate, we would simplify further, e.g. leading to the following
abstraction (again with four states):
LRR LLLLRL
LLR I R
M??? M???
M???
M?RL M?LR
P?L D?L
D?R P?R
We get a heuristic value of 3 for the initial state, better than any PDB heuristic that is a proper abstraction.
The example generalizes to more locations and trucks, even if we stick to the size limit of 4 (after merging).
Generic Algorithm Heuristic Properties Summary
Generic Algorithm Template
Generic Merge & Shrink Algorithm abs := {Tπ{v} |v ∈V}
while abs contains more than one abstract transition system:
select A1,A2 fromabs
shrink A1 and/or A2 untilsize(A1)·size(A2)≤N abs := abs\ {A1,A2} ∪ {A1⊗ A2}
returnthe remaining abstract transition system in abs N: parameter bounding number of abstract states Questions for practical implementation:
Which abstractions to select? merging strategy How to shrink an abstraction? shrinking strategy How to chooseN? usually: as high as memory allows
Generic Algorithm Heuristic Properties Summary
Heuristic Properties
Generic Algorithm Heuristic Properties Summary
Content of this Course: Merge & Shrink
Merge & Shrink
Synchronized Product Merge & Shrink Algorithm
Heuristic Properties Strategies Label Reduction
Generic Algorithm Heuristic Properties Summary
Heuristic Properties
Each iteration of the algorithm corresponds to a
transformation of the collection absof transition systems.
The exact transformation depends on the specific instantiation of the generic algorithm
(e.g. of the merging and the shrinking strategy).
For analyzing the properties of the resulting heuristic, we analyze properties of the individual transformations.
Generic Algorithm Heuristic Properties Summary
Collections of Transition Systems
Definition (Collection of Transition Systems)
A setX of transition systems is acollection of transition systems if allT ∈X have the same set of labels and the same cost function.
Thecombined systemis TX :=N
T ∈X T.
Remark: Strictly speaking, the combined system is not well-defined as the Cartesian product is neither commutative nor associative.
For our purpose it is sufficient that the results of all possible combination orders are isomorphic.
Generic Algorithm Heuristic Properties Summary
Safe Transformations
Definition (Safe Transformation)
LetX andX0 be collections of transition systems with label setsL andL0 and cost functions c andc0, respectively.
The transformation fromX toX0 is safe if there exist functionsσ andλmapping the states and labels ofTX to the states and labels ofTX0 such that
c0(λ(`))≤c(`) for all`∈L,
if hs, `,ti is a transition ofTX then hσ(s), λ(`), σ(t)i is a transition of TX0, and
if s is a goal state ofTX thenσ(s) is a goal state of TX0.
Generic Algorithm Heuristic Properties Summary
Examples
X: Collection of transition systems
Replacement with Synchronized Product is Safe
LetT1,T2 ∈X with T16=T2. The transformation fromX to X0:= (X\ {T1,T2})∪ {T1⊗ T2} is safe with σ= id andλ= id.
Abstraction is Safe
Letα be an abstraction forTi ∈X. The transformation from X to X0:= (X\ {Ti})∪ {Tiα} is safe withλ= id and
σ(hs1, . . . ,sni) =hs1, . . . ,si−1, α(si),si+1, . . . ,sni.
(Proofs omitted.)
Generic Algorithm Heuristic Properties Summary
Heuristic Properties (1)
Theorem
Let X and X0 be collections of transition systems. If the
transformation from X to X0 issafe with functions σ andλthen h(s) =h∗T
X0(σ(s))is a safe, goal-aware, admissible, and consistent heuristic forTX.
Proof.
We prove goal-awareness and consistency, the other properties follow from these two.
Goal-awareness: For all goal statess? of TX, state σ(s?) is a goal state ofTX0 and therefore h(s?) =h∗T
X0(σ(s?)) = 0. . . .
Generic Algorithm Heuristic Properties Summary
Heuristic Properties (2)
Proof (continued).
Consistency: Letc andc0 be the label cost functions of X andX0, respectively. Consider states of TX and transitionhs, `,ti.
AsTX0 has a transition hσ(s), λ(`), σ(t)i, it holds that h(s) =h∗T
X0(σ(s))
≤c0(λ(`)) +h∗T
X0(σ(t))
=c0(λ(`)) +h(t)
≤c(`) +h(t)
The second inequality holds due to the requirement on the label costs.
Generic Algorithm Heuristic Properties Summary
Exact Transformations
Definition (Exact Transformation)
LetX andX0 be collections of transition systems with label setsL andL0 and cost functions c andc0, respectively.
The transformation fromX to X0 is exactif there exist functions σ andλmapping the states and labels ofTX to the states and labels ofTX0 such that
1 σ andλsatisfy the requirements of safe transformations,
2 ifhs0, `0,t0i is a transition ofTX0 then hs, `,tiis a transition of TX for all s ∈σ−1(s0),t∈σ−1(t0) and some`∈λ−1(`0),
3 if s0 is a goal state of TX0 then all states s ∈σ−1(s0) are goal states of TX, and
4 c(`) =c0(λ(`)) for all`∈L.
no “new” transitions and goal states, no cheaper labels
Generic Algorithm Heuristic Properties Summary
Examples
Replacement with Synchronized Product is Exact
LetT1,T2 ∈X with T16=T2. The transformation fromX to X0:= (X\ {T1,T2})∪ {T1⊗ T2} is exact with σ= id and λ= id.
(Proof omitted.)
More examples will follow.
Generic Algorithm Heuristic Properties Summary
Heuristic Properties with Exact Transformations (1)
Theorem
Let X and X0 be collections of transition systems. If the
transformation from X to X0 isexact with functionsσ and λthen h∗T
X(s) =h∗T
X0(σ(s)).
Proof.
As the transformation is safe,h∗T
X0(σ(s)) is admissible for TX and thereforeh∗T
X(s)≥h∗T
X0(σ(s)).
For the other direction, we show that for every states0 ofTX0 and goal pathπ0 for s0, there is for each s ∈σ−1(s0) a goal path inTX
that has the same cost. . . .
Generic Algorithm Heuristic Properties Summary
Heuristic Properties with Exact Transformations (2)
Proof (continued).
Proof via induction over the length ofπ0.
|π0|= 0: Ifs0 is a goal state ofTX0 then eachs ∈σ−1(s0) is a goal state ofTX and the empty path is a goal path fors in TX.
|π0|=i+ 1: Let π0 =hs0, `0,t0iπt00, where π0t0 is a goal path of lengthi fromt0. Then there is for eacht ∈σ−1(t0) a goal pathπt
of the same cost inTX. Furthermore, for alls ∈σ−1(s0) there is a label`∈λ−1(`0) such thatTX has a transitionhs, `,tiwith t∈σ−1(t0). The path π=hs, `,tiπt is a solution for s in T. As` and`0 must have the same cost andπt andπ0t0 have the same cost,π has the same cost asπ0.
Generic Algorithm Heuristic Properties Summary
Sequences of Transformations
Theorem (Sequences of Transformations)
Let X1, . . . ,Xn be collections of transition systems.
If for i∈ {1, . . . ,n−1} the transformation from Xi to Xi+1 is safe (exact) then the transformation from X1 to Xnis safe (exact).
Proof idea: The composition of the σ andλfunctions of each step satisfy the required conditions.
Generic Algorithm Heuristic Properties Summary
Consequences
Generic Merge & Shrink Algorithm abs := {Tπ{v} |v ∈V} =: X0
while abs contains more than one abstract transition system:
select A1,A2 fromabs
shrink A1 and/or A2 untilsize(A1)·size(A2)≤N abs := abs\ {A1,A2} ∪ {A1⊗ A2}
returnthe remaining abstract transition system in abs Initially Tabs is the concrete transition system.
Each iteration performs a safe transformation ofabs.
→ the corresponding abstraction heuristic is safe, goal-aware,
→ consistent, and admissible.
If shrinking is exact, the corresponding heuristic is perfect.
Generic Algorithm Heuristic Properties Summary
Summary
Generic Algorithm Heuristic Properties Summary
Summary
Projections perfectly reflecta fewstate variables.
Merge-and-shrink abstractions are ageneralization that can reflect allstate variables, but in apotentially lossy way.
The merge stepscombine two abstract transition systems by replacing them with theirsynchronized product.
The shrink stepsmake an abstract system smaller by abstracting it further.
As we only use safe transformations, the resulting heuristic is alwaysadmissible.
If we use only exacttransformations, the resulting heuristic is perfect.