jxx123/simglucose

How to set up the input/Controller in this repo to determine the basal rate with only insulin input (without meal)?

Opened this issue · 7 comments

I read the code of this repo. Your code is well-written. However, I think I need more clarification about the tutorial to better understand how to use your repo correctly.

In your tutorial, you give an example of BBcontroller that changes the meal "scen=[(7,45), ...]" as input. To my understanding, in BBController the insulin = basal (determined by patient) + bolus (meal). We couldn't change insulin input without meals here, right?

I also try PIDController, which seems to change the insulin intake instead (if I understand correctly). However, the results show that BG drops very quickly (PIDController(P=1, I=1, D=1, target=120)).

My question is: how to set up the input/Controller in your repo to determine the basal rate that makes the BG be a fixed number, let's say 120, if I want to only control the insulin as the input (without meal).

Any hints would be helpful. Thanks in advance.

Hi, you can only control the insulin through the action of the environment. Do you mean you want to also change CHO through the action?

Hi, you can only control the insulin through the action of the environment. Do you mean you want to also change CHO through the action?

I update my description of the question. Looking forward to your future reply.

Thanks a lot.

BBController needs meal information (how much carb is taken by the patient currently) to determine the bolus amount, but this meal information is not necessary for a controller. You can definitely specify an insulin amount without the meal information. For example PIDController does not use the meal information at all.

The P, I and D parameters need to be tuned carefully to have acceptable performance. Setting all of them to 1 might not be a good idea.

Ideally, if you are using BBController, and there is no meal intake at all (you can setup custom scenario with all the meal amount to be 0), the glucose level should be staying at its balance point, which might not be 120 (it varies among patients).

If you want to make the glucose level stabilized at arbitrary level by changing the basal rate, then I would say this is a super hard problem since it is a nonlinear system. It took my whole PhD years to figure this out by designing various controllers. I don't have a good answer for it, and that is also the purpose I created this environment to train AI to accomplish that :).

Thank you for your detailed explanation. I'm thinking about your suggestion.

Hi all!
I have a question slightly related to this issue.

My goal is to obtain simulations showing hyper- and hypo-glycemia events during one of the windows (t 30 min, 60 min and 120 min after meal).
In a first attempt, I tried to modify the bolus rate that the BBcontroller administered to patients. In the case of hyperglycemia, I had to reduce the bolus by up to one tenth of what the controller calculates for a fixed amount of carbohydrates. My expectation is that the bolus would need to be reduced less drastically in order to obtain hyperglycemic events. Similarly, I have needed to increase the bolus 10-fold in order to obtain hypoglycemic events.

From the preivous answers, I have interpreted that the BBcontroller can be tuned in terms of meal quantity but it is not recommended to alter the basal and bolus rates due to the complexity of the system. Therefore, I assume that my first attempt is wrong.

I was wondering if it is a good approach to modify the target so that I can generate hypo and hyper-glycemia events.

Thanks in advance!

I think your approach of changing the bolus to 1/10 or 10x of the original amount is good to generate hypo hyper-glycemia events.

Modifying target (I assume you mean the target here

def __init__(self, target=140):
) will only change part of the bolus (the correction part, see here
(glucose - self.target) / quest.CF.values).item() # unit: U
). It helped a bit, but not very effective I believe.

Thank you a lot for the reply!
My question was more related to why it is necessary to vary the bolus values so much in order to obtain simulations within hypo glycemia. In real life, scaling a factor of 10 in the bolus does not seem safe for any patient.
I have been doing some more research on hypo and hyper glycemia scenarios for S2008 simulator.
It seems that the S2008 version fails to reproduce the hypoglycemia results with fidelity to the clinical results (Visentin R, Dalla Man C, Kovatchev B, Cobelli C. The university of Virginia/Padova type 1 diabetes simulator matches the glucose traces of a clinical trial. Diabetes Technol Ther. 2014 Jul;16(7):428-34. doi: 10.1089/dia.2013.0377. Epub 2014 Feb 26. PMID: 24571584; PMCID: PMC4074748.).
Indeed, your implementation is correct, and, as you suggested, it is correct to change the bolus amount.
What must be wrong is some element of the original modeling.
Thank you very much for the help and congratulations for the great job!

I think your approach of changing the bolus to 1/10 or 10x of the original amount is good to generate hypo hyper-glycemia events.

Modifying target (I assume you mean the target here

def __init__(self, target=140):

) will only change part of the bolus (the correction part, see here

(glucose - self.target) / quest.CF.values).item() # unit: U

). It helped a bit, but not very effective I believe.