AI-Planning / AI-Planning/pddl
Effects 'When' and 'ForAll' lack instantiate method
- 主要语言
- Python
- 星标
- 177
- 派生
- 43
- 平均合并
- 49 分钟
- 30 天内合并 PR
- 1
描述
### Subject of the issue
The recent action instantiation feature (#158) is useful. However, the current implementation fails for actions with a `(forall ...)` effect.
```
'Forall' object has no attribute 'instantiate'
File "/home/jjewett/miniforge3/envs/skillet/lib/python3.11/site-packages/pddl/action.py", line 93, in instantiate
effect=self.effect.instantiate(instantiation) if self.effect else None,
^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jjewett/project/embodied-repair/conditional_repair/.dev/fastd.py", line 21, in
grounded = action.instantiate([obj])
^^^^^^^^^^^^^^^^^^^^^^^^^
```
This is because pddl.logic.effects.ForAll is treated as a Formula in action.effect, but does not implement `instantiate`.
```
>>> action.effect.__repr__
'Forall(frozenset({Variable(p)}), (friendly ?o ?p))'
```
### Your environment
- OS: Ubuntu 24.04
- Python version: 3.11.14
- Package Version 0.4.5
### Steps to reproduce
```
(define (domain hello-world)
(:requirements :typing :conditional-effects )
(:predicates
(hello-said)
(friendly ?o ?p)
)
; This action changes the state from not said to said
(:action say-hello
:parameters (?o)
:precondition (and )
:effect (and (forall (?p) (friendly ?o ?p)))
)
)
(define (problem hello-world-problem)
(:domain hello-world)
(:objects
o1 p1 p2 - object
)
(:init
)
(:goal (friendly o1 p1)
)
)
```
```
domain = DomainParser()(domain_str)
problem = ProblemParser()(problem_str)
obj = next(iter(problem.objects))
action = next(iter(domain.actions))
grounded = action.instantiate([obj])
```
### Expected behaviour
It should not error out. `ForAll` should instantiate its effect. `When` should instantiate its condition and effect.
### Actual behaviour
pddl.logic.effects.ForAll gives the error showed above.
pddl.logic.effects.When gives a similar error.
贡献指南
评估
这个 Issue 还没有评估数据。