Launching over version 0.1.2. Solving the actions list as input.
Project description
📊 Reinforcement Learning in Inventory Optimization using Q-Learning
This repository contains a Python implementation of an inventory optimization model using Q-Learning, a Reinforcement Learning (RL) algorithm. The model is designed to help manage inventory levels by making optimal decisions on order quantities based on forecasted demand, initial stock levels, and inventory capacity.
🚀 Introduction
Efficient inventory management is crucial for reducing costs and avoiding stockouts or overstocking. This project implements a Q-Learning-based optimizer that learns to make optimal inventory decisions over time. It considers factors such as forecasted demand, security stock, and inventory capacity to minimize costs and maintain optimal stock levels.
✨ Features
- 🧠 Q-Learning Algorithm: Implements Q-Learning for decision-making based on temporal difference learning.
- 🔄 Dynamic Inventory Management: Adjusts inventory levels based on forecasted consumption dynamically without traditional rules.
- 🛠️ Customizable Parameters: Adjustable learning rate, discount factor, and exploration rate.
- 📈 Visualizations: Plots inventory levels, forecast, and order amounts to provide insights into the optimization process.
Installation 🚀
You can install the RLInventoryOpt library directly from GitHub. Follow the instructions below to get started!
Install from GitHub 🌟
To install the library directly from GitHub, use the following command:
pip install RLInventoryOpt
🔧 Usage
Initialize the Model
Create an instance of the QLearningOptimizer class.
To create any model for inventory optimization, you have to follow this:
- Create a forecasting model and predict the future consuption.
- You have to know the limitations of your system such as security stock, maximum level of stock, initial stock, lead time, and the minimal order quantity.
- The actions are limited based from 1 to 6 times the minimal order quantity.
from RLInventoryOpt.qlearning import QLearningOptimizer
import numpy as np
# Example forecasted demand for 6 months
forecast = np.array([400, 325, 356, 210, 150, 400])
# Initial conditions of the system
initial_state = {
"stock": 800,
"leadTime": 2,
"minimumOrder": 100,
"securityStock": 200,
"maximalCapacity": 1000
}
# Define the actions
actions = ["no", "m", "2m", "3m", "4m", "5m", "6m"]
# Initialize the optimizer
model = QLearningOptimizer(
forecast=forecast,
initial_stock=initial_state["stock"],
security_stock=initial_state["securityStock"],
capacity=initial_state["maximalCapacity"],
n_actions=actions,
min_order=initial_state["minimumOrder"],
lead_time=initial_state["leadTime"],
alpha=0.1,
gamma=0.6,
epsilon=0.1
)
# Train the model
model.fit(epochs=1000)
# Predict inventory levels and actions
predictions = model.predict()
# Plot the results
model.plot("bar")
A detailed explanation can be found on this article on Medium: https://lnkd.in/gDEvav59
⚙️ Customization
You can customize the behavior of the agent modifying the parameters for training.
- alpha (float): Learning rate (default: 0.1)
- gamma (float): Discount factor (default: 0.6)
- epsilon (float): Exploration rate (default: 0.1)
☕ Support the Project
If you find this inventory optimization tool helpful and would like to support its continued development, consider buying me a coffee. Your support helps maintain and improve this project!
Other Ways to Support
- ⭐ Star this repository
- 🍴 Fork it and contribute
- 📢 Share it with others who might find it useful
- 🐛 Report issues or suggest new features
Your support, in any form, is greatly appreciated! 🙏
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rlinventoryopt-0.1.5.tar.gz.
File metadata
- Download URL: rlinventoryopt-0.1.5.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c348815cf55ab0dd9f775667f69b2402759a443a1b28e3b2012e92258044d4e
|
|
| MD5 |
2bf32e5bd9231232039cb9721ab7caa3
|
|
| BLAKE2b-256 |
06db73f94427a667747b7251f5e1688cdb55247e29c44be010f8482ba734f50a
|
Provenance
The following attestation bundles were made for rlinventoryopt-0.1.5.tar.gz:
Publisher:
cd.yaml on sebassaras02/rf_inventory_optimization
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rlinventoryopt-0.1.5.tar.gz -
Subject digest:
8c348815cf55ab0dd9f775667f69b2402759a443a1b28e3b2012e92258044d4e - Sigstore transparency entry: 186713637
- Sigstore integration time:
-
Permalink:
sebassaras02/rf_inventory_optimization@fc60f955764a0fe5ea50cc6cf13a506fdb6545a2 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/sebassaras02
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yaml@fc60f955764a0fe5ea50cc6cf13a506fdb6545a2 -
Trigger Event:
workflow_run
-
Statement type:
File details
Details for the file rlinventoryopt-0.1.5-py3-none-any.whl.
File metadata
- Download URL: rlinventoryopt-0.1.5-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e04979b4afa7357287442067ecec0ff5a4951ba1b9ec34d13ef396de999662a3
|
|
| MD5 |
3e1b8af5fa4006657747901f0157f247
|
|
| BLAKE2b-256 |
51d374d29a41f22b24da3c287ae76947e8e32ed4eb4808a27678a45ac3de2a84
|
Provenance
The following attestation bundles were made for rlinventoryopt-0.1.5-py3-none-any.whl:
Publisher:
cd.yaml on sebassaras02/rf_inventory_optimization
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rlinventoryopt-0.1.5-py3-none-any.whl -
Subject digest:
e04979b4afa7357287442067ecec0ff5a4951ba1b9ec34d13ef396de999662a3 - Sigstore transparency entry: 186713645
- Sigstore integration time:
-
Permalink:
sebassaras02/rf_inventory_optimization@fc60f955764a0fe5ea50cc6cf13a506fdb6545a2 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/sebassaras02
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yaml@fc60f955764a0fe5ea50cc6cf13a506fdb6545a2 -
Trigger Event:
workflow_run
-
Statement type: