Abstract
Background:
Maintaining glycemic equilibrium can be challenging for people living with type 1 diabetes (T1D) as many factors (eg, length, type, duration, insulin on board, stress, and training) will impact the metabolic changes triggered by physical activity potentially leading to both hypoglycemia and hyperglycemia. Therefore, and despite the noted health benefits, many individuals with T1D do not exercise as much as their healthy peers. While technology advances have improved glucose control during and immediately after exercise, it remains one of the key limitations of artificial pancreas (AP) systems, largely because stopping insulin at the onset of exercise may not be enough to prevent impending, exercise-induced hypoglycemia.
Methods:
A hybrid AP algorithm with subject-specific exercise behavior recognition and anticipatory action is designed to prevent hypoglycemic events during and after moderate-intensity exercise. Our approach relies on a number of key innovations, namely, an activity informed premeal bolus calculator, personalized exercise pattern recognition, and a multistage model predictive control (MS-MPC) strategy that can transition between reactive and anticipatory modes. This AP design was evaluated on 100 in silico subjects from the most up-to-date FDA-accepted UVA/Padova metabolic simulator, emulating an outpatient clinical trial setting. Results with a baseline controller, a regular MPC (rMPC), are also included for comparison purposes.
Results:
In silico experiments reveal that the proposed MS-MPC strategy markedly reduces the number of exercise-related hypoglycemic events (8 vs 68).
Conclusion:
An anticipatory mode for insulin administration of a monohormonal AP controller reduces the occurrence of hypoglycemia during moderate-intensity exercise.
Introduction
Type 1 diabetes (T1D) is an autoimmune condition resulting in absolute insulin deficiency and a life-long need for exogenous insulin. 1 Glycemic control in T1D remains a challenge, despite the availability of modern insulin analogs, 2 and advanced technology such as insulin pumps, continuous glucose monitoring (CGM) 3 and artificial pancreas (AP) systems that automatically titrate insulin doses. 4
Artificial pancreas systems have become a focus of significant research and industrial development.4,5 During the past decade, studies have advanced from short-term, inpatient investigations using algorithm-driven manual control 6 to long-term clinical trials in free-living conditions. 7 Most AP studies show a significant reduction in glucose variability, particularly overnight, and lower risk of hypoglycemia. In September 2016, the US Food and Drug Administration (FDA) approved the first hybrid, closed-loop control system, the Medtronic 670G. This AP is capable of automatically adjusting the insulin basal rate, but still faces many issues, such as time spent in closed loop (72%-75%),8,9 low time-in-range (~65%) in comparison to other proposed systems, and its hybrid design: user input for major disturbances like meals and exercise.8,10
In spite of significant effort from the scientific community, meals and exercise remain the most challenging hurdles to overcome before a fully automated AP can be developed. Physical activity is particularly challenging to account for, as its effects on glucose are based on intensity, duration, and patient-specific physiology.11,12 For example, moderate-intensity exercise is known to cause a decrease in glucose levels as opposed to high-intensity and anaerobic exercise which may cause an increase in glucose levels, and hence, an increased insulin requirement. 12 The current treatment guides suggest basal insulin reduction for pump users and/or carbohydrate supplementation prior to moderate exercise. 13 A recent study showed that in order to prevent exercise-related hypoglycemia, basal insulin needs to be reduced ~90 to 120 minutes before activity began.12,14 However, these approaches should be taken cautiously, since carbohydrate overconsumption and aggressive reduction of basal insulin levels may also lead to hyperglycemia during and after exercise. 15
Studies addressing different AP designs to improve glycemic control during and after exercise bouts are increasingly prevalent in the literature.16-23 In these studies, the incorporation of additional sensors (eg, HR and accelerometry) for exercise detection and the use of different control strategies were assessed during moderate-intensity exercise (eg, one-hour brisk walk, bicycling, and soccer).
The proposed multistage model predictive controller (MS-MPC) differs from the previous exercise-oriented AP designs through three major improvements: (i) the incorporation of subject-specific exercise behavior into the controller design which can be updated periodically, (ii) anticipatory and reactive modes that compensate for expected and ongoing exercise, and (iii) an adaptive detuning strategy that modulates the controller’s aggressiveness before and after a meal. Additionally, the controller leverages the Unified Safety System (USS Virginia), a safety supervision module to limit basal injections based on the perceived risk for hypoglycemia. 24 The safety and performance of the MS-MPC and a regular MPC (baseline controller—rMPC) are evaluated on 100 in silico subjects from the most up-to-date FDA-accepted UVA/Padova simulator in a specific outpatient clinical trial design, including intra- and interpatient variations. Here, the primary outcome is the comparison between the number of hypoglycemic treatments.
Methods
Prediction Model
In this work, both the baseline rMPC and the proposed MS-MPC make predictions using a personalized version of the Subcutaneous Oral Glucose Minimal Model (SOGMM). 25 Model equations are as follows:
where
and
Model Parameters of the Subcutaneous Oral Glucose Minimal Model.
In this work, synthetic glucose measurements for model identification were generated from the FDA-accepted UVA/Padova simulator.27,28 To this end, for each of the 100 in silico adults, 10 days of data collection considering intrapatient and interday variability were simulated with three meals per day. Since in the simulator each subject is equipped with a particular Gb, Equation (8) was not used in this in silico study.
A subset of parameters was selected,

