job-shop-lib 1.0.0b4__py3-none-any.whl → 1.0.0b5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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.4"
22
+ __version__ = "1.0.0-b.5"
23
23
 
24
24
  __all__ = [
25
25
  "Operation",
@@ -1,6 +1,6 @@
1
1
  """Contains wrappers for the environments."""
2
2
 
3
- from typing import TypeVar, TypedDict
3
+ from typing import TypeVar, TypedDict, Generic
4
4
  from gymnasium import ObservationWrapper
5
5
  import numpy as np
6
6
  from numpy.typing import NDArray
@@ -12,11 +12,13 @@ from job_shop_lib.reinforcement_learning import (
12
12
  create_edge_type_dict,
13
13
  map_values,
14
14
  )
15
- from job_shop_lib.graphs import NodeType, JobShopGraph
16
- from job_shop_lib.exceptions import ValidationError
15
+ from job_shop_lib.graphs import NodeType
17
16
  from job_shop_lib.dispatching.feature_observers import FeatureType
18
17
 
19
18
  T = TypeVar("T", bound=np.number)
19
+ EnvType = TypeVar( # pylint: disable=invalid-name
20
+ "EnvType", bound=SingleJobShopGraphEnv | MultiJobShopGraphEnv
21
+ )
20
22
 
21
23
 
22
24
  class ResourceTaskGraphObservationDict(TypedDict):
@@ -28,7 +30,7 @@ class ResourceTaskGraphObservationDict(TypedDict):
28
30
 
29
31
 
30
32
  # pylint: disable=line-too-long
31
- class ResourceTaskGraphObservation(ObservationWrapper):
33
+ class ResourceTaskGraphObservation(ObservationWrapper, Generic[EnvType]):
32
34
  """Observation wrapper that converts an observation following the
33
35
  :class:`ObservationDict` format to a format suitable to PyG's
34
36
  [`HeteroData`](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.data.HeteroData.html).
@@ -48,26 +50,12 @@ class ResourceTaskGraphObservation(ObservationWrapper):
48
50
  env: The environment to wrap.
49
51
  """
50
52
 
51
- def __init__(self, env: SingleJobShopGraphEnv | MultiJobShopGraphEnv):
53
+ def __init__(self, env: EnvType):
52
54
  super().__init__(env)
55
+ self.env = env # Unnecessary, but makes mypy happy
53
56
  self.global_to_local_id = self._compute_id_mappings()
54
57
  self.type_ranges = self._compute_node_type_ranges()
55
58
 
56
- @property
57
- def job_shop_graph(self) -> JobShopGraph:
58
- """Returns the job shop graph from the environment.
59
-
60
- Raises:
61
- ValidationError: If the environment is not an instance of
62
- ``SingleJobShopGraphEnv`` or ``MultiJobShopGraphEnv``.
63
- """
64
- if isinstance(self.env, (SingleJobShopGraphEnv, MultiJobShopGraphEnv)):
65
- return self.env.job_shop_graph
66
- raise ValidationError(
67
- "The environment must be an instance of "
68
- "SingleJobShopGraphEnv or MultiJobShopGraphEnv"
69
- )
70
-
71
59
  def step(self, action: tuple[int, int]):
72
60
  """Takes a step in the environment.
73
61
 
@@ -127,7 +115,7 @@ class ResourceTaskGraphObservation(ObservationWrapper):
127
115
  """
128
116
  mappings = {}
129
117
  for node_type in NodeType:
130
- type_nodes = self.job_shop_graph.nodes_by_type[node_type]
118
+ type_nodes = self.unwrapped.job_shop_graph.nodes_by_type[node_type]
131
119
  if not type_nodes:
132
120
  continue
133
121
  # Create mapping from global ID to local ID
@@ -148,7 +136,7 @@ class ResourceTaskGraphObservation(ObservationWrapper):
148
136
  """
149
137
  type_ranges = {}
150
138
  for node_type in NodeType:
151
- type_nodes = self.job_shop_graph.nodes_by_type[node_type]
139
+ type_nodes = self.unwrapped.job_shop_graph.nodes_by_type[node_type]
152
140
  if not type_nodes:
153
141
  continue
154
142
  start = min(node.node_id for node in type_nodes)
@@ -197,7 +185,7 @@ class ResourceTaskGraphObservation(ObservationWrapper):
197
185
  }
198
186
  node_features_dict = {}
199
187
  for node_type, feature_type in node_type_to_feature_type.items():
200
- if node_type in self.job_shop_graph.nodes_by_type:
188
+ if node_type in self.unwrapped.job_shop_graph.nodes_by_type:
201
189
  node_features_dict[feature_type.value] = observation[
202
190
  feature_type.value
203
191
  ]
@@ -210,7 +198,7 @@ class ResourceTaskGraphObservation(ObservationWrapper):
210
198
  ]
211
199
  job_ids_of_ops = [
212
200
  node.operation.job_id
213
- for node in self.job_shop_graph.nodes_by_type[
201
+ for node in self.unwrapped.job_shop_graph.nodes_by_type[
214
202
  NodeType.OPERATION
215
203
  ]
216
204
  ]
@@ -256,3 +244,8 @@ class ResourceTaskGraphObservation(ObservationWrapper):
256
244
  )[0]
257
245
 
258
246
  return removed_nodes_dict, original_ids_dict
247
+
248
+ @property
249
+ def unwrapped(self) -> EnvType:
250
+ """Returns the unwrapped environment."""
251
+ return self.env # type: ignore[return-value]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: job-shop-lib
3
- Version: 1.0.0b4
3
+ Version: 1.0.0b5
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.0b4
63
+ pip install job-shop-lib==1.0.0b5
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.
@@ -1,4 +1,4 @@
1
- job_shop_lib/__init__.py,sha256=I9Ifdoq10hPCyLVpLFUKHTjSldDRCqJx-raUQKid0aw,643
1
+ job_shop_lib/__init__.py,sha256=3Ip52vXCTCs_JAhhNCpSs1Q2omWPbPzKzM1g47mO5eA,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
@@ -52,7 +52,7 @@ job_shop_lib/graphs/graph_updaters/_residual_graph_updater.py,sha256=SfgmDyMwfW5
52
52
  job_shop_lib/graphs/graph_updaters/_utils.py,sha256=X5YfwJA1CCgpm1r9C036Gal2CkDh2SSak7wl7TbdjHw,704
53
53
  job_shop_lib/reinforcement_learning/__init__.py,sha256=opqJyVJ6VPyeaQOQr4hmUTkiUAXOi5tbyCnuNw5jLTI,1421
54
54
  job_shop_lib/reinforcement_learning/_multi_job_shop_graph_env.py,sha256=memQefVWqatRNodt8hBXVvFcgQKJRmnuB8AWqiDl8_k,15746
55
- job_shop_lib/reinforcement_learning/_resource_task_graph_observation.py,sha256=C4sEssy4TqHdr6nLJlg7Cdg48RBRSvmkYDzG1vaTf6U,9920
55
+ job_shop_lib/reinforcement_learning/_resource_task_graph_observation.py,sha256=ROu_oTsjLvuU5cdvZ2A8D5HWlEZ3NfPtjNWJYH5ilJA,9648
56
56
  job_shop_lib/reinforcement_learning/_reward_observers.py,sha256=iWHccnujeAKyTQn2ilQ4BhcEccoSTyJqQ5yOiP5GG_Y,2984
57
57
  job_shop_lib/reinforcement_learning/_single_job_shop_graph_env.py,sha256=3mljeI4k9haLDuDZZhv4NcLpb1_xOlQNdEqMoRsh6bw,16592
58
58
  job_shop_lib/reinforcement_learning/_types_and_constants.py,sha256=xozdM_Wabdbe9e1a769p5980OSNBwQqc9yyaSGW2ODQ,1743
@@ -65,7 +65,7 @@ job_shop_lib/visualization/gantt/_plot_gantt_chart.py,sha256=9-NSSNsVcW8gYLZtAuF
65
65
  job_shop_lib/visualization/graphs/__init__.py,sha256=282hZFg07EyQu4HVt4GzFfYnY6ZF376IMjnWZ5eg0ZQ,611
66
66
  job_shop_lib/visualization/graphs/_plot_disjunctive_graph.py,sha256=4VBMYiFXXkCGSnGYN9iqNtWrbLJQxAMHojPHhAbdA0s,14387
67
67
  job_shop_lib/visualization/graphs/_plot_resource_task_graph.py,sha256=RgJqHS5hJh3KkyaLbtpG_bER981BFRwGpflz7I7gS64,13271
68
- job_shop_lib-1.0.0b4.dist-info/LICENSE,sha256=9mggivMGd5taAu3xbmBway-VQZMBzurBGHofFopvUsQ,1069
69
- job_shop_lib-1.0.0b4.dist-info/METADATA,sha256=9tz-kjhEJIDvEjr5B69IOBI6_gREvO53E1sAN0iKFQk,16424
70
- job_shop_lib-1.0.0b4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
71
- job_shop_lib-1.0.0b4.dist-info/RECORD,,
68
+ job_shop_lib-1.0.0b5.dist-info/LICENSE,sha256=9mggivMGd5taAu3xbmBway-VQZMBzurBGHofFopvUsQ,1069
69
+ job_shop_lib-1.0.0b5.dist-info/METADATA,sha256=NxGDA_C8w6GQlV1zcrkIawyHekRWR8VTvNwQR9s7Ci4,16424
70
+ job_shop_lib-1.0.0b5.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
71
+ job_shop_lib-1.0.0b5.dist-info/RECORD,,