我试图在节点网络中找到最短路径。从x1y1开始,到x9y9结束。从一个节点到另一个节点的每次移动都有一定的成本分配给它。目标是找到总成本最低的路径。问题描述
:init 部分包含有关连接哪些节点以及连接成本是多少的信息:
(: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)
)
如您所见,我将 x1y1 和 x2y1 之间的连接成本设置为 100,因此应该避免这种连接。但是规划器总是创建一个包含此连接的解决方案,而不是寻找总成本更低的路径。
规划器输出:
屏幕截图规划器输出
我是 PDDL 的新手,我不知道出了什么问题。因此,我在下面发布了所有代码:
领域:
;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))
)
)
)
问题:
(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))
)