  Learning-enabled controllers have been adopted in various cyber-physical
systems (CPS). When a learning-enabled controller fails to accomplish its task
from a set of initial states, researchers leverage repair algorithms to
fine-tune the controller's parameters. However, existing repair techniques do
not preserve previously correct behaviors. Specifically, when modifying the
parameters to repair trajectories from a subset of initial states, another
subset may be compromised. Therefore, the repair may break previously correct
scenarios, introducing new risks that may not be accounted for. Due to this
issue, repairing the entire initial state space may be hard or even infeasible.
As a response, we formulate the Repair with Preservation (RwP) problem, which
calls for preserving the already-correct scenarios during repair. To tackle
this problem, we design the Incremental Simulated Annealing Repair (ISAR)
algorithm, which leverages simulated annealing on a barriered energy function
to safeguard the already-correct initial states while repairing as many
additional ones as possible. Moreover, formal verification is utilized to
guarantee the repair results. Case studies on an Unmanned Underwater Vehicle
(UUV) and OpenAI Gym Mountain Car (MC) show that ISAR not only preserves
correct behaviors from previously verified initial state regions, but also
repairs 81.4% and 23.5% of broken state spaces in the two benchmarks. Moreover,
the average signal temporal logic (STL) robustnesses of the ISAR repaired
controllers are larger than those of the controllers repaired using baseline
methods.
