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))
)