A Boyer-Moore Type Algorithm for Timed Pattern Matching

Masaki Waga, Takumi Akazaki, Ichiro Hasuo

Monitoring the health of complex, real-time systems—such as autonomous vehicles, medical devices, or high-frequency trading platforms—requires sifting through massive logs of "timed words" (events paired with precise timestamps). Identifying specific patterns within these logs is computationally expensive due to the continuous nature of time and the sheer volume of data. This research introduces a significant optimization by adapting the classic Boyer-Moore string-matching logic to the domain of timed automata.

The Challenge of Timed Pattern Matching

Timed Pattern Matching (TPM) involves taking a long execution log (a timed word) and a specification (a timed pattern) and identifying all time intervals where the log satisfies the pattern. This task faces two primary hurdles:

  1. Continuous Time: Unlike standard strings, timed words involve real-valued timestamps, making the search space theoretically infinite.
  2. Computational Cost: Naive algorithms check for matches at every possible starting point in a log. For "big data" monitoring tasks, this brute-force approach is too slow for real-time or large-scale offline analysis.

While previous work often utilized Timed Regular Expressions (TRE), this paper shifts the focus to Timed Automata (TA). TAs are more expressive and provide a structural framework better suited for the proposed Boyer-Moore optimization.

Adapting Boyer-Moore to Timed Systems

The core innovation of this work is the adaptation of the Boyer-Moore (BM) algorithm. In classic string matching, BM scans the pattern from right to left and uses "skip functions" ($\Delta_1$ and $\Delta_2$) to jump ahead in the text when a mismatch occurs, avoiding redundant comparisons.

To apply this to timed systems, the authors developed several key techniques:

  • Discretized Time via Region Automata: They utilize the "region construction" technique to transform the infinite state space of a Timed Automaton into a finite "Region Automaton." This abstraction allows for the pre-calculation of safe skip distances.
  • Timed $\Delta_2$ Skip Function: The authors defined a skip function based on the minimum length of runs in the region automaton. If a segment of the log does not match the suffix of any valid pattern, the algorithm calculates the maximum safe distance it can jump forward without missing a potential match.
Region automaton construction for a Timed Automaton, showing pre-calculated skip parameters.

The efficiency of the matching phase depends on this pre-processing. By analyzing the structure of the automaton, the algorithm can rule out matches over large segments of the log.

The $\Delta_2$ skip table for state $s_3$, demonstrating the calculation of safe jump distances.

Experimental Evaluation and Results

The algorithm was evaluated across five distinct test cases, ranging from untimed baseline patterns to complex automotive engine logs. A key practical test involved a dataset generated from a Simulink engine model (sldemo_enginewc), where the task was to detect anomalies such as torque remaining "high" for more than one second.

Key Findings:

  • Significant Speedup: In both synthetic tests and the automotive engine log, the Boyer-Moore optimization roughly halved the execution time compared to naive brute-force algorithms.
  • Linear Scalability: Execution time scales linearly with the length of the input log, confirming its suitability for very large datasets.
  • Practical Viability: Pre-processing time for the automotive example was negligible (under 10ms), demonstrating that the overhead of region construction is manageable for real-world engineering tasks.

Limitations and Future Directions

Despite its success, the approach has limitations. The primary bottleneck is the Region Automaton construction; for very complex patterns, the state space can explode, potentially exceeding available memory.

Future work aims to address this by replacing region automata with zone automata, a more efficient representation of clock constraints. Additionally, the authors plan to integrate the $\Delta_1$ (character-based) skip function to further enhance the algorithm's performance.

Summary updated

BibTeX
@inproceedings{waga2016boyer,
  author = {Masaki Waga and Takumi Akazaki and Ichiro Hasuo},
  title = {{A Boyer-Moore Type Algorithm for Timed Pattern Matching}},
  booktitle = {FORMATS},
  year = {2016},
  doi = {10.1007/978-3-319-44878-7\_8},
}
Figure