Agents
polars_ts.iiot_agents.agents
Predictive-maintenance agents: spectral features, health, RUL, scheduling.
The agents form a pipeline: :class:SpectralFeatureAgent extracts vibration
band energies, :class:HealthIndexAgent fuses multi-sensor signals into a
health index, :class:RULEstimator projects Remaining Useful Life, and the
reinforcement-learning :class:MaintenanceSchedulerAgent decides when to
operate, inspect, or maintain.
SpectralFeatureAgent
Extract vibration band-energy features from a sensor window via FFT.
A dependency-free complement to the imaging module's to_spectrogram /
to_scalogram: computes RMS amplitude and the fraction of spectral
energy in low/mid/high frequency bands, which shift as bearings and gears
degrade.
Parameters
n_bands Number of equal-width frequency bands to summarise energy over.
extract(window)
Return [rms, band_0_frac, …, band_{n_bands-1}_frac] for a 1D window.
HealthIndexAgent
Fuse multi-sensor readings into a health index in [0, 1].
Degradation is modelled as growth in each sensor's RMS amplitude relative to a healthy baseline; per-sensor degradation scores are fused by weighted mean and mapped to a health index (1 = healthy, 0 = failed).
Parameters
baseline
Per-sensor healthy RMS baseline. Inferred from the first warmup
steps when omitted.
warmup
Number of initial steps used to infer baseline when not supplied.
fail_ratio
RMS ratio (current / baseline) at which health reaches 0.
weights
Optional per-sensor fusion weights (defaults to equal weighting).
fit_baseline(sensors)
Infer the healthy per-sensor RMS baseline from initial observations.
score(window)
Return a fused health index in [0, 1] for a multi-sensor window.
window is (w, n_sensors) or a single (n_sensors,) row.
RULEstimator
Estimate Remaining Useful Life by extrapolating the health trend.
Fits a linear trend to the recent health-index history and projects the
number of steps until it reaches failure_threshold.
Parameters
failure_threshold Health level defining failure. min_history Minimum number of points before a finite RUL is returned.
estimate(health_history)
Return estimated steps until failure (inf if not yet declining).
MaintenanceSchedulerAgent
Tabular Q-learning agent that schedules maintenance from health state.
The health index is discretised into n_states buckets; the agent learns
a Q-value for each (health_bucket, action) pair from environment reward,
balancing uptime against maintenance cost and failure risk.
Parameters
n_states Number of health buckets (finer = more granular timing). n_actions Size of the maintenance action set. alpha, gamma, epsilon Learning rate, discount factor, and epsilon-greedy exploration rate. seed Seed for the exploration RNG.
bucket(health)
Map a health index in [0, 1] to a discrete state bucket.
act(state, explore=False)
Return an action for state (epsilon-greedy when explore).
update(state, action, reward, next_state)
Apply a Q-learning temporal-difference update.