job_shop_lib.graphs.graph_updaters¶
Contains classes and functions for updating the graph representation of the job shop scheduling problem.
Currently, the following classes and utilities are available:
Observer that builds and updates a job shop graph. |
|
Updates the residual graph based on the completed operations. |
|
Updates the graph based on the completed operations. |
|
Removes the operation node of the scheduled operation from the graph. |
- class GraphUpdater(dispatcher, job_shop_graph, *, subscribe=True)[source]¶
Bases:
DispatcherObserverObserver that builds and updates a job shop graph.
This observer uses a provided graph builder function to initialize the job shop graph and a graph updater function to update the graph after each scheduled operation.
- initial_job_shop_graph¶
The initial job shop graph. This is a copy of the graph that was received when the observer was created. It is used to reset the graph to its initial state.
- job_shop_graph¶
The current job shop graph. This is the graph that is updated after each scheduled operation.
- Parameters:
dispatcher (Dispatcher) -- The dispatcher instance to observe.
job_shop_graph (JobShopGraph) -- The job shop graph to update.
subscribe (bool) -- Whether to subscribe to the dispatcher. If
True, the observer will subscribe to the dispatcher when it is initialized. IfFalse, the observer will not subscribe to the dispatcher.
- abstract update(scheduled_operation)[source]¶
Updates the job shop graph after an operation has been dispatched.
- Parameters:
scheduled_operation (ScheduledOperation)
- Return type:
None
- class ResidualGraphUpdater(dispatcher, job_shop_graph, *, subscribe=True, remove_completed_machine_nodes=True, remove_completed_job_nodes=True)[source]¶
Bases:
GraphUpdaterUpdates the residual graph based on the completed operations.
This observer updates the residual graph by removing the completed operation, machine and job nodes from the graph. It subscribes to the
IsCompletedObserverto determine which operations, machines and jobs have been completed.- remove_completed_machine_nodes¶
If
True, removes completed machine nodes from the graph.
- remove_completed_job_nodes¶
If
True, removes completed job nodes from the graph.
- Parameters:
dispatcher (Dispatcher) -- The dispatcher instance to observe.
job_shop_graph (JobShopGraph) -- The job shop graph to update.
subscribe (bool) -- If
True, automatically subscribes the observer to the dispatcher. Defaults toTrue.remove_completed_machine_nodes (bool) -- If
True, removes completed machine nodes from the graph. Defaults toTrue.remove_completed_job_nodes (bool) -- If
True, removes completed job nodes from the graph. Defaults toTrue.
- property is_completed_observer: IsCompletedObserver¶
~job_shop_lib.dispatching.feature_observers. IsCompletedObserver instance.
- Type:
Returns the
- Type:
class
- update(scheduled_operation)[source]¶
Updates the residual graph based on the completed operations.
- Parameters:
scheduled_operation (ScheduledOperation)
- Return type:
None
- class DisjunctiveGraphUpdater(dispatcher, job_shop_graph, *, subscribe=True, remove_completed_machine_nodes=True, remove_completed_job_nodes=True)[source]¶
Bases:
ResidualGraphUpdaterUpdates the graph based on the completed operations.
This observer updates the graph by removing the completed operation, machine and job nodes from the graph. It subscribes to the
IsCompletedObserverto determine which operations, machines and jobs have been completed.After an operation is dispatched, one of two disjunctive arcs that connected it with the previous operation is dropped. Similarly, the disjunctive arcs associated with the previous scheduled operation are removed.
- remove_completed_machine_nodes¶
If
True, removes completed machine nodes from the graph.
- remove_completed_job_nodes¶
If
True, removes completed job nodes from the graph.
- Parameters:
dispatcher (Dispatcher) -- The dispatcher instance to observe.
job_shop_graph (JobShopGraph) -- The job shop graph to update.
subscribe (bool) -- If
True, automatically subscribes the observer to the dispatcher. Defaults toTrue.remove_completed_machine_nodes (bool) -- If
True, removes completed machine nodes from the graph. Defaults toTrue.remove_completed_job_nodes (bool) -- If
True, removes completed job nodes from the graph. Defaults toTrue.
- update(scheduled_operation)[source]¶
Updates the disjunctive graph.
After an operation is dispatched, one of two arcs that connected it with the previous operation is dropped. Similarly, the disjunctive arcs associated with the previous scheduled operation are removed.
- Parameters:
scheduled_operation (ScheduledOperation) -- The scheduled operation that was dispatched.
- Return type:
None
- remove_completed_operations(job_shop_graph, completed_operations)[source]¶
Removes the operation node of the scheduled operation from the graph.
- Parameters:
job_shop_graph (JobShopGraph) -- The job shop graph to update.
dispatcher -- The dispatcher instance.
completed_operations (Iterable[Operation])
- Return type:
None