 (defn make-incremental-dijkstra-search [initial-nodes]
   (let [q (make-queue initial-nodes)]
     (reify IncrementalSearch
-      (next-solution-or-cutoff [min-reward]
+      (next-partial-solution [min-reward]
         (incremental-dijkstra q min-reward expand-node extract-goal-state)))))
 
-; (util/print-debug 1 "\nRefining " (second  name) (first name) "with min-reward [" min-reward "]" "\n" (map #(vector (pretty-state (:initial-state (first %))) (map env/action-name (:remaining-actions (first %))) (next %)) (queues/pq-peek-pairs child-queue)))
+
+;; TODO: need "generalized-goal" dijkstra search.  
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Exhaustive Search ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;; No reason to use this except to emulate SAHTN.
+;; Note: destroys cost order, but should still work correctly.
+
+(defn make-exhaustive-search [sp]
+  (reify IncrementalSearch
+    (next-partial-solution [min-reward]
+      (loop [results []]
+        (let [{:keys [result-pairs max-reward]} (next-partial-solution sp Double/NEGATIVE_INFINITY)]
+          (let [next-results (into results result-pairs)]
+            (if (= max-reward Double/NEGATIVE_INFINITY)
+                (PartialResult next-results max-reward)
+              (recur next-results))))))))
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Cached Search ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-;; TODO: split refine into PartialResult type, always give new reward -- more accurate.
 
 (defn make-cached-search-factory
   "Return a cache-fn, where (cache-fn) returns fresh IncrementalSearch views on

          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-solution-or-cutoff top Double/NEGATIVE_INFINITY)]
      (when (not (number? result))
        (second result)))))

;; For SAHA, nothing is open.
;  Or strcture is same.


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; State-Abstracted Search ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defn lift-partial-result [partial-result context-state context-reward]
  (let [{:keys [result-pairs max-reward]} partial-result]
    (PartialResult (map #(generalize-outcome-pair % context-state context-reward) result-pairs)
                   (+ max-reward context-reward))))

(defn make-search-in-context [subsearch context-state context-reward]
  (reify IncrementalSearch
    (next-partial-solution [min-reward]
      (lift-partial-result (next-partial-solution subsearch (- min-reward context-reward))
                           context-state context-reward))))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
