job-shop-lib 1.0.0b2__py3-none-any.whl → 1.0.0b3__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,7 +19,7 @@ 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-b.2"
22
+ __version__ = "1.0.0-b.3"
23
23
 
24
24
  __all__ = [
25
25
  "Operation",
@@ -8,9 +8,9 @@ The main classes and functions available in this package are:
8
8
  NodeType
9
9
  build_disjunctive_graph
10
10
  build_solved_disjunctive_graph
11
- build_agent_task_graph
12
- build_complete_agent_task_graph
13
- build_agent_task_graph_with_jobs
11
+ build_resource_task_graph
12
+ build_complete_resource_task_graph
13
+ build_resource_task_graph_with_jobs
14
14
 
15
15
  """
16
16
 
@@ -12,6 +12,7 @@
12
12
  IdleTimeReward
13
13
  RenderConfig
14
14
  add_padding
15
+ create_edge_type_dict
15
16
 
16
17
  """
17
18
 
@@ -27,7 +28,10 @@ from job_shop_lib.reinforcement_learning._reward_observers import (
27
28
  IdleTimeReward,
28
29
  )
29
30
 
30
- from job_shop_lib.reinforcement_learning._utils import add_padding
31
+ from job_shop_lib.reinforcement_learning._utils import (
32
+ add_padding,
33
+ create_edge_type_dict,
34
+ )
31
35
 
32
36
  from job_shop_lib.reinforcement_learning._single_job_shop_graph_env import (
33
37
  SingleJobShopGraphEnv,
@@ -47,4 +51,5 @@ __all__ = [
47
51
  "ObservationDict",
48
52
  "add_padding",
49
53
  "MultiJobShopGraphEnv",
54
+ "create_edge_type_dict",
50
55
  ]
@@ -1,6 +1,6 @@
1
1
  """Utility functions for reinforcement learning."""
2
2
 
3
- from typing import TypeVar, Any, Tuple, Optional, Type
3
+ from typing import TypeVar, Any, Type, Literal
4
4
 
5
5
  import numpy as np
6
6
  from numpy.typing import NDArray
@@ -12,9 +12,9 @@ T = TypeVar("T", bound=np.number)
12
12
 
13
13
  def add_padding(
14
14
  array: NDArray[Any],
15
- output_shape: Tuple[int, ...],
15
+ output_shape: tuple[int, ...],
16
16
  padding_value: float = -1,
17
- dtype: Optional[Type[T]] = None,
17
+ dtype: Type[T] | None = None,
18
18
  ) -> NDArray[T]:
19
19
  """Adds padding to the array.
20
20
 
@@ -90,6 +90,42 @@ def add_padding(
90
90
  return padded_array
91
91
 
92
92
 
93
+ def create_edge_type_dict(
94
+ edge_index: NDArray[T], type_ranges: dict[str, tuple[int, int]]
95
+ ) -> dict[tuple[str, Literal["to"], str], NDArray[T]]:
96
+ """Organizes edges based on node types.
97
+
98
+ Args:
99
+ edge_index:
100
+ numpy array of shape (2, E) where E is number of edges
101
+ type_ranges: dict[str, tuple[int, int]]
102
+ Dictionary mapping type names to their corresponding index ranges
103
+ [start, end) in the ``edge_index`` array.
104
+
105
+ Returns:
106
+ A dictionary with keys (type_i, "to", type_j) and values as edge
107
+ indices
108
+ """
109
+ edge_index_dict: dict[tuple[str, Literal["to"], str], NDArray] = {}
110
+ for type_name_i, (start_i, end_i) in type_ranges.items():
111
+ for type_name_j, (start_j, end_j) in type_ranges.items():
112
+ key: tuple[str, Literal["to"], str] = (
113
+ type_name_i,
114
+ "to",
115
+ type_name_j,
116
+ )
117
+ # Find edges where source is in type_i and target is in type_j
118
+ mask = (
119
+ (edge_index[0] >= start_i)
120
+ & (edge_index[0] < end_i)
121
+ & (edge_index[1] >= start_j)
122
+ & (edge_index[1] < end_j)
123
+ )
124
+ edge_index_dict[key] = edge_index[:, mask]
125
+
126
+ return edge_index_dict
127
+
128
+
93
129
  if __name__ == "__main__":
94
130
  import doctest
95
131
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: job-shop-lib
3
- Version: 1.0.0b2
3
+ Version: 1.0.0b3
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
@@ -60,7 +60,7 @@ See [this](https://colab.research.google.com/drive/1XV_Rvq1F2ns6DFG8uNj66q_rcoww
60
60
  Version 1.0.0 is currently in beta stage and can be installed with:
61
61
 
62
62
  ```bash
63
- pip install job-shop-lib==1.0.0b2
63
+ pip install job-shop-lib==1.0.0b3
64
64
  ```
65
65
 
66
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.
@@ -89,11 +89,7 @@ Although this version is not stable and may contain breaking changes in subseque
89
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
- <<<<<<< HEAD
93
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).
94
- =======
95
- - **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).
96
- >>>>>>> 031bdf3 ([Docs] Update links in README to point to the correct GitHub URLs for tutorials and examples)
97
93
 
98
94
  <!-- end key features -->
99
95
 
@@ -1,4 +1,4 @@
1
- job_shop_lib/__init__.py,sha256=xXYzjYqn-98QKOMQ4_fOBZYQ6Z6GUydDW5BNXiVSRCE,643
1
+ job_shop_lib/__init__.py,sha256=fj4EeaNf1NTAbpB0EH9OnhS_MjP1MCe03Xr6JNrLC_g,643
2
2
  job_shop_lib/_base_solver.py,sha256=p17XmtufNc9Y481cqZUT45pEkUmmW1HWG53dfhIBJH8,1363
3
3
  job_shop_lib/_job_shop_instance.py,sha256=hNQGSJj0rEQpS-YhzwWmM6QzCWp6r--89jkghSgLvUs,18380
4
4
  job_shop_lib/_operation.py,sha256=hx2atpP8LPj9fvxpZIfhBFr9Uq6JP-MKAX5JzTvFXso,3847
@@ -40,7 +40,7 @@ job_shop_lib/generation/_general_instance_generator.py,sha256=e-NDkH-NoCwa14oADj
40
40
  job_shop_lib/generation/_instance_generator.py,sha256=VV0OKX4JgFq3I1EY6s3LrOdPjM3v4lH6S1hkUebTkFQ,4615
41
41
  job_shop_lib/generation/_transformations.py,sha256=X-hTAJVIHZ3bmF1rqS0zCit8r5SGpHpV8Fcl92fejow,5336
42
42
  job_shop_lib/generation/_utils.py,sha256=cBhGILE0FE3TqvWoHqpaFEffO8D2fb869pF-BdMlYsg,3617
43
- job_shop_lib/graphs/__init__.py,sha256=zw4aOE-7QF8Lt8316rCUwOEAGqznjiijumTlGqBmfuw,1840
43
+ job_shop_lib/graphs/__init__.py,sha256=RI9vGUR_89X34UoHpl1HYZpxT8JOWg8dwZTe5ImDCVg,1849
44
44
  job_shop_lib/graphs/_build_disjunctive_graph.py,sha256=UbUYdeQaaeEqLchcKJGHEFGl4wElfGLb1o_R-u8wqnA,5120
45
45
  job_shop_lib/graphs/_build_resource_task_graphs.py,sha256=GHUHkUNPxVf1miScgPPMe2YqlXFEMxIy5cDhNw7OZ1E,6954
46
46
  job_shop_lib/graphs/_constants.py,sha256=K-GeVvh_DTWpo1KOX1clmxWS_pkUJbq19yOBmrCVIxI,1086
@@ -50,12 +50,12 @@ job_shop_lib/graphs/graph_updaters/__init__.py,sha256=UhnZL55e3cAv7hVetB6bRmIOn8
50
50
  job_shop_lib/graphs/graph_updaters/_graph_updater.py,sha256=j1f7iWsa62GVszK2BPaMxnKBCEGWa9owm8g4VWUje8w,1967
51
51
  job_shop_lib/graphs/graph_updaters/_residual_graph_updater.py,sha256=SfgmDyMwfW56OBjJPaU76c42IsX5qx9j-eMtrv0DjKk,6047
52
52
  job_shop_lib/graphs/graph_updaters/_utils.py,sha256=X5YfwJA1CCgpm1r9C036Gal2CkDh2SSak7wl7TbdjHw,704
53
- job_shop_lib/reinforcement_learning/__init__.py,sha256=gOY-C6BMeFr3084MKMMbW0CoK7gMsaOYNsgnYuepswQ,1033
53
+ job_shop_lib/reinforcement_learning/__init__.py,sha256=IohAO2-eAdgeAsNG2czRhI5Eu9jKPnDnB8Z-ne_L1as,1124
54
54
  job_shop_lib/reinforcement_learning/_multi_job_shop_graph_env.py,sha256=ib1Y6cItVvId4PfesiQ0XKbh9y6h8LVhD0gYDO4wSlk,15732
55
55
  job_shop_lib/reinforcement_learning/_reward_observers.py,sha256=iWHccnujeAKyTQn2ilQ4BhcEccoSTyJqQ5yOiP5GG_Y,2984
56
56
  job_shop_lib/reinforcement_learning/_single_job_shop_graph_env.py,sha256=DZnXeXmzMGKq-vwFhxukmSDN1UyrkUfbnjpjFtC9_Bs,15845
57
57
  job_shop_lib/reinforcement_learning/_types_and_constants.py,sha256=xozdM_Wabdbe9e1a769p5980OSNBwQqc9yyaSGW2ODQ,1743
58
- job_shop_lib/reinforcement_learning/_utils.py,sha256=ksg2ghSncxd0K3AR5hGS5PQejjd-Hgx6LGtXX_oatOc,2523
58
+ job_shop_lib/reinforcement_learning/_utils.py,sha256=PZWUZVc_Du90PYvKeTxe0dLkCuK3KwQ3D5I54kk5x0U,3808
59
59
  job_shop_lib/visualization/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
60
60
  job_shop_lib/visualization/gantt/__init__.py,sha256=HGXwRgDuMAldqU0JBdiZCd5e79XBz1r96qHeDVlzE54,1145
61
61
  job_shop_lib/visualization/gantt/_gantt_chart_creator.py,sha256=LTsVhpB1Fb_2o08HRZPPXSekwzR7fyTSC6h549XMqhU,8638
@@ -64,7 +64,7 @@ job_shop_lib/visualization/gantt/_plot_gantt_chart.py,sha256=9-NSSNsVcW8gYLZtAuF
64
64
  job_shop_lib/visualization/graphs/__init__.py,sha256=282hZFg07EyQu4HVt4GzFfYnY6ZF376IMjnWZ5eg0ZQ,611
65
65
  job_shop_lib/visualization/graphs/_plot_disjunctive_graph.py,sha256=4VBMYiFXXkCGSnGYN9iqNtWrbLJQxAMHojPHhAbdA0s,14387
66
66
  job_shop_lib/visualization/graphs/_plot_resource_task_graph.py,sha256=RgJqHS5hJh3KkyaLbtpG_bER981BFRwGpflz7I7gS64,13271
67
- job_shop_lib-1.0.0b2.dist-info/LICENSE,sha256=9mggivMGd5taAu3xbmBway-VQZMBzurBGHofFopvUsQ,1069
68
- job_shop_lib-1.0.0b2.dist-info/METADATA,sha256=_6waZfwgtsPOyvZ5rw18aulHrqEOJji5jcde9NrQBpg,16978
69
- job_shop_lib-1.0.0b2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
70
- job_shop_lib-1.0.0b2.dist-info/RECORD,,
67
+ job_shop_lib-1.0.0b3.dist-info/LICENSE,sha256=9mggivMGd5taAu3xbmBway-VQZMBzurBGHofFopvUsQ,1069
68
+ job_shop_lib-1.0.0b3.dist-info/METADATA,sha256=m-NzkaDXbblEXE7O-iQEYOdQQCPDvj6LiRcJKqenpHg,16424
69
+ job_shop_lib-1.0.0b3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
70
+ job_shop_lib-1.0.0b3.dist-info/RECORD,,