# Mining Road Traffic Rules with Signal Temporal Logic and Grammar-Based Genetic Programming

^{1}

^{2}

^{3}

^{*}

## Abstract

**:**

## 1. Introduction

## 2. Related Work

## 3. Background: Signal Temporal Logic

**Definition**

**1**

**Definition**

**2**

**Definition**

**3**

## 4. Problem Statement

## 5. Methodology

#### 5.1. Evolutionary Algorithm

- (1)
- It builds the offspring population ${P}^{\prime}$, with $|{P}^{\prime}|={n}_{\mathrm{pop}}$, by iteratively selecting one (mutation, with $1-{p}_{\mathrm{xover}}$ probability) or two (crossover, with ${p}_{\mathrm{xover}}$ probability) parents chosen with tournament selection of size ${n}_{\mathrm{tour}}$ and then applying the genetic operator. If the resulting solution ${\phi}_{c}$ is already part of the offspring ${P}^{\prime}$ or parent population P, a new solution is generated, and the process is repeated for a maximum number of ${n}_{\mathrm{atts}}$ attempts; otherwise ${s}_{c}$ is added to ${P}^{\prime}$ and its fitness $f\left(\phi \right)$ is computed.
- (2)
- It merges the parent and offspring populations ${P}^{\prime}$ and P.
- (3)
- It shrinks the resulting new population P, until its size is ${n}_{\mathrm{pop}}$, by iteratively removing the worst solution.

Algorithm 1: The EA for the optimization. |

#### 5.2. Fitness Function

#### 5.3. Grammar for STL Formula Structures

## 6. Experimental Evaluation

- RQ1
- Can we mine specifications that describe the input unlabeled trajectories?
- RQ2
- Are the mined specifications readable and interpretable for a human?

#### 6.1. Data

#### 6.2. Data Processing

#### 6.3. Results

#### 6.3.1. RQ1: Solutions That Are Effective

#### 6.3.2. RQ2: Specifications That Are Readable and Interpretable for a Human

- (i)
- to poise the distances from the neighbors, and
- (ii)
- to drive neither too fast nor too slow.

## 7. Conclusions and Future Work

## Author Contributions

## Funding

## Institutional Review Board Statement

## Informed Consent Statement

## Data Availability Statement

## Conflicts of Interest

## References

- Hussain, R.; Zeadally, S. Autonomous cars: Research results, issues, and future challenges. IEEE Commun. Surv. Tutor.
**2018**, 21, 1275–1313. [Google Scholar] [CrossRef] - Jobin, A.; Ienca, M.; Vayena, E. The global landscape of AI ethics guidelines. Nat. Mach. Intell.
**2019**, 1, 389–399. [Google Scholar] [CrossRef] - Michael, J.B.; Drusinsky, D.; Wijesekera, D. Formal Methods in Cyberphysical Systems. Computer
**2021**, 54, 25–29. [Google Scholar] [CrossRef] - Deshmukh, J.V.; Donzé, A.; Ghosh, S.; Jin, X.; Juniwal, G.; Seshia, S.A. Robust online monitoring of signal temporal logic. Form. Methods Syst. Des.
**2017**, 51, 5–30. [Google Scholar] [CrossRef][Green Version] - Bortolussi, L.; Gulisano, V.; Medvet, E.; Palyvos-Giannas, D. Automatic Translation of Spatio-Temporal Logics to Streaming-Based Monitoring Applications for IoT-Equipped Autonomous Agents. In Proceedings of the 6th International Workshop on Middleware and Applications for the Internet of Things, Davis, CA, USA, 9–13 December 2019; pp. 7–12. [Google Scholar]
- Whigham, P. Inductive bias and genetic programming. In Proceedings of the First International Conference on Genetic Algorithms in Engineering Systems: Innovations and Applications, IET, Sheffield, UK, 12–14 September 1995; pp. 461–466. [Google Scholar]
- Bartocci, E.; Bortolussi, L.; Nenzi, L.; Sanguinetti, G. System design of stochastic models using robustness of temporal properties. Theor. Comput. Sci.
**2015**, 587, 3–25. [Google Scholar] [CrossRef][Green Version] - Bortolussi, L.; Silvetti, S. Bayesian Statistical Parameter Synthesis for Linear Temporal Properties of Stochastic Models. In Proceedings of the International Conference on Tools and Algorithms for the Construction and Analysis of Systems, Thessaloniki, Greece, 14–20 April 2018; pp. 396–413. [Google Scholar]
- Krige, D.G. A Statistical Approach to Some Mine Valuation and Allied Problems on the Witwatersrand. Doctoral Dissertation, University of the Witwatersrand, Johannesburg, South Africa, 1951. [Google Scholar]
- Srinivas, N.; Krause, A.; Kakade, S.; Seeger, M. Gaussian Process Optimization in the Bandit Setting: No Regret and Experimental Design. In Proceedings of the International Conference on Machine Learning, Haifa, Israel, 21–24 June 2010; pp. 1015–1022. [Google Scholar]
- Jin, X.; Donzé, A.; Deshmukh, J.V.; Seshia, S.A. Mining Requirements From Closed-Loop Control Models. IEEE Trans. Comput. Aided Des. Integr. Circuits Syst.
**2015**, 34, 1704–1717. [Google Scholar] [CrossRef][Green Version] - Jha, S.; Tiwari, A.; Seshia, S.A.; Sahai, T.; Shankar, N. Telex: Passive STL learning using only positive examples. In Proceedings of the International Conference on Runtime Verification, Seattle, WA, USA, 13–16 September 2017; Springer: Berlin/Heidelberg, Germany, 2017; pp. 208–224. [Google Scholar]
- Nenzi, L.; Silvetti, S.; Bartocci, E.; Bortolussi, L. A robust genetic algorithm for learning temporal specifications from data. In Proceedings of the International Conference on Quantitative Evaluation of Systems, Beijing, China, 4–7 September 2018; Springer: Berlin/Heidelberg, Germany, 2018; pp. 323–338. [Google Scholar]
- Kong, Z.; Jones, A.; Ayala, A.I.M.; Gol, E.A.; Belta, C. Temporal logic inference for classification and prediction from data. In Proceedings of the HSCC ’14, Berlin, Germany, 15–17 April 2014. [Google Scholar]
- Bombara, G.; Vasile, C.I.; Penedo, F.; Yasuoka, H.; Belta, C. A Decision Tree Approach to Data Classification using Signal Temporal Logic. In Proceedings of the HSCC ’16, Vienna, Austria, 12–14 April 2016. [Google Scholar]
- Mohammadinejad, S.; Deshmukh, J.V.; Puranic, A.G.; Vazquez-Chanlatte, M.; Donzé, A. Interpretable classification of time-series data using efficient enumerative techniques. In Proceedings of the 23rd International Conference on Hybrid Systems: Computation and Control, Nashville, TN, USA, 19–21 May 2020. [Google Scholar]
- Vazquez-Chanlatte, M.M.; Deshmukh, J.V.; Jin, X.; Seshia, S.A. Logical clustering and learning for time-series data. In Proceedings of the CAV, Heidelberg, Germany, 24–28 July 2017. [Google Scholar]
- Jha, S.; Tiwari, A.; Seshia, S.A.; Sahai, T.; Shankar, N. TeLEx: Learning signal temporal logic from positive examples using tightness metric. Form. Methods Syst. Des.
**2019**, 54, 1–24. [Google Scholar] [CrossRef] - Medvet, E.; Bartoli, A.; Talamini, J. Road Traffic Rules Synthesis Using Grammatical Evolution. In Proceedings of the European Conference on the Applications of Evolutionary Computation, Amsterdam, The Netherlands, 19–21 April 2017; Springer: Berlin/Heidelberg, Germany, 2017; pp. 173–188. [Google Scholar]
- Maler, O.; Nickovic, D. Monitoring Temporal Properties of Continuous Signals. In Proceedings of the FORMATS, Grenoble, France, 22–24 September 2004; Volume 3253, pp. 152–166. [Google Scholar] [CrossRef][Green Version]
- Donzé, A.; Ferrer, T.; Maler, O. Efficient Robust Monitoring for STL. In Proceedings of the CAV, Saint Petersburg, Russia, 13–19 July 2013; pp. 264–279. [Google Scholar]
- Virgolin, M.; De Lorenzo, A.; Randone, F.; Medvet, E.; Wahde, M. Model Learning with Personalized Interpretability Estimation (ML-PIE). In Proceedings of the Genetic and Evolutionary Computation Conference Companion, Association for Computing Machinery, New York, NY, USA, 10–14 July 2021; GECCO ’21. pp. 1355–1364. [Google Scholar] [CrossRef]
- Virgolin, M.; De Lorenzo, A.; Medvet, E.; Randone, F. Learning a Formula of Interpretability to Learn Interpretable Formulas. In Parallel Problem Solving from Nature—PPSN XVI; Springer: Cham, Switzerland, 2020; pp. 79–93. [Google Scholar]
- Koza, J.R.; Koza, J.R. Genetic Programming: On the Programming of Computers by Means of Natural Selection; MIT Press: Cambridge, MA, USA, 1992; Volume 1. [Google Scholar]
- Squillero, G.; Tonda, A. Divergence of character and premature convergence: A survey of methodologies for promoting diversity in evolutionary optimization. Inf. Sci.
**2016**, 329, 782–799. [Google Scholar] [CrossRef][Green Version] - Bartoli, A.; De Lorenzo, A.; Medvet, E.; Squillero, G. Multi-level diversity promotion strategies for Grammar-guided Genetic Programming. Appl. Soft Comput.
**2019**, 83, 105599. [Google Scholar] [CrossRef] - Luke, S. Essentials of Metaheuristics; Lulu: Raleigh, NC, USA, 2009; Volume 113. [Google Scholar]
- Bartocci, E.; Bortolussi, L.; Loreti, M.; Nenzi, L.; Silvetti, S. MoonLight: A Lightweight Tool for Monitoring Spatio-Temporal Properties. In Proceedings of the Runtime Verification—20th International Conference, RV 2020, Los Angeles, CA, USA, 6–9 October 2020; Lecture Notes in Computer, Science. Deshmukh, J., Nickovic, D., Eds.; Springer: Berlin/Heidelberg, Germany, 2020; Volume 12399, pp. 417–428. [Google Scholar] [CrossRef]
- Alexiadis, V.; Colyar, J.; Halkias, J.; Hranac, R.; McHale, G. The next generation simulation program. ITE J. Inst. Transp. Eng.
**2004**, 74, 22–26. [Google Scholar] - Bentley, J.L. Multidimensional binary search trees used for associative searching. Commun. ACM
**1975**, 18, 509–517. [Google Scholar] [CrossRef]

**Figure 1.**A derivation tree of the grammar of Figure 2 for the formula $({a}_{1}<r){\mathrm{S}}_{[{t}_{1},{t}_{2}]}\neg ({a}_{2}>r)$.

**Figure 2.**The CFG for describing STL formula structures. Non-terminal symbols are enclosed in angle brackets: the topmost non-terminal symbol, $\langle \mathrm{formula}{}_{}\rangle $, is the starting symbol ${s}_{0}$ of the grammar. The derivation rules for the symbols $\langle \mathrm{formula}i{}_{i}\rangle $, $\langle \mathrm{logic}i{}_{i}\rangle $, $\langle \mathrm{temp}i{}_{i}\rangle $ are parametric on i, which represents the nesting level. The derivation rule for $\langle \mathrm{attr}{}_{}\rangle $ is the one that makes the grammar tailored to a given system with attributes $A=\{{a}_{1},{a}_{2},\cdots ,{a}_{\left|A\right|}\}$.

**Figure 3.**Sample frame reproducing the traffic of the dataset [29]. Each colored box represents a car. Dotted lines are lane separators, while solid lines are guardrails. The two segments projecting out from the first level of the road are the boundaries of the on-ramp. The second level of road is the continuation of the top one, while the red shaded rectangle is the range for the trajectory endpoints.

**Figure 4.**A car and its eight neighboring regions. Regions are labeled using cardinal directions. Boundaries can be swiftly computed starting from the $x,y$ positions of the front-left corner of the car, using car width and car height (provided in the dataset).

**Figure 5.**Distribution of the robustness $\rho (\phi ,\mathit{x},t)$, computed for all the I-80 trajectories $\mathit{x}$, for the best individual $\phi $ found in each run.

**Figure 7.**Number of occurrences of operators and attributes for the best individual of each evolutionary run.

**Table 1.**Fitness f, solution (derivation tree) size $\left|\phi \right|$ for the best individuals found in each run, and evolution time in seconds. Reported as median ± standard deviation.

f | $\left|\mathit{\phi}\right|$ | Time [$\mathbf{s}$] |
---|---|---|

0.063 ± 0.009 | 52.5 ± 6.5 | 3876.6 ± 426.4 |

Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations. |

© 2021 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Pigozzi, F.; Medvet, E.; Nenzi, L. Mining Road Traffic Rules with Signal Temporal Logic and Grammar-Based Genetic Programming. *Appl. Sci.* **2021**, *11*, 10573.
https://doi.org/10.3390/app112210573

**AMA Style**

Pigozzi F, Medvet E, Nenzi L. Mining Road Traffic Rules with Signal Temporal Logic and Grammar-Based Genetic Programming. *Applied Sciences*. 2021; 11(22):10573.
https://doi.org/10.3390/app112210573

**Chicago/Turabian Style**

Pigozzi, Federico, Eric Medvet, and Laura Nenzi. 2021. "Mining Road Traffic Rules with Signal Temporal Logic and Grammar-Based Genetic Programming" *Applied Sciences* 11, no. 22: 10573.
https://doi.org/10.3390/app112210573