I'm implementing a charging action in PDDL2.1 that is based off a function (charge_level)
. The function value for (charge_level)
works and updates ~10Hz.
I want to create an action called charge
which continues until the charge_level
reaches a threshold. That is
(:durative-action charge
:duration ( CONTINUE UNTIL (> (charge_level) HIGH_THRES)))
:condition (and
(at start ( < (charge_level) LOW_THRES)))
:effect (and
)
))
How might I implement this? I was trying to assign the ?duration
variable to charge_level
and set :duration (> ?duration HIGH_THRES)
but it wouldn't plan successfully.
Thanks in advance!
The answer depends on two aspects of your solution:
For the first aspect: if your domain also models the discharging effect in other actions, and if your planner supports continuous effects, you could model the action in a similar way to this boil
action:
(:durative-action boil-water
:parameters ()
:duration (>= ?duration 0)
:condition (and
(at start (and
(not (boiling))
))
(over all (and
(<= (water-temperature) 100)
))
)
:effect (and
(at start (and
(boiling)
))
(at end (and
(not (boiling))
))
(increase (water-temperature) (* #t 1.0))
)
)
You can fin the full example is here.
The continuous effect (increase (water-temperature) (* #t 1.0))
is what defines how quickly is the temperature changing in time. With that, the planner can reason about how long the action should take. That is why the duration is defined without any upper bound :duration (>= ?duration 0)
. This is assuming there is another action in the domain or goal in the problem, which require the water-temperature
to be of certain numeric value. Otherwise the planner has no reason to add the action to the plan.
Another approach is to use process
(and event
) as defined in PDDL+.
And regarding the second aspect: if your domain does not really need to reason about the value of the charge_level
, you should delegate that to your plan execution infrastructure. In practice, it is much simpler to evaluate a boolean predicate fully_charged
based on the condition (> (charge_level) HIGH_THRES))
outside the planner as part of your state inference.