Dynamic Rule-Based Algorithm to Tune Insulin-on-Board Constraints for a Hybrid Artificial Pancreas System

The artificial pancreas (AP) is a system intended to control blood glucose levels through automated insulin infusion, reducing the burden of subjects with type 1 diabetes to manage their condition. To increase patients' safety, some systems limit the allowed amount of insulin active in the body, known as insulin-on-board (IOB). The safety auxiliary feedback element (SAFE) layer has been designed previously to avoid overreaction of the controller and thus avoiding hypoglycemia. In this work, a new method, so-called “dynamic rule-based algorithm,” is presented in order to adjust the limits of IOB in real time. The algorithm is an extension of a previously designed method which aimed to adjust the limits of IOB for a meal with 60 grams of carbohydrates (CHO). The proposed method is intended to be applied on hybrid AP systems during 24 h operation. It has been designed by combining two different strategies to set IOB limits for different situations: (1) fasting periods and (2) postprandial periods, regardless of the size of the meal. The UVa/Padova simulator is considered to assess the performance of the method, considering challenging scenarios. In silico results showed that the method is able to reduce the time spent in hypoglycemic range, improving patients' safety, which reveals the feasibility of the approach to be included in different control algorithms.


Introduction
Type 1 diabetes (T1D) is a chronic condition in which the pancreatic beta-cells either stop or reduce drastically the production of insulin. Insulin is a hormone whose function is to facilitate the glucose uptake from the bloodstream into the cells to be used or stored. Subjects with absence of insulin in the body face very high levels of blood glucose (BG) (hyperglycemia), which can lead to long-term micro-and macrovascular complications [1,2]. erefore, subjects living with T1D must inject insulin exogenously in order to regulate blood in a lifelong challenge [3], and intensive insulin therapy reduces the risk of long-term complications [4]. But maintaining blood glucose levels into near-normoglycemia is not a trivial task, and if insulin is overdosed, BG may fall to dangerously low levels (hypoglycemia), which can lead to serious hazards, such as diabetic coma or even death [5].
Over the last years, researchers have been working towards a closed-loop system to control BG automatically [6].
is system, known as artificial pancreas (AP), is usually composed of a continuous glucose monitor (CGM), a control algorithm, and continuous subcutaneous insulin infusion through a pump. Insulin-only AP systems consider only insulin infusion to control BG, and dual-hormone AP systems also consider glucagon infusion to elevate BG to reduce the risk of hypoglycemia. AP systems can also be classified into two different categories based on the degree of automation: hybrid closed-loop system, in which subjects are involved in the control loop and must announce meals or other disturbances to anticipate their effects, and fully closed-loop systems, where no actions are required from the patients [7,8].
One of the main challenges of the AP system is achieving postprandial glucose control mainly because the insulin absorption through the subcutaneous tissue is slower than the appearance of glucose in the blood after a meal [9]. Due to this difference in dynamics of insulin action and carbohydrate (CHO) absorption, attempts to avoid hyperglycemic peaks are usually accompanied by hypoglycemic excursions [10]. Several approaches have been tested to overcome such issue [11][12][13][14], but while an ultrarapid insulin analogue is not available [15], postprandial control using subcutaneous route will continue to be a challenging situation for closed-loop systems. Diverse studies have included estimations of insulin concentration in the body to avoid excessive insulin stacking [16][17][18][19]; however, hypo-and hyperglycemia are still a hazard for AP systems, and novel approaches are still required.
Revert and colleagues introduced a safety auxiliary feedback element, so-called SAFE layer [20], to limit excessive insulin in the subcutaneous tissue, i.e., insulin-onboard (IOB). is layer is based on the sliding mode reference conditioning technique [21] and acts on the glucose reference signal when a specific constraint, related with the maximum IOB allowed (IOB), is violated. Such technique has already been applied in different control schemes [22][23][24][25], but so far it is not clear the best methodology to tune IOB. e selection of the constraint IOB is critical in the design of the closed-loop system. is parameter regulates insulin infusion based on an estimation of the IOB. As higher IOB, more insulin the controller will be allowed to deliver. Considering that once insulin is injected into the body, it cannot be removed, it will act naturally lowering BG levels.
e Spanish Consortium on Artificial Pancreas and Diabetes Technology has been working over the last decade on the development of a new artificial pancreas system. In the first clinical trial, to evaluate the performance of the PD controller with the SAFE layer, an individualized constraint IOB was designed to control postprandial BG levels after the consumption of a meal with 60 grams of CHO [26]. e closed-loop controller achieved better outcomes compared with the open-loop therapy, reducing significantly the time spent in hyperglycemia without increase the risk of hypoglycemia. However, a limitation of this study is that IOB was tuned for this specific meal size. erefore, novel approaches on how to select IOB for meals of different sizes are required to cope with daily-life operation of an AP system. In this work, a novel approach to tune IOB is presented. is new approach takes into account previous open-loop therapy to set IOB for periods without meals and in case of the announcement of meals, IOB can be raised to reduce hyperglycemia without leading to hypoglycemia in the late postprandial period. e proposal is evaluated in silico using the UVa/Padova simulator [27].

Control-Loop Scheme.
In this section, the control scheme considered in this work is introduced. e control algorithm consists of two loops, as depicted by Figure 1. e inner loop is composed by a proportional derivative (PD) controller with an insulin feedback (IFB) loop. e outer loop contains the SAFE layer [20], which is inspired on the sliding mode reference conditioning technique [21]. is SAFE layer applies a discontinuous signal generated by a switching law when estimations of IOB (IOB) surpass a preset limit of IOB (IOB). Later, the discontinuous signal is filtered generating a smooth reference signal (G rf ) to be applied into the controller. erefore, this safety layer is able to maintain IOB inside desired bounds. e control action produced by the PD controller is presented as follows: where K p is the proportional gain, T d is the derivative time, G rf is the glucose reference filtered after the action of the SAFE layer, and G(t) is the interstitial BG measurements provided by the CGM. en, the control action computed by the PD is augmented by two feed-forward signals: u bolus and u basal . e signal u basal is the insulin obtained from patients' daily basal profile. e term u bolus is an impulse signal in case of the announcement of meals to compensate the disturbance caused by the ingestion of CHO. e IFB algorithm [28] emulates the beta-cell physiology in healthy subjects, suppressing insulin secretion as plasma insulin concentration increases. e combination of the PD algorithm with both SAFE layer and IFB algorithm has already been investigated and shown to be more effective than when they are used separately [29]. e final control action signal provided to the insulin pump is where c is gain parameter and I p is the is the estimated deviation of plasma insulin from steady state conditions (basal levels). e term G rf in equation (1) is the conditioned reference due to the action of the SAFE layer to maintain IOB below IOB. Since the IOB is inaccessible, an insulin absorption model is considered to estimate IOB [30], through the following equation: where C 1 (t) and C 2 (t) are two compartments, K DIA is a constant related with the duration of insulin action (DIA), and IOB is the estimation of IOB. e SAFE layer has a software-based nature and consists of two main elements: a switching block responsible to generate a discontinuous signal to maintain IOB into the desired range and a firstorder filter to smooth the discontinuous signal before being applied to the main controller. Consider the sliding function σ(t) defined by equation (4), the switching logic is defined as follows: with W > 0 mg/dl. Finally, the discontinuous signal is filtered by the following equation and generates smooth changes in the glucose reference signal: Note that when σ(t) > 0, IOB is greater than IOB. In order to drive IOB to the desired range, i.e., below IOB, u d must be decreased. e addition of W in equation (6) generates G rf greater than G r , diminishing the insulin suggestion provided by the main controller and thus reducing IOB. When IOB is below IOB, no further action is provided by the outer loop, letting the controller work freely.

IOB Constraint Tuning.
e selection of the constraint IOB is a critical point in the design of the control system. In this work, a new tuning approach for IOB is presented. In patients with T1D, insulin requirements vary during the day and also between days (intra-and interday variability). On traditional insulin pump therapy, physicians configure patients' pump to deliver a steady flow of basal insulin to cope with intraday variability. In addition, insulin boluses are delivered when meals are informed by patients, to cover the disturbance caused on glycemic balance due to the ingestion of CHO [3]. e artificial pancreas under development by our research group has been evaluated clinically, where 20 T1D subjects (age 40.7 ± 10.4 years, T1D duration 22.2 ± 9.9 years, and A1c 7.8 ± 0.7%) used the CL system in front of a mixed meal containing 60 grams of CHO [26]. In this trial, an individualized IOB tune was considered in order the improve postprandial glycemic control when compared with standard open-loop therapy. For this specific trial, where a single meal with 60 grams of CHO was consumed, IOB was adjusted based on parameters taken from patients' open-loop therapy and computed in an offline procedure. e procedure to compute IOB was as follows: considering that patients were in basal levels of IOB, IOB was computed as the estimation of IOB levels 90 minutes after the administration of an augmented bolus, by equation (3), to compensate this 60 grams meal.
is augmented bolus was computed by adding to the standard bolus the amount of basal insulin that would have been delivered in the next hour in the case of being in open-loop therapy. erefore, knowing in advance the size of the meal and all the parameters necessary to compute this augmented bolus, it was possible to compute in an offline fashion what would be the estimation of IOB levels 90 minutes after the meal bolus.
is single value was applied as IOB limit during in this clinical trial [26].
Due to the huge amount of insulin in meal boluses, IOB violates IOB, and a high frequency discontinuous signal is generated by the SAFE layer in order to return IOB back to IOB bounds. is action forces insulin delivery to zero for approximately 90 minutes, minimizing the effects of controller's overcorrection. When σ(t) ≤ 0 (equation (4)), insulin infusion may be restored if the controller deems necessary.
However, a single value of IOB may not be sufficient for 24-hour operation, especially due to the large intrapatient variability in T1D and to the different activities performed by subjects in their daily-life. e major problem observed in the strategy presented previously is that too high values of IOB may cause that the SAFE layer be ineffective because it will act in very few conditions, e.g., only after a meal bolus. It is comprehensible having higher IOB tuning during postprandial periods, especially because subjects tend to underestimate the CHO content in meals [31]. However, during late postprandial period, where the effects of meals have been covered either by the bolus or by the controller suggestions, such high values of IOB may lead to excess of insulin in the body, increasing the risk of hypoglycemia.
In this work, a new method to tune IOB to overcome the limitations presented by the former strategy is proposed. e new approach is called "dynamic rule-based" (DRB) algorithm and is intended to be used on hybrid artificial pancreas systems for 24-hour operation, where meals of any size are consumed. e proposed approach combines two different strategies to set IOB for different situations: (1) fasting periods: where no big disturbance is expected, and the controller must deal mainly with intraday variability and (2) postprandial periods: where a substantial raise in BG levels is expected due to the consumption of a meal and insulin bolus may not be enough to compensate such disturbance. In summary, the DRB algorithm generates a time-varying IOB based on patients' basal insulin profile taken from open-loop therapy, and when a meal is announced, the algorithm evaluated in real-time if IOB should be increased temporarily in order to reduce hyperglycemia. e following sections depict the algorithm, and a flowchart is also presented in Figure 2 to clarify the operation of the DRB algorithm.
where IOB bl is the baseline for IOB and K IOB is a gain that regulates the amplitude of IOB bl , with K IOB > 0. In case of K IOB < 1, IOB will not be allowed to be greater than it would have been during open-loop therapy. On the contrary, with K IOB > 1, the insulin controller can suggest more insulin than what is programmed by the open-loop therapy. us, K IOB should be selected in order to protect patients from hypoglycemia but also allowing the control algorithm to suggest insulin above open-loop regimen when necessary. us, during fasting periods, IOB is set to be equal to IOB bl . In this work, the parameter K IOB is set to 1.3 for daytime period (06: 00-23:00) and to 1.1 for night-time period (23:00-06:00).
Although this approach may be able to provide good glycemic control in front of intraday variability, patients in free-living conditions take CHO on several occasions during the day, requiring a greater amount of insulin for these periods. erefore, the strategy of IOB during fasting periods is combined with another one, intended for postprandial periods, presented in the following section.

Postprandial Periods.
e tuning of IOB during postprandial period is an extension to the method already validated clinically by Rossetti and colleagues [26]. Here, the method is generalized for meals with different amount of CHO and also includes a set of rules based on BG readings to modify IOB. is set of rules has been designed to determine if it is necessary to increase IOB, for cases which the bolus was not enough to drive BG to near-normoglycemia levels.
e method works as follows: in case of the announcement of a meal, an insulin bolus is delivered as a feedforward action. is bolus is an augmented version of the standard bolus computation, by adding a portion of the future basal delivery according to the size of the meal, as shown in the following equation: where M CHO is the content of CHO of the meal (in grams), I2C is the insulin-to-CHO ratio, G r is the BG reference, and CF is the correction factor. After the bolus, IOB surpasses IOB, and then u final is forced to zero, while IOB is greater than IOB, due to the action of the SAFE layer. e parameter T IOB (in minutes, equation (9)) is introduced to regulate the starting time after the meal from when IOB may be increased. After T IOB minutes, BG readings start to be evaluated in order to check whether IOB needs to be increased, aiming to drive BG below a selected target (G). If in this moment, BG is greater than a threshold (G), a new IOB limit is computed to control postprandial BG, based on equation (10).
is value is maintained as IOB, while BG is greater than G. Finally, when BG returns to values below G, IOB returns to follow IOB bl . Note that the parameters G and G can be adjusted intuitively by physicians. For a more aggressive postprandial control, these parameters should be decreased as follows: e final tuning for IOB is determined during a real-time procedure, based on the dynamic behavior of patients basal insulin profile and also in the set of rules activated after the announcement of meals, to increase IOB during postprandial periods. Figure 2 depicts a flowchart of the proposed method to facilitate the understanding. e variables "PP_state" and "flag_PP" included in Figure 2 were considered for implementation purposes. In the initialization of the system, both variables should be set to zero. "PP_state" indicates that a meal has been consumed, and that IOB may be increased considering a set of rules to evaluated BG levels T IOB minutes after the announcement of the meal. e variable "flag_PP" guarantees that a single value of IOB PP is computed for each meal. Figure 3 depicts the application of the method in one representative virtual patient during a simulation, with a meal containing 45 g of CHO at 07:30 (represented by the green triangle in Figure 3(a)). Note that 67.5 minutes after the meal (computed by equation (9)), the limit of IOB has been increased because BG levels were above G. When IOB was increased, the controller suggested more insulin in order to reduce the postprandial excursions since the insulin bolus was not enough for this specific meal. is period of time represents the first meal of a single patient during Scenario C, which is detailed in Section 2.3.3.
In summary, the DRB algorithm has been designed to make use of patients' basal profile, which is an indicative of insulin requirements along the day, combined with a modified version of the approach already tested clinically with real patients, which achieved good results during postprandial control. In addition, BG measurements has been incorporated to set IOB, aiming to track glucose back to regular values safely. All the relevant parameters used in the simulations are listed in Table 1.

In Silico Evaluation.
e proposed method is validated in the UVa/Padova simulator [27] on three challenging scenarios, including intrapatient variability in insulin sensitivity and in meal absorption rate [32].
Circadian variability has been included to simulate different requirements of insulin during the day and follows a sinusoidal variation. e parameters V mx and k p3 , which are related with the insulin sensitivity are modified as follows: where q(t) is the corresponding time-varying parameter; q 0 is the default individual parameter value (V mx or k p3 ), and rand is a uniformly distributed random number between 0 and 1. Additionally, meal absorption rate and insulin absorption parameters (parameters k abs , k d , k a1 , and k a2 ) assume different values (±30% around the standard value) after every single meal consumption. Further details about the aforementioned parameters are described elsewhere [27,33].

Scenario A.
is scenario is considered to compare the performance of the DRB algorithm (IOB DRB ) against the method already validated clinically, with a fixed value for IOB (IOB F ). In a 7-day scenario, the adult cohort consumed a single meal containing 60 grams of CHO per day, between 10:00 and 16:00, in order to assess the postprandial control under different intrapatient variability conditions. is amount of CHO has been selected to conduct a fairly comparison since the former strategy was clinically validated for this specific meal size.

Scenario B.
is scenario is considered to compare the performance of the DRB algorithm (IOB DRB ) in front of meals with CHO content varying between 40 and 120 grams of CHO. In a 45-day scenario, the adult cohort consumed a single meal per day, between 08:00 and 19:00, in order to assess the postprandial control under different intrapatient variability conditions. It is considered just a single meal per day in order to avoid the accumulated effects of meals in the results.

Scenario C.
A 14-day scenario is considered to assess the performance of the proposed method intended to mimic real-life operation of the AP systems. A total of three meals, with different amounts of CHO, are consumed per day at 7:30 (45 grams), 13:00 (90 grams), and 18:30 (50 grams). An error of ± 15% on CHO counting has also been included to challenge the system. To apply meal absorption variability, the 10 mixed meal models from each patient were randomly assigned for each meal intake along with the simulation. A total of four different strategies are applied in this scenario: (1) the DRB algorithm to adjust IOB (IOB DRB ), (2) a fixed value of IOB as used in Scenario A (IOB F ), (3) IOB is set to be equal to IOB bl , without the rules considered for postprandial period (IOB bl ), and (4) the same insulin controller considered in other strategies, but without IOB.

Results and Discussion
In this section, glycemic outcomes are presented for all the scenarios previously described.
e performance of different methods to adjust IOB is evaluated according the time spent into different glycemic ranges [34]. Results are computed based on CGM measurements. Individual metrics for the adult cohort from the simulator are computed, and then the results are presented as the median (25th-75th percentile) among the cohort. Additionally, the occurrence of hypoglycemic episodes (defined as at least 15 consecutive minutes with glucose below 70 mg/dl) is also analyzed. Table 2 shows the metrics for Scenario A. ese metrics assess the performance of IOB DRB and IOB F during postprandial period (i.e., 4 hours following the meal), once the last has been designed for such purpose. e metrics used for this evaluation are: average BG levels, percentage of time spent in different glycemic ranges, glycemic excursion (defined as the difference between the maximum BG level and the premeal BG level), and the total insulin delivered by the controller after the meal bolus.

Scenario A.
Note that both strategies achieved similar results. Although IOB F obtained numerical results slightly superior than the proposed method, no significant difference was observed in any of the metrics. e new strategy (IOB DRB ), besides being applicable for meals of any size, achieved equivalent outcomes when compared with the former strategy, which was designed for meals with 60 grams of CHO and achieved good results in real patients.
However, analyzing the whole simulation period (7days), the new strategy was able to eliminate the occurrence of hypoglycemic events, while five events were observed for IOB F . is fact reinforces the hypothesis that modifying IOB over the day increases patients safety. Table 3 shows the metrics during postprandial period in Scenario B for the two methods applied in this Scenario B.   Journal of Healthcare Engineering Different from Scenario A, in Scenario B, meals from different sizes were considered to evaluate the postprandial performance of the controller, which is more realistic. Results showed a slight superiority of the IOB DRB against the IOB F in all the glycemic metrics analyzed. Notice that the percentage of time spent in tight glycemic range increased from 38.1% to 41.52%, while the percentage of time spent in hyperglycemia reduces at the same time, from 15.63% to 14.14%. is analysis shows that the previous tuning of IOB may not be sufficient for varied size of meals. Table 4 shows the results for the 14-day scenario comparing the system with the DRB algorithm (IOB DRB ) against the other strategies. It displays the mean glucose, percentage of time spent in different glycemic ranges and the number of hypoglycemic events for the entire cohort.

