Skip to content

Commit

Permalink
Further fixes to HDDL plan output.
Browse files Browse the repository at this point in the history
  • Loading branch information
rpgoldman committed Nov 4, 2023
1 parent 88cd7e6 commit 2446efd
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 7 deletions.
4 changes: 2 additions & 2 deletions shop3/buildapp/shop-app-entrypoints.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@
cmd args))
(let ((tree1 (load-file (first args)))
(tree2 (load-file (second args))))
(setf tree1 (shop::canonically-order tree1)
tree2 (shop::canonically-order tree2))
(setf tree1 (shop::canonically-order-plan-tree tree1)
tree2 (shop::canonically-order-plan-tree tree2))
(cond ((equalp tree1 tree2)
(format t "~&Trees match.~%")
(uiop:quit 0))
Expand Down
9 changes: 7 additions & 2 deletions shop3/buildapp/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ else
fi
compare_trees
fi
echo "... ok"

echo "Test SHOP with 1 argument and plan tree"
INPUT=$(mktemp -t "inputXXXXXX")
Expand All @@ -247,6 +248,7 @@ else
fi
compare_trees
fi
echo "... ok"


echo "Test ESS-SHOP with 2 arguments"
Expand All @@ -260,6 +262,7 @@ elif [ "$RES" != "$EXPECTED" ]; then
echo "Plan result did not equal the expected."
exit 1
fi
echo "... ok"

echo "Test ESS-SHOP with 1 argument"
INPUT=$(mktemp -t "input.XXXXXXXXXXX")
Expand All @@ -274,6 +277,7 @@ elif [ "$RES" != "$EXPECTED" ]; then
echo "Plan result did not equal the expected."
exit 1
fi
echo "... ok"

echo "Test ESS SHOP with 2 arguments and plan-tree"

Expand All @@ -293,10 +297,11 @@ else
# These don't compare properly because the ESS trees have INOP nodes in them
# compare_trees
fi
echo "... ok"

echo "Test ESS SHOP with 1 argument and plan tree"
INPUT=$(mktemp -t "inputXXXXXX")
cat logistic.lisp Log_ran_problems_15.lisp >> ${INPUT}
cat logistic.lisp Log_ran_problems_15.lisp > ${INPUT}
PLAN=$(mktemp -t "planXXXXXX")
PLAN_TREE=$(mktemp -t "treeXXXXXX")
ess-shop --tree-file ${PLAN_TREE} --plan-file ${PLAN} ${INPUT}
Expand All @@ -313,6 +318,6 @@ else
# These don't compare properly because the ESS trees have INOP nodes in them
# compare_trees
fi

echo "... ok"

exit 0
2 changes: 1 addition & 1 deletion shop3/hddl/hddl-plan.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ HDDL plan encoded as an s-expression."
(iter (for root in root-tasks)
(as i = (task-index root))
;; (format t "~&Root = ~S index = ~d~%" i root)
(collecting (task-index root))))
(collecting i)))
(setf decompositions (plan-tree->decompositions tree))
`(:hddl-plan
:actions ,indexed-plan
Expand Down
32 changes: 30 additions & 2 deletions shop3/tests/hddl-tests.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
(,treevar (shop::tree (first , returns))))
,@body))))

(defmacro with-hddl-plan ((hddl-planvar ess-plan ess-tree) &body body)
`(let ((,hddl-planvar (hddl-plan ,ess-plan ,ess-tree)))
,@body))

#+ignore
(test plan-test
(load-log-problem)
Expand All @@ -58,6 +62,8 @@
;; (is (equalp expected-tree tree))
))



#+ignore
(test translate-tree
(load-log-problem)
Expand All @@ -77,9 +83,21 @@
(test translate-tree-ess
(load-log-problem)
(with-plan-and-tree (plan tree :ess t)
(let ((hddl-plan-sexp
(hddl-plan plan tree)))
(with-hddl-plan (hddl-plan-sexp plan tree)
(is-true hddl-plan-sexp)
(is (equalp (iter (for i from 1)
(as step in (shop:shorter-plan plan))
(collecting (cons i step)))
(getf (rest hddl-plan-sexp) :actions)))
(let ((decomps (getf (rest hddl-plan-sexp) :decompositions))
(roots (getf (rest hddl-plan-sexp) :roots)))
(flet ((find-decomp (n)
(or (find n decomps :key (lambda (x) (hddl-translator::decomposition-record-node-id x)))
(error "No decomposition with node-id ~d" n))))
(is (equalp (mapcar #'shop::strip-task-sexp (rest (shop::problem-tasks (shop:find-problem 'shop-user::log-ran-15-1 nil))))
(iter (for root-no in roots)
(as node = (find-decomp root-no))
(collecting (hddl-translator::decomposition-record-task node)))))))
(let ((max-act 124)
(act-alist (getf (rest hddl-plan-sexp) :actions))
(root-list (getf (rest hddl-plan-sexp) :roots)))
Expand All @@ -88,6 +106,16 @@
(is (equalp (alexandria:iota 15 :start (1+ max-act))
root-list))))))

(test hddl-test-ess
(load-log-problem)
(with-plan-and-tree (plan tree :ess t)
(with-hddl-plan (hddl-plan plan tree)
hddl-plan
)
;;(is (equalp expected-plan plan))
;; (is (equalp expected-tree tree))
))


(in-package :shop-user)
(defparameter shop-hddl-tests::expected-plan
Expand Down

0 comments on commit 2446efd

Please sign in to comment.