import pandas as pd import numpy as np def optimize_slotting(df: pd.DataFrame): """ Assign aisle/rack based on velocity. Fast → aisles 1–5 Medium → 6–12 Slow → 13–20 """ df = df.copy() def assign_location(row): if row["Velocity"].lower() == "fast": aisle = np.random.randint(1, 6) elif row["Velocity"].lower() == "medium": aisle = np.random.randint(6, 12) else: aisle = np.random.randint(13, 20) rack = np.random.randint(1, 30) return aisle, rack df["Suggested Aisle"], df["Suggested Rack"] = zip(*df.apply(assign_location, axis=1)) return df