  Neural networks have been increasingly applied for control in
learning-enabled cyber-physical systems (LE-CPSs) and demonstrated great
promises in improving system performance and efficiency, as well as reducing
the need for complex physical models. However, the lack of safety guarantees
for such neural network based controllers has significantly impeded their
adoption in safety-critical CPSs. In this work, we propose a controller
adaptation approach that automatically switches among multiple controllers,
including neural network controllers, to guarantee system safety and improve
energy efficiency. Our approach includes two key components based on formal
methods and machine learning. First, we approximate each controller with a
Bernstein-polynomial based hybrid system model under bounded disturbance, and
compute a safe invariant set for each controller based on its corresponding
hybrid system. Intuitively, the invariant set of a controller defines the state
space where the system can always remain safe under its control. The union of
the controllers' invariants sets then define a safe adaptation space that is
larger than (or equal to) that of each controller. Second, we develop a deep
reinforcement learning method to learn a controller switching strategy for
reducing the control/actuation energy cost, while with the help of a safety
guard rule, ensuring that the system stays within the safe space. Experiments
on a linear adaptive cruise control system and a non-linear Van der Pol's
oscillator demonstrate the effectiveness of our approach on energy saving and
safety enhancement.
