idinn: Inventory-Dynamics Control with Neural Networks

idinn implements inventory dynamics–informed neural network and other related controllers for solving single-sourcing and dual-sourcing problems. Controllers and inventory dynamics are implemented into customizable objects using PyTorch as backend to enable users to find the optimal controllers for the user-specified inventory systems.

Demo

For a quick demo, you can run our Streamlit app. The app allows you to interactively train and evaluate neural controllers for user-specified dual-sourcing systems.

Alternatively, refer to our Jupyter notebook in Colab.

Example Usage

>>> from idinn.sourcing_model import SingleSourcingModel
>>> from idinn.single_controller import BaseStockController
>>> from idinn.demand import UniformDemand

>>> # Initialize the sourcing model
>>> single_sourcing_model = SingleSourcingModel(
...     lead_time=0,
...     holding_cost=5,
...     shortage_cost=495,
...     batch_size=32,
...     init_inventory=10,
...     demand_generator=UniformDemand(low=1, high=4),
... )

>>> # Initialize a controller
>>> controller = BaseStockController()

>>> # Train the controller
>>> controller.fit(
...     sourcing_model=single_sourcing_model,
...     seed=42,
... )

>>> # Simulate and plot the results
>>> controller.plot(sourcing_model=single_sourcing_model, sourcing_periods=100)

>>> # Calculate the optimal order quantity for applications
>>> controller.predict(current_inventory=10, past_orders=[1, 5])
0