Repository navigation
Offer slow retrospective correction; show Guard + Runway v2 and its guard - #2643
Merged
Merged
Conversation
…uard Slow retrospective correction (LoopKit/LoopAlgorithm#16) becomes an algorithm experiment. When it is on, Loop reads 72 hours of glucose, carbs from 72 hours plus the longest absorption time, and doses from 72 hours plus the insulin activity duration, with schedule history covering them, since the experiment keeps no state. Its level and ISF multiplier are recorded on the dosing decision, and the bolus screen and forecast details forecasts use the multiplier so they match the algorithm's. Guard + Runway is labeled v2, its description says what changed, and its recorded parameters carry version 2. The forecast details screen draws the forecast the low guard checks as a dotted line while Guard + Runway is selected, and no longer lowers the comparison forecast by the band, since the second version no longer lowers the displayed forecast.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on LoopKit/LoopKit#683 for the chart's guard line. LoopKit/LoopAlgorithm#16 (Guard + Runway v2 and slow retrospective correction) is already in LoopAlgorithm
main; the LoopWorkspace bump, LoopKit/LoopWorkspace#568, brings it in.Slow retrospective correction
A new row under Settings → Algorithm Experiments, with its own description and toggle, off by default.
History. The experiment keeps no state, so when it's on
fetchDatareads:Carb ratio, ISF, basal and override history follow those windows, since they are derived from them. That satisfies the algorithm's new
carbRatioOrSensitivityStartsAfterCarbEntrycheck. With the experiment off, nothing changes.Recorded. The dosing decision's
slowRetrospectiveCorrectionexperiment carrieslevelandmultiplier.Matching forecasts. The bolus screen, the manual dose screen and forecast details draw their own forecasts with
predictGlucose. It now takes the ISF multiplier from the algorithm's last run, so those forecasts match the algorithm's.Forecast details. A Slow Retrospective Correction row shows the ISF multiplier and the level. Deselecting it draws the comparison forecast at the scheduled ISF.
Analytics. An on/off user property and an experiment-change event, as for the other experiments.
Guard + Runway v2
guardAndRunwayexperiment carriesversion: 2, so v1 and v2 data can be told apart.The guard on forecast details
While Guard + Runway is on and its row is selected, forecast details draws the forecast the low guard checks as a dotted line. That's
GuardAndRunwayOutput.guarded(predictedGlucose), shown when the band applied, and the row says so. Deselecting the row hides it.The comparison forecast is no longer lowered by the band, because in v2 the displayed forecast isn't.
Testing
testSlowRetrospectiveCorrectionReadsThreeDaysOfHistory: with the experiment on, glucose from 71 h ago and a carb entry from 80 h ago are read, and the carb ratio and ISF timelines reach back past that entry. With it off, neither is read.testSlowRetrospectiveCorrectionIsRecordedOnTheDosingDecision: three days of an unexplained slow rise give a positive level and a multiplier below 1, and the multiplier is recorded on the loop's dosing decision.