• Keine Ergebnisse gefunden

The Basic CHnMM Decoding Algorithm

algorithm to omit those paths that cannot possibly yield the highest joint path probability. The resulting CHnMM algorithm is usually practically feasible, but for long traces may consume too much memory. We will therefore also develop a modified algorithm for the Decoding task that is slightly slower than the original one, but requires far less memory.

Proxel: evenwiththe modified Proxel merging of the Decoding task, each Proxel of that task after the first time step has a unique predecessor Proxel (it has to have at least one predecessor, since Proxels are only created by following possi-ble activity completions from other Proxels; and it has at most one predecessor, since all others are discarded through the modified merging). To solve the De-coding problem one simply adds enough information to each Proxel to uniquely determine its predecessor, i.e. the predecessor’s discrete state and age vector.

Then, when the Proxel representing the final state of the most likely path has been determined by the modified Forward algorithm, its links and those of its predecessors can iteratively be followed backwards to reconstruct the complete most likely path of (discrete) states, thereby solving the Decoding problem.

The complete Decoding algorithm using modified Proxel merging and Proxel backlinks is given as pseudocode in three parts: Algorithm 2 details the compu-tations for a single time step of the modified Forward algorithm with alternative Proxel merging semantics used to find the end state of the most likely path, Al-gorithm 3 details the computations for a single backtracking step used to find a given predecessor on the most likely path, and Algorithm 4 uses the other two algorithms to solve the Decoding task for a given trace of observations.

All three algorithms assume that Proxels contain links to their predecessors, so that the normal Proxel definition of ρ = (q, ~τ , α) needs to be extended to ρ= (q, ~τ , α, qparent, ~τparent).

Algorithm 2: DecodingForwardStep Input: A, T R, Rt, vt+1,∆t, N, T, K Rt+1=∅;

1

foreachρ∈Rt do

2

i =ρ.q;

3

psojourn= Y

j∈{1,...,N|aij6=∅}

1−cdf(aij.dist)(ρ.τaij.id+ ∆t) 1−cdf(aij.dist)(ρ.τaij.id) ;

4

foreachj∈ {1, . . . , N|aij 6=∅} do

5

Rowi={ai1, . . . , aiN};

6

Rowj={aj1, . . . , ajN};

7

~ τ0k0 =

8









τk+ ∆t ifT Rk ∈Rowi∧T Rk 6=aij∧ ¬isExp(T Rk.dist)∧ (T Rk ∈Rowj∨T Rk.aging)

τk ifT Rk ∈/Rowi∧T Rk.aging∧ ¬isExp(T Rk.dist)

0 otherwise

µ=hrf(aij.dist);

9

ρ0= (j, ~τ0, ρ.α∗psojourn∗µ(ρ.τaij.id+ ∆t)∗aij.b(vn+1), ρ.q, ρ.~τ);

10

if ρ0.α= 0thencontinue;

11

if ∃ρ00∈Rn+1 with(ρ00.q=ρ0.q∩ρ00.~τ =ρ0.~τ)then

12

if ρ0.α > ρ00.αthen

13

Rn+1= (Rn+1\{ρ00})∪ {ρ0};

14

else Rn+1=Rn+1∪ {ρ0};

15

return Rn+1 16

Algorithm 2 is almost identical to a single step of the CHnMM Forward algorithm (cf. Algorithm 1 on Page 46) Its inputs arethe state transition matrix M, the set of activitiesT R, the set of Proxels after thetth observationRt, the symbolvt+1of the next observation, the time ∆tbetween the last and the next observation, and the numbers of discrete statesN, observationsT and activities K, respectively. The only differences to the Forward algorithm are the addition of links to predecessor Proxels and the modified merging, which discards the source Proxel with the lower probability.

Note that as with the Forward algorithm, all probabilities stored in Proxels for the Decoding task are actually virtual probabilities that must not be inter-preted as literal probabilities. However, since the ratio of two virtual probabili-ties is the same as the ratio of the corresponding unknown actual probabiliprobabili-ties, the maximum of two virtual probabilities can be used in place of the maximum of the unknown actual probabilities, and will yield the same path.

