jxx123 / simglucose

A Type-1 Diabetes simulator implemented in Python for Reinforcement Learning purpose
MIT License
232 stars 109 forks source link

Input meal size different from recorded meal size #35

Closed AdeLouis closed 2 years ago

AdeLouis commented 3 years ago

Hi! Thanks for this package, super helpful. I was wondering why the inputted meal size and the actual recorded value in the output files differ. For example in the advanced usage example, the input size of the first meal is 45, but in the out put file, it registers as 15.

From the code, it seems there is a division between meal size and sample time (= 3).

Could you give more details on this? Thanks!

jxx123 commented 3 years ago

Yeah, the recorded meal is a rate (g/min), so it is recorded as 15 g/min, and the sample time is 3 min, so the meal amount is 15 g/min * 3 min = 45 g. That is the area is the meal amount, not the value.

Sorry if it is a bit confusing.

AdeLouis commented 3 years ago

Oh, I see that makes sense. This would also imply that in the basal-bolus controller, the bolus is being computed using the first 1/3 of the meal size and not the entire meal amount correct? So if a meal is 45g in total, the bolus amount is calculated using 15g (since its a third of the meal)

jxx123 commented 3 years ago

Yes you can understand it that way.

To be more specific, the meal info that the basal bolus controller gets is the full size (45g), I should've kept it more consistent. https://github.com/jxx123/simglucose/blob/8f6696a628543a553fd9d5aa55d935be23bd7b38/simglucose/controller/basal_bolus_ctrller.py#L30

Then the bolus is divided by the sample time here https://github.com/jxx123/simglucose/blob/8f6696a628543a553fd9d5aa55d935be23bd7b38/simglucose/controller/basal_bolus_ctrller.py#L82

So in the end you can say the bolus is based on 15g, because it is also a rate instead of the absolute amount.

AdeLouis commented 2 years ago

That makes sense. Thank you! I will close this issue then.