openaps / oref0

oref0: The open reference implementation of the OpenAPS reference design.
http://www.OpenAPS.org
MIT License
431 stars 395 forks source link

Don't over-extrapolate deviations below target #508

Closed AdrianLxM closed 7 years ago

AdrianLxM commented 7 years ago

Don't over-extrapolate deviations below target

As talked about: In order to not overreact to the short but steep rise after treating hypoglycemia with glucose I suggest use a lower extrapolation time frame.

This gave me good results:

    var deviation = Math.round(10 * 30 / 5 * ( glucose_status.avgdelta - bgi ) )/10;
    if (deviation > 0 && (bg < profile.max_bg || glucose_status.avgdelta < -2 )){
    //use only 15 minutes if BG is falling fast on a positive deviation
    //  or BG still below maxBG
        deviation = deviation/2;
    }

With the current determine-basal it might be much less of a problem anyway as it uses a "minDelta" for which the 30minute-delta is used. Maybe when correcting to a higher level for activity?

scottleibrand commented 7 years ago

I think with minDelta and other safety checks, this has been addressed.