Supply chain¶
Multi-SKU warehouses and the inventory record they hold.
InventoryItems¶
A dataclass capturing the per-SKU attributes a warehouse needs:
inv = sw.InventoryItems(
part_names=["widget", "gizmo", "sprocket"],
unit_cost=[1.0, 2.5, 0.7],
stock_level=[20.0, 10.0, 50.0],
batchsize=[20.0, 10.0, 50.0],
reorder_points=[5.0, 3.0, 15.0],
repairable_prc=[0.0, 0.0, 0.0],
repair_times=[1.0, 1.0, 1.0],
newbuy_leadtimes=[3.0, 5.0, 2.0],
)
All list-shaped fields must be the same length. Numeric fields are
coerced to np.ndarray after construction so warehouse operations stay
vectorised.
Warehouse¶
wh = sw.Warehouse(inventory=inv, name="store")
env = sw.SimEnvironment(dt=1.0, end=80.0)
env.register(wh)
env.run()
Decrement stock during a tick using wh.decrement_vector(per_sku_amounts).
The warehouse handles the reorder logic against inventory.reorder_points.
Recording stock for plots¶
rec = sw.WarehouseStockRecorder(wh, name="store_stock")
env.register(rec) # AFTER the warehouse so the recorder snapshots
# post-tick state
...
sw.plot_warehouse_stock(rec).write_html("stock.html",
include_plotlyjs="cdn")
API¶
Inventory and supply-chain simulation primitives.
InventoryItems
dataclass
¶
InventoryItems(part_names: Sequence[str], unit_cost: Sequence[float], stock_level: Sequence[float], batchsize: Sequence[float], reorder_points: Sequence[float], repairable_prc: Sequence[float], repair_times: Sequence[float], newbuy_leadtimes: Sequence[float], shelf_life: Sequence[float] = list(), failure_rate: Sequence[float] = list())
A collection of SKUs that share a storage location.
All list-shaped fields must be the same length (one entry per SKU).
Numeric fields are coerced to np.ndarray on __post_init__ so
vectorised warehouse operations don't have to re-check types at runtime.
Warehouse
¶
Warehouse(inventory: InventoryItems, name: str | None = None, parent_warehouse: 'Warehouse | str' = 'industry')
Bases: Entity
Multi-SKU warehouse with (R, Q) reorder policy.
Source code in src/simweave/supplychain/warehouse.py
decrement_vector
¶
Vectorised consumption; returns a boolean mask of which SKUs succeeded.
Source code in src/simweave/supplychain/warehouse.py
process_orders
¶
estimate_demand_rate
¶
Crude demand rate = lifetime orders / total_sim_time.