 (defn refine-pn [pn input-summary min-reward]
   (let [{:keys [sub-output-set-pointer excluded-child-set summary-bound]} pn]
     (refine-osp! sub-output-set-pointer min-reward excluded-child-set)
-    (assoc pn :output-summary (compute-plan-node-output-summary input-summary sub-output-set-pointer summary-bound))))
+    (assoc pn :output-summary (compute-plan-node-output-summary input-summary sub-output-set-pointer excluded-child-set summary-bound))))
 
 
 (defn split-pn-output [pn input-set input-summary min-step-reward]

  (state-set/constrain (state/transfer-effects input-set (osp-output-set sub-output-set-pointer))
                       output-constraint))

(defn compute-plan-node-output-summary [input-summary sub-output-set-pointer summary-bound]
  (->> (full-osp-summary sub-output-set-pointer)
       (min-summary summary-bound )
       (add-summaries input-summary)))

(defn make-plan-node [input-set input-summary sub-output-set-pointer
                      excluded-child-set output-constraint summary-bound]
  (PlanNode. sub-output-set-pointer excluded-child-set output-constraint summary-bound
             (compute-plan-node-output-set input-set sub-output-set-pointer output-constraint)
             (compute-plan-node-output-summary input-summary sub-output-set-pointer summary-bound)))

(defn make-initial-plan-node [action [input-set input-summary]]
  (let [sub (get-subproblem-root-pointer input-set action (constantly is/pos-inf))]
    (make-plan-node input-set input-summary sub #{} {} +best-summary+)))


(defn plan-node-output-set-and-summary [pn]
  [(:output-set pn) (:output-summary pn)])


    plans-by-output-set))

(defn split-osp
  "Return new-child-osps.  Currently splits children >= min-reward when parent < min-reward."
  [osp min-reward excluded-child-set]
  (when (< (max-reward (max-summary (osp-plan-summary osp) (osp-ancestor-summary osp))) min-reward)
    (filter #(>= (max-reward (full-osp-summary %)) min-reward)
            (remove excluded-child-set (osn-child-pointers @(:node-atom osp))))))

(defn can-split-osp? [osp excluded-child-set]
  (> (apply max is/neg-inf (map (comp max-reward #(osp-descendent-summary % #{}))
                                (remove excluded-child-set (osn-child-pointers @(:node-atom osp)))))
     (max-reward (max-summary (osp-plan-summary osp) (osp-ancestor-summary osp)))))




