By clicking “Accept All Cookies”, you agree to the storing of cookies on your device to enhance site navigation, analyze site usage, and assist in our marketing efforts. View our Privacy Policy for more information.

Building Real-Time Digital Twins with a Rules Engine

Simplified Creation of Analytics Logic Lowers the Learning Curve for Using Digital Twins in Streaming Analytics

As discussed in earlier blog posts, real-time digital twins offer a breakthrough new approach to streaming analytics by providing a means for continuously analyzing each incoming telemetry stream from thousands of data sources. Because they maintain state information about each data source, they can immediately spot issues unique to that data source and generate alerts within a few milliseconds. In contrast, conventional “batch-oriented” streaming analytics typically do not mine this telemetry in real-time and may not uncover important, actionable trends for several minutes or hours. These unique capabilities, combined with real-time data aggregation to boost situational awareness, give real-time digital twins unique advantages in a wide range of applications, including contact tracing, telematics, logistics, smart cities, security, financial services, healthcare, and much more.

Real-time digital twins provide a software technique for orchestrating the execution of analytics code that examines incoming messages from a single data source and maintains state information about that data source. The ScaleOut Digital Twin Streaming Service™ hosts instances of real-time digital twins in the Microsoft Azure cloud or on-premises, manages the delivery of messages from various message hubs, and implements data aggregation and visualization. Application developers typically implement a single method containing analytics code written in standard programming languages, such as Java, C#, and JavaScript, which take full advantage of the object-oriented, real-time digital twin model. Here is a depiction of a real-time digital twin showing the message processing code and state information unique to a specific data source:

Rules-Based Real-Time Digital Twins

In many applications, a rules-based formulation of analytics logic can simplify application code and open up development of real-time digital twins to analysts who lack object-oriented programming experience. Rules-based algorithms have been widely adopted over the years and proven to provide a straightforward technique for expressing business logic in numerous applications and expert systems. In their simplest form, rules are expressed as “IF condition THEN action” statements which are executed sequentially by a “rules engine.” Other rules which just perform actions, such as calculations or message sending, can be expressed with “DO action” statements. These rules replace programming code with simple, highly readable statements that can be used in many applications where more complex logic is not required.

For example, consider an IoT application in which a real-time digital twin is monitoring messages sent from a thermometer and looking for a situation in which the temperature either spikes beyond an allowed limitof 250 deg. or exceeds an allowed average value of 112 deg. This logic could be expressed with the following rules, which are executed for each incoming message. Note that the temperature reading within the message is called Incoming.Temp here, and the other variables maintain state information within the real-time digital twin’s instance for this thermometer. For example, the number of temperature spikes is maintained in the variable NumEvents.

DO CurrentTemp = Incoming.Temp
IF CurrentTemp > MaxTemp THEN MaxTemp = CurrentTemp
DO AverageTemp = AverageTemp * NumSamples + CurrentTemp
DO NumSamples = NumSamples + 1
DO AverageTemp = AverageTemp / NumSamples
IF MaxTemp > 250.0 THEN NumEvents = NumEvents + 1
IF MaxTemp > 250.0 THEN LogMessage.Message = "Max temp exceeded" AND LogMessage
IF AverageTemp > 112.0 THEN LogMessage.Message = "Average temp exceeded" AND LogMessage

The following diagram shows how message are delivered to a thermometer’s real-time digital twin instance and are analyzed by the rules engine:

Development Tool for Building Rules-Based Models

To simplify the development of rules-based analytics code for real-time digital twins, ScaleOut Software has developed the ScaleOut Rules Engine Development Tool™. This Windows-based graphical development environment enables application developers to create and test rule-based digital twin models prior to deploying them on the streaming service for production use. Using this tool, developers create a model by specifying:

  • Instance properties to be tracked, such as AverageTemp, MaxTemp, and NumEvents in the example
  • Message properties that will be used, such as Incoming.Temp for incoming messages
  • Rules to be executed (like the ones listed above)

The tool validates the rules when they are created to make sure that they will execute. Next, the user can test the model by sending it messages and observing changes in the values of the properties. The rules can be run one at a time for each message to verify that they are creating the desired state changes and outgoing messages. The development tool can simulate sending message back to the data source, to another real-time digital twin instance, or to the message log in the service’s UI.

Here is a screenshot of the development tool during a test of a rules-based model for a thermometer:

Note that during production use, the streaming service can aggregate instance properties across all real-time digital twin instances and visualize the results. The rules engine running in each real-time digital twin instance updates property values as it processes incoming messages, and the results are immediately aggregated. For example, if the thermometers supplied their locations, the average temperature could be plotted by region. This allows managers to immediately spot patterns in the data across all data sources and direct responses where they are most urgently needed.

Summing Up

The integration of a rules engine within real-time digital twins lowers barriers to entry in creating streaming analytics. The highly intuitive formulation of application logic as a set of rules to be sequentially evaluated makes it straightforward for domain experts to implement streaming analytics for many applications without the need for programming skills. The power of real-time digital twins working together, combined with continuous aggregate analytics, enables telemetry from many thousands of data sources to be simultaneously  analyzed and creates a breakthrough in situational awareness.