Skip to content

Commit

Permalink
[Refactor] Refactor edge addition in disjunctive graph to improve cla…
Browse files Browse the repository at this point in the history
…rity and efficiency
  • Loading branch information
Pabloo22 committed Oct 9, 2024
1 parent f9e4b04 commit 0bbe905
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions job_shop_lib/graphs/_build_disjunctive_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,13 @@ def build_solved_disjunctive_graph(schedule: Schedule) -> JobShopGraph:
# Iterate over each machine and add only the edges that match the solution
# order
for machine_schedule in schedule.schedule:
# Add the disjunctive edges that reflect the sequence in the solved
# schedule
nodes = [
graph.nodes[scheduled_op.operation.operation_id]
for scheduled_op in machine_schedule
]
for i in range(len(nodes) - 1):
for i, scheduled_operation in enumerate(machine_schedule):
if i + 1 >= len(machine_schedule):
break
next_scheduled_operation = machine_schedule[i + 1]
graph.add_edge(
nodes[i],
nodes[i + 1],
scheduled_operation.operation.operation_id,
next_scheduled_operation.operation.operation_id,
type=EdgeType.DISJUNCTIVE,
)

Expand Down

0 comments on commit 0bbe905

Please sign in to comment.