Algorithm 3: DecodingBacktrackingStep Input: Rt, ρmaxt+1

Result: Proxel of thetth time step that is part of the most likely path of internal states.

returnonlyρ∈Rt withρ.q=ρmaxt+1.qparent∧ρ.~τ=ρmaxt+1.~τparent 1

Algorithm 3 simply uses the links of a single Proxel ρmaxt+1 to find its predecessor from the set of ProxelsRtof the previous time step.

Algorithm 4: Decoding Iterative Input: A, T R,Π, O, N, T, K

Result: Sequence of internal statesq0, . . . , qT that is most likely to have created the sequence of observationsO

R0= [

i∈{1,...N|πi6=0}

{(i, ~0, πi,∅,∅)};

1

fort = 1 toT do

2

Rt=DecodingForwardStep(A, T R, Rt−1, ot.v, ot.e−ot−1.e, N, T, K

3

);

ρmax = arg max

ρ∈RT

(ρ.α);

4

qTmax.q;

5

fort = T to1 do

6

ρmax =DecodingBacktrackingStep (Rt−1, ρmax));

7

qt−1max.q;

8

return(q0, . . . , qT)

9

Algorithm 4 uses the two other algorithms to solve the Decoding problem.

Its inputs are the same as for the Forward algorithm: The model specification (A,Π), the set of activitiesT R, the trace of observationsO and the numbers of discrete statesN, observationsT and activitiesK. Like the Forward algorithm it assumes that the trace being with a dummy observationo0with an arbitrary symbol and timeo0.e= 0.

It first creates all Proxels for all time steps with the modified Forward algo-rithm (lines 2 and 3), then finds the Proxel representing the final state of the most likely path (line 4) and finally iteratively follows the links of that Proxel and its predecessors backwards to retrieve the complete path (lines 6–8).

Properties of the Algorithm The modified Forward algorithm and its back-tracking as shown in Algorithm 4 together solve the CHnMM Decoding problem.

The computational complexity is identical to that of the normal CHnMM For-ward algorithm that solves the Evaluation task: for the ForFor-ward part of the computation, the same number of Proxels are generated in each time step of the two algorithms, since successor Proxels with the same discrete state and age vector are created in both algorithms and Proxels are also merged under the same conditions. The adding of predecessor links to Proxels adds only a small constant time overhead, and the following of links to predecessors in the backtracking part of the algorithm requires only the lookup of a single Proxel for each time step. Thus, judging by the computational complexity alone, the algorithm for the Decoding task is practically feasible whenever the Forward algorithm for the CHnMM Evaluation task is feasible and so the limitations of practical feasibility of the Forward algorithm (cf. Section 4.5.2) ostensible apply to the algorithm for the Decoding task as well.

However, the Decoding algorithm has a very different memory complexity:

In order to follow the links back to predecessors, those predecessor Proxels need to exist and thus the algorithm must hold all Proxels of all time steps in memory at the same time, whereas the Forward algorithm needed to store at most two time steps at once.

This has a noticable influence on the memory consumption as the following example shows: a single Proxel for the Decoding task of the Car Rental Agency model has a size of 96 bytes on x86-64 hardware. For each time step the algo-rithm generates on average 25000 Proxels, resulting in a memory requirement of 2.4M B per time step. For the CHnMM Forward algorithm, this translates to less than five megabytes of memory that are required to store all Proxels for the respective current and next time step. To perform the Decoding task for the Car Rental Station model with the trace used in the Experiments in Section 4.5 containing about 1400 observations would however require more than three gigabytes of memory. That amount of memory is barely available for a single application on 2011 commodity hardware.

The computational complexity of the algorithms has been shown experi-mentally to be linear in the number of observations, meaning that behavior reconstruction for far longer traces (e.g. 100000 observations and more) is com-putationally feasible. For those traces, however, the memory consumption of the modified Forward algorithm solving the Decoding task would be several hundred gigabytes and thus would render such a task unfeasible with the cur-rent algorithm on commodity hardware. In the next Section, an alternative algorithm to solve the CHnMM Decoding task is therefore developed that has a much more favorable memory consumption pattern.