Skip to main content
Version: Next

ts_shape.events.production.bottleneck_detection

Classes
NameDescription
BottleneckDetectionEventsProduction: Bottleneck Detection

BottleneckDetectionEvents​

classsource
BottleneckDetectionEvents(
dataframe: pd.DataFrame,
*,
time_column: str = "systime",
event_uuid: str = "prod:bottleneck",
value_column: str = "value_bool",
run_states: Collection[Any] | None = None,
value_range: tuple[float | None, float | None] | None = None
) -> None

Bases: Base

Production: Bottleneck Detection

Identify which station constrains a production line by analyzing utilization of multiple boolean run-state signals.

Methods:

  • station_utilization: Per-station uptime percentage per window.
  • detect_bottleneck: Identify the bottleneck station per window.
  • shifting_bottleneck: Track when the bottleneck moves between stations.
  • throughput_constraint_summary: Summary statistics across all stations.
Functions
NameDescription
station_utilizationPer-station uptime percentage per time window.
detect_bottleneckIdentify the bottleneck station per window.
shifting_bottleneckTrack when the bottleneck identity changes between stations.
throughput_constraint_summarySummary statistics for bottleneck analysis.
Parameters
NameTypeDescriptionDefault
dataframeDataFrameLong-format frame holding one boolean run-state signal per station (uuid identifies the station).required
time_columnstrTimestamp column.'systime'
event_uuidstrUUID stamped on emitted events.'prod:bottleneck'
value_columnstrColumn holding the run state (truthy = running).'value_bool'
run_statesCollection[Any] | NoneValues of the run signal that mean running (e.g. {2} for a mode signal where 2 is automatic, or {"RUN"}); every other known value is not running. None (default) uses value_range or reads the signal as a bool, with a DataQualityWarning when it is not one.None
value_rangetuple[float | None, float | None] | None(lower, upper) inclusive bounds; a value inside counts as running (either bound may be None). Used when run_states is None.None

station_utilization​

methodsource
station_utilization(
station_uuids: list[str], window: str = "1h", *, time_weighted: bool = True
) -> pd.DataFrame

Per-station uptime percentage per time window.

Parameters
NameTypeDescriptionDefault
station_uuidslist[str]List of UUID strings identifying station run-state signals.required
windowstrResample window (e.g. '1h', '30m').'1h'
time_weightedboolWhen True (default), utilization is time-weighted: each sample is weighted by the gap to the next sample (as in RuntimeAccountingEvents), so it reflects wall-clock time in the running state on change-encoded and irregularly sampled signals. The trailing sample of a station has no successor and carries no weight. When False, utilization is the mean of the boolean samples in the window, which equals the time share only under uniform sampling.True
Returns
TypeDescription
DataFrameDataFrame with columns: start, end (start + window),
DataFrameduration_seconds, uuid (the station uuid), source_uuid (the
DataFramestation uuid), utilization_pct.

detect_bottleneck​

methodsource
detect_bottleneck(
station_uuids: list[str], window: str = "1h", *, time_weighted: bool = True
) -> pd.DataFrame

Identify the bottleneck station per window.

The bottleneck is the station with the highest utilization — it is always running because it is the constraint.

Parameters
NameTypeDescriptionDefault
station_uuidslist[str]List of station run-state UUIDs.required
windowstrResample window.'1h'
time_weightedboolForwarded to :meth:station_utilization (default True).True
Returns
TypeDescription
DataFrameDataFrame with columns: start, end, duration_seconds, uuid (the
DataFramedetector's event uuid), source_uuid (the bottleneck station uuid),
DataFramebottleneck_uuid, utilization_pct.

shifting_bottleneck​

methodsource
shifting_bottleneck(
station_uuids: list[str], window: str = "1h", *, time_weighted: bool = True
) -> pd.DataFrame

Track when the bottleneck identity changes between stations.

Parameters
NameTypeDescriptionDefault
station_uuidslist[str]List of station run-state UUIDs.required
windowstrResample window.'1h'
time_weightedboolForwarded to :meth:station_utilization.True
Returns
TypeDescription
DataFrameDataFrame with columns: systime, uuid (the detector's event uuid),
DataFramesource_uuid ("<from_uuid>,<to_uuid>"), from_uuid, to_uuid,
DataFrameprevious_utilization, new_utilization.

throughput_constraint_summary​

methodsource
throughput_constraint_summary(
station_uuids: list[str],
window: str = "1h",
*,
time_weighted: bool = True,
as_frame: bool = True
) -> pd.DataFrame | dict[str, Any]

Summary statistics for bottleneck analysis.

Parameters
NameTypeDescriptionDefault
station_uuidslist[str]List of station run-state UUIDs.required
windowstrResample window.'1h'
time_weightedboolForwarded to :meth:station_utilization.True
as_frameboolWhen True (default), return one row per station (see below). as_frame=False returns the dictionary form; it is deprecated, emits a DeprecationWarning and will be removed in the next major release.True
Returns
TypeDescription
DataFrame | dict[str, Any]With as_frame=True (default), a summary DataFrame with one row
DataFrame | dict[str, Any]per station that has data, in station_uuids order, columns:
DataFrame | dict[str, Any]- start, end, duration_seconds: the analysed span (first window start to last window end), the same on every row
DataFrame | dict[str, Any]- uuid, source_uuid: the station uuid
DataFrame | dict[str, Any]- bottleneck_count: windows in which the station was the bottleneck (bottleneck_counts of the dict form)
DataFrame | dict[str, Any]- bottleneck_pct: share of windows, 0-100 (bottleneck_percentages)
DataFrame | dict[str, Any]- avg_utilization_pct: mean utilization over the windows (avg_utilization_per_station)
DataFrame | dict[str, Any]- most_frequent_bottleneck: True on the station that was the bottleneck most often
DataFrame | dict[str, Any]With as_frame=False (deprecated), a dict with:
DataFrame | dict[str, Any]bottleneck_counts, bottleneck_percentages,
DataFrame | dict[str, Any]most_frequent_bottleneck, avg_utilization_per_station.