How uw-ctrl/stlcg-plus-plus works
Project type and purpose
• Type: Python library / toolbox for computing robustness of Signal Temporal Logic (STL) formulas.
• Purpose: Given time‐series signals and STL formulas, build a PyTorch computation graph to compute robustness values and support visualization.
File structure
• Top‐level files:
– setup.py: packaging/build script.
– demo.ipynb: usage example & notebook‐style tutorial.
– README.md: high‐level overview and installation.
• Package directory “stlcgpp”:
– formula.py: definitions and constructors for STL formulas and predicates.
– utils.py: helper routines (e.g., signal formatting, tensor conversions).
– viz.py: plotting and visualization utilities for formulas and robustness traces.
– tests.py: unit tests for formula evaluation and utility correctness.
README for additional insights
• Dependencies: Python 3.10+, PyTorch.
Main components & their interactions
a. Components
1. User Interface (demo.ipynb / client code)
2. Formula Builder (stlcgpp/formula.py)
3. Utilities (stlcgpp/utils.py)
4. Computation Engine (PyTorch)
5. Visualization Module (stlcgpp/viz.py)
6. Distribution & Packaging (setup.py, PyPI)
7. Tests (stlcgpp/tests.py)
b. Relationships & data flow
• Client supplies input signals → Utils preprocess into PyTorch tensors.
• Formula Builder constructs a computation graph using PyTorch operators.
• PyTorch engine executes the graph → outputs robustness scores and traces.
• Visualization Module consumes the numeric results → renders plots.
• Tests validate each step by invoking utils, formula, and viz in isolation.
c. Architectural patterns / principles
– Modular layering: clear separation of formula logic, tensor utilities, and visualization.
– Pipeline pattern: linear data processing from input → graph construction → evaluation → output.
– Dependency injection: client code orchestrates modules without tight coupling.
d. Key technologies & libraries
– Python 3.10+
– PyTorch (computation graphs)
– Matplotlib / Plotly (via viz.py for plotting)
– Jupyter Notebook for demo/ipynb usage
Elements
– Input signals → Utils → Formula Builder → PyTorch Engine → Visualization → Output.
• Annotations for key interfaces (e.g., “.to_tensor()”, “build_graph()”, “plot_trace()”).