-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
163 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,186 +1,210 @@ | ||
# Job Shop Scheduling Algorithms | ||
# Performant Job Shop Scheduling (PER-JSP) | ||
|
||
This project implements various algorithms for solving the Job Shop Scheduling Problem (JSSP), including Q-Learning and Actor-Critic methods. It provides both a C++ library and Python bindings for easy integration into different environments. | ||
A high-performance Job Shop Scheduling Problem (JSSP) solver with C++ core and Python bindings. The project provides both a fast C++ library and intuitive Python interface for solving JSSP using various algorithms including Q-Learning and Actor-Critic methods. | ||
|
||
## Features | ||
|
||
- Job Shop Environment simulation | ||
- Q-Learning algorithm implementation | ||
- Actor-Critic algorithm implementation | ||
- Taillard problem instance generator | ||
- Visualization of scheduling results | ||
- Python bindings for easy integration | ||
- 🚀 High-performance C++ core with Python bindings | ||
- 🐍 Pure Python fallback implementation | ||
- 🔧 Flexible environment configuration | ||
- 📊 Built-in visualization | ||
- 📈 Support for standard benchmark problems (Taillard) | ||
- 🧮 Multiple solver algorithms | ||
|
||
### Implemented Algorithms | ||
| Algorithm | Implemented | Notes | | ||
|-----------|:-----------:|-------| | ||
| Q-Learning | ✅ | | | ||
| SARSA | ❌ | | | ||
| DQN (Deep Q-Network) | ❌ | | | ||
| Double DQN | ❌ | | | ||
| Dueling DQN | ❌ | | | ||
| Actor-Critic | ✅ | | | ||
| A2C (Advantage Actor-Critic) | ❌ | | | ||
| A3C (Asynchronous Advantage Actor-Critic) | ❌ | | | ||
| PPO (Proximal Policy Optimization) | ❌ | | | ||
| TRPO (Trust Region Policy Optimization) | ❌ | | | ||
| SAC (Soft Actor-Critic) | ❌ | | | ||
| DDPG (Deep Deterministic Policy Gradient) | ❌ | | | ||
| TD3 (Twin Delayed DDPG) | ❌ | | | ||
| MADDPG (Multi-Agent DDPG) | ❌ | | | ||
| QMIX (Q-Mixing) | ❌ | | | ||
| VDN (Value Decomposition Networks) | ❌ | | | ||
| Genetic Algorithms | ❌ | | | ||
| Particle Swarm Optimization | ❌ | | | ||
| Simulated Annealing | ❌ | | | ||
| Ant Colony Optimization | ❌ | | | ||
|
||
### Implemented Simulator Features | ||
| Feature | Implemented | Notes | | ||
|---------|:-----------:|-------| | ||
| Jobs | ✅ | | | ||
| Operations | ✅ | | | ||
| Actions | ✅ | | | ||
| Bindings | ✅ | | | ||
| Taillard | ✅ | | | ||
| Manual Environment Creator | ❌ | | | ||
| Tool Changing | ❌ | | | ||
| Tool Properties | ❌ | | | ||
| Machine Breakdowns | ❌ | | | ||
| Job Priority | ❌ | | | ||
| Setup Times | ❌ | | | ||
| Due Dates | ❌ | | | ||
|
||
## Dependencies | ||
|
||
This project uses vcpkg to manage C++ dependencies. The dependencies are specified in the `vcpkg.json` manifest file in the root directory of the project. | ||
|
||
Before building the project, ensure you have the following installed: | ||
|
||
### Build Tools | ||
```bash | ||
sudo apt-get install build-essential pkg-config cmake git curl zip unzip tar autoconf autoconf-archive libtool | ||
``` | ||
| Algorithm | Status | Implementation | | ||
|-----------|:------:|----------------| | ||
| Q-Learning | ✅ | C++/Python | | ||
| Actor-Critic | ✅ | C++/Python | | ||
| SARSA | ❌ | Planned | | ||
| DQN | ❌ | Planned | | ||
| PPO | ❌ | Planned | | ||
| DDPG | ❌ | Planned | | ||
|
||
### Environment Features | ||
| Feature | Status | Notes | | ||
|---------|:------:|-------| | ||
| Jobs/Operations | ✅ | Full support | | ||
| Taillard Benchmarks | ✅ | Built-in | | ||
| Custom Environments | ✅ | JSON format | | ||
| Machine Breakdowns | 🚧 | In progress | | ||
| Tool Management | 🚧 | In progress | | ||
| Priority Scheduling | 🚧 | Planned | | ||
|
||
## Installation | ||
|
||
There are two ways to install PER-JSP: | ||
|
||
### 1. Python-Only Installation (Fast Install) | ||
For users who only need the Python implementation without C++ optimizations: | ||
|
||
### GLEW | ||
```bash | ||
sudo apt-get install libxmu-dev libxi-dev libgl-dev libglu1-mesa-dev | ||
PYTHON_ONLY=1 pip install . | ||
``` | ||
|
||
### GLFW3 | ||
```bash | ||
sudo apt-get install libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev | ||
``` | ||
This installation: | ||
- ✅ No C++ compiler needed | ||
- ✅ No system dependencies required | ||
- ✅ Quick installation | ||
- ❌ Lower performance compared to C++ version | ||
|
||
### Python3 | ||
```bash | ||
sudo apt-get install python3 python3-dev | ||
``` | ||
### 2. Full Installation (With C++ Extensions) | ||
For users who want maximum performance: | ||
|
||
### Performance Tools (for WSL2) | ||
```bash | ||
sudo apt-get install linux-tools-common linux-tools-generic | ||
sudo /usr/lib/linux-tools-6.8.0-36/perf | ||
``` | ||
|
||
### vcpkg Setup | ||
|
||
To install vcpkg: | ||
First, install system dependencies: | ||
|
||
```bash | ||
git clone https://github.com/Microsoft/vcpkg.git | ||
cd vcpkg | ||
./bootstrap-vcpkg.sh | ||
# Ubuntu/Debian | ||
sudo apt-get update && sudo apt-get install -y \ | ||
build-essential \ | ||
cmake \ | ||
ninja-build \ | ||
git \ | ||
pkg-config \ | ||
libgl-dev \ | ||
libglu1-mesa-dev \ | ||
libxrandr-dev \ | ||
libxinerama-dev \ | ||
libxcursor-dev \ | ||
libxi-dev \ | ||
python3-dev | ||
|
||
# macOS | ||
brew install cmake ninja pkg-config | ||
|
||
# Windows (with Visual Studio installed) | ||
# No additional dependencies needed | ||
``` | ||
|
||
Set the `VCPKG_ROOT` environment variable to the vcpkg installation directory: | ||
|
||
Then install the package: | ||
```bash | ||
export VCPKG_ROOT=/path/to/vcpkg | ||
pip install . | ||
``` | ||
|
||
## Building the Project | ||
This installation: | ||
- ✅ Maximum performance | ||
- ✅ All features available | ||
- ❓ Requires system dependencies | ||
- ❓ Longer installation time | ||
|
||
This project uses CMakePresets.json to manage build configurations. There are two main configurations: debug and release. | ||
## Quick Start | ||
|
||
1. Clone the repository: | ||
```bash | ||
git clone https://github.com/cair/job-shop-simulator.git | ||
cd job-shop-simulator | ||
``` | ||
|
||
2. To configure and build the project in debug mode: | ||
```bash | ||
cmake --preset=debug | ||
cmake --build --preset=debug | ||
``` | ||
```python | ||
from per_jsp import Environment, QLearning | ||
|
||
3. To configure and build the project in release mode: | ||
```bash | ||
cmake --preset=release | ||
cmake --build --preset=release | ||
``` | ||
# Create environment | ||
env = Environment.from_taillard(1) # Load Taillard instance 1 | ||
|
||
## Installing the Python Package | ||
# Create solver | ||
solver = QLearning( | ||
env, | ||
learning_rate=0.1, | ||
discount_factor=0.9, | ||
exploration_rate=0.1 | ||
) | ||
|
||
To install the Python package, first ensure that the `VCPKG_ROOT` environment variable is set, then run: | ||
# Train | ||
solver.train(episodes=1000) | ||
|
||
```bash | ||
pip install . | ||
# Get solution | ||
schedule = solver.get_best_schedule() | ||
schedule.visualize() | ||
``` | ||
|
||
This will automatically use CMakePresets.json to build the project and install the Python package. | ||
|
||
## Usage | ||
## Advanced Usage | ||
|
||
### C++ Library | ||
### Custom Problem Instance | ||
|
||
To use the C++ library in your project, include the necessary headers and link against the library: | ||
```python | ||
from per_jsp import Environment | ||
|
||
# Define your problem | ||
problem = { | ||
"jobs": [ | ||
{"operations": [ | ||
{"machine": 0, "processing_time": 10}, | ||
{"machine": 1, "processing_time": 20} | ||
]}, | ||
{"operations": [ | ||
{"machine": 1, "processing_time": 15}, | ||
{"machine": 0, "processing_time": 25} | ||
]} | ||
] | ||
} | ||
|
||
# Create environment | ||
env = Environment.from_dict(problem) | ||
``` | ||
|
||
```cpp | ||
#include <jobshop/job_shop_environment.h> | ||
#include <jobshop/job_shop_qlearning.h> | ||
### Using Different Solvers | ||
|
||
// Your code here | ||
```python | ||
from per_jsp import Environment, ActorCritic | ||
|
||
env = Environment.from_taillard(1) | ||
|
||
# Actor-Critic solver | ||
solver = ActorCritic( | ||
env, | ||
actor_lr=0.001, | ||
critic_lr=0.001, | ||
discount_factor=0.99 | ||
) | ||
|
||
# Train with specific settings | ||
solver.train( | ||
episodes=1000, | ||
max_steps=10000, | ||
verbose=True | ||
) | ||
``` | ||
|
||
### Python Module | ||
|
||
After installing the Python package, you can use it in your Python code: | ||
## Performance Comparison | ||
|
||
```python | ||
import jobshop | ||
| Problem Size | Python-Only | With C++ | Speedup | | ||
|-------------|-------------|----------|---------| | ||
| 6x6 | 1.00x | 8.45x | 8.45x | | ||
| 10x10 | 1.00x | 12.3x | 12.3x | | ||
| 20x20 | 1.00x | 15.7x | 15.7x | | ||
|
||
# Create a job shop environment | ||
env = jobshop.JobShopEnvironment(jobs) | ||
## Contributing | ||
|
||
# Create a Q-Learning agent | ||
agent = jobshop.JobShopQLearning(env, alpha=0.1, gamma=0.9, epsilon=0.3) | ||
Contributions are welcome! See our [Contributing Guide](CONTRIBUTING.md) for details. | ||
|
||
# Train the agent | ||
agent.train(num_episodes=1000) | ||
### Development Setup | ||
|
||
# Print the best schedule | ||
agent.printBestSchedule() | ||
``` | ||
```bash | ||
# Clone repository | ||
git clone https://github.com/cair/per-jsp | ||
cd per-jsp | ||
|
||
## Project Structure | ||
# Create virtual environment | ||
python -m venv venv | ||
source venv/bin/activate # or `venv\Scripts\activate` on Windows | ||
|
||
- `src/`: Contains the C++ source files | ||
- `include/`: Contains the header files | ||
- `bindings/`: Contains the Python bindings | ||
- `CMakeLists.txt`: The main CMake configuration file | ||
- `CMakePresets.json`: Defines the build presets | ||
- `vcpkg.json`: Specifies the project dependencies for vcpkg | ||
# Install in development mode | ||
pip install -e ".[dev]" | ||
``` | ||
|
||
## License | ||
|
||
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details. | ||
This project is licensed under the MIT License - see [LICENSE](LICENSE) for details. | ||
|
||
## Contributing | ||
## Citation | ||
|
||
If you use this software in your research, please cite: | ||
|
||
Contributions are welcome! Please feel free to submit a Pull Request. | ||
```bibtex | ||
@software{andersen2024perjsp, | ||
author = {Andersen, Per-Arne}, | ||
title = {PER-JSP: A Performant Job Shop Scheduling Framework}, | ||
year = {2024}, | ||
url = {https://github.com/cair/per-jsp} | ||
} | ||
``` | ||
|
||
## Contact | ||
## Support | ||
|
||
If you have any questions or feedback, please open an issue on the GitHub repository. | ||
- 📖 [Documentation](https://github.com/cair/per-jsp/wiki) | ||
- 🐛 [Issue Tracker](https://github.com/cair/per-jsp/issues) | ||
- 💬 [Discussions](https://github.com/cair/per-jsp/discussions) |