  With the growing scale of Cyber-Physical Systems (CPSs), it is challenging to
maintain their stability under all operating conditions. How to reduce the
downtime and locate the failures becomes a core issue in system design. In this
paper, we employ a hierarchical contract-based resilience framework to
guarantee the stability of CPS. In this framework, we use Assume Guarantee
(A-G) contracts to monitor the non-functional properties of individual
components (e.g., power and latency), and hierarchically compose such contracts
to deduce information about faults at the system level. The hierarchical
contracts enable rapid fault detection in large-scale CPS. However, due to the
vast number of components in CPS, manually designing numerous contracts and the
hierarchy becomes challenging. To address this issue, we propose a technique to
automatically decompose a root contract into multiple lower-level contracts
depending on I/O dependencies between components. We then formulate a
multi-objective optimization problem to search the optimal parameters of each
lower-level contract. This enables automatic contract refinement taking into
consideration the communication overhead between components. Finally, we use a
case study from the manufacturing domain to experimentally demonstrate the
benefits of the proposed framework.
