Skip to content

Commit 901ccef

Browse files
authored
Merge pull request #66 from bikuta6/v2.0.0
Significant refactor to the gym environments and the `JobShopGraph` class.
2 parents ed7949f + 8e31b36 commit 901ccef

40 files changed

+1040
-1142
lines changed

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -257,17 +257,17 @@ disjunctive_graph = build_disjunctive_graph(instance)
257257

258258
>>> disjunctive_graph.nodes_by_type
259259
defaultdict(list,
260-
{<NodeType.OPERATION: 1>: [Node(node_type=OPERATION, value=O(m=0, d=1, j=0, p=0), id=0),
261-
Node(node_type=OPERATION, value=O(m=1, d=1, j=0, p=1), id=1),
262-
Node(node_type=OPERATION, value=O(m=2, d=7, j=0, p=2), id=2),
263-
Node(node_type=OPERATION, value=O(m=1, d=5, j=1, p=0), id=3),
264-
Node(node_type=OPERATION, value=O(m=2, d=1, j=1, p=1), id=4),
265-
Node(node_type=OPERATION, value=O(m=0, d=1, j=1, p=2), id=5),
266-
Node(node_type=OPERATION, value=O(m=2, d=1, j=2, p=0), id=6),
267-
Node(node_type=OPERATION, value=O(m=0, d=3, j=2, p=1), id=7),
268-
Node(node_type=OPERATION, value=O(m=1, d=2, j=2, p=2), id=8)],
269-
<NodeType.SOURCE: 5>: [Node(node_type=SOURCE, value=None, id=9)],
270-
<NodeType.SINK: 6>: [Node(node_type=SINK, value=None, id=10)]})
260+
{<NodeType.OPERATION: 1>: [Node(node_type=OPERATION, value=O(m=0, d=1, j=0, p=0), id=("OPERATION", 0)),
261+
Node(node_type=OPERATION, value=O(m=1, d=1, j=0, p=1), id=("OPERATION", 1)),
262+
Node(node_type=OPERATION, value=O(m=2, d=7, j=0, p=2), id=("OPERATION", 2)),
263+
Node(node_type=OPERATION, value=O(m=1, d=5, j=1, p=0), id=("OPERATION", 3)),
264+
Node(node_type=OPERATION, value=O(m=2, d=1, j=1, p=1), id=("OPERATION", 4)),
265+
Node(node_type=OPERATION, value=O(m=0, d=1, j=1, p=2), id=("OPERATION", 5)),
266+
Node(node_type=OPERATION, value=O(m=2, d=1, j=2, p=0), id=("OPERATION", 6)),
267+
Node(node_type=OPERATION, value=O(m=0, d=3, j=2, p=1), id=("OPERATION", 7)),
268+
Node(node_type=OPERATION, value=O(m=1, d=2, j=2, p=2), id=("OPERATION", 8))],
269+
<NodeType.SOURCE: 5>: [Node(node_type=SOURCE, value=None, id=('SOURCE', 0))],
270+
<NodeType.SINK: 6>: [Node(node_type=SINK, value=None, id=('SINK', 0))]})
271271
```
272272

273273
Other attributes include:

docs/source/examples/05-Load-Benchmark-Instances.ipynb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@
303303
],
304304
"source": [
305305
"import numpy as np\n",
306+
"\n",
306307
"np.array(ft06.durations_matrix)"
307308
]
308309
},

docs/source/examples/09-SingleJobShopGraphEnv.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@
4949
" feature_observer_configs=feature_observer_configs,\n",
5050
" reward_function_config=DispatcherObserverConfig(IdleTimeReward),\n",
5151
" render_mode=\"human\", # Try \"save_video\"\n",
52-
" render_config={\n",
53-
" \"video_config\": {\"fps\": 4}\n",
54-
" }\n",
52+
" render_config={\"video_config\": {\"fps\": 4}},\n",
5553
")"
5654
]
5755
},
@@ -252,7 +250,9 @@
252250
"import numpy as np\n",
253251
"\n",
254252
"rewards = np.array(env.reward_function.rewards)\n",
255-
"print(f\"{len(list(filter(lambda x: x != 0, rewards)))} zeros out of {len(rewards)}\")"
253+
"print(\n",
254+
" f\"{len(list(filter(lambda x: x != 0, rewards)))} zeros out of {len(rewards)}\"\n",
255+
")"
256256
]
257257
},
258258
{

docs/source/examples/12-ReadyOperationsFilter.ipynb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,13 @@
375375
" df = print_makespans_for_optimizations(ta01, pdr)\n",
376376
" print()\n",
377377
" # Chamge the number of xticks to 10\n",
378-
" df.sort_values(by=\"Makespan\", ascending=False).plot.barh(x=\"Filter Combination\", y=\"Makespan\", title=pdr.name, xlim=(1500, 2000), xticks=range(1500, 2001, 50))\n",
378+
" df.sort_values(by=\"Makespan\", ascending=False).plot.barh(\n",
379+
" x=\"Filter Combination\",\n",
380+
" y=\"Makespan\",\n",
381+
" title=pdr.name,\n",
382+
" xlim=(1500, 2000),\n",
383+
" xticks=range(1500, 2001, 50),\n",
384+
" )\n",
379385
" dfs.append(df)"
380386
]
381387
},
@@ -408,7 +414,9 @@
408414
"source": [
409415
"df_combined = pd.concat(dfs, keys=[pdr.name for pdr in DispatchingRuleType])\n",
410416
"\n",
411-
"df_combined.groupby(\"Filter Combination\").agg(\"mean\").sort_values(by=\"Makespan\", ascending=False).plot.barh(title=\"Average Makespan\")"
417+
"df_combined.groupby(\"Filter Combination\").agg(\"mean\").sort_values(\n",
418+
" by=\"Makespan\", ascending=False\n",
419+
").plot.barh(title=\"Average Makespan\")"
412420
]
413421
},
414422
{

job_shop_lib/.DS_Store

6 KB
Binary file not shown.

job_shop_lib/dispatching/feature_observers/_dates_observer.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,7 @@ def update(self, scheduled_operation: ScheduledOperation):
135135
elapsed_time = current_time - self._previous_current_time
136136
self._previous_current_time = current_time
137137
cols = [
138-
self._attribute_map[attr]
139-
for attr in self.attributes_to_observe
138+
self._attribute_map[attr] for attr in self.attributes_to_observe
140139
]
141140
self.features[FeatureType.OPERATIONS][:, cols] -= elapsed_time
142141

job_shop_lib/graphs/_build_disjunctive_graph.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,12 @@ def build_solved_disjunctive_graph(schedule: Schedule) -> JobShopGraph:
8181
break
8282
next_scheduled_operation = machine_schedule[i + 1]
8383
graph.add_edge(
84-
scheduled_operation.operation.operation_id,
85-
next_scheduled_operation.operation.operation_id,
84+
graph.get_operation_node(
85+
scheduled_operation.operation.operation_id
86+
),
87+
graph.get_operation_node(
88+
next_scheduled_operation.operation.operation_id
89+
),
8690
type=EdgeType.DISJUNCTIVE,
8791
)
8892

0 commit comments

Comments
 (0)