Technical Articles

Developing a Simulator and Multivariable Control Algorithms for Artificial Pancreas Systems

By Dr. Ali Cinar and Dr. Mudassir M. Rashid, Illinois Institute of Technology


For individuals with type 1 diabetes mellitus (T1DM), artificial pancreas (AP) systems can reduce the risks of both immediate life-threatening and long-term health conditions, including severe hypoglycemia, cardiovascular disease, neuropathy, and retinopathy. At the core of any AP system is its insulin dosing control algorithm. Most control algorithms receive measurements from a continuous glucose monitoring (CGM) sensor and send dosing requirements to a subcutaneous insulin infusion pump. The user manually provides additional information: meal information for computation of insulin boluses, and exercise information to change the glucose target values and/or reduce insulin infusion during physical activity.

Although more effective at glycemic control than manually administered insulin injections, AP systems do have limitations. For example, most AP system control algorithms do not account for physical activities that can cause significant nonlinearities in the glucose-insulin dynamics of individuals with T1DM. Further, it may take up to approximately 45 minutes before insulin injected into subcutaneous tissue reaches the bloodstream to affect blood glucose concentrations. As a result, there is a significant amount of time lost when using systems that make control decisions solely based on glucose concentration readings.

The Cinar research group at the Illinois Institute of Technology (IIT) is actively developing advanced, multivariable control algorithms for AP systems that interpret physiological signals, such as heart rate, galvanic skin response, skin temperature, and blood volume pulse, as well as accelerometer readings—all obtained from wearable wristband devices. Developed in MATLAB®, our control algorithms take these physiological signals into account to help detect and assess physical activities that can disrupt glucose homeostasis, thereby enabling more effective glucose concentration control without need for any manual inputs about exercise. Recently, we have also used MATLAB to develop the multivariable Glucose–Insulin-Physiological Variable Simulator (mGIPsim), a simulation software that has helped our group and other research teams accelerate the development and assessment of innovative control algorithms for AP systems (Figure 1).

A diagram showing the workflow for the mGIPsim simulator generating physiological signals for virtual patients based on user-defined meal, insulin, and physical activity inputs and feeding that information to the multivariable AP system, which then generates insulin and rescue carbohydrates.

Figure 1. An input-output diagram of the mGIPsim simulator, which generates physiological signals for virtual patients based on user-defined meal, insulin, and physical activity inputs.

Implementing Adaptive, Multivariable Control Algorithms

From a control design perspective, the human body is a highly nonlinear system with time-varying parameters. Its responses change not only from one individual to another, but throughout the day for the same individual. As a result, simplistic control strategies for regulating glucose concentrations have been replaced by algorithms based on various types of model predictive control. The model-predictive control strategies we have implemented in MATLAB are much more effective, in part due to their ability to adjust the model recursively, handle multivariable systems and incorporate constraints needed to moderate overcorrections and avoid overdosing. Our predictive control algorithms compute optimal control actions based on a cost function and adaptive, personalized glucose-insulin models. Importantly, the algorithms use physiological signals measured by wearable devices to factor physical activity into their predictions.

Architecturally, our control algorithms fit into AP systems that include several other modules also implemented in MATLAB (Figure 2). These modules perform essential functions such as predicting hypoglycemia and hyperglycemia and issuing warning for action, classifying the individual’s physical activity (planned and unexpected activities), detecting meals and estimating their carbohydrate content (to make meal announcement an option), and handling equipment faults.

Diagram depicting the AP system’s workflow for monitoring and analyzing a patient’s glucose activity, physical activity, and hypoglycemia risk.

Figure 2. A multimodule, multivariable AP system, with controller, pump, glucose monitor, wearable sensors, and key support modules.

The control algorithms we’ve developed have performed well on several trials conducted in clinical experiments. As an example, in one trial with 15 patients, an AP system equipped with the first generation of our control algorithm significantly increased the amount of time spent in the normal glucose concentration range and eliminated incidents of severe hypoglycemia in all subjects participating in the study.

While these experiments demonstrated the effectiveness and potential of our approach, they were time-consuming and expensive. Recruiting participants, getting them to commit to a regular testing schedule, and then running days-long experiments took a great deal of time and slowed the pace of our research.

Developing the mGIPsim Simulator

The Cinar research group recognized that we could accelerate the development and testing of AP control algorithms by using a simulator in place of real T1DM patients. The difficulty was that existing simulators lacked the physiological signals that our control algorithms needed; they were designed to provide only blood glucose concentrations and insulin information as outputs.

