diff --git a/Sources/LoopAlgorithm/AlgorithmInput.swift b/Sources/LoopAlgorithm/AlgorithmInput.swift index 1cc1e28..42c2ded 100644 --- a/Sources/LoopAlgorithm/AlgorithmInput.swift +++ b/Sources/LoopAlgorithm/AlgorithmInput.swift @@ -37,7 +37,7 @@ public protocol AlgorithmInput { var emulation: AlgorithmEmulationOptions? { get } // Defaults to nil (no emulation) /// Optional algorithm experiments; the empty set is standard LoopAlgorithm. Conforming types that do /// not provide it get the empty set. - var experiments: Set { get } + var experiments: Set { get } /// The person's volatility baseline for the `guardAndRunway` experiment's volatility band: the median /// σ5 (mg/dL per 5 min) over their last four weeks of glucose, from `GlucoseVolatility.baseline(_:)`. /// When nil it is computed from `glucoseHistory` if that holds at least a day of readings; otherwise @@ -47,6 +47,6 @@ public protocol AlgorithmInput { public extension AlgorithmInput { var emulation: AlgorithmEmulationOptions? { nil } - var experiments: Set { [] } + var experiments: Set { [] } var volatilityBaseline: Double? { nil } } diff --git a/Sources/LoopAlgorithm/AlgorithmInputFixture.swift b/Sources/LoopAlgorithm/AlgorithmInputFixture.swift index 9493f06..9f26e39 100644 --- a/Sources/LoopAlgorithm/AlgorithmInputFixture.swift +++ b/Sources/LoopAlgorithm/AlgorithmInputFixture.swift @@ -37,7 +37,7 @@ public struct AlgorithmInputFixture: AlgorithmInput { public var gradualTransitionsThreshold: Double? public var emulation: AlgorithmEmulationOptions? /// Optional experiments; absent in existing fixtures, which therefore run standard LoopAlgorithm. - public var experiments: Set = [] + public var experiments: Set = [] public var volatilityBaseline: Double? public var recommendationInsulinModel: InsulinModel { @@ -155,7 +155,7 @@ extension AlgorithmInputFixture: Codable { self.automaticBolusApplicationFactor = try container.decodeIfPresent(Double.self, forKey: .automaticBolusApplicationFactor) self.gradualTransitionsThreshold = try container.decodeIfPresent(Double.self, forKey: .gradualTransitionsThreshold) ?? 40.0 self.emulation = try container.decodeIfPresent(AlgorithmEmulationOptions.self, forKey: .emulation) - self.experiments = Set(try container.decodeIfPresent([AlgorithmExperiment].self, forKey: .experiments) ?? []) + self.experiments = Set(try container.decodeIfPresent([ExperimentOption].self, forKey: .experiments) ?? []) self.volatilityBaseline = try container.decodeIfPresent(Double.self, forKey: .volatilityBaseline) } diff --git a/Sources/LoopAlgorithm/Experiments/AlgorithmExperiments.swift b/Sources/LoopAlgorithm/Experiments/AlgorithmExperiments.swift index 3367092..c21076c 100644 --- a/Sources/LoopAlgorithm/Experiments/AlgorithmExperiments.swift +++ b/Sources/LoopAlgorithm/Experiments/AlgorithmExperiments.swift @@ -12,7 +12,7 @@ import Foundation /// Each experiment is an on/off switch with no tunable parameters, so that people who choose the same /// switches pool into one group whose results can be compared. Experiments combine: each acts on its own /// part of the algorithm, and a combination is its own group. -public enum AlgorithmExperiment: String, Codable, CaseIterable, Sendable { +public enum ExperimentOption: String, Codable, CaseIterable, Sendable { /// LoopEval guard + runway (C20 + C29 + C40). A lows guard, plus a little more correction when there /// is room for it: @@ -71,7 +71,7 @@ struct ExperimentParameters: Equatable { /// `volatilityBaseline` is the person's median σ5 (mg/dL per 5 min); only the band uses it. /// Integral RC and the glucose-based application factor are switched where they act, not here. - init(experiments: Set, volatilityBaseline: Double?) { + init(experiments: Set, volatilityBaseline: Double?) { if experiments.contains(.guardAndRunway) { postLowRiseCut = PostLowRiseCut() runwayReserve = RunwayReserve() diff --git a/Sources/LoopAlgorithm/LoopAlgorithm.swift b/Sources/LoopAlgorithm/LoopAlgorithm.swift index cbf3b07..d905bd7 100644 --- a/Sources/LoopAlgorithm/LoopAlgorithm.swift +++ b/Sources/LoopAlgorithm/LoopAlgorithm.swift @@ -185,7 +185,7 @@ public struct LoopAlgorithm { gradualTransitionsThreshold: Double? = 40.0, momentumVelocityMaximum: LoopQuantity? = nil, emulation: AlgorithmEmulationOptions = AlgorithmEmulationOptions(), - experiments: Set = [] + experiments: Set = [] ) -> LoopPrediction where CarbType: CarbEntry, GlucoseType: GlucoseSampleValue, InsulinDoseType: InsulinDose { var prediction: [PredictedGlucoseValue] = [] diff --git a/Sources/LoopAlgorithm/RetrospectiveCorrection/IntegralRetrospectiveCorrection.swift b/Sources/LoopAlgorithm/RetrospectiveCorrection/IntegralRetrospectiveCorrection.swift index a132bb2..3e7b95f 100644 --- a/Sources/LoopAlgorithm/RetrospectiveCorrection/IntegralRetrospectiveCorrection.swift +++ b/Sources/LoopAlgorithm/RetrospectiveCorrection/IntegralRetrospectiveCorrection.swift @@ -75,7 +75,7 @@ public class IntegralRetrospectiveCorrection: RetrospectiveCorrection { var currentDate: Date = Date() /// Experimental weight on the correction while the current discrepancy is positive (rising), set by - /// the post-low rise-cut (see `AlgorithmExperiment`). 1.0 is standard IRC. + /// the post-low rise-cut (see `ExperimentOption`). 1.0 is standard IRC. let riseScale: Double public init(effectDuration: TimeInterval, diff --git a/Sources/LoopAlgorithm/RetrospectiveCorrection/StandardRetrospectiveCorrection.swift b/Sources/LoopAlgorithm/RetrospectiveCorrection/StandardRetrospectiveCorrection.swift index 2060c82..6d9220f 100644 --- a/Sources/LoopAlgorithm/RetrospectiveCorrection/StandardRetrospectiveCorrection.swift +++ b/Sources/LoopAlgorithm/RetrospectiveCorrection/StandardRetrospectiveCorrection.swift @@ -26,7 +26,7 @@ public class StandardRetrospectiveCorrection: RetrospectiveCorrection { private let unit = LoopUnit.milligramsPerDeciliter /// Experimental weight on a positive (rising) discrepancy, set by the post-low rise-cut (see - /// `AlgorithmExperiment`). 1.0 is standard RC. + /// `ExperimentOption`). 1.0 is standard RC. let riseScale: Double public init(effectDuration: TimeInterval, useLegacyDecay: Bool = false, riseScale: Double = 1.0) { diff --git a/Tests/LoopAlgorithmTests/AlgorithmExperimentsTests.swift b/Tests/LoopAlgorithmTests/AlgorithmExperimentsTests.swift index 861954f..6a6bcf5 100644 --- a/Tests/LoopAlgorithmTests/AlgorithmExperimentsTests.swift +++ b/Tests/LoopAlgorithmTests/AlgorithmExperimentsTests.swift @@ -272,7 +272,7 @@ final class AlgorithmExperimentsTests: XCTestCase { let back = try decoder.decode(AlgorithmInputFixture.self, from: encoder.encode(input)) XCTAssertEqual(back.experiments, [.guardAndRunway]) XCTAssertEqual(back.volatilityBaseline, 4.2) - XCTAssertEqual(AlgorithmExperiment.allCases, [.guardAndRunway, .integralRetrospectiveCorrection, .glucoseBasedApplicationFactor]) + XCTAssertEqual(ExperimentOption.allCases, [.guardAndRunway, .integralRetrospectiveCorrection, .glucoseBasedApplicationFactor]) } func testFixtureRoundTripCarriesACombination() throws {