Algorithm 2: Algorithm for constructing a regular expres-
sion describing a set of plans.
procedure REGEXPGEN(Plans - list of plans)
2: if exists an action in all plans then
a ← select an action in all plans
4: for each plan in Plans do
parts ← plan.split(a)
6: I ←RegExpGen([parts.first()])
E ←RegExpGen([parts.last()])
8: M ←RegExpGen(parts[1:len-1])
return Exp(a,I,M,E,Plans)
10: end for
else
12: join present actions to a set J
return J, (J)
+
or (J)
∗
as appropriate
14: end if
end procedure
0 drive_tent {0: ’guy0’, 2: ’place1’, 4: ’tent3’}
1 put_up {0: ’guy0’, 1: ’place1’, 2: ’tent3’}
2 drive {1: ’place0’, 2: ’place1’}
3 drive_passenger {1: ’place1’, 2: ’place0’}
4 walk_together {0: ’E’, 1: ’place1’, 3: ’place0’}
5 (walk_together )+ {0: ’E’, 1: ’place1’, 3: ’place0’}
6 drive_passenger {1: ’place1’, 2: ’place0’}
7 drive {1: ’place0’, 2: ’place1’}
8 drive {1: ’place0’, 2: ’place1’}
9 put_down {0: ’girl0’, 1: ’place1’, 2: ’F’}
10 (drive_tent {0: ’girl0’, 1: ’place1’, 2: ’place2’, 4: ’F’}
11 put_up {0: ’girl0’, 1: ’place2’, 2: ’F’}
12 drive {0: ’I’, 1: ’H’, 2: ’place2’}
13 drive_passenger {1: ’place2’, 2: ’H’, 4: ’I’}
14 walk_together {0: ’D’, 1: ’place2’, 3: ’H’}
15 (walk_together )+ {0: ’D’, 1: ’place2’, 3: ’H’}
16 drive_passenger {1: ’place2’, 2: ’H’}
17 drive {1: ’H’, 2: ’place2’}
18 drive {1: ’H’, 2: ’place2’}
19 put_down )+ {1: ’place2’, 2: ’C’}
Figure 4: Attributed Regular Expression Example.
4 CONNECTING ATTRIBUTES IN
ACTIONS
Assume now, that we got a regu-
lar expression with sequence of actions
put_down, drive_tent, put_up describing
tent transport. If action attributes are ignored then
these actions may deal with different tents and
different locations and, hence, the action sequence
may be meaningless. The meaning of the control
knowledge was that we put down some ?tent at
certain location ?from, then we drive that tent to
another location ?to, where we put that tent up. This
information can be encoded via shared attributes of
the actions, for example:
(put_down ? ?from ?tent)
(drive_tent ? ?from ?to ? ?tent)
(put_up ? ?to ?tent)
In this section we address the problem how to connect
the attributes of actions or, in other words, how to find
equivalence classes of actions’ attributes.
Figure 4 shows the final equivalence classes as
part of the regular expression, so we will use it to ex-
plain the notation used. Each line contains exactly
one action (and possibly some delimiters ’(’, ’)’, ’+’).
We number the attributes of each action starting with
0, Figure 4 shows only the attributes that are shared
between the actions (for example, attributes 1 and 3
are missing in the first action drive_tent as they are
not shared with other actions). The group of shared
attributes is identified by a specific label. For ex-
ample, the label place1 tells: the attribute 2 of ac-
tion 0 should be passed as attribute 1 to action 1 and
then as attribute 2 in action 2 etc. The same attribute
is used up to the line 10 as the attribute 1 of action
drive_tent and then forgotten (not used in the rest
of the plan).
This shared attribute is represented
by the label place1 and the set of pairs
{(0,2),(1,1),(2,2),(3,1),(4,2),...,(10,1)}, where
each pair means (actionLine,attributePosition). We
will call the label with the corresponding set an
equivalence class. A set of equivalence classes is
called a pattern.
While we construct the underlying regular expres-
sion top-down, the pattern is constructed bottom-up,
starting from the elementary parts of the regular ex-
pression.
The same recursive tree structure as in Algo-
rithm 1 is followed. Compared to Algorithm 1, the
sub-plan is extended by the immediate predecessor
and the immediate successor (if they exist).
Consider the example in Table 1. The first ac-
tion to split is put
down. Assume the action ap-
pears four times in the plan, therefore three sub-plans
P
M
1
,P
M
2
,P
M
3
are sent to the middle part in the brack-
ets. The second split in the middle part is put up, a
single remaining I
2
is action drive tent. The sequence
of three actions, ’put down,drive tent,put up’, is sent
to the leaf ’drive tent’ for each of the three sub-plans
P
M
1
,P
M
2
,P
M
3
. These action triples are listed in Table 2
(we will denote them as P
1
,P
2
,P
3
).
Table 1: Regular expression evolution: at the first level, ac-
tion put down is chosen for the split. On the second level
in the middle is the split put up. I
2
contains a single action
drive tent in all plans.
I
1
. put down.( M
1
. put down)
∗
. E
1
I
1
. put down.( I
2
. put up. E
2
. put down)
∗
. E
1
I
1
. put down.( drive tent. put up. E
2
. put down )
∗
. E
1
Table 2: Elementary Pattern Generation.
P
1
(put-down g0 p0 t0) (drive-tent g0 p0 p1 c0 t0) (put-up g0 p1 t0)
P
2
(put-down g0 p1 t0) (drive-tent g0 p1 p2 c0 t0) (put-up g0 p2 t0)
P
3
(put-down g0 p2 t4) (drive-tent g0 p2 p3 c0 t0) (put-up g0 p3 t0)
P (put-down 0:G 1:X ) (drive-tent 0:G 1:X 2:Y 4:T) (put-up 0:G 1:Y 2:T)
ICAART 2020 - 12th International Conference on Agents and Artificial Intelligence
962