3. The Merge-and-Shrink Framework
3.8. Discussion of Generalized Label Reduction
3.8.3. Efficient Implementation
In the following, we describe the techniques used for an efficient implementation of the merge- and-shrink framework in Fast Downward. Some of these techniques have already been used in the older implementation using the previous theory of label reduction (cf. Section 4.3 by Helmert et al.,2014) and in our first, non-optimized implementation of generalized label reduction in Fast Downward, used in our original conference paper (Sievers et al.,2014). All improvements based on generalized label reduction are implemented in the state-of-the-art optimized code base of merge-and-shrink. Hence there are two implementations we compare here, and we describe both of them in the following, distinguishing clearly between optimizations present in the previous implementation and in the optimized implementation.
In both implementations, we do not store transitions as an adjacency list as it is common with graphs, but we store all transitions grouped by labels. This allows an efficient application of all transformations of transition systems, as we will see below. Additionally, and in contrast to the previous implementation, we store label groups of locally equivalent labels (i.e. we store the local equivalence relation on labels for each transition system), disregarding their cost (the cost of a label group is the minimum cost of any participating label) and store their transitions only once rather than separately for each label. This was not possible in the previous implementation where labels were associated with preconditions and effects of operators. In addition, due to this more memory-efficient representation, we can also represent so-called irrelevant labels,10
i.e. have one group that represents irrelevant labels. The previous implementation did not store transitions of irrelevant labels explicitly, which led to various special-casing.
Furthermore, we maintain a valid-state invariant for transition systems, which states that la- bels and their transitions are grouped (i.e. local equivalence relations on labels have been com- puted), that the transitions are sorted and unique within label groups (which eases the com- putation of locally equivalent labels, because this requires comparing sets of transitions), that g- and/or h-values for each transition system are computed, depending on the requirements on distance information of the chosen merge, shrink, and prune strategy, and that all factors are 10A label l is irrelevant in Θ if for all states s of Θ, there is exactly one transition s −→ s ∈ Θ, i.e. the labell
induces self-looping transitions for all states. A label l is relevant if it is not irrelevant. See also Definition5.5on page109.
pruned according to the prune strategy.11 We make sure that after applying any transformation
to the factored transition system, all transition systems are in a valid state again. This contrasts the previous implementation which also guaranteed that transitions were sorted and unique (for single labels), but did not enforce this as an invariant, but only on demand (before shrinking and merging, but not after merging), and which always computed both g- and h-value distance information (because it always used full pruning).
Another difference is due to the changed layout of the main loop: we apply prune trans- formations according the prune strategy PS after merging, because only when computing the product system, new dead states can arise. The previous implementation performed pruning while shrinking, and hence only pruned transition systems before they were further processed.
In both implementations, we compute distance information of transition systems by perform- ing Dijkstra’s algorithm (Dijkstra, 1959). This is the only place where we need an explicit adjacency list representation of transition systems.
We now turn our attention to the different merge-and-shrink transformations. When applying a shrink transformation to the factored transition system, the shrink strategy computes a state mapping in the form of an equivalence relation on states. We first compute the explicit state mapping from this equivalence relation, assigning a consecutive number to each equivalence class. This state mapping can then be applied to both the transition system with its represen- tation of transitions grouped by labels and to the FM. From the equivalence relation on states, we update the information on goal states. This implementation of shrinking is identical to the previous implementation by Helmert et al.
When applying a merge transformation to the factored transition system, merging two tran- sition systems Θ1 and Θ2, we do not compute the full product of states and their transitions as
it has been done in the previous implementation by Helmert et al., because this would require to compute the local equivalence relation on labels from scratch after computing the product. Instead, we use a bucket-based approach to directly compute the refinement of the local equiva- lence relations on labels of Θ1 and Θ2, collecting their transitions accordingly. To compute the
merge FM, all that needs to be done is to set its table to map pairs of component states to their product state.
When applying a prune transformation, we first need to compute the set of unreachable and/or irrelevant states for the to-be-pruned transition system, depending on the chosen options for pruning. As the required distance information is always up-to-date for all transition systems (valid-state invariant), we simply collect all states whose g- and/or h-value is infinity and either prune them by entirely removing them and their transitions from the transition system (original pruning), or by applying an abstraction that maps all unreachable/irrelevant states to two sin- gle states (pruning as abstraction), as described at the end of Section3.5. The FM is updated by applying a state mapping that maps all pruned states to ⊥ and leaves all other entries un- changed. The former implementation of pruning (removing states and transitions) is identical to the previous implementation by Helmert et al.
Computing a label reduction with the algorithm shown on page76is also favored by our rep- 11We remark that the layout of the algorithm as discussed above is chosen to accommodate the needs of our invariant.
In particular, concerning pruning, we prune all atomic factors once, and since new pruning opportunities can only arise in product factors, we also prune immediately after merging.
resentation that stores the local equivalence relations on labels for all transition systems and all transitions grouped by labels. In particular, the loop of the method Θ-COMBINABLE-RELATION
simply uses the already computed local equivalence relations on labels (EQUIVREL) rather than
computing it from scratch (valid-state invariant). For efficient REFINE operations as discussed
in the description of the algorithm, we store labels in linked lists. Computing the label mapping (LABELMAPPING) is straight-forward and is done as computing the state mapping from the
equivalence relation on states when shrinking. As we store locally equivalent labels of different costs in the same group, for exact label reductions, we need to further split the computed label mapping according to label costs.
Applying the label mapping (APPLY) can be efficiently done as follows. When updating a
transition system for which we know that only locally equivalent labels are combined (which is the case for all transition systems other than Θ when applying a label mapping based on Θ- combinability), all we have to do is to remove the old labels from their group (they are all in the same group) and adding the new label to it; the transitions remain. Otherwise, we need to remove the old labels from their groups (potentially different ones) and add a new singleton group for the new label. While doing so, we collect the transitions of all to be removed labels and combine them to form the transitions of the new label. If label groups become empty, we remove them together with their transitions. We also need to recompute the costs of all modified label groups. Finally, we recompute the local equivalence relation on labels to restore the valid-state invariant for the transitions system.
In contrast to the previous implementation by Helmert et al., we directly encode the heuristic values into the final FM σ rather than keeping σ together with the distance information of the final transition system Θ. This means that the FM does not store the abstraction mapping from Θ(Π)to Θ but represents the heuristic function, i.e. a mapping from states s of Θ(Π) to hΘ(s).
We remark that the above improvements compared to the previous implementation also affect some of the transformation strategies of the merge-and-shrink toolbox. We come back to that impact when discussing these strategies in the next chapter.
To conclude this section, the following list summarizes the differences of the optimized im- plementation compared to the previous one. All of these changes, except the last point of the list, are only possible due to the addition of generalized label reduction.
• We store labels and their transitions grouped according to the equivalence relation on labels within each transition system, including representing irrelevant labels.
• We maintain a valid-state invariant of transition systems. This means that we always store groups of locally equivalent labels, keep their transitions sorted and unique, and have distance information computed as required by all transformation strategies.
• We compute product systems without computing the full product of all transitions but rather by directly computing the label groups and their transitions as a refinement of the local equivalence relations on labels of the two components.
• We encode the heuristic directly into the final FM.
In our experimental study, we will compare merge-and-shrink based on generalized label reduc- tion using the previous and the optimized implementation.