Hybrid Co-simulation: It's about time
Abstract
Model-based design methodologies are commonly used in industry for the development of cyber-physical systems (CPSs). There are many different languages, tools, and formalisms for model-based design, each with its strengths and weaknesses. Instead of accepting the weaknesses of a particular tool, an alternative is to embrace heterogeneity and develop tool integration platforms and protocols to leverage the strengths from other environments. A fairly recent attempt in this direction is an open interface standard called Functional Mock-up Interface (FMI), which is focused on the convenient exchange and co-simulation of simulation models (Functional Mock-up Units, FMUs), primarily between component suppliers and OEMs. As it stands, FMI has reached acceptance in industry, but its specification (version 2.0) provides only limited support for hybrid co-simulation-simulating systems that mix continuous and discrete behaviors, which are commonly used to model CPSs. This paper identifies FMI's time representation based on floating-point numbers as a key problem, because it does not support well the discrete events that typically occur at the cyber-physical boundary; it is only suitable for modeling continuous dynamics without discrete behaviors. While time is a central concept in reasoning about the physical world, it is largely abstracted away when reasoning about the cyber world. As a result, the engineering methods for CPSs have misaligned abstractions between the physics domain, the mathematical domain used to model physics, the computational domain used to implement these mathematical abstractions for simulation, and the computational domain used on the cyber side of CPSs. The most common resolution for this conundrum is to adopt the naive Newtonian ideal model of time, where time is a real number known everywhere and advancing uniformly. But ironically, Newtonian time proves not so practical for hybrid co-simulation. The obvious reason is that digital computers do not work with real numbers. Whereas real numbers have infinite precision, their floating-point representation does not. This discrepancy leads to unpredictable quantization errors that may accumulate. Although real numbers can be compared for equality (e.g., to define “simultaneity”), it rarely makes sense to do so for floating-point numbers. We show that the approach taken in FMI (and many other modeling frameworks) that embraces a naive Newtonian physical model of time, and a cyber-approximation of this model using floating-point numbers, is inadequate for CPSs; it leads to models with unnecessarily inexplicable, nondeterministic, and complex behaviors. Our analysis concludes that a model of time that solely uses integers solves many of these problems. Specifically, we propose to use a 64-bit unsigned integer representation with arbitrary resolution, given as a power of ten, allowing model parameters specified in decimal to be represented exactly (granted ample resolution). Integer arithmetic is computationally efficient, and, for well-chosen resolutions, this representation will tolerate very long simulations without overflow. It is also easily converted to and from floating-point representations, albeit not losslessly. Given the vast range of time scales used across different simulation models, we believe that choosing a fixed universal time resolution does not make sense. Instead, we describe an algorithm that picks an adequate time resolution for a particular model and we provide procedures for time quantization needed to reconcile discrepacies between internal time representations of co-simulated FMUs. We propose concrete extensions to the FMI standard for the support of hybrid co-simulation that enable the use of integer time, automatic choice of time resolution, and the use of absent signals. We explain in detail how these extensions can be implemented mod-ularly within the frameworks of existing simulation environments and with support for legacy FMUs and superdense time.