job-shop-lib 1.0.0a4__py3-none-any.whl → 1.0.0a5__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
job_shop_lib/__init__.py CHANGED
@@ -19,6 +19,8 @@ from job_shop_lib._schedule import Schedule
19
19
  from job_shop_lib._base_solver import BaseSolver, Solver
20
20
 
21
21
 
22
+ __version__ = "1.0.0-a.5"
23
+
22
24
  __all__ = [
23
25
  "Operation",
24
26
  "JobShopInstance",
@@ -26,4 +28,5 @@ __all__ = [
26
28
  "Schedule",
27
29
  "Solver",
28
30
  "BaseSolver",
31
+ "__version__",
29
32
  ]
@@ -54,8 +54,8 @@ class JobShopInstance:
54
54
  jobs (list[list[Operation]]):
55
55
  A list of lists of operations. Each list of operations represents
56
56
  a job, and the operations are ordered by their position in the job.
57
- The ``job_id``, ``position_in_job``, and `operation_id` attributes
58
- of the operations are set when the instance is created.
57
+ The ``job_id``, ``position_in_job``, and ``operation_id``
58
+ attributes of the operations are set when the instance is created.
59
59
  name (str):
60
60
  A string with the name of the instance.
61
61
  metadata (dict[str, Any]):
@@ -2,6 +2,7 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ from typing import Any
5
6
  import time
6
7
 
7
8
  from ortools.sat.python import cp_model
@@ -151,7 +152,7 @@ class ORToolsSolver(BaseSolver):
151
152
  self._set_objective(instance)
152
153
 
153
154
  def _create_schedule(
154
- self, instance: JobShopInstance, metadata: dict[str, object]
155
+ self, instance: JobShopInstance, metadata: dict[str, Any]
155
156
  ) -> Schedule:
156
157
  """Creates a Schedule object from the solution."""
157
158
  operations_start: dict[Operation, int] = {
@@ -153,6 +153,36 @@ class Dispatcher:
153
153
  responsible for scheduling the operations on the machines and keeping
154
154
  track of the next available time for each machine and job.
155
155
 
156
+ The core method of the class are:
157
+
158
+ .. autosummary::
159
+
160
+ dispatch
161
+ reset
162
+
163
+ It also provides methods to query the state of the schedule and the
164
+ operations:
165
+
166
+ .. autosummary::
167
+
168
+ current_time
169
+ available_operations
170
+ available_machines
171
+ available_jobs
172
+ unscheduled_operations
173
+ scheduled_operations
174
+ ongoing_operations
175
+ completed_operations
176
+ uncompleted_operations
177
+ is_scheduled
178
+ is_ongoing
179
+ next_operation
180
+ earliest_start_time
181
+ remaining_duration
182
+
183
+ The above methods which do not take any arguments are cached to improve
184
+ performance. After each scheduling operation, the cache is cleared.
185
+
156
186
  Args:
157
187
  instance:
158
188
  The instance of the job shop problem to be solved.
@@ -189,11 +219,11 @@ class Dispatcher:
189
219
  self.instance = instance
190
220
  self.schedule = Schedule(self.instance)
191
221
  self.ready_operations_filter = ready_operations_filter
222
+ self.subscribers: list[DispatcherObserver] = []
192
223
 
193
224
  self._machine_next_available_time = [0] * self.instance.num_machines
194
225
  self._job_next_operation_index = [0] * self.instance.num_jobs
195
226
  self._job_next_available_time = [0] * self.instance.num_jobs
196
- self.subscribers: list[DispatcherObserver] = []
197
227
  self._cache: dict[str, Any] = {}
198
228
 
199
229
  def __str__(self) -> str:
@@ -236,7 +266,9 @@ class Dispatcher:
236
266
  for subscriber in self.subscribers:
237
267
  subscriber.reset()
238
268
 
239
- def dispatch(self, operation: Operation, machine_id: int) -> None:
269
+ def dispatch(
270
+ self, operation: Operation, machine_id: int | None = None
271
+ ) -> None:
240
272
  """Schedules the given operation on the given machine.
241
273
 
242
274
  The start time of the operation is computed based on the next
@@ -249,15 +281,21 @@ class Dispatcher:
249
281
  The operation to be scheduled.
250
282
  machine_id:
251
283
  The id of the machine on which the operation is to be
252
- scheduled.
284
+ scheduled. If ``None``, the :class:`~job_shop_lib.Operation`'s
285
+ :attr:`~job_shop_lib.Operation.machine_id` attribute is used.
253
286
 
254
287
  Raises:
255
288
  ValidationError: If the operation is not ready to be scheduled.
289
+ UninitializedAttributeError: If the operation has multiple
290
+ machines in its list and no ``machine_id`` is provided.
256
291
  """
257
292
 
258
293
  if not self.is_operation_ready(operation):
259
294
  raise ValidationError("Operation is not ready to be scheduled.")
260
295
 
296
+ if machine_id is None:
297
+ machine_id = operation.machine_id
298
+
261
299
  start_time = self.start_time(operation, machine_id)
262
300
 
263
301
  scheduled_operation = ScheduledOperation(
@@ -38,11 +38,11 @@ def create_composite_operation_filter(
38
38
  ReadyOperationsFilter | str | ReadyOperationsFilterType
39
39
  ],
40
40
  ) -> ReadyOperationsFilter:
41
- """Creates and returns a composite filter based on the specified list of
42
- filters.
41
+ """Creates and returns a :class:`ReadyOperationsFilter` function by
42
+ combining multiple filter strategies.
43
43
 
44
- The composite filter function filters operations based on the specified
45
- list of filter strategies.
44
+ The composite filter function applies multiple filter strategies
45
+ iteratively in the order they are specified in the list.
46
46
 
47
47
  Args:
48
48
  ready_operations_filters:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: job-shop-lib
3
- Version: 1.0.0a4
3
+ Version: 1.0.0a5
4
4
  Summary: An easy-to-use and modular Python library for the Job Shop Scheduling Problem (JSSP)
5
5
  License: MIT
6
6
  Author: Pabloo22
@@ -17,7 +17,7 @@ Requires-Dist: imageio[ffmpeg] (>=2.34.1,<3.0.0)
17
17
  Requires-Dist: matplotlib (>=3,<4)
18
18
  Requires-Dist: networkx (>=3,<4)
19
19
  Requires-Dist: numpy (>=1.26.4,<2.0.0)
20
- Requires-Dist: ortools (>=9.9,<9.10)
20
+ Requires-Dist: ortools (>=9.9,<10.0)
21
21
  Requires-Dist: pyarrow (>=15.0.0,<16.0.0)
22
22
  Requires-Dist: pygraphviz (>=1.12,<2.0) ; extra == "pygraphviz"
23
23
  Description-Content-Type: text/markdown
@@ -60,10 +60,10 @@ See [this](https://colab.research.google.com/drive/1XV_Rvq1F2ns6DFG8uNj66q_rcoww
60
60
  Version 1.0.0 is currently in alpha stage and can be installed with:
61
61
 
62
62
  ```bash
63
- pip install job-shop-lib==1.0.0a4
63
+ pip install job-shop-lib==1.0.0a5
64
64
  ```
65
65
 
66
- Although this version is not stable and may contain breaking changes in subsequent releases, it is recommended to install it to access the new reinforcement learning environments and familiarize yourself with new changes (see the [latest pull requests](https://github.com/Pabloo22/job_shop_lib/pulls?q=is%3Apr+is%3Aclosed)). This version is the first one with a [documentation page](https://job-shop-lib.readthedocs.io/en/latest/).
66
+ Although this version is not stable and may contain breaking changes in subsequent releases, it is recommended to install it to access the new reinforcement learning environments and familiarize yourself with new changes (see the [latest pull requests](https://github.com/Pabloo22/job_shop_lib/pulls?q=is%3Apr+is%3Aclosed)). There is a [documentation page](https://job-shop-lib.readthedocs.io/en/latest/) for versions 1.0.0a3 and onward.
67
67
 
68
68
  <!-- end installation -->
69
69
 
@@ -71,25 +71,25 @@ Although this version is not stable and may contain breaking changes in subseque
71
71
 
72
72
  ## Key Features :star:
73
73
 
74
- - **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).
74
+ - **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).
75
75
 
76
- - **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).
76
+ - **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).
77
77
 
78
78
  - **Random Instance Generation**: Create random instances with customizable sizes and properties or augment existing ones. See [`generation`](job_shop_lib/generation) package.
79
79
 
80
80
  - **Multiple Solvers**:
81
- - **Constraint Programming Solver**: OR-Tools' CP-SAT solver. See [Solving the Problem](docs/source/examples/02-Solving-the-Problem.ipynb).
81
+ - **Constraint Programming Solver**: OR-Tools' CP-SAT solver. See [Solving the Problem](https://github.com/Pabloo22/job_shop_lib/blob/main/docs/source/tutorial/02-Solving-the-Problem.ipynb).
82
82
 
83
- - **Dispatching Rule Solvers**: Use any of the available dispatching rules or create custom ones. See [Dispatching Rules](docs/source/examples/03-Dispatching-Rules.ipynb).
83
+ - **Dispatching Rule Solvers**: Use any of the available dispatching rules or create custom ones. See [Dispatching Rules](https://github.com/Pabloo22/job_shop_lib/blob/main/docs/source/examples/03-Dispatching-Rules.ipynb).
84
84
 
85
- - **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).
85
+ - **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](https://github.com/Pabloo22/job_shop_lib/blob/main/docs/source/examples/06-Save-Gif.ipynb).
86
86
 
87
87
  - **Graph Representations**:
88
- - **Disjunctive Graphs**: Represent and visualize instances as disjunctive graphs. See [Disjunctive Graph](docs/source/examples/04-Disjunctive-Graph.ipynb).
89
- - **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).
88
+ - **Disjunctive Graphs**: Represent and visualize instances as disjunctive graphs. See [Disjunctive Graph](https://github.com/Pabloo22/job_shop_lib/blob/main/docs/source/examples/04-Disjunctive-Graph.ipynb).
89
+ - **Agent-Task Graphs**: Encode instances as agent-task graphs (introduced in [ScheduleNet paper](https://arxiv.org/abs/2106.03051)). See [Agent-Task Graph](https://github.com/Pabloo22/job_shop_lib/blob/main/docs/source/examples/07-Agent-Task-Graph.ipynb).
90
90
  - Build your own custom graphs with the `JobShopGraph` class.
91
91
 
92
- - **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).
92
+ - **Gymnasium Environments**: Two environments for solving the problem with Graph Neural Networks (GNNs) or any other method, and Reinforcement Learning (RL). See [SingleJobShopGraphEnv](https://github.com/Pabloo22/job_shop_lib/blob/main/docs/source/examples/09-SingleJobShopGraphEnv.ipynb) and [MultiJobShopGraphEnv](https://github.com/Pabloo22/job_shop_lib/blob/main/docs/source/examples/10-MultiJobShopGraphEnv.ipynb).
93
93
 
94
94
  <!-- end key features -->
95
95
 
@@ -1,6 +1,6 @@
1
- job_shop_lib/__init__.py,sha256=Ci5ipn-zciO88C5aX5Wx-UN8iBTbpde3dSSg02ZcfwM,597
1
+ job_shop_lib/__init__.py,sha256=727ReBd86kZgmAYA8lkYhDRaAnqJ6iH6uBP-zIRbjw4,643
2
2
  job_shop_lib/_base_solver.py,sha256=p17XmtufNc9Y481cqZUT45pEkUmmW1HWG53dfhIBJH8,1363
3
- job_shop_lib/_job_shop_instance.py,sha256=hc_rYHv0RRvcBmQLtXcSTZJ_YQxKBfhoSEcTNvf8Oio,18319
3
+ job_shop_lib/_job_shop_instance.py,sha256=OoKkZRQK6kbk0zgiXc-0mFk8t7aFpWK2Cah-vmI60AY,18321
4
4
  job_shop_lib/_operation.py,sha256=6YgAuqFQgvoGIYTkdsBh-b8mVlc0i9AIw8cqmiTXeHE,3809
5
5
  job_shop_lib/_schedule.py,sha256=QQ7orbpd00pTjJvsh8bNuRSEFJLst8B8GaCSB8JPXTY,11251
6
6
  job_shop_lib/_scheduled_operation.py,sha256=krjGn47VwsC7bXUTqlUq8Y-DpiSE9q2z8bqwgJVpAZo,2697
@@ -8,11 +8,11 @@ job_shop_lib/benchmarking/__init__.py,sha256=BYCrJUNr_uk2c0xIbDt07OnUMhQx8Dudkuk
8
8
  job_shop_lib/benchmarking/_load_benchmark.py,sha256=-cgyx0Kn6uAc3KdGFSQb6eUVQjQggmpVKOH9qusNkXI,2930
9
9
  job_shop_lib/benchmarking/benchmark_instances.json,sha256=F9EvyzFwVxiKAN6rQTsrMhsKstmyUmroyWduM7a00KQ,464841
10
10
  job_shop_lib/constraint_programming/__init__.py,sha256=kKQRUxxS_nVFUdXGnf4bQOD9mqrXxZZWElS753A4YiA,454
11
- job_shop_lib/constraint_programming/_ortools_solver.py,sha256=gRoImEBUa8_io-TzbSS-3f0CJ7UwacU5Lrz0bsDqibo,10462
11
+ job_shop_lib/constraint_programming/_ortools_solver.py,sha256=oMPeA2VHoYX1ZvmygQ8kYew40ITLAQATmM4OhgVFuXM,10482
12
12
  job_shop_lib/dispatching/__init__.py,sha256=2VQYWNSyuDx3zzrDPCEzs5VJd2AIJvF7vA7LwK5z2V4,1648
13
- job_shop_lib/dispatching/_dispatcher.py,sha256=5B2KA0-nHLeFsZ1KxZxwLJ2muknzQVhwqUV4pFlo6bw,21218
13
+ job_shop_lib/dispatching/_dispatcher.py,sha256=uy4_EHdhwhGLWc1zv1AtY9FApP-70AdjCnLa3_q2nOQ,22316
14
14
  job_shop_lib/dispatching/_dispatcher_observer_config.py,sha256=034m83TsZXAb89nPxGRZm--0KSaGA9tJnr-7aYQs6tU,2479
15
- job_shop_lib/dispatching/_factories.py,sha256=njS5yUd5K74ceAUFcqofUlx0efMvfJB6twdZdrCqhfE,4596
15
+ job_shop_lib/dispatching/_factories.py,sha256=D9m_tHUqQe-aGc50X_5HSm27nELwm4VyVEg6zUudkyg,4643
16
16
  job_shop_lib/dispatching/_history_observer.py,sha256=Vl8rQaxekUeEB-AyNxyC3c76zQakeh-rdri2iDnZvXw,610
17
17
  job_shop_lib/dispatching/_ready_operation_filters.py,sha256=Mywt57h8Nlj6XrptWakVt9n1Tq4jsneZFQEgjLMxJgw,5731
18
18
  job_shop_lib/dispatching/_unscheduled_operations_observer.py,sha256=LNEzqOWqEf6fvtkQrDmDWFEhCfA75OgEtzdomzbxYII,2683
@@ -60,7 +60,7 @@ job_shop_lib/visualization/_gantt_chart_video_and_gif_creation.py,sha256=aPy7y0o
60
60
  job_shop_lib/visualization/_plot_agent_task_graph.py,sha256=AaBTD_S34WjrsZnL_iMAplR_f67RahZi7x58SOvp-q0,8834
61
61
  job_shop_lib/visualization/_plot_disjunctive_graph.py,sha256=Vo3c2oHQ8YkLbwrDr76zh4yzCuQk-gkVeyWN-7Zj71o,14279
62
62
  job_shop_lib/visualization/_plot_gantt_chart.py,sha256=1WCJ5Gjl3dwA-w4Jn9suIg-ZGR28yYUAy8Jp-IiyvfI,6842
63
- job_shop_lib-1.0.0a4.dist-info/LICENSE,sha256=9mggivMGd5taAu3xbmBway-VQZMBzurBGHofFopvUsQ,1069
64
- job_shop_lib-1.0.0a4.dist-info/METADATA,sha256=14EToNDww1XMWqiMJguxDG6ER1ApNGnowyjBR5CC8vY,15656
65
- job_shop_lib-1.0.0a4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
66
- job_shop_lib-1.0.0a4.dist-info/RECORD,,
63
+ job_shop_lib-1.0.0a5.dist-info/LICENSE,sha256=9mggivMGd5taAu3xbmBway-VQZMBzurBGHofFopvUsQ,1069
64
+ job_shop_lib-1.0.0a5.dist-info/METADATA,sha256=R-7tM_SWNJV6JoTtDh_FlO6SbD-fXQt36Ro0KZAzLKk,16184
65
+ job_shop_lib-1.0.0a5.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
66
+ job_shop_lib-1.0.0a5.dist-info/RECORD,,