DEV Community

PackForge Industries
PackForge Industries

Posted on

Find the Bottleneck in a Packing Line with 20 Lines of Python

A packing line is just a pipeline: fill, seal, label, carton, tape, strap, wrap. Like any pipeline, it runs at the speed of its slowest stage. If you have ever profiled code, you already know how to think about this.

Normalise every stage to the same unit

Machine specs come in mixed units: cartons per minute, cartons per hour, metres per minute of belt speed. Convert everything to units per hour first.

def per_hour(value, unit, carton_length_mm=None, gap_mm=0):
    if unit == "per_min":
        return value * 60
    if unit == "per_hour":
        return value
    if unit == "m_per_min":  # belt speed -> cartons, needs carton length
        pitch_m = (carton_length_mm + gap_mm) / 1000
        return value / pitch_m * 60
    raise ValueError(unit)
Enter fullscreen mode Exit fullscreen mode

The belt-speed case matters: a carton sealer rated at 24 m/min does not seal 24 cartons a minute. With 400 mm cartons and a 400 mm gap between them, that is 30 cartons a minute, and the real limit is usually how fast people can feed it.

Model the line

line = {
    "filling":        per_hour(18, "per_min"),
    "carton sealing": per_hour(24, "m_per_min", carton_length_mm=400, gap_mm=400),
    "flap fold + seal": per_hour(25, "per_min"),
    "random sealer":  per_hour(600, "per_hour"),
}

bottleneck = min(line, key=line.get)
for stage, rate in sorted(line.items(), key=lambda kv: kv[1]):
    util = line[bottleneck] / rate
    print(f"{stage:18} {rate:7.0f}/h  utilisation {util:5.0%}")
print("Bottleneck:", bottleneck, "->", round(line[bottleneck]), "units/hour")
Enter fullscreen mode Exit fullscreen mode

Output:

random sealer          600/h  utilisation  100%
filling               1080/h  utilisation   56%
flap fold + seal      1500/h  utilisation   40%
carton sealing        1800/h  utilisation   33%
Bottleneck: random sealer -> 600 units/hour
Enter fullscreen mode Exit fullscreen mode

(The filling rate is illustrative; the sealer figures are real spec values.)

What to do with the result

  • Upgrading a non-bottleneck stage is wasted money. In the example, a faster carton sealer changes nothing.
  • Low utilisation is a signal, not a failure: those stages can absorb short stoppages elsewhere.
  • Add buffers (accumulation tables) in front of the bottleneck so it never starves.

The sealer numbers above (24 m/min belt speed, up to 25 cartons/min with flap folding, about 500 to 700 mixed cartons per hour on a random size sealer) come from this overview of automatic carton sealing machines, if you want to plug in other real figures.

Top comments (0)