downweight Autosens if not enough data
This commit is contained in:
parent
53ba6d46d5
commit
064a8915a0
|
@ -7,5 +7,8 @@ import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult;
|
|||
*/
|
||||
|
||||
public interface SensitivityInterface {
|
||||
double MIN_HOURS = 1;
|
||||
double MIN_HOURS_FULL_AUTOSENS = 4;
|
||||
|
||||
AutosensResult detectSensitivity(long fromTime, long toTime);
|
||||
}
|
||||
|
|
|
@ -158,8 +158,18 @@ public class SensitivityAAPSPlugin extends PluginBase implements SensitivityInte
|
|||
ratio = Math.max(ratio, SafeParse.stringToDouble(SP.getString(R.string.key_openapsama_autosens_min, "0.7")));
|
||||
ratio = Math.min(ratio, SafeParse.stringToDouble(SP.getString(R.string.key_openapsama_autosens_max, "1.2")));
|
||||
|
||||
//If not-excluded data <= MIN_HOURS -> don't do Autosens
|
||||
//If not-excluded data >= MIN_HOURS_FULL_AUTOSENS -> full Autosens
|
||||
//Between MIN_HOURS and MIN_HOURS_FULL_AUTOSENS: gradually increase autosens
|
||||
double autosensContrib = (Math.min(Math.max(MIN_HOURS, deviationsArray.size() / 12d), MIN_HOURS_FULL_AUTOSENS) - MIN_HOURS) / (MIN_HOURS_FULL_AUTOSENS - MIN_HOURS);
|
||||
ratio = autosensContrib * (ratio - 1) + 1;
|
||||
|
||||
if (autosensContrib != 1d) {
|
||||
ratioLimit += "(" + deviationsArray.size() + " of " + MIN_HOURS_FULL_AUTOSENS * 12 + " values) ";
|
||||
}
|
||||
|
||||
if (ratio != rawRatio) {
|
||||
ratioLimit = "Ratio limited from " + rawRatio + " to " + ratio;
|
||||
ratioLimit += "Ratio limited from " + rawRatio + " to " + ratio;
|
||||
log.debug(ratioLimit);
|
||||
}
|
||||
|
||||
|
|
|
@ -170,8 +170,18 @@ public class SensitivityOref0Plugin extends PluginBase implements SensitivityInt
|
|||
ratio = Math.max(ratio, SafeParse.stringToDouble(SP.getString(R.string.key_openapsama_autosens_min, "0.7")));
|
||||
ratio = Math.min(ratio, SafeParse.stringToDouble(SP.getString(R.string.key_openapsama_autosens_max, "1.2")));
|
||||
|
||||
//If not-excluded data <= MIN_HOURS -> don't do Autosens
|
||||
//If not-excluded data >= MIN_HOURS_FULL_AUTOSENS -> full Autosens
|
||||
//Between MIN_HOURS and MIN_HOURS_FULL_AUTOSENS: gradually increase autosens
|
||||
double autosensContrib = (Math.min(Math.max(MIN_HOURS, deviationsArray.size() / 12d), MIN_HOURS_FULL_AUTOSENS) - MIN_HOURS) / (MIN_HOURS_FULL_AUTOSENS - MIN_HOURS);
|
||||
ratio = autosensContrib * (ratio - 1) + 1;
|
||||
|
||||
if (autosensContrib != 1d) {
|
||||
ratioLimit += "(" + deviationsArray.size() + " of " + MIN_HOURS_FULL_AUTOSENS * 12 + " values) ";
|
||||
}
|
||||
|
||||
if (ratio != rawRatio) {
|
||||
ratioLimit = "Ratio limited from " + rawRatio + " to " + ratio;
|
||||
ratioLimit += "Ratio limited from " + rawRatio + " to " + ratio;
|
||||
log.debug(ratioLimit);
|
||||
}
|
||||
|
||||
|
|
|
@ -179,8 +179,18 @@ public class SensitivityOref1Plugin extends PluginBase implements SensitivityInt
|
|||
ratio = Math.max(ratio, SafeParse.stringToDouble(SP.getString(R.string.key_openapsama_autosens_min, "0.7")));
|
||||
ratio = Math.min(ratio, SafeParse.stringToDouble(SP.getString(R.string.key_openapsama_autosens_max, "1.2")));
|
||||
|
||||
//If not-excluded data <= MIN_HOURS -> don't do Autosens
|
||||
//If not-excluded data >= MIN_HOURS_FULL_AUTOSENS -> full Autosens
|
||||
//Between MIN_HOURS and MIN_HOURS_FULL_AUTOSENS: gradually increase autosens
|
||||
double autosensContrib = (Math.min(Math.max(MIN_HOURS, deviationsArray.size() / 12d), MIN_HOURS_FULL_AUTOSENS) - MIN_HOURS) / (MIN_HOURS_FULL_AUTOSENS - MIN_HOURS);
|
||||
ratio = autosensContrib * (ratio - 1) + 1;
|
||||
|
||||
if (autosensContrib != 1d) {
|
||||
ratioLimit += "(" + deviationsArray.size() + " of " + MIN_HOURS_FULL_AUTOSENS * 12 + " values) ";
|
||||
}
|
||||
|
||||
if (ratio != rawRatio) {
|
||||
ratioLimit = "Ratio limited from " + rawRatio + " to " + ratio;
|
||||
ratioLimit += "Ratio limited from " + rawRatio + " to " + ratio;
|
||||
log.debug(ratioLimit);
|
||||
}
|
||||
|
||||
|
|
|
@ -180,9 +180,18 @@ public class SensitivityWeightedAveragePlugin extends PluginBase implements Sens
|
|||
ratio = Math.max(ratio, SafeParse.stringToDouble(SP.getString(R.string.key_openapsama_autosens_min, "0.7")));
|
||||
ratio = Math.min(ratio, SafeParse.stringToDouble(SP.getString(R.string.key_openapsama_autosens_max, "1.2")));
|
||||
|
||||
//If not-excluded data <= MIN_HOURS -> don't do Autosens
|
||||
//If not-excluded data >= MIN_HOURS_FULL_AUTOSENS -> full Autosens
|
||||
//Between MIN_HOURS and MIN_HOURS_FULL_AUTOSENS: gradually increase autosens
|
||||
double autosensContrib = (Math.min(Math.max(MIN_HOURS, data.size() / 12d), MIN_HOURS_FULL_AUTOSENS) - MIN_HOURS) / (MIN_HOURS_FULL_AUTOSENS - MIN_HOURS);
|
||||
ratio = autosensContrib * (ratio - 1) + 1;
|
||||
|
||||
if (autosensContrib != 1d) {
|
||||
ratioLimit += "(" + data.size() + " of " + MIN_HOURS_FULL_AUTOSENS * 12 + " values) ";
|
||||
}
|
||||
|
||||
if (ratio != rawRatio) {
|
||||
ratioLimit = "Ratio limited from " + rawRatio + " to " + ratio;
|
||||
if (Config.logAutosensData)
|
||||
ratioLimit += "Ratio limited from " + rawRatio + " to " + ratio;
|
||||
log.debug(ratioLimit);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue