A Python tool for repairing test requirements based on trace suites and repair desirability metrics.
ReqRep repairs requirements for Cyber-Physical Systems (CPS) to restore compliance between system behavior (as captured by trace suites) and formalized requirements.
Inputs:
- Trace suite directory: A folder containing
.csvfiles, each representing signal values over time for the CPS-under-test. - Requirement: A Simulink Requirements Table logic expression that may not be satisfied by the traces.
- Desirable property: A property to optimize during repair.
Output:
A repaired requirement that:
- (1) Satisfies all traces in the suite,
- (2) Optimizes for the desirable property.
- Python 3.6 or higher
- pip (Python package installer)
-
Clone the repository:
git clone <repository-url> cd reqrep
-
(Recommended) Create and activate a virtual environment:
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install the package:
pip install -e .Or:
pip install .
After installing the package, you can run the repair tool from the command line. The script requires you to specify the trace suite directory and one or more input variable names. Optional arguments allow you to customize the repair process.
python bin/main.py [-h] [-p PREV0] [-t THRESHOLD] [-i ITERATIONS] trace_suite input_vars [input_vars ...]trace_suite: Path to the directory containing the trace suite (CSV files)input_vars: One or more input variable names (space-separated)
-h,--help: Show help message and exit-p PREV0,--prev0 PREV0: Value to use for the previous time step when evaluated at time step 0 (default: 0)-t THRESHOLD,--threshold THRESHOLD: Threshold value for repair (default: 100.0)-i ITERATIONS,--iterations ITERATIONS: Number of repair iterations (default: 10)
python bin/main.py data/traces xin reset TL BL dT ic youtThis will process all trace files in the data/traces/ directory using the specified input variables.
- All arguments after the trace suite directory are treated as input variable names.
- Use the
-hflag to see all available options and their descriptions. - Make sure your Python environment has all dependencies installed (see Installation section).
reqrep/
├── bin/
│ └── main.py # Main entry point
├── data/
│ ├── case_studies/ # Case study data (AFC, AT-AT1, ...)
│ ├── dummy/ # Dummy trace data
│ └── traces/ # Example traces
├── scripts/ # Miscellaneous scripts
├── src/
│ └── repair/
│ ├── approach/
│ │ ├── optimization/ # Approach based on genetic programming
│ │ └── transformation/ # Transformation-based approach
│ ├── fitness/ # Fitness metrics (correctness, desirability)
│ └── grammar/ # Requirement Grammar
├── pyproject.toml # Project configuration
└── README.md # This file