一个PDDL简单教程
(照例mark一下学习收获)
首先介绍一下pddl结构:
我的理解是,这是一个strips的模型实现语言
pddl??planner??plan
对于strips来说,包含的元素有
p(predicates)
f(fluents/facts)
I(only one initial state)
g(a set of goal states)
o(operator)
1)一个domain file:
主要含type,predicates,action的precondition,add, delete的操作
2)一个problem file:
含initial state和goal state
然后工具:
1)online pddl:
http://editor.planning.domains.
2)vscode:
extensions里面install pddl
然后,运行的时候,双击对应的domain file和problem file,保证上面菜单只有这两个被打开,然后运行快捷键是option+p(Mac)
简单例子很多地方都有,代码还是比较容易懂的,就不在这里讲了,下面主要列一下可用的语法:
1)exists
注意这个exists一定要加s,不然就一直报错说‘(’问题。。。ps出现这种报错问题可以先看看语法有没有错,单词拼写有没有错
假设type中定义了一个type叫做node
1 2 3 | (:types node ) |
我们有个predicates叫做(cat ?pos - node),意思是在这个position上有只猫
官方document对exist的定义是(exists (node)(condition))
eg:
1 2 3 4 | (exists (?pos - node) (cat ?pos) ) |
意思是,存在位置上有猫的位置
能用在precondition formula和effect formula
2)forall
forall用法和exists差不多
eg:
1 2 3 4 | (forall (?pos - node) (cat ?pos) ) |
意思是,对所有位置上有猫的点
只能用在precondition formula
3)and和or和not
and:
括号内两个条件都为真(and(predicate_1)(predicate_2)),则整个才为真;
or:
括号内只要有一个条件为真(or(predicate_1)(predicate_2)),整个为真;
not:
(not(predicate))
3)=
(= ?pos1 ?pos2)
4)when
条件判断,用在effect formula
1 2 3 4 | when( (predicate_1) (predicate_2) ) |
当predicate_1发生时,执行predicate_2
pddl得到的不一定是optimal,他只负责给出一个plan,他的结果取决于使用的solver
附上官方document链接:
http://users.cecs.anu.edu.au/~patrik/pddlman/writing.html
一个example: