Download PDF

TD3-LSTM with Proactive Safety Layer for Closed-Loop Blood Glucose Regulation in Type 1 Diabetes

Assia SAYDTAHIRI, Azzedine ELMAJIDI, Anas HATIM, Hicham ELLOUAD
1LARTID, National School of Applied Sciences of Marrakech, Cadi Ayyad University, Marrakech, Morocco
2LAREFERENCE, Faculty of Legal Economic and Social Sciences of Marrakech, Cadi Ayyad University, Marrakech, Morocco
3LEBPBAI, Faculty of Medicine and Pharmacy of Marrakech, Cadi Ayyad University, Marrakech, Morocco
a.saydtahiri.ced@uca.ac.ma, elmajidi@gmail.com, hatim.anas@gmail.com, h.ellouad.ced@uca.ac.ma
How to cite: SAYDTAHIRI Assia, ELMAJIDI Azzedine, HATIM Anas, ELLOUAD Hicham, TD3-LSTM with Proactive Safety Layer for Closed-Loop Blood Glucose Regulation in Type 1 Diabetes, Sciences Methods and Technologies International Journal (SciMeTech), (2026) Vol 2, Issue 2, p 69-76
Abstract
This paper presents a novel closed-loop insulin delivery system for type 1 diabetes management, combining a Twin Delayed Deep Deterministic Policy Gradient (TD3) reinforcement learning agent with a Long Short-Term Memory (LSTM) encoder and a Proactive Safety Layer (PSL). The LSTM encodes a two-hour continuous glucose monitoring (CGM) history to capture temporal glucose dynamics, enabling the TD3 agent to make informed dosing decisions under unannounced meal conditions. The Proactive Safety Layer acts as a hard safety constraint, preemptively attenuating insulin doses when short-term hypoglycemia risk is detected, independently of the learned policy. Evaluated on 10 adult virtual patients using the FDA-approved UVA/Padova simulator without meal announcements, the system achieved a mean Time-in-Range (TIR) of 73.7% �0�0�� 5.5%, exceeding the 70% clinical threshold, with a 10.7% improvement over the TD3 baseline (63.0%) and complete elimination of hyperglycemic episodes (0.0%). The modular PSL demonstrates that safety can be enforced without policy retraining, making it highly adaptable for clinical applications where safety constraints may evolve independently. These results confirm that temporal glucose memory combined with proactive safety intervention produces clinically meaningful improvements in glycemic control.
Keywords: Type 1 diabetes, Artificial pancreas, Deep reinforcement learning, TD3, LSTM, Proactive safety, Closed-loop control

References

  1. Dhaif, S. S., Abbas, S. M., Hussain, A. M., & Ibrahim, N. A. (2025). Diabetes health indicators: analysis and cases reported. SHIFAA, 2025, 52-61.
  2. Bequette, B. W., Cameron, F., Buckingham, B. A., Maahs, D. M., & Lum, J. (2018). Overnight hypoglycemia and hyperglycemia mitigation for individuals with type 1 diabetes: how risks can be reduced. IEEE Control Systems Magazine, 38(1), 125-134.
  3. Ait Bourkha, M. E., Hatim, A., Nasir, D., El Beid, S., Ez-ziymy, S., & Tahiri, A. S. (2024). Ventricular Ectopic beats detection-based wavelet scattering network and ensemble bagged trees for smart medical systems. Procedia Computer Science, 236, 468-475.
  4. Hettiarachchi, C., Malagutti, N., Nolan, C. J., Suominen, H., & Daskalaki, E. (2024). G2P2C�0�9�㡱A modular reinforcement learning algorithm for glucose control by glucose prediction and planning in Type 1 Diabetes. Biomedical Signal Processing and Control, 90, 105839.
  5. Pinsker, J. E., Lee, J. B., Dassau, E., Seborg, D. E., Bradley, P. K., Gondhalekar, R., ... & Doyle III, F. J. (2016). Randomized crossover comparison of personalized MPC and PID control algorithms for the artificial pancreas. Diabetes care, 39(7), 1135-1142.
  6. Nasir, D., Hatim, A., Ait Bourkha, M. E., El Beid, S., & Ez-ziymy, S. (2024). Closed loop control of blood glucose levels in diabetes using an artificial neural network controller. Procedia Computer Science, 236, 444-451.
  7. Lee, S., Kim, J., Park, S. W., Jin, S. M., & Park, S. M. (2020). Toward a fully automated artificial pancreas system using a bioinspired reinforcement learning design: In silico validation. IEEE Journal of Biomedical and Health Informatics, 25(2), 536-546.
  8. Fujimoto, S., Hoof, H., & Meger, D. (2018, July). Addressing function approximation error in actor-critic methods. In International conference on machine learning (pp. 1587-1596). PMLR.
  9. Zhao, Y. F., Chaw, J. K., Ang, M. C., Tew, Y., Shi, X. Y., Liu, L., & Cheng, X. (2025). A safe-enhanced fully closed-loop artificial pancreas controller based on deep reinforcement learning. PloS one, 20(1), e0317662.
  10. Sutton, R. S., & Barto, A. G. (1998). Reinforcement learning: An introduction (Vol. 1, No. 1, pp. 9-11). Cambridge: MIT press.
  11. Man, C. D., Micheletto, F., Lv, D., Breton, M., Kovatchev, B., & Cobelli, C. (2014). The UVA/PADOVA type 1 diabetes simulator: new features. Journal of diabetes science and technology, 8(1), 26-34.
  12. Garg, S. K., Kipnes, M., Castorino, K., Bailey, T. S., Akturk, H. K., Welsh, J. B., ... & Beck, S. E. (2022). Accuracy and safety of Dexcom G7 continuous glucose monitoring in adults with diabetes. Diabetes technology & therapeutics, 24(6), 373-380.
  13. Magni, L., Raimondo, D. M., Man, C. D., Breton, M., Patek, S., De Nicolao, G., ... & Kovatchev, B. P. (2008). Evaluating the efficacy of closed-loop glucose regulation via control-variability grid analysis. Journal of diabetes science and technology, 2(4), 630-635.
  14. Hochreiter, S., & Schmidhuber, J. (1997). Long short-term memory. Neural computation, 9(8), 1735-1780.
  15. Battlino, T., Danne, T., Bergenstal, R. M., Amiel, S. A., Beck, R., Biester, T., & Phillip, M. (2019). Clinical targets for continuous glucose monitoring data interpretation: recommendations from the international consensus on time in range. Diabetes care, 42(8), 1593-1603.
  16. Davidson, P. C., Hebbelwhite, H. R., Steed, R. D., & Bode, B. W. (2008). Analysis of guidelines for basal-bolus insulin dosing: basal insulin, correction factor, and carbohydrate-to-insulin ratio. Endocrine Practice, 14(9), 1095-1101.
  17. Dalla Man, C., Raimondo, D. M., Rizza, R. A., & Cobelli, C. (2007). GIM, simulation software of meal glucose�0�9�㡱insulin model.
  18. American Diabetes Association. (2023). Standards of care in diabetes�0�9�㡱2023 abridged for primary care providers. Clinical Diabetes, 41(1), 4-31.
  19. Panya, T., & Khamkong, M. (2024). Deep Reinforcement Learning for Automated of Asian Stocks Trading. In Applications of Optimal Transport to Economics and Related Topics (pp. 539-554). Cham: Springer Nature Switzerland.
  20. Zhu, T., Li, K., Herrero, P., & Georgiou, P. (2020). Basal glucose control in type 1 diabetes using deep reinforcement learning: An in silico validation. IEEE Journal of Biomedical and Health Informatics, 25(4), 1223-1232.