'Q: PDDL doesn't compile problem and domain
I don't know why it doesn't work. here is my code:
Domain
(define (domain tren_mover)
(:requirements :adl)
(:predicates
(conectado ?x ?y)
(en ?x ?y)
(movil ?x)
)
(:action mover
:parameters (?tren ?origen ?destino)
:precondition
(and
(movil ?tren)
(en ?origen ?destino)
(conectado ?origen ?destino)
)
:effect
(and
(en ?tren ?destino)
(not (en ?tren ?origen))
)
)
)
Problem
(define (problem tren_en_movimiento)
(:domain tren_mover)
(:objects
T - tren
F1- Fábrica1
F2 - Fábrica2
A - almacén
P - puerto
)
(:init
(en puerto tren)
(mover tren)
(conectado A P)
(conectado P F2)
(conectado F2 F1)
(conectado F1 A)
(conectado A F1)
(conectado F1 F2)
(conectado F2 P)
(conectado P A)
)
(:goal (and
(en F1 T)
)
)
)
The Error message that appears is:
Failed to parse the problem -- invalid syntax (, line 37)
/tmp/solver_planning_domains_tmp_4C4oEmiiY8B3Q/domain.pddl:
syntax error in line 16, '':
domain definition expected
Solution 1:[1]
There are several logical and syntactical mistakes in your code:
Logical
(en ?origen ?destino) how can you put two positions in the same place! it should be the tren who has to be in the origin position.
Syntactical
- The
objectsin the problem, you have to understand the difference betweentypesandobjects, you are mixing between them! - There is a typo in the initial state, you are using
moverinstead ofmovil. - in the
goal, you are usingand()which is not needed, and moreover causes an error as you don't have two predicates to combine!
Domain
(define (domain tren_mover)
(:requirements :adl)
(:predicates
(conectado ?x ?y)
(en ?x ?y)
(movil ?x)
)
(:action mover
:parameters (?tren ?origen ?destino)
:precondition
(and
(movil ?tren)
(en ?tren ?origen)
(conectado ?origen ?destino)
)
:effect
(and
(en ?tren ?destino)
(not (en ?tren ?origen))
)
)
)
Problem
(define (problem tren_en_movimiento)
(:domain tren_mover)
(:objects tren Fabrica1 Fabrica2 almacen puerto)
(:init
(en tren puerto)
(movil tren)
(conectado almacen puerto)
(conectado puerto Fabrica2)
(conectado Fabrica2 Fabrica1)
(conectado Fabrica1 almacen)
(conectado almacen Fabrica1)
(conectado Fabrica1 Fabrica2)
(conectado Fabrica2 puerto)
(conectado puerto almacen)
)
(:goal
(en tren Fabrica1)
)
)
Solution 2:[2]
I think you should consider including the requirement :typing to categorize the parameters used in predicates and actions. Due to this error, the :objects in the problem file can't be parsed correctly.
Please refer to this link: https://planning.wiki/ref/pddl/requirements#typing and try to rectify errors.
Also, You can use VS Code plugin available for PDDL to avoid syntax errors and solve the plan. It can be found here: https://marketplace.visualstudio.com/items?itemName=jan-dolejsi.pddl
Best Regards!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 |
