Skip to content

Commit

Permalink
Fix issues handling timeouts.
Browse files Browse the repository at this point in the history
  • Loading branch information
rpgoldman committed Nov 22, 2023
1 parent 03bc995 commit 9ae1215
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion panda-planner.asd
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
(in-package :panda-planner-asd)

(defsystem panda-planner
:depends-on (pddl-planners)
:depends-on (pddl-planners hddl-utils)
:version (:read-file-form "version.lisp-expr")
:pathname "planners/"
:components ((:file "panda")))
29 changes: 19 additions & 10 deletions planners/panda.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

(multiple-value-bind (output error-output success)
(uiop:run-program (list "timeout"
"--signal=KILL"
;; "--signal=KILL"
(format nil "~ds" remaining-time)
panda-pi-parser
(namestring domain-file)
Expand All @@ -48,15 +48,18 @@
:error-output :output
:output :string)
(declare (ignore error-output))
(unless (zerop success)
(error "Failed to parse the domain and/or problem with exit code ~d.~%Output:~%~a" success output)))
(cond ((= success 124)
(error "Timed out while parsing the domain and/or problem"))
((zerop success))
(t
(error "Failed to parse the domain and/or problem with exit code ~d.~%Output:~%~a" success output))))
(decf remaining-time (elapsed-seconds start-time (get-internal-run-time)))
(when (< remaining-time 0) (error "Timeout during parsing."))
(when verbose (format t "~&Done parsing HDDL inputs.~%"))
(setf start-time (get-internal-run-time))
(multiple-value-bind (output error-output success)
(uiop:run-program (list "timeout"
"--signal=KILL"
;; "--signal=KILL"
(format nil "~ds" remaining-time)
panda-pi-grounder
parsed-file
Expand All @@ -66,27 +69,33 @@
:output :string)
(declare (ignore error-output))
(decf remaining-time (elapsed-seconds start-time (get-internal-run-time)))
(unless (zerop success)
(error "Failed to ground the problem with exit code ~d.~%Output:~%~a" success output))
(cond ((= success 124)
(error "Timed out while grounding the domain and problem"))
((zerop success))
(t
(error "Failed to ground the domain and problem with exit code ~d.~%Output:~%~a" success output)))
(when (search "unreachable" output)
(error "Panda grounder proved the problem unsolveable.~%Output:~%~a" output)))
(when (< remaining-time 0) (error "Timeout during grounding."))
(when verbose (format t "~&Done grounding Panda problem.~%"))

(delete-file raw-plan)
(setf start-time (get-internal-run-time))
(multiple-value-bind (output error-output success)
(uiop:run-program (list panda-pi-engine
(format nil "--timelimit=~d" remaining-time)
grounded-file)
:ignore-error-status t
:error-output :output
:if-output-exists :supersede
:output raw-plan)
(declare (ignore output error-output))
(decf remaining-time (elapsed-seconds start-time (get-internal-run-time)))
(when (< remaining-time 0) (error "Timeout during grounding."))
(unless (zerop success)
(error "Failed to solve the problem with exit code ~d.~%Output:~%~a" success (alexandria:read-file-into-string raw-plan))))
(when (< remaining-time 0) (error "Timeout during planning."))
(cond ((or (= success 124) (= success 137))
(error "Timed out while finding a solution for the problem (pandaPIengine)"))
((zerop success))
(t
(error "Failed to solve the problem with exit code ~d.~%Output:~%~a" success (alexandria:read-file-into-string raw-plan)))))
(when verbose (format t "~&Done solving Panda problem.~%"))
(multiple-value-bind (output error-output success)
(uiop:run-program (list panda-pi-parser "-c" raw-plan hddl-plan)
Expand Down
2 changes: 1 addition & 1 deletion version.lisp-expr
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"3.2.0"
"3.2.1"

0 comments on commit 9ae1215

Please sign in to comment.