Skip to content

Env

polars_ts.iiot_agents.env

Predictive-maintenance environment for industrial IoT sensor streams.

Models a machine degrading toward failure as a multi-sensor time series. At each step a maintenance agent chooses to operate, inspect, or maintain; the reward trades machine uptime against inspection/maintenance cost and a large penalty for running a degraded machine to failure.

The environment plays back a fixed degradation trajectory (actions do not mutate the sensor stream); the learning signal is the timing of maintenance relative to the true failure point.

MachineEnv

Environment over a machine's multi-sensor degradation trajectory.

Parameters

sensors 2D array (n_steps, n_sensors) of sensor readings (e.g. vibration amplitude, temperature, current). May contain NaN for dropped samples (carried forward). failure_step Index at which the machine fails. If omitted it is inferred from health crossing failure_threshold (or the last step if never). health Optional ground-truth health trajectory in [0, 1] (1 = healthy). When omitted, downstream agents estimate health from sensors. failure_threshold Health level at or below which the machine is considered failed. maintenance_cost, inspect_cost, failure_penalty, uptime_reward Reward components (see :meth:step).

reset()

Reset to the first observation and return it.

step(action)

Advance one observation given a maintenance action.

Reward logic:

  • MAINTAIN — pay maintenance_cost but gain a timeliness bonus that peaks just before failure_step (rewards well-timed preventive maintenance; penalises maintaining a healthy machine).
  • INSPECT — pay a small inspect_cost.
  • OPERATE — earn uptime_reward before failure; incur failure_penalty if operated at/after failure_step.
Returns

tuple (observation, reward, done, info).

_forward_fill(arr)

Carry the last valid reading forward per sensor; back-fill leading NaNs.