Skip to content

Commit be4753c

Browse files
authored
1.0.0-alpha.1: Merge pull request #6 from development
1.0.0-alpha.1: Add Gymnasium Environments, Graph Updaters, `dispatching.rule` package, and some structural refactoring in `dispatching` package.
2 parents a1b91d4 + f313ae3 commit be4753c

File tree

151 files changed

+7632
-2686
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+7632
-2686
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
/examples/*_frames/
1+
README.rst
2+
3+
docs/source/examples/*_frames/
24
/exploration_notebooks/
35
# Byte-compiled / optimized / DLL files
46
__pycache__/

Makefile

+7-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,10 @@ test:
66
poetry run pytest --cov=job_shop_lib --cov-report lcov:lcov.info --mpl
77

88
poetry_install_all:
9-
poetry install --with notebooks --with test --with lint --all-extras
9+
poetry install --with notebooks --with test --with lint --with docs --all-extras
10+
11+
html_docs:
12+
cd docs && make html
13+
14+
clean_docs:
15+
cd docs && make clean

README.md

+61-38
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<div align="center">
22

3-
<img src="images/logo_with_transparent_background.png" height="150px">
3+
<img src="docs/source/images/jslib_minimalist_logo_no_background_fixed.png" height="150px">
44

5-
<h1>Job Shop Library</h1>
5+
<h1>JobShopLib</h1>
66

77
[![Tests](https://github.com/Pabloo22/job_shop_lib/actions/workflows/tests.yaml/badge.svg)](https://github.com/Pabloo22/job_shop_lib/actions/workflows/tests.yaml)
88
![Python versions](https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12-blue)
@@ -11,25 +11,57 @@
1111

1212
</div>
1313

14-
An easy-to-use and modular Python library for the Job Shop Scheduling Problem (JSSP) with a special focus on graph representations.
14+
JobShopLib is a Python package for creating, solving, and visualizing Job Shop Scheduling Problems (JSSP).
1515

16-
It provides intuitive data structures to represent instances and solutions, as well as solvers and visualization tools.
16+
It follows a modular design, allowing users to easily extend the library with new solvers, dispatching rules, visualization functions, etc.
1717

18-
See the [this](https://colab.research.google.com/drive/1XV_Rvq1F2ns6DFG8uNj66q_rcowwTZ4H?usp=sharing) Google Colab notebook for a quick start guide!
18+
See [this](https://colab.research.google.com/drive/1XV_Rvq1F2ns6DFG8uNj66q_rcowwTZ4H?usp=sharing) Google Colab notebook for a quick start guide!
1919

20-
## Installation
20+
## Installation :package:
2121

22-
You can install the library from PyPI:
22+
<!-- start installation -->
23+
24+
JobShopLib is distributed on [PyPI](https://pypi.org/project/job-shop-lib/) and it supports Python 3.10+.
25+
26+
You can install the latest version using `pip`:
2327

2428
```bash
2529
pip install job-shop-lib
2630
```
2731

28-
## Quick Start :rocket:
32+
<!-- end installation -->
33+
34+
<!-- key features -->
35+
36+
## Key Features :star:
37+
38+
- **Data Structures**: Easily create, manage, and manipulate job shop instances and solutions with user-friendly data structures. See [Getting Started](docs/source/examples/00-Getting-Started.ipynb) and [How Solutions are Represented](docs/source/examples/01-How-Solutions-are-Represented.ipynb).
39+
40+
- **Benchmark Instances**: Load well-known benchmark instances directly from the library without manual downloading. See [Load Benchmark Instances](docs/source/examples/05-Load-Benchmark-Instances.ipynb).
41+
42+
- **Random Instance Generation**: Create random instances with customizable sizes and properties or augment existing ones. See [`generation`](job_shop_lib/generation) package.
43+
44+
- **Multiple Solvers**:
45+
- **Constraint Programming Solver**: OR-Tools' CP-SAT solver. See [Solving the Problem](docs/source/examples/02-Solving-the-Problem.ipynb).
46+
47+
- **Dispatching Rule Solvers**: Use any of the available dispatching rules or create custom ones. See [Dispatching Rules](docs/source/examples/03-Dispatching-Rules.ipynb).
48+
49+
- **Gantt Charts**: Visualize final schedules and how are they created iteratively by dispatching rule solvers or sequences of scheduling decisions with GIFs or videos. See [Save Gif](docs/source/examples/06-Save-Gif.ipynb).
50+
51+
- **Graph Representations**:
52+
- **Disjunctive Graphs**: Represent and visualize instances as disjunctive graphs. See [Disjunctive Graph](docs/source/examples/04-Disjunctive-Graph.ipynb).
53+
- **Agent-Task Graphs**: Encode instances as agent-task graphs (introduced in [ScheduleNet paper](https://arxiv.org/abs/2106.03051)). See [Agent-Task Graph](docs/source/examples/07-Agent-Task-Graph.ipynb).
54+
- Build your own custom graphs with the `JobShopGraph` class.
55+
56+
- **Gymnasium Environments**: Two environments for solving the problem with Graph Neural Networks (GNNs) or any other method, and Reinforcement Learning (RL). See [SingleJobShopGraphEnv](docs/source/examples/09-SingleJobShopGraphEnv.ipynb) and [MultiJobShopGraphEnv](examples/10-MultiJobShopGraphEnv.ipynb).
57+
58+
<!-- end key features -->
59+
60+
## Some Examples :rocket:
2961

3062
### Create a Job Shop Instance
3163

32-
You can create a Job Shop Instance by defining the jobs and operations. An operation is defined by the machine(s) it is processed on and the duration (processing time).
64+
You can create a `JobShopInstance` by defining the jobs and operations. An operation is defined by the machine(s) it is processed on and the duration (processing time).
3365

3466
```python
3567
from job_shop_lib import JobShopInstance, Operation
@@ -60,7 +92,7 @@ from job_shop_lib.benchmarking import load_benchmark_instance
6092
ft06 = load_benchmark_instance("ft06")
6193
```
6294

63-
The module `benchmarks` contains functions to load the instances from the file and return them as `JobShopInstance` objects without having to download them
95+
The module `benchmarking` contains functions to load the instances from the file and return them as `JobShopInstance` objects without having to download them
6496
manually.
6597

6698
The contributions to this benchmark dataset are as follows:
@@ -122,7 +154,7 @@ Every solver is a `Callable` that receives a `JobShopInstance` and returns a `Sc
122154
```python
123155
import matplotlib.pyplot as plt
124156

125-
from job_shop_lib.cp_sat import ORToolsSolver
157+
from job_shop_lib.constraint_programming import ORToolsSolver
126158
from job_shop_lib.visualization import plot_gantt_chart
127159

128160
solver = ORToolsSolver(max_time_in_seconds=10)
@@ -131,7 +163,7 @@ ft06_schedule = solver(ft06)
131163
fig, ax = plot_gantt_chart(ft06_schedule)
132164
plt.show()
133165
```
134-
![Example Gannt Chart](images/ft06_solution.png)
166+
![Example Gannt Chart](docs/source/images/ft06_solution.png)
135167

136168
### Solve an Instance with a Dispatching Rule Solver
137169

@@ -167,7 +199,7 @@ create_gif(
167199
)
168200
```
169201

170-
![Example Gif](examples/ft06_optimized.gif)
202+
![Example Gif](docs/source/examples/output/ft06_optimized.gif)
171203

172204
The dashed red line represents the current time step, which is computed as the earliest time when the next operation can start.
173205

@@ -194,11 +226,11 @@ fig = plot_disjunctive_graph(instance)
194226
plt.show()
195227
```
196228

197-
![Example Disjunctive Graph](images/example_disjunctive_graph.png)
229+
![Example Disjunctive Graph](docs/source/images/example_disjunctive_graph.png)
198230

199231

200-
> [!WARNING]
201-
> This plot function requires having the optional dependency [PyGraphViz](https://pygraphviz.github.io/) installed.
232+
> [!TIP]
233+
> Installing the optional dependency [PyGraphViz](https://pygraphviz.github.io/) is recommended.
202234
203235
The `JobShopGraph` class provides easy access to the nodes, for example, to get all the nodes of a specific type:
204236

@@ -253,7 +285,7 @@ plt.show()
253285
```
254286

255287
<div align="center">
256-
<img src="examples/agent_task_graph.png" width="300">
288+
<img src="docs/source/images/agent_task_graph.png" width="300">
257289
</div>
258290
<br>
259291

@@ -263,43 +295,34 @@ For more details, check the [examples](examples) folder.
263295

264296
## Installation for development
265297

266-
### With Poetry
298+
<!-- start installation development -->
267299

268300
1. Clone the repository.
269301

270-
2. Install [poetry](https://python-poetry.org/docs/) if you don't have it already:
271-
```bash
272-
pip install poetry==1.7
273-
```
274-
3. Create the virtual environment:
275302
```bash
276-
poetry shell
303+
git clone https://github.com/Pabloo22/job_shop_lib.git
304+
cd job_shop_lib
277305
```
278-
4. Install dependencies:
306+
307+
2. Install [poetry](https://python-poetry.org/docs/) if you don't have it already:
308+
279309
```bash
280-
poetry install --with notebooks --with test --with lint --all-extras
310+
pip install poetry
281311
```
282-
or equivalently:
312+
313+
3. Install dependencies:
283314
```bash
284315
make poetry_install_all
285316
```
286317

287-
### With PyPI
288-
289-
If you don't want to use Poetry, you can install the library directly from the source code:
290-
291-
```bash
292-
git clone https://github.com/Pabloo22/job_shop_lib.git
293-
cd job_shop_lib
294-
pip install -e .
295-
```
318+
<!-- end installation development -->
296319

297-
## License
320+
## License :scroll:
298321

299322
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
300323

301324

302-
## References
325+
## References :books:
303326

304327
- J. Adams, E. Balas, and D. Zawack, "The shifting bottleneck procedure
305328
for job shop scheduling," Management Science, vol. 34, no. 3,

docs/Makefile

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = source
9+
BUILDDIR = build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/make.bat

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=source
11+
set BUILDDIR=build
12+
13+
%SPHINXBUILD% >NUL 2>NUL
14+
if errorlevel 9009 (
15+
echo.
16+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
17+
echo.installed, then set the SPHINXBUILD environment variable to point
18+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
19+
echo.may add the Sphinx directory to PATH.
20+
echo.
21+
echo.If you don't have Sphinx installed, grab it from
22+
echo.https://www.sphinx-doc.org/
23+
exit /b 1
24+
)
25+
26+
if "%1" == "" goto help
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

docs/source/api.rst

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
API
2+
===
3+
4+
.. autosummary::
5+
:toctree: api
6+
:recursive:
7+
8+
job_shop_lib
9+
10+
11+
.. rubric:: Subpackages and Modules
12+
13+
.. autosummary::
14+
15+
job_shop_lib.benchmarking
16+
job_shop_lib.constraint_programming
17+
job_shop_lib.dispatching
18+
job_shop_lib.exceptions
19+
job_shop_lib.generation
20+
job_shop_lib.graphs
21+
job_shop_lib.reinforcement_learning
22+
job_shop_lib.visualization
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
job\_shop\_lib.benchmarking
2+
===========================
3+
4+
.. automodule:: job_shop_lib.benchmarking
5+
6+
7+
8+
9+
10+
11+
12+
13+
14+
15+
16+
17+
18+
19+
20+
21+
22+
23+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
job\_shop\_lib.constraint\_programming
2+
======================================
3+
4+
.. automodule:: job_shop_lib.constraint_programming
5+
6+
7+
8+
9+
10+
11+
12+
13+
14+
15+
16+
17+
18+
19+
20+
21+
22+
23+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
job\_shop\_lib.dispatching.feature\_observers
2+
=============================================
3+
4+
.. automodule:: job_shop_lib.dispatching.feature_observers
5+
6+
7+
8+
9+
10+
11+
12+
13+
14+
15+
16+
17+
18+
19+
20+
21+
22+
23+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
job\_shop\_lib.dispatching
2+
==========================
3+
4+
.. automodule:: job_shop_lib.dispatching
5+
6+
7+
8+
9+
10+
11+
12+
13+
14+
15+
16+
17+
18+
19+
20+
21+
22+
23+
24+
.. rubric:: Modules
25+
26+
.. autosummary::
27+
:toctree:
28+
:recursive:
29+
30+
job_shop_lib.dispatching.feature_observers
31+
job_shop_lib.dispatching.rules
32+

0 commit comments

Comments
 (0)