ECSE 4132 Project:
System Identification and Control for an Artificial Pancreas System
Introduction
Jonathan Lin, Vlad Joukov Dana Kuli ́c University of Waterloo Monash University
August 2019
In this project, you will work in a simulation environment to develop a model of the food-Insulin response of a type II diabetic patient, and derive a controller for providing appropriate insulin medication to control the blood sugar level of such patients.
In healthy people, homeostasis (steady state equilibrium) blood glucose level is regulated by insulin, which is produced by the pancreas. When food intake occurs, the blood glucose level rises. Insulin lowers the blood glucose level by absorbing glucose into the liver, fat, and muscle cells. In Type II diabetics, the body becomes resistant to insulin response, or the body secretes less insulin to counter the sugar presence. A common treatment technique is to apply insulin injections to compensate for the lack of proper body response. One treatment methodology is to require patients to monitor their blood glucose level and self- administer appropriate levels of insulin. This process can be automated by sampling the body’s blood sugar levels and applying an injection of insulin at an appropriate time. In this project, you will investigate the blood glucose response to insulin and food, and come up with a controller which can provide appropriate insulin medication. The project consists of two parts:
1. Identifying the transfer function that represents the open-loop response of the patient, and
2. implementing an insulin pump that will stabilize the blood glucose level of the patient to a target level following food intake.
You will work in groups of two to complete the project. Please form your own group and register it on the Moodle site. Any questions (and answers!) about the project should be posted to the Moodle discussion forum.
Part I: System Identification
Objective: Perform system identification of a Type II diabetic patient by examining the open-loop signal response of insulin.
1
In this part of the project, you will be given a model of a diabetic patient. Your objective will be to come up with a transfer function model of the patient that closely resembles the provided patient model. To get you started, the sample code provides the transfer function of a simple first order system. You must develop a method of testing the patient model to come up with an improved transfer function that minimizes the root-mean-square error (RMSE) between your transfer function and the true patient model. Note that the underlying model includes an initial condition that can be set, as well as the transfer function itself.
Figure 1: Open-loop system of a patient. The signal input of this system is insulin, while the disturbance input is food. The output of the system is the blood (plasma) glucose level.
Getting started: Download the MATLAB code package and run testSysID single.m. This will gen- erate a simulated patient, run the function sysId.m (the system identification code that you will be modi- fying), and plot the output against a reference output. The reference output is a fixed first order system that is designed to loosely follow the simulated patient.
Modify sysId.m as you see fit to generate your automated system identification code. You can also modify the interVector.m code, which currently generates an insulin step input, to see how changing the input can change the output response. Your sysId.m can use any sort of input to perform the identification, but the assessment of this assignment will be done using insulin step response. SysId.m can use any order system, not just first order. In addition, the model can accept a food (disturbance) input if you are interested in exploring the disturbance response of the patient. Please do not use MATLAB’s built-in system identification functions, as usage of these functions will result in 0% assigned.
These files were created with MATLAB 2018a, they may not work with earlier versions of MATLAB.
Grading
Please submit only the sysId.m file to Moodle Part I project submission.
To grade the performance of your system identification, a set of 10 pre-determined patients will be
simulated.
A given participant will be considered identified if the RMSE between the step response generated from
your sysId and the simulated patient is better than the RMSE between the referenceId and the simulated patient. The RMSE is calculated as follows:
Σni=0|xi − yi|2
RMSE = n (1)
For each patient with RMSE below the RMSE of the reference ID, you will be awarded 1 mark, for a maximum of 10 marks. This part will be worth 20% of your project grade.
2
Figure 2: The step response of the simulated patient (blue). Your objective is to get the ID RMSE (yellow) to be lower than the reference RMSE (orange).
Part II: Controller Design
Objective: Design a controller that will be used within an insulin pump to augment the Type II diabetic patient’s insulin response.
This assignment uses the same patient generation process as in Part I (System Identification). You will now design a controller that ensures that the patient’s plasma glucose level always remains within specified bounds and reaches a target steady state value. You must ensure that the plasma glucose level settles between 63 and 126 mg/dl, and does not drop below 39.6 mg/dl or exceed 298.8 mg/dl. Biologically speaking, there is no general absolute limit of when too much or too little plasma glucose is dangerous as it is dependent on the patient. These values are guidelines obtained from population surveys and serve as useful rules of thumb.
Getting started: Download the MATLAB code package and run testControl single.m. This will generate a simulated patient, run ctrlDesign.m (the controller design code that you will be modifying), and plot the output response to food disturbances. You can comment out line 10 or 11 to switch between a fasting response (no food) and a 3 meal response. As with the system identification step, the patients are randomly generated, so if your controller depends on knowing the patient model parameters, please incorporate your system identification code from Part I. If you wish to improve your system identification code, you can do so during this stage of the project.
Grading
Please submit your ctrlDesign.m file to Moodle Part II project submission. Your ctrlDesign.m file should include your final system identification code in the SysID function in the file.
3
In part II, you have the opportunity to refine your system identification. To generate your system identification grade for Part II, for each of the 10 patients, we will compute the RMSE of your model, using Equation 1. You will be marked out of 10 via the following formula:
0 if RMSE > referenceId mark for a patient = 10 − 10 RMSE otherwise.
referenceId
This part of the project is marked out of 100 and is worth 20% of your total project mark.
To grade your controller, for each of the 10 patients, we will generate a random eating pattern, simulate
your closed loop system for 20 hours and assign a mark out of 10 via the following formula:
mark for a patient =
0 if response enters the red zone 10 × (proportion of time spent in green zone) otherwise.
This part of the project is marked out of 100 and is worth 60% of the total project mark.
References:
1. C. Man, R. Rizza and C. Cobelli, ”Meal Simulation Model of the Glucose-Insulin System,” in IEEE Transactions on Biomedical Engineering, vol. 54, no. 10, pp. 1740-1749, 2007.
2. Center for Disease Control, ”National Health and Nutrition Examination Survey,” 1994. Available online: https://wwwn.cdc.gov/nchs/nhanes/nhanes3/Default.aspx
3. Diabetes Canada, ”Managing Your Blood Sugar”, 2018. Available online: https://www.diabetes.ca/diabetes- and-you/healthy-living-resources/blood-glucose-insulin/managing-your-blood-sugar
4. United States National Library of Medicine, ”MedlinePlus: Low Blood Sugar”, 2018. Available online: https://medlineplus.gov/ency/patientinstructions/000085.htm
4
Figure 3: This figure illustrates the insulin concentration of healthy (solid) and Type II diabetics after consuming a meal, averaged over several participants. Note that diabetic response has a much larger peak and settles at a higher value (Man et al., 2007).
5
Figure 4: A feedback loop containing the patient model and the controller that you will design.
Figure 5: Glucose response of the patient with no controller. The orange line plots the patient’s glucose level throughout the day. You can notice 3 spikes, corresponding to 3 meals eaten by the patient. The green zone indicates the target glucose range. The red zone indicates dangerous glucose range. Your objective is to keep the patient glucose level (orange) in the green region as much as possible, while avoiding the red regions.
6