AI-Planning / AI-Planning/pddl
Effects 'When' and 'ForAll' lack instantiate method
- Vorherrschende Sprache
- Python
- Sterne
- 177
- Forks
- 43
- Ø Merge
- 49 Min.
- Gemergte PRs (30 T.)
- 1
Beschreibung
### 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.
Beitragsleitfaden
Bewertung
Dieses Issue wurde noch nicht bewertet.