1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
use crate::types::{GoalDefinition, Interval, TimeSpecifier};
/// A timed goal definition.
///
/// ## Usage
/// Used by [`PrefTimedGD`](crate::PrefTimedGD).
#[derive(Debug, Clone, PartialEq)]
pub enum TimedGD {
/// ## `at start`
/// An expression or predicate with `at start` prefixed to it means that the condition
/// must be true at the start of the action in order for the action to be applied. e.g.
///
/// ```pddl
/// (at start (at ?rover ?from-waypoint))
/// ```
///
/// expresses that `at start` the given rover is `at` the `from-waypoint`.
/// Confusingly in this particular domain, the `at` is a predicate representing the
/// location of an object `at` a point, whilst `at start` is a keyword.
///
/// `at start` is usually applied per predicate.
///
/// ## `at end`
/// An expression or predicate with `at end` prefixed to it means that the condition
/// must be true at the end of the action in order for the action to be applied e.g.
///
/// ```pddl
/// (at end (>= (battery-amount ?rover) 0))
/// ```
///
/// expresses that whilst this fact doesn't have to be true at the start or during the action,
/// it must be true at the end. In this case, we're expressing that the battery amount at the
/// end of the action must be greater than zero.
At(TimeSpecifier, GoalDefinition),
/// ## `over all`
/// An expression or predicate with an overall prefixed to it, means that the condition
/// must be true throughout the action, including at the start and end. e.g.
///
/// ```pddl
/// (over all (can-move ?from-waypoint ?to-waypoint))
/// ```
///
/// At all points in the execution of the action the given expression must evaluate to true.
/// In the case above, we are expressing that it must be possible to move from the from
/// waypoint to the to waypoint all the way through the action. I.e. we don't want to get
/// half way through the action to find that after a certain point a path has become blocked.
Over(Interval, GoalDefinition),
}
impl TimedGD {
pub const fn new_at(time: TimeSpecifier, gd: GoalDefinition) -> Self {
Self::At(time, gd)
}
pub const fn new_over(interval: Interval, gd: GoalDefinition) -> Self {
Self::Over(interval, gd)
}
}
impl From<(TimeSpecifier, GoalDefinition)> for TimedGD {
fn from(value: (TimeSpecifier, GoalDefinition)) -> Self {
TimedGD::At(value.0, value.1)
}
}
impl From<(Interval, GoalDefinition)> for TimedGD {
fn from(value: (Interval, GoalDefinition)) -> Self {
TimedGD::Over(value.0, value.1)
}
}