A Web-Based Educational Simulation Package for Glucose-Insulin Levels in the Human Body

"The simulator does not differentiate between people regarding their sex, age, race, or BMI (body mass index); instead it represents an average person. Also, GlucoSim does not take into account intra- and inter-personal variations and it should not be used for making medical decisions."
The GlucoSim should only be used for educational purposes.


1. Constant Injection Rate:

This mode simulates the case where there is constant injection of insulin.

The infusion site for the insulin pump is based on the option selected from the graphical user interface while the insulin injections (insulin dose) are subcutaneous injections.

If subcutaneous infusion is selected for constant rate injection, entering bolus dose values as insulin dose in graphical user interface can simulate use of current commercial pumps.

2. Proportional Integral Derivative (PID) Control :
The PID control algorithm is as follows:


For this case, e(t), the error is the deviation of measured blood glucose concentration from the set point (the optimal value of 80 mg/dl). p(t) is the output of the controller (controlled variable, insulin injection rate).

The controller takes action based on the deviation of blood glucose concentration from the optimum value. The first term in the brackets is the proportional term which takes the current value of the error into account. It provides a rapid adjustment of manipulated variable and speeds the dynamic response. The second term (integral term) sums up the past error values and basically takes the history of the system into account therefore can eliminate steady state error in the case of set point change or persistent disturbance. The last term (derivative term) has predictive effect and it takes the future state of the system into account.

Tuning Parameters:
tI (integral time), tD (derivative time) determines the relative weight of the three terms where the weight of proportional term is 1. Increasing tD (derivative time) will increase the weight of derivative term , while increasing tI (integral time) will decrease the weight of integral term.

KC is the gain of the controller. The negative value is due to the fact that increasing injection rate will decrease the blood glucose concentration. Increasing the magnitude of KC will result in a more aggressive controller which will inject more insulin at the same conditions.

Anti-reset windup: It is common practice to have settings that prevent the buildup of integral (reset) term. In this case, (when enabled) the settings put a maximum value to the magnitude of the integral term and the integral term is reduced to a value when the both error and integral have the same sign.

3. Internal Model Control (IMC):

The IMC diagram is as follows:

TF: Transfer function

Unlike PID control, IMC algorithm utilizes a built-in internal model to compute the output (injection rate) from the feedback (blood insulin concentration). In the generation of IMC algorithm, the invertable part of the process model is inverted (in Laplace domain) and a filter is added to the algorithm if necessary. For this case the model is a simple version of the actual model. (First order plus time delay). The filter is a first order filter with tf (filter time constant).

Tuning Parameters:
Filter time constant tf : It is the desired closed-loop time constant. Decreasing tf will cause the controller to become more agressive.

Model parameters: They are the parameters of the internal model. Normally they should be set to the default values by clicking "Set to default model parameters". Hovewer a first order plus time delay model may not be able to predict the actual model accurately at every condition (the default values are determined from the response of blood glucose concentration to a step input of 2mU/min) so the parameters can be a part of the tuning.

4. Model Predictive Control (MPC):

MPC is a model-based control algorithm more sophisticated than Internal Model Control (IMC). Two main components of MPC are:

- Controller

- Estimator

The estimator (for this case: Linear Kalman filter) has an internal model of the process (linear 33th order) and it estimates the each state of the system (e.g. glucose amount in stomach, insulin concentration in the interstitial fluid) using the limited feedback from the system (blood glucose concentration) in the presence of measurement noise. It estimates the states at each sampling time (measurement time).

The controller has an internal model of the process (for this case linearized version of the actual model, 33th order) and at each sampling time it computes future insulin injection rates that will minimize the predicted values of the deviation of blood glucose levels from the optimum value (set point, reference point, 80 mg/dl). Basically it solves the following optimization problem:

p: prediction horizon

m: control horizon

u: insulin injection rate (mU/min) Du: change in injection rate 0 < u < 100 mU/min

y: estimates of future glucose level measurements

Gy: Weight for deviation of predicted glucose concentration from set point

Gu: Weight for change in injection rate

r: 80 mg/dl reference (set point)

Controller receives the initial values for the optimization problem (current states of the system) from the estimator. The controller solves the optimization problem at each sampling time with the updated states from the estimator.

Tuning Parameters:
Weight for set point tracking penalty Gy and weight for input move penalty Gu : Here an increased Gu causes the injection rate to change more smoothly as it penalizes the change in injection rate more in the objective function. Thus a larger ratio of Gy to Gu makes the controller more aggressive while a small ratio makes it less aggressive.

Prediction and control horizon: The larger the horizons, the further time the controller takes into account in the optimization problem. One disadvantage of having large horizons is the large amount of time that it takes to solve the optimization problem. The control horizon should be less than or equal to prediction horizon.

Insulin Route:

The infusion site for the insulin pump is based on the option selected from the graphical user interface while the insulin injections (insulin dose) are subcutaneous injections.

Back to Top