Scenario C.
e results display the solid performance of the strategies using the SAFE layer when compared with the insulin controller without IOB limitation, mainly to avoid hypoglycemia. e arm with the IOB DRB strategy achieved the lowest amount of hypoglycemic events when compared with the other methods. e IOB F strategy is the one with the lowest mean glucose values during daytime, but the fixed value of IOB is not enough to avoid hypoglycemic events, especially during night-time. On the contrary, the IOB bl arm considered only the adjustment for IOB presented in Section 2.2.1. Such approach did not consider the rule-based algorithm to increase IOB during postprandial periods, and this is reflected in the slightly worse outcomes for this strategy when compared with IOB DRB , during daytime. e IOB DRB arm achieved lower mean glucose values and spent less time in the hyperglycemic range, when compared with the IOB bl arm.
Also during daytime, it can be observed that IOB DRB achieved higher mean glucose values when compared with the insulin controller without IOB, considerably above the G r . Although these values are higher than in healthy people, they are still acceptable considering the recommendations of the American Diabetes Association (ADA) [35], which is A1C <7% for nonpregnant adults. e median GMI (glucose management indicator) achieved by the proposed method during daytime is 6.7%, which gives the approximate A1C levels based on CGM measurements [36]. During night-time, IOB DRB was able to lower mean glucose, without any hypoglycemic event. Considering 24-hour period for the entire scenario, the proposed method achieved a median GMI of 6.5%, within the limits recommendable by the ADA. e control-variability grid-analysis (CVGA) [37], in Figure 4, allows a graphical visualization regarding the glycemic variability within an observational period of 24 hours. Note that the IOB DRB approach achieved the highest percentage of points falling either in Zone A or Zone B, with 97.85%. Additionally, Figure 5 shows the dynamics of BG and insulin delivery for a single day, comparing IOB DRB with the arm without IOB limits, to better illustrate the influence of the IOB in the control action.
Observing the results in Table 4 and Figure 4 it is possible to note that the action of the SAFE layer avoids the overreaction of the insulin controller due to the rise of glucose, caused by the meals. Although the results obtained by the DRB algorithm are only slightly better when compared with the other strategies which included the SAFE layer, it was observed a reduction on the occurrence of hypoglycemic events without leading to excessive hyperglycemia. All the three hypoglycemic events observed in the IOB DRB arm were caused by the meal bolus and not by any insulin suggested by the controller after the meal. erefore, the hypoglycemic episodes were very likely caused by overestimation of CHO content to compute the bolus. e starting point of the proposed method was another strategy which has already been extensively tested both in silico and clinically, making the task of achieving better results even more difficult. Nevertheless, it has been possible to improve slightly the performance of the AP system in this in silico study, being able to apply different limits of IOB according to the CHO content of meals and by applying a lower IOB during night-time. Any improvement in     Journal of Healthcare Engineering postprandial glycemic control can reflect in a reduction on the risks associated with long-term complications, given its correlation with A1C levels [38], and the avoidance of nocturnal hypoglycemia is a major concern in T1D treatment. In addition, it also allows modification on the parameters of the proposed algorithm to be performed intuitively by physicians, if they deem necessary to further improvements on glycemic control. However, clinical trials involving real patients must be conducted to assess the performance of the proposed algorithm under real-life operation, in which patients may forget to announce meals, and the performance of the DRB algorithm may not be suitable to avoid hyperglycemia. Furthermore, the DRB algorithm may not be applicable in fully automatic AP systems, in which patients do not need to announce meals. Finally, the adjustments of IOB is a major task for AP systems which considers the SAFE layer, and the proper adjustment of this constraint also plays an important role even during physical activity [39,40], by reducing the amount of injected insulin during and after exercise.

Conclusions
e dynamic rule-based algorithm proposed in this work has been designed to tune in real-time limiting of IOB to safely control BG levels. is algorithm is intended for 24-hour operation, which includes postprandial and fasting periods. During postprandial periods, it allows the increase of IOB limits when more insulin is required to have a more aggressive controller but yet safe. e strategy has been evaluated in silico under challenging conditions and achieved satisfactory performance, with emphasis on the reduction of hypoglycemic events during nocturnal period and without excessive hyperglycemia during postprandial period for meals with different CHO contents. Although, in this paper, the proposed strategy has been applied and evaluated in a PD controller, such approach could also be used by other algorithms, since the SAFE layer can be added to control algorithms of any nature.

Data Availability
e data used to support the findings of this study are available from the corresponding author upon request.

Conflicts of Interest
e authors declare that there are no conflicts of interest regarding the publication of this paper. Journal of Healthcare Engineering 9