 (defn make-if-deadlock-hla [hierarchy var dl-plan nodl-plan]
   (let [name [:if-deadlock var (map env/action-name dl-plan) (map env/action-name nodl-plan)]
         av   (action-var var)
-        pc   ;(:full-context hierarchy )#_
-             (util/safe-get-in hierarchy [:precondition-context-map var])]
+        pc   (util/safe-get-in hierarchy [:precondition-context-map var])]
     (reify :as this
       env/Action
        (action-name [] name)

  (let [name          [:fire-action effect-var]
        reduced-pm    (dissoc (:precond-map a) effect-var)
        child-var-map (:child-var-map hierarchy)
        pc            ;(:full-context hierarchy ) #_
                      ;(util/safe-get-in hierarchy [:precondition-context-map effect-var]) #_
                      (into #{(action-var effect-var)}
                            (apply concat
                                   (for [p (keys reduced-pm)]
                                     (cons (free-var p) 
                                           (cons (parent-var p effect-var) 
                                                 (get-in hierarchy [:precondition-context-map p]))))))]
;    (println "FA" name)
  (reify :as this
    env/Action

  [(asplan-skip-solution-name sol) rew])



;; TODO: faster & early deadlock detection.
;; TODO: detect "out-of-context" deadlock, fail immediately.
;; TODO: precond ordering when we activate (handled by activation-actions?)


;  (let [e (make-random-infinite-taxi-sas2 1 2 1 2)] (println (time (run-counted #(uniform-cost-search e)))) (println (time (run-counted #(asplan-solution-pair-name (uniform-cost-search (make-asplan-env e))))))  (println (debug 0 (time (run-counted #(asplan-solution-pair-name (dsh-ucs-inverted (make-asplan-skip-henv e))))))))

; (let [e (make-random-infinite-taxi-sas2 1 2 1 2)] (interactive-hierarchical-search (make-asplan-skip-henv e)))

; (let [e (make-random-infinite-taxi-sas2 2 2 2 2)] (interactive-hierarchical-search (make-asplan-skip-henv e)))

; (let [e (force (nth ipc2-logistics 0))] (println (time (run-counted #(uniform-cost-search e)))) (println (time (run-counted #(asplan-solution-pair-name (uniform-cost-search (make-asplan-env e))))))  (println (debug 0 (time (run-counted #(asplan-skip-solution-pair-name (dsh-ucs-inverted (make-asplan-skip-henv e))))))))

























(comment ; May use later for more fine-grained stuff.
 (defn split-preconds 
   "Return [deadlocked matching free-unmatching reserved-unmatching]"
