I am a beginner in PDDL. I am trying to write a domain file for Petri net with a fire transaction function.
(define (domain newpetri)
(:requirements :strips :typing :fluents)
(:types place transition)
(:predicates
(incoming ?p - place ?t - transition)
(outgoing ?t - transition ?p - place)
)
(:functions
(number-of-tokens ?p)
)
(:action fire-transition
:parameters (?t - transition)
:preconditions
(forall
(?p - place)
(or (not (incoming ?p ?t))
(> (number-of-tokens ?p) 0)))
:effects
(forall
(?p - place)
(when
(incoming ?p ?t)
(decrease (number-of-tokens ?p))))
(forall
(?p - place)
(when
(outgoing ?t ?p)
(increase (number-of-tokens ?p))))
)
it gives me an error in the following part:
(forall
(?p - place)
(or (not (incoming ?p ?t))
(> (number-of-tokens ?p) 0)))
should I define the place and the transition in predicate?? Thanks.
I already wrote a domain and problem
(define (domain petri)
(:requirements :strips :typing :fluents)
(:types
token place
)
(:predicates
(at ?v - token ?p - place)
(connected ?v - token ?p1 ?p2 - place)
)
(:functions
(initial-token ?v - token)
(required-token ?p1 ?p2 - place)
(total-tokens-used)
)
(:action move
:parameters (?v - token ?from ?to - place)
:precondition (and (at ?v ?from)
(connected ?v ?from ?to)
(>= (initial-token ?v) (required-token ?from ?to)))
:effect (and (not (at ?v ?from))
(at ?v ?to)
(decrease
(initial-token ?v)
(required-token ?from ?to))
(increase
(total-tokens-used)
(required-token ?from ?to))
)
)
)
--------------------------------------------------
(define (problem petriproblem)
(:domain petri)
(:objects
token - token
spring summer fall winter - place
)
(:init
(at token spring)
(= (initial-token token) 3)
(connected token spring summer)
(connected token summer fall)
(connected token fall winter)
(connected token winter spring)
(= (required-token spring summer) 1)
(= (required-token summer fall) 1)
(= (required-token fall winter) 1)
(= (total-tokens-used) 0)
)
(:goal
(at token winter)
)
(:metric minimize
(total-tokens-used)
)
)
I am trying to use the same logic, by replacing the total-tokens-used with number-of-tokens and comparing the number-of-tokens between the incoming and outgoing transitions to determine whether the fire transition condition is valid or not. but I didn't know exactly how to do that.