 (defn make-descendents [state action prim-constructor ref-constructor]
   (if (env/primitive? action)
       (when-let [[ss sr] (and (env/applicable? action state) (env/successor action state))]
-        [(prim-constructor ss sr)])
+        [(prim-constructor (vary-meta ss assoc :opt [action]) sr)])
     (map ref-constructor (hierarchy/immediate-refinements action state))))
 
 (defn generalize-outcome-pair [[outcome-state reward] gen-state reward-to-gen-state]

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Drivers  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defn sahucs-simple [henv]
  (binding [*problem-cache* (HashMap.)]
    (let [e    (hierarchy/env henv)
          init (env/initial-logging-state e)
          tla  (hierarchy/TopLevelAction e [(hierarchy/initial-plan henv)])
          top  (make-incremental-dijkstra-search (make-initial-sp-nodes init tla)) 
          result (next-partial-solution top Double/NEGATIVE_INFINITY)]
      (assert (< (count (:result-pairs result 1))))
      (second (first (:result-pairs result))))))


(defn blablabla [henv]

      (assert (< (count (:result-pairs result 1))))
      (second (first (:result-pairs result))))))

;; TODO: compare performance to other algorithms.  


;; For SAHA, nothing is open.
;  Or strcture is same.
 ; Goal is: ?
