Search-based Automated Program Repair of CPS Controllers Modeled in Simulink-Stateflow
Aitor Arrieta, Pablo Valle, Shaukat Ali
TL;DR
This paper tackles the cost and scalability of repairing CPS software modeled in Simulink/Stateflow by introducing FlowRepair, a search-based APR tool tailored to Stateflow. It integrates global and local search guided by SBFL-derived suspiciousness, and introduces three CPS-specific repair objectives to operate under long simulation runtimes where traditional pass/fail metrics are sparse. FlowRepair employs 15 mutation operators across States and Transitions and maintains two archives to manage plausible and partial patches within a time budget, evaluated on 9 real faults across three CPS domains. Empirical results show FlowRepair repairing the majority of faults and outperforming a baseline in several cases, with replication materials provided to support adoption and future work exploring patch prioritization and LLM-assisted mutation strategies. The work advances practical automated repair for Stateflow models and points toward broader APR applicability in CPS engineering.
Abstract
Stateflow models are widely used in the industry to model the high-level control logic of Cyber-Physical Systems (CPSs) in Simulink--the defacto CPS simulator. Many approaches exist to test Simulink models, but once a fault is detected, the process to repair it remains manual. Such a manual process increases the software development cost, making it paramount to develop novel techniques that reduce this cost. Automated Program Repair (APR) techniques can significantly reduce the time for fixing bugs by automatically generating patches. However, current approaches face scalability issues to be applicable in the CPS context. To deal with this problem, we propose an automated search-based approach called FlowRepair, explicitly designed to repair Stateflow models. The novelty of FlowRepair includes, (1) a new algorithm that combines global and local search for patch generation; (2) a definition of novel repair objectives (e.g., the time a fault remained active) specifically designed for repairing CPSs; and (3) a set of mutation operators to repair Stateflow models automatically. We evaluated FlowRepair with three different case study systems and a total of nine faulty stateflow models. Our experiments suggest that (1) Flo wRepaircan fix bugs in stateflow models, including models with multiple faults; (2) FlowRepair surpasses or performs similarly to a baseline APR technique inspired by a well-known CPS program repair approach. Besides, we provide both a replication package and a live repository, paving the way towards the APR of CPSs modeled in Simulink.
