Artificial-Pancreas / iAPS

MIT License
180 stars 727 forks source link

[Issue] Profil CR adjustmenet isn't considered in the alternative bolus calculator #931

Closed charlesstyves closed 2 weeks ago

charlesstyves commented 2 weeks ago

Profil CR adjustmenet isn't considered in the alternative bolus calculator. Here is an example made in simulator mode.

Starting scenario

ISF : 3 mmol/L/U CR : 10 g/U Target : 5.5 mmol/L BG : 4.7 mmol/L Bolus ratio : 100% Profile : Not activated COB : 10 g IOB : 0 U

Carbs : 10 g / 10 g/U = 1 U Glucose : (4.7 mmol/L - 5.5 mmol/L) / 3 mmol/U = - 0.266

Perfect, theorical calculation is same as the picture below.

20241110_002041000_iOS

200% profile applyed to ISF/CR scenario

ISF : 3 mmol/L/U => 1.5 mmol/L/U CR : 10 g/U => 5 g/U Target : 5.5 mmol/L BG : 4.7 mmol/L Bolus ratio : 100% Profile : 200% ISF/CR COB : 10 g IOB : 0 U

Carbs : 10 g / 5 g/U = 2 U Glucose : (4.7 mmol/L - 5.5 mmol/L) / 1.5 mmol/U = - 0.533

As you can see below, glucose calculation match but not carbs calculation. Carbs calculation was done with the schedule ratio of 10 g/U without consideration of the profile.

20241110_002127000_iOS

Jon-b-m commented 2 weeks ago

Resolved in dev branch https://github.com/Artificial-Pancreas/iAPS/commit/8a21d3751f75e5beb983c50744ef8011a94920b2