Example of identification results for one of the in silico adults. The solid blue line represents the daily glucose profile generated using the UVA/Padova simulator and the dashed blue line is the glucose predicted by the identified model. The orange line indicates the insulin boluses and basal pattern.
where ‖.‖ indicates the two-norm, and
Average Estimates from In Silico Data for the Selected Parameters of the Subcutaneous Oral Glucose Minimal Model.
Hybrid Multistage AP With Exercise Behavior Recognition
Multistage model predictive control was introduced by Lucia et al30,31 as a way to make the MPC strategy robust for cases where the prediction model is uncertain but less conservative than classic approaches. This approach assumes a tree of semi-independent disturbance realizations which are only related in the initial condition by means of the so-called non-anticipativity constraint. Such a formulation makes it possible to include further insight of what may happen in the future. In this sense, future control actions can be adapted according to hypothetical future realizations of the uncertainty.
In our case, we assume the effect of moderate-intensity exercise bouts on glucose dynamics as the main source of uncertainty in the prediction model. Since the user is not expected to exercise at the exact same time or for the same duration, different exercise realizations arise. Instead of optimizing the insulin infusion for a given exercise condition, a specific number of
Subject-Specific Exercise Behavior
Exercise input
The UVA/Padova simulator is equipped with an exercise model that describes widely acknowledged short- and long-term exercise-related alterations in insulin-independent glucose uptake (Uii), endogenous glucose production (EGP), and insulin sensitivity (SI).12,32-35 While the increase in Uii was modeled as a pulse-wise signal that is only active during exercise, 12 changes in SI and EGP were defined to increase during exercise and slowly decay to their baselines in hours following. Data from four randomized cross-over clinical studies (NCT01418703, NCT01390259, 2009-A00421-56, and 2010-A00538-31) were considered for model tuning to statistically describe the immediate increase observed in all Uii, EGP, and SI. On the other hand, the glucose clamp procedure described in McMahon et al 36 was simulated to represent the long-term effect of exercise on glycemia and adjust the time constants associated with the posterior decays in SI and EGP. For each in silico adult of the simulator, the glucose infusion rates (GIRs) needed to maintain the glucose level at its basal value during a 45-minute bout of moderate exercise and in the hours following was commanded by a discrete proportional-derivative controller. The biphasic behavior of GIR detected in McMahon et al 36 was successfully recreated by adjusting the decay of both SI and EGP after exercise, and accommodating the increase in SI that occurs several hours later and then decays slowly to its baseline.
To consider this effect in the MPC predictions, SOGMM was augmented by including the additional input
The identified parameters are
with
where

Above: Mean
Extracting subject-specific exercise behavior
To represent data that would be collected leading up to a clinical admission, we simulated 30 days for each of the in silico subjects involved in our protocol. On one-half the 30 simulated days, the subjects exercised for about 45 minutes in between 4 and 7
A total of 24-hour exercise-related disturbance signals were then clustered into five distinct groups (to meet the tradeoff of number of parallel controllers and performance) using the k-medoids algorithm with a squared Euclidean distance measure. Although not described here in full due to space constraints, the decision to choose five clusters was based on an experiment where approximately 30 days of exercise data from different patients were clustered using different cluster sizes. The average silhouette score was calculated from each of these configurations and five clusters provided the highest silhouette score on average for the subjects in the training data. The clustered signals were then averaged across each sampling period to create a 24-hour profile trace for each grouping. The proportion of days of the month that fell into each cluster was considered its relative probability for each subject
where
Figure 3 shows an example clustering for an in silico subject. For simplicity in this particular implementation, five profiles for each subject were generated. Two profiles had average traces equal to 0 (

Clustered glucose uptake signals for 30 days of a representative subject’s exercise data. Red lines show profile (average) trace. Black lines show each trace represented in the cluster. Probability of each cluster occurring shown above each respective subplot.
Multistage Model Predictive Control
The core of the AP system is represented by the MS-MPC whose mathematical problem is defined as follows:
where
In the above formulation, Equation (16) corresponds to the linear state-space representation of the
where
where
with
Each model prediction uses
In order to improve the AP’s safety, we propose a detuning strategy for
with
By default, the AP operates in anticipative mode and progressively reduces the insulin infusion during times where there is a high probability of exercise. If exercise is detected, the system transitions to reactive mode, meaning that instead of having
Exercise-Informed Premeal Bolus
An exercise-informed premeal bolus calculator was developed to adjust the patient’s insulin bolus based on the anticipated increase in glucose uptake during the hours following exercise. In section C, we explain the generation of the signal
Mealtime insulin is computed based on the carbohydrate intake,
where
Unlike the basal insulin controller actions, no anticipatory action is taken in meal bolus calculations. Bolus adjustments are made only based on the disturbance signal from the previously observed exercise. In the specific clinical trial design that this manuscript features, a mealtime bolus is administered at the end of the first increased glucose uptake phase, and therefore, no significant meal bolus reduction is applied.
Numerical Simulations
The presented results were obtained using the most up-to-date version of the FDA accepted UVA/Padova simulator. 27 All 100 virtual adults were used for this evaluation. Dawn phenomena and intra- and interday insulin sensitivity variations were included in the experimental setup. Simulation protocol was designed to mimic the 36-hour in vivo clinical trial where the feasibility of the proposed control strategy will be tested (see Figure 4).

Timeline of the in silico protocol.
Closed-loop simulations started at 11.00
On day 1, the subjects received a lunch and dinner at 1:00 and 7:30
Results
The above protocol was used as a testbed to assess the safety and efficacy of the MS-MPC strategy in preventing hypoglycemic events and regulating glucose levels. The performance and safety of the proposed controller is compared to a baseline controller, the rMPC, published elsewhere. 40 The tuning parameters for both controllers are presented in Table 3.
Tuning Parameters for the Regular Model Predictive Control and Multistage Model Predictive Control.
Abbreviations: r-MPC, regular model predictive control; MS-MPC, multistage model predictive control.
Figure 5 shows an individual closed-loop response under both MS-MPC and rMPC. As illustrated, the anticipatory response of the MS-MPC avoids the hypoglycemic event during exercise by progressively reducing the insulin infusion rate when exercise is likely to happen. Note that although the rMPC reacts to the effect of exercise on the glucose level by almost switching off the insulin pump, that action is still futile, 41 and the subject required a hypo treatment.

Individual closed-loop response with the proposed multistage model predictive control (green) and regular model predictive control (red). The filled light blue and pink regions represent the 70 to 180 mg/dL range and the exercise period, respectively.
The average closed-loop responses obtained with both the proposed MS-MPC and rMPC are compared in Figure 6 and the average results are summarized in Table 4. Safety and effectiveness endpoints based on consensus outcome metrics for glucose controllers’ performances 42 are computed for the duration of the in silico protocol. Time within the target range of 70 to 180 mg/dL exceeds 80%, and the primary safety parameter, the low blood glucose index (LBGI), indicates minimal risk of hypoglycemia (LBGI < 1.1). 43 As expected, the MS-MPC demonstrates better performance for hypoglycemia protection during and after exercise than the rMPC with less time spent in hypoglycemia. In this regard, 58 subjects received at least one hypo treatment during the exercise period and 10 subjects received two under rMPC, while only eight received the treatment when using the MS-MPC. In addition, exercise was suspended 44 times with the rMPC and four with the MS-MPC. Differences between the number of exercise suspensions and hypo treatments are because, in some cases, rescue carbs were administered at the end of the exercise period. It is worth remarking that although higher average glucose concentration is obtained with the MS-MPC controller, the high blood glucose index (HBGI) still indicates low risk of hyperglycemia (HBGI < 4.5). 43 In the future, however, mechanisms to transition the underinsulinization state to a state of normal infusion rate will be explored to avoid postprandial glycemic excursions.

Closed-loop responses for all the in silico adults with the proposed multistage model predictive control (green) and regular model predictive control (red). The thick lines are the median values, and the boundaries of the filled areas are the 25th and 75th percentiles. The filled light blue and pink regions represent the 70 to 180 mg/dL range and the exercise period, respectively.
Average Closed-loop Results for all the In Silico Adults With the Multistage Model Predictive Control and Regular Model Predictive Control Strategies.
Abbreviations: r-MPC, regular model predictive control; MS-MPC, multistage model predictive control.
# hypo treats during exercise indicates the number of hypo treatments (15 g CHO, fast absorption) given to the entire in silico cohort during the exercise period.
Discussion
Meaningful studies and position papers have shown the importance of manipulating insulin infusion proactively to prevent hypoglycemic events during and after moderate-intensity exercise.11-13 In this contribution, we have demonstrated promising mechanisms to (i) gather user-specific exercise behavior, (ii) provide this useful insight to a predictive controller able to reduce insulin infusion in a prospective way, and (iii) transition between anticipative and reactive modes according to the certainty on the occurrence of exercise. The main objective of this AP strategy is to reduce the risk of hypoglycemia during and after exercise. In this regard, in silico results suggest that the proposed closed-loop system decreases both the time in hypoglycemia and the number of hypo treatments, without increasing the risk of hyperglycemia beyond safe levels. Hypo treatments were included in these simulations to recreate the future in vivo evaluation of this AP strategy, where the safety of the participant is our main priority. The performance of the MS-MPC in preventing exercise-related hypoglycemia against the rMPC is highlighted when hypo treatments are removed from the simulations (% time < 70 mg/dL during exercise [median (interquartile range, IQR)]: MS-MPC, 0.0 (0.0)%; rMPC, 15.4 (38.5)%).
Despite benefits, as illustrated in Figure 6, higher glucose peaks are detected after the meal that follows when exercise is likely to occur. This is mainly due to the underinsulinization state reached to avoid the hypoglycemia during exercise. We acknowledge that this is a limitation of the proposed system. A possible solution is to allow the controller to respond more aggressively and/or progressively transition to a normal insulin state before meal consumption. In that case, postprandial glucose excursions will be further mitigated, but this comes at the expense of increasing the risk of late hypoglycemia due to the delayed glucose uptake associated with exercise and the sustained duration of action of the current insulin analogs. Insulins with faster-on and -off pharmacodynamics would be beneficial in this scenario where anticipatory reduction of insulin levels is necessary and later increase in the risk of hypoglycemia is expected. Finally, it is worth considering that in these simulations we are assigning to each subject three exercise-related signatures randomly distributed between 4 and 7
Conclusion
This contribution proposes a novel (hybrid) AP system based on MS-MPC for hypoglycemia prevention during and after moderate-intensity exercise bouts. To test the safety and reliability of our AP system, we created an in silico replica of an upcoming outpatient clinical trial in our FDA-accepted UVA/Padova metabolic simulator including both inter- and intrapatient variability. Results demonstrated that our controller is safe and effective in preventing exercise-related hypoglycemia in the proposed scenario.
Footnotes
Declaration of Conflict of Interests
The author(s) declared the following potential conflicts of interest with respect to the research, authorship, and/or publication of this article: JGT, PC, JC, and BO have nothing to declare. MDB consults for Roche Diagnostics, Sanofi-Aventis, and Ascensia Diabetes Care; receives research support from Dexcom, Senseonics, Tandem, Roche Diagnostics, Sanofi-Aventis, and Ascensia Diabetes Care; and holds equity in TypeZero Technologies.
Funding
The author(s) disclosed receipt of the following financial support for the research, authorship, and/or publication of this article: This work has been supported by the National Institutes of Health (NIH) under Grant 1DP3DK106826-01.