We decided to build our own simulator in MATLAB that would provide physiological signals such as heart rate, energy expenditure, and other physiological variables our controllers needed in addition to blood glucose concentration. The result is mGIPsim, the first simulator designed to assess controllers that make use of this additional physiological data. The simulator uses dynamic nonlinear physiologic and metabolic models that we developed to compute glucose concentrations and physiological variables. These computations take into account scenarios involving meal consumption, insulin administration, and physical activity that the user defines via a graphical user interface. The simulator relies on a set of virtual patients with unique demographic profiles and T1D characteristics from a distribution of more than a dozen model parameters that were identified using clinical data. These parameters include demographic information such as age, height, weight, and resting heart rate, as well as the number of years the individual has had diabetes and their basal insulin rate.

We packaged the underlying simulator models together with a user interface we had designed to create a standalone application in MATLAB (Figure 3). In addition to using this standalone mGIPsim application as a teaching tool in undergraduate and graduate level courses at Illinois Tech, we’ve also made it available to colleagues at other universities for academic research.

Screenshot of the mGIPsim app user interface, with various functionality buttons.

Figure 3. The mGIPsim standalone application user interface.

To use the simulator, a researcher first selects a cohort of virtual subjects (out of a pool of 20 virtual patients) before specifying meal and exercise regimens for the subjects via the user interface. For example, the user can define when each virtual subject eats breakfast, lunch, dinner, and snacks, as well as the carbohydrate content consumed at each meal. The user can also define the time, duration, and intensity of exercise activities, such as running on a treadmill or pedaling a stationary bike. The meals and exercises can be specified to occur within time windows and with ranges of feature values for meal and exercise events, which enables mGIPsim to randomly select the time and characteristics of these events within these specified ranges, a feature that is critical for long-duration simulations. Based on these inputs and the virtual subject profiles, the simulator then generates signals for glucose concentration, energy expenditure (EE), and other physiological variables for use in control algorithm testing and assessment (Figure 4).

Two plots: The first compares actual and predicted energy expenditure on the y-axis with time on the x-axis for treadmill activity. The second plot compares actual and predicted energy expenditure on the y-axis with time on the x-axis for stationary bike exercises.

Figure 4. Plots comparing actual and predicted EE for (a) treadmill and (b) stationary bike exercises. Plots like these were used to validate the simulator.

Mobile Device Deployment and Ongoing Development

One advantage of using MATLAB for algorithm development is that it provides a path for deploying our controllers on mobile devices for use in real multivariable automated insulin delivery systems. To do this, we use MATLAB Coder™ to generate C code from our MATLAB algorithms, and then embed the code along with other C modules in a Java® wrapper to execute on the mobile device. In this setup, the controller running on the device communicates with an insulin pump, a continuous glucose monitor, and a wearable wristband (which provides physiological data). The device can also communicate with applications in the cloud to log data and employ machine learning algorithms, for example, to detect or predict trends in patient data that may affect glucose concentration dynamics (Figure 5). In addition to this line of research, we are actively pursuing several others, including the use of physiological data to identify periods of acute psychological stress, which also strongly affect glucose concentrations for individual with diabetes.

A diagram showing the different types of hardware and software that enable information flow in an artificial pancreas system. There is a feedback loop involving a controller mvAID that receives information from medical wearables such as a wristband and CGM, stores and analyzes that data on the cloud, and then provides that information to an insulin pump.

Figure 5. Information flow in an artificial pancreas, also knows as a multivariable automated insulin delivery system.

About the Author

Ali Cinar holds a Ph.D. degree in chemical engineering from Texas A&M University, College Station. He is a professor of chemical engineering and biomedical engineering at the Illinois Institute of Technology, Chicago, and he has been the director of the Engineering Center for Diabetes Research and Education since 2004. His current research interests include modeling, supervision, and control of complex systems; modeling and prediction of glucose concentration dynamics in diabetes; and machine learning and adaptive control techniques for artificial pancreas system development.

Mudassir M. Rashid obtained his B.Eng. and Ph.D. degrees in Chemical Engineering from McMaster University, Hamilton, Ontario, Canada. He is currently a research assistant professor of chemical and biological engineering and director of the pharmaceutical engineering program at the Illinois Institute of Technology, Chicago, Illinois. His research interests include machine learning, deep learning, virtual patients, medical digital twins, and artificial intelligence in medicine.

Published 2023

View Articles for Related Industries