Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[irtgraph.l] do not set cost when arc is not costed-arc #603

Merged
merged 6 commits into from
Nov 29, 2021

Conversation

knorth55
Copy link
Contributor

@knorth55 knorth55 commented Aug 19, 2021

When I try to solve graph with normal arc with depth-first-graph-search-solver, I got the following error.
this is because arc is assumed as costed-arc. which has :cost methods.
this PR check if arc has :cost or not, and set 0 cost when arc is not costed-arc.
this is useful for non-cost-using solvers such as depth-first-graph-solver and so on.

7.E1-irteusgl$ (setq path (send solver :solve *pddl-graph* :verbose t))
nil
8.E1-irteusgl$ Call Stack (max depth: 20):
  0: at (send arc :cost)
  1: at (+ (send from :cost) (send arc :cost))
  2: at (send prblm :path-cost self (car successor) (cdr successor))
  3: at (send #:inst2934 :init (cdr successor) :parent self :action (car successor) :cost (send prblm :path-cost self (car successor) (cdr successor)))
  4: at (let ((#:inst2934 (instantiate solver-node))) (send #:inst2934 :init (cdr successor) :parent self :action (car successor) :cost (send prblm :path-cost self (car successor) (cdr successor))) #:inst2934)
  5: at (instance solver-node :init (cdr successor) :parent self :action (car successor) :cost (send prblm :path-cost self (car successor) (cdr successor)))
  6: at (cons (instance solver-node :init (cdr successor) :parent self :action (car successor) :cost (send prblm :path-cost self (car successor) (cdr successor))) ret)
  7: at (setq ret (cons (instance solver-node :init (cdr successor) :parent self :action (car successor) :cost (send prblm :path-cost self (car successor) (cdr successor))) ret))
  8: at (setf ret (cons (instance solver-node :init (cdr successor) :parent self :action (car successor) :cost (send prblm :path-cost self (car successor) (cdr successor))) ret))
  9: at (push (instance solver-node :init (cdr successor) :parent self :action (car successor) :cost (send prblm :path-cost self (car successor) (cdr successor))) ret)
  10: at (while #:dolist2932 (setq successor (pop #:dolist2932)) (push (instance solver-node :init (cdr successor) :parent self :action (car successor) :cost (send prblm :path-cost self (car successor) (cdr successor))) ret))
  11: at (let ((successor nil) (#:dolist2932 successors)) nil (while #:dolist2932 (setq successor (pop #:dolist2932)) (push (instance solver-node :init (cdr successor) :parent self :action (car successor) :cost (send prblm :path-cost self (car successor) (cdr successor))) ret)) nil)
  12: at (dolist (successor successors) (push (instance solver-node :init (cdr successor) :parent self :action (car successor) :cost (send prblm :path-cost self (car successor) (cdr successor))) ret))
  13: at (let ((ret nil)) (dolist (successor successors) (push (instance solver-node :init (cdr successor) :parent self :action (car successor) :cost (send prblm :path-cost self (car successor) (cdr successor))) ret)) ret)
  14: at (let ((successors (send* prblm :successors state args))) (let ((ret nil)) (dolist (successor successors) (push (instance solver-node :init (cdr successor) :parent self :action (car successor) :cost (send prblm :path-cost self (car successor) (cdr successor))) ret)) ret))
  15: at (send target-node :expand prblm :verbose verbose)
  16: at (send self :add-list-to-open-list (send target-node :expand prblm :verbose verbose))
  17: at (cond ((send prblm :goal-test (send target-node :state)) (return-from :solve (send target-node :path))) ((not (send self :find-node-in-close-list target-node)) (push (send target-node :state) close-list) (send self :add-list-to-open-list (send target-node :expand prblm :verbose verbose))))
  18: at (let ((target-node (send self :pop-from-open-list :debug verbose))) (cond ((send prblm :goal-test (send target-node :state)) (return-from :solve (send target-node :path))) ((not (send self :find-node-in-close-list target-node)) (push (send target-node :state) close-list) (send self :add-list-to-open-list (send target-node :expand prblm :verbose verbose)))))
  19: at (while (not (send self :null-open-list?)) (let ((target-node (send self :pop-from-open-list :debug verbose))) (cond ((send prblm :goal-test (send target-node :state)) (return-from :solve (send target-node :path))) ((not (send self :find-node-in-close-list target-node)) (push (send target-node :state) close-list) (send self :add-list-to-open-list (send target-node :expand prblm :verbose verbose))))))
/home/knorth55/install/jskeus/eus/Linux64/bin/irteusgl 0 error: cannot find method :cost in (send arc :cost)

@knorth55 knorth55 changed the title do not set cost when arc is not costed-arc [irtgraph.l] do not set cost when arc is not costed-arc Aug 19, 2021
@k-okada
Copy link
Member

k-okada commented Nov 2, 2021

thanks for catch, Another solution might be

(defmethod graph
  ;; :path-cost returns cost from 'from-node' to 'to-node' by 'action'.                                          
  (:path-cost (from arc to)
    (if (or (not (derivedp from costed-arc))
            (not (derivedp to costed-arc)))
        1
      (+ (send from :cost) (send arc :cost))))

@knorth55
Copy link
Contributor Author

Travis CI is not running because of negative credit.
We need to disable Travis CI required.

Screenshot 2021-11-16 16:14:58

@k-okada k-okada merged commit 1fb745b into euslisp:master Nov 29, 2021
@knorth55 knorth55 deleted the fix-graph-solver branch November 29, 2021 04:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants