AI-Planning / AI-Planning/pddl

Effects 'When' and 'ForAll' lack instantiate method

Aberta
#180 0 comentários 0 reações 0 responsáveis Ver no GitHub
Linguagem predominante
Python
Estrelas
177
Forks
43
Merge médio
49min
PRs com merge (30d)
1

Descrição

### 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.

Guia de contribuição

Abrir o guia de contribuição

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.