ts_shape.events.production.line_balancing
Line balancing and takt analysis for assembly / production lines.
Classic industrial-engineering line-balancing metrics computed from per-station cycle-completion signals:
- station cycle times (windowed),
- line balance efficiency, balance delay and smoothness index,
- theoretical minimum number of stations for a given takt,
- a Yamazumi (station-loading) table.
A station is identified by a boolean cycle-completion-trigger signal; the time between consecutive rising edges is that station's cycle time.
Classes
| Name | Description |
|---|---|
LineBalancingEvents | Line balancing and takt analysis from per-station cycle signals. |
LineBalancingEvents
LineBalancingEvents(
dataframe: pd.DataFrame,
station_uuids: dict[str, str],
*,
event_uuid: str = "prod:line_balance",
value_column: str = "value_bool",
time_column: str = "systime"
) -> None
Bases: Base
Line balancing and takt analysis from per-station cycle signals.
Example usage::
lb = LineBalancingEvents(
df,
station_uuids={
"uuid_s1": "Station 1",
"uuid_s2": "Station 2",
"uuid_s3": "Station 3",
},
)
lb.station_cycle_times(window="1h")
lb.balance_metrics(takt_time="55s", window="1h")
lb.yamazumi(demand=480, available_time="8h")
Functions
| Name | Description |
|---|---|
station_cycle_times | Per-station cycle-time statistics per time window. |
balance_metrics | Line-level balance metrics per time window. |
yamazumi | Yamazumi (station-loading) table over the whole dataset. |
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
dataframe | DataFrame | Input DataFrame with timeseries data. | required |
station_uuids | dict[str, str] | Mapping of cycle-completion-trigger UUID -> station name, in line order, e.g. {"u1": "Station 1"}. | required |
event_uuid | str | UUID to tag derived events with. | 'prod:line_balance' |
value_column | str | Column holding the boolean cycle trigger. | 'value_bool' |
time_column | str | Name of the timestamp column. | 'systime' |
station_cycle_times
station_cycle_times(window: str = '1h') -> pd.DataFrame
Per-station cycle-time statistics per time window.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
window | str | Resample window (e.g. "1h", "30min"). | '1h' |
Returns
| Type | Description |
|---|---|
DataFrame | Summary-shape DataFrame with columns: start, end, duration_seconds, |
DataFrame | uuid, station_name, cycle_time_mean, cycle_time_mean_seconds, |
DataFrame | cycle_time_median, cycle_time_median_seconds, cycle_time_std, |
DataFrame | cycle_time_std_seconds, cycle_count. Cycle times are in seconds. |
DataFrame | Canonical twin columns: cycle_time_mean_seconds, |
DataFrame | cycle_time_median_seconds, cycle_time_std_seconds, each |
DataFrame | right after its deprecated unitless column (same values), which |
DataFrame | is removed in the next major release. |
balance_metrics
balance_metrics(
*,
takt_time: Number | None = None,
demand: float | None = None,
available_time: Number | None = None,
window: str = "1h",
require_all_stations: bool = False
) -> pd.DataFrame
Line-level balance metrics per time window.
Balance efficiency = sum(station times) / (station_count * bottleneck).
Takt is resolved from takt_time or from demand plus
available_time; when neither is given, theoretical_min_stations
is NaN.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
takt_time | Number | None | Takt time as seconds or an offset string (e.g. "55s"). | None |
demand | float | None | Units required over available_time. | None |
available_time | Number | None | Available production time (seconds or offset string). | None |
window | str | Resample window. | '1h' |
require_all_stations | bool | When False (default), station_count counts only stations that completed at least one cycle in the window. A completely stopped or starved station -- the worst imbalance -- then drops out of the denominator and the line reads as well balanced. When True, the constructor's full set of station_uuids is used as the denominator, so a missing station drags efficiency down, and a stations_missing column reports how many known stations produced no cycle. | False |
Returns
| Type | Description |
|---|---|
DataFrame | Summary-shape DataFrame with columns: start, end, duration_seconds, |
DataFrame | n_stations, station_count, bottleneck_uuid, bottleneck_cycle_time, |
DataFrame | bottleneck_cycle_time_seconds, takt_seconds, |
DataFrame | balance_efficiency_pct, balance_delay_pct, smoothness_index, |
DataFrame | theoretical_min_stations (plus stations_missing when |
DataFrame | require_all_stations=True). |
DataFrame | Canonical twin columns: station_count (after n_stations), |
DataFrame | bottleneck_cycle_time_seconds (after |
DataFrame | bottleneck_cycle_time); each holds the same values as the |
DataFrame | deprecated column right before it, which is removed in the next |
DataFrame | major release. |
yamazumi
yamazumi(
*,
takt_time: Number | None = None,
demand: float | None = None,
available_time: Number | None = None
) -> pd.DataFrame
Yamazumi (station-loading) table over the whole dataset.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
takt_time | Number | None | Takt time as seconds or an offset string. | None |
demand | float | None | Units required over available_time. | None |
available_time | Number | None | Available production time (seconds or offset string). | None |
Returns
| Type | Description |
|---|---|
DataFrame | DataFrame with columns: uuid, station_name, cycle_time_mean, |
DataFrame | cycle_time_mean_seconds, takt_seconds, loading_pct, |
DataFrame | idle_to_takt_seconds, is_bottleneck. Stations are returned in the |
DataFrame | order given to the constructor. |
DataFrame | Canonical twin columns: cycle_time_mean_seconds (after |
DataFrame | cycle_time_mean); it holds the same values as the deprecated |
DataFrame | column right before it, which is removed in the next major |
DataFrame | release. |