TieredGpsAlgorithm

class TieredGpsAlgorithm(profile: TuningProfile = milewayV1Profile(), envelope: DeviceEnvelope = DeviceEnvelope.Default) : MileageAlgorithm

Kalman-smoothed, speed-adaptive GPS cleaning — the algorithm Mileway's LocationProcessor actually runs today, extracted onto the MileageAlgorithm seam so its thresholds can be swept and its output can be shadow-compared against other algorithms.

milewayV1Profile reproduces LocationProcessor's hardcoded defaults exactly (same source: AbnormalDetectionConfig.DEFAULT + LocationTrackingConstants), so this class with that profile and DeviceEnvelope.Default is a drop-in numerical match for the shipped app.

Two deliberate divergences from the source, both forced by the seam this class conforms to rather than by choice:

  • LocationProcessor.process() also takes isPaused/suppressSpike/motionStill/ harshAccel — caller-supplied context that has no home on Fix. MileageAlgorithm.process is deliberately Fix-only (see its doc), so those overrides are out of scope here; only the context recoverable from the fix stream itself (accuracy, speed, mock, elapsed time) is used.

  • A hard "instant teleport" spike is folded into abnormalDistanceM and spikeDistanceM in the source (double counted, spike-as-audit-tag). AlgorithmState's documented invariant requires cleanedM == originalM - abnormalM - mockM with spike excluded from originalM entirely — so here a spike is its own exclusive DistanceBucket.SPIKE, never also counted as DistanceBucket.ABNORMAL or folded into originalM. Total spike+abnormal+cleaned+mock distance is unchanged; which bucket a spike lands in is not.

DeviceEnvelope scales every threshold: the two absolute "ceiling" knobs scale as a ratio against their own default (so DeviceEnvelope.Default is a strict no-op regardless of what a tuning profile sets them to), the three multiplier fields apply directly.

Constructors

Link copied to clipboard
constructor(profile: TuningProfile = milewayV1Profile(), envelope: DeviceEnvelope = DeviceEnvelope.Default)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override val id: AlgorithmId

Stable identity, used for persistence, selection and shadow-mode result attribution.

Link copied to clipboard
open override val knobs: List<KnobSpec>

The knobs this algorithm understands. Drives generic tuning UI and automated sweeps.

Functions

Link copied to clipboard
open fun flush(): List<FixResult>

Emit anything still buffered and end the journey.

Link copied to clipboard
open override fun process(fix: Fix): FixResult

Consume one fix and report what it contributed.

Link copied to clipboard
open override fun reset(session: SessionContext)

Begin a new journey. Must clear all accumulated state.

Link copied to clipboard
open override fun restore(state: AlgorithmState)

Resume from a snapshot.

Link copied to clipboard
open override fun snapshot(): AlgorithmState

Capture enough state to resume this journey later. Must round-trip with restore.