1

I try to find the shortest path in a net of nodes. Start at x1y1 and end up in x9y9. Each move from node to node has a certain cost assigned to it. The goal is, to find the path with the lowest total cost.

Problem description

The :init section contains the information about which nodes are connected and what the cost of the connection is:

(:init
    (neighbor x1y1 x1y2)
    (neighbor x1y2 x1y3)
    (neighbor x1y1 x2y1)
    (neighbor x1y3 x9y9)
    (neighbor x2y1 x9y9)
    (on runner x1y1)
    (= (cost-total) 0)
    (= (cost-step x1y1 x1y2) 2)
    (= (cost-step x1y2 x1y3) 2)
    (= (cost-step x1y1 x2y1) 100)
    (= (cost-step x1y3 x9y9) 2)
    (= (cost-step x2y1 x9y9) 2)
)

As you can see, I set the cost for the connection between x1y1 and x2y1 to 100 so this connection should be avoided. But the Planner always creates a solution that includes this connection rather than finding a path with less total cost.

Planner Output:
Screenshot Planner Output

I'm new with PDDL and I have no idea what's wrong. Therefore, I posted all code below:

Domain:

;Header and description

(define (domain domain_name)

;remove requirements that are not needed
(:requirements :strips :typing :fluents :action-costs)
;(:requirements :strips :fluents :durative-actions :timed-initial-literals :typing :conditional-effects :negative-preconditions :duration-inequalities :equality)

(:types player field
)

; un-comment following line if constants are needed
;(:constants )

(:predicates
    (on ?player - player ?loc - field)
    (neighbor ?start - field ?end - field)
)


(:functions
    (cost-total)
    (cost-step ?from - field ?to - field)
)

(:action move
    :parameters (?player - player ?from - field ?to - field)
    :precondition (and 
        (on ?player ?from)
        (neighbor ?from ?to)
    )
    :effect (and 
        (on ?player ?to)
        (not (on ?player ?from))
        (increase (cost-total) (cost-step ?from ?to))
    )
)

)

Problem:

(define (problem problem_name) (:domain domain_name)
(:objects x1y1 x1y2 x2y1 x1y3 x9y9 - field
          runner - player
)

(:init
    (neighbor x1y1 x1y2)
    (neighbor x1y2 x1y3)
    (neighbor x1y1 x2y1)
    (neighbor x1y3 x9y9)
    (neighbor x2y1 x9y9)
    (on runner x1y1)
    (= (cost-total) 0)
    (= (cost-step x1y1 x1y2) 2)
    (= (cost-step x1y2 x1y3) 2)
    (= (cost-step x1y1 x2y1) 100)
    (= (cost-step x1y3 x9y9) 2)
    (= (cost-step x2y1 x9y9) 2)
)

(:goal (and
    (on runner x9y9)
))

;un-comment the following line if metric is needed
(:metric minimize (cost-total))
)
jaal5
  • 11
  • 2

2 Answers2

0

By the screenshot, it looks like you're using the vscode plugin and thus likely the online solver. This is not an optimal solver, and so there's no guarantee on which actions it will or won't use.

Either way, first step is to confirm you have an optimal planner running. Then we can dig into the PDDL if there's still an issue.

haz
  • 625
  • 4
  • 12
  • Yes, I am using the plugin with the online solver. Is there a way to use another planner? – jaal5 Apr 27 '20 at 00:46
  • It's possible to set up your own server with an optimal planner running behind the scenes, but it's a non-trivial task. Eventually (within half a year likely), the online solver will provide the option to run an optimal planner instead of the far quicker satisficing one, and that change should hopefully be reflected in the vscode plugin as well. – haz Apr 27 '20 at 02:44
0

Your code is correct, only you need is to use a special solver. I recommended you use the Optic-CPL solver, here is that link to download or maybe download the solver that I use.

Download compiled binaries

This working in Ubuntu 12.10 to 20.04

To use the solver, you need the following command:

$ ./optic-clp -n domain.pddl problem.pddl