You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
JobShopLib is a Python package for creating, solving, and visualizing job shop scheduling problems (JSSP).
17
+
JobShopLib is a Python package for **creating**, **solving**, and **visualizing**
18
+
job shop scheduling problems.
17
19
18
-
It follows a modular design, allowing users to easily extend the library with new solvers, dispatching rules, visualization functions, etc.
20
+
It provides solvers based on:
19
21
20
-
We support multiple solvers, including:
21
-
-**Constraint Programming**: Based on OR-Tools' CP-SAT solver. It supports **release dates, deadlines, and due dates.** See the ["Solving the Problem" tutorial](https://github.com/Pabloo22/job_shop_lib/blob/main/docs/source/tutorial/02-Solving-the-Problem.ipynb) for an example.
22
-
-**Dispatching Rules**: A set of predefined rules and the ability to create custom ones. They support arbitrary **setup times, machine breakdowns, release dates, deadlines, and due dates**. See the [following example](https://github.com/Pabloo22/job_shop_lib/blob/main/docs/source/examples/03-Dispatching-Rules.ipynb). You can also create videos or GIFs of the scheduling process. For creating GIFs or videos, see the [Save Gif example](https://github.com/Pabloo22/job_shop_lib/blob/main/docs/source/examples/04-Save-Gif.ipynb).
23
-
-**Metaheuristics**: Currently, we have a **simulated annealing** implementation that supports **release dates, deadlines, and due dates**. We also support arbitrary neighborhood search strategies, including swapping operations in the critical path as described in the paper "Job Shop Scheduling by Simulated Annealing" by van Laarhoven et al. (1992); and energy functions. See our [simulated annealing tutorial](https://github.com/Pabloo22/job_shop_lib/blob/main/docs/source/tutorial/04-Simulated-Annealing.ipynb).
24
-
-**Reinforcement Learning**: Two Gymnasium environments for solving the problem with **graph neural networks** (GNNs) or any other method. The environments support **setup times, release dates, deadlines, and due dates.** We're currently building a tutorial on how to use them.
-**Constraint programming** (CP-SAT from Google OR-Tools)
25
26
26
-
We also provide useful utilities, data structures, and visualization functions:
27
-
-**Intuitive Data Structures**: Easily create, manage, and manipulate job shop instances and solutions with user-friendly data structures. See [Getting Started](https://github.com/Pabloo22/job_shop_lib/blob/main/docs/source/tutorial/00-Getting-Started.ipynb) and [How Solutions are Represented](https://github.com/Pabloo22/job_shop_lib/blob/main/docs/source/tutorial/01-How-Solutions-are-Represented.ipynb).
28
-
-**Benchmark Instances**: Load well-known benchmark instances directly from the library without manual downloading. See [Load Benchmark Instances](https://github.com/Pabloo22/job_shop_lib/blob/main/docs/source/examples/05-Load-Benchmark-Instances.ipynb).
29
-
-**Random Instance Generation**: Create random instances with customizable sizes and properties. See [`this tutorial`](https://github.com/Pabloo22/job_shop_lib/blob/main/docs/source/tutorial/03-Generating-New-Instances.ipynb).
30
-
-**Gantt Charts**: Visualize final schedules and how they are created iteratively by dispatching rule solvers or sequences of scheduling decisions with GIFs or videos.
31
-
-**Graph Representations**: Represent and visualize instances as disjunctive graphs or agent-task graphs (introduced in the ScheduleNet paper). Build your own custom graphs with the `JobShopGraph` class. See the [Disjunctive Graphs](https://github.com/Pabloo22/job_shop_lib/blob/main/docs/source/tutorial/04-Disjunctive-Graphs.ipynb) and [Resource Task Graphs](https://job-shop-lib.readthedocs.io/en/stable/examples/07-Resource-Task-Graph.html) examples.
27
+
It also includes utilities for:
32
28
33
-
## Installation :package:
29
+
-**Load benchmark instances**
30
+
-**Generating random problems**
31
+
-**Gantt charts**
32
+
-**Disjunctive graphs** (and any variant)
33
+
- Training a GNN-based dispatcher using **reinforcement learning** or **imitation learning**
34
34
35
-
<!-- start installation -->
35
+
It supports:
36
+
-**Multi-machine operations**
37
+
-**Release dates**
38
+
-**Deadlines and due dates**
36
39
37
-
```bash
38
-
pip install job-shop-lib
39
-
```
40
+
JobShopLib's design is intended to be modular and easy-to-use:
40
41
41
-
or
42
42
43
-
```bash
44
-
poetry add job-shop-lib
45
-
```
43
+
```python
44
+
import matplotlib.pyplot as plt
45
+
plt.style.use("ggplot")
46
46
47
-
<!-- end installation -->
47
+
from job_shop_lib import JobShopInstance, Operation
48
+
from job_shop_lib.benchmarking import load_benchmark_instance
49
+
from job_shop_lib.generation import GeneralInstanceGenerator
50
+
from job_shop_lib.constraint_programming import ORToolsSolver
51
+
from job_shop_lib.visualization import plot_gantt_chart, create_gif, plot_gantt_chart_wrapper
52
+
from job_shop_lib.dispatching import DispatchingRuleSolver
For an in-depth explanation of the library (v1.0.0), including its design, features, reinforcement learning environments, and some experiments, please refer to my [Bachelor's thesis](https://www.arxiv.org/abs/2506.13781).
61
+
# load a popular benchmark instance,
62
+
ft06 = load_benchmark_instance("ft06")
52
63
53
-
You can also cite the library using the following BibTeX entry:
### Solve an Instance with a Dispatching Rule Solver
176
209
177
-
A dispatching rule is a heuristic guideline used to prioritize and sequence jobs on various machines. Supported dispatching rules are:
210
+
A dispatching rule is a heuristic guideline used to prioritize and sequence jobs on various machines. Supported dispatching rules are (although you can also create your own):
The dashed red line represents the current time step, which is computed as the earliest time when the next operation can start.
213
246
@@ -219,14 +252,8 @@ The dashed red line represents the current time step, which is computed as the e
219
252
220
253
One of the main purposes of this library is to provide an easy way to encode instances as graphs. This can be very useful, not only for visualization purposes but also for developing graph neural network-based algorithms.
221
254
222
-
A graph is represented by the `JobShopGraph` class, which internally stores a `networkx.DiGraph` object.
223
-
224
255
#### Disjunctive Graph
225
256
226
-
The disjunctive graph is created by first adding nodes representing each operation in the jobs, along with two special nodes: a source $S$ and a sink $T$. Each operation node is linked to the next operation in its job sequence by **conjunctive edges**, forming a path from the source to the sink. These edges represent the order in which operations of a single job must be performed.
227
-
228
-
Additionally, the graph includes **disjunctive edges** between operations that use the same machine but belong to different jobs. These edges are bidirectional, indicating that either of the connected operations can be performed first. The disjunctive edges thus represent the scheduling choices available: the order in which operations sharing a machine can be processed. Solving the job shop scheduling problem involves choosing a direction for each disjunctive edge such that the overall processing time is minimized.
229
-
230
257
```python
231
258
from job_shop_lib.visualization import plot_disjunctive_graph
-`nodes_by_machine`: A nested list mapping each machine to its associated operation nodes, aiding in machine-specific analysis.
276
-
-`nodes_by_job`: Similar to `nodes_by_machine`, but maps jobs to their operation nodes, useful for job-specific traversal.
277
-
278
278
#### Resource-Task Graph
279
279
280
280
Introduced in the paper "ScheduleNet: Learn to solve multi-agent scheduling problems with reinforcement learning" by [Park et al. (2021)](https://arxiv.org/abs/2106.03051), the resource-task graph (orginally named "agent-task graph") is a graph that represents the scheduling problem as a multi-agent reinforcement learning problem.
@@ -390,6 +390,23 @@ Any contribution is welcome, whether it's a small bug or documentation fix or a
390
390
391
391
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
392
392
393
+
## Publication :scroll:
394
+
395
+
For an in-depth explanation of the library (v1.0.0), including its design, features, reinforcement learning environments, and some experiments, please refer to https://www.arxiv.org/abs/2506.13781.
396
+
397
+
You can also cite the library using the following BibTeX entry:
398
+
399
+
```bibtex
400
+
@misc{arino2025jobshoplib,
401
+
title={Solving the Job Shop Scheduling Problem with Graph Neural Networks: A Customizable Reinforcement Learning Environment},
0 commit comments