Reputation: 1
I don't know why it doesn't work. here is my code:
(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))
)
)
)
(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
Upvotes: 0
Views: 788
Reputation: 3854
There are several logical and syntactical mistakes in your code:
(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.
objects
in the problem, you have to understand the difference between types
and objects
, you are mixing between them!mover
instead of movil
.goal
, you are using and()
which is not needed, and moreover causes an error as you don't have two predicates to combine!(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))
)
)
)
(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)
)
)
Upvotes: 1
Reputation: 15
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!
Upvotes: 0