jobshoplab.utils.state_machine_utils package

Submodules

jobshoplab.utils.state_machine_utils.buffer_type_utils module

replace_buffer_state(state, buffer_state)[source]
Parameters:
state : State

Return type:

State

get_buffer_config_by_id(buffers, buffer_id)[source]

Get a buffer config by its ID from a tuple of BufferConfig objects.

Parameters:
buffers : tuple[BufferConfig, ...]

A tuple of BufferConfig objects.

buffer_id : str

The ID of the desired buffer.

Returns:

The BufferConfig object with the specified ID.

Return type:

BufferConfig

Raises:

InvalidValue – If the desired buffer is not found in the given tuple of buffers.

is_job_in_buffer(buffer_state, job_id)[source]

Check if a job is in a buffer.

Parameters:
buffer_state : BufferState

The buffer to check.

job_id : str

The ID of the job to check.

Returns:

True if the job is in the buffer, False otherwise.

Return type:

bool

put_in_buffer(buffer_state, buffer_config, job_state)[source]

Put a job in a buffer.

Parameters:
buffer_state : BufferState

The buffer to put the job in.

job_state : JobState

The job to put in the buffer.

buffer_config : BufferConfig

Returns:

The updated buffer state.

Return type:

BufferState

switch_buffer(instance, buffer_from_state, buffer_to_state, job_state)[source]

Switch a job from one buffer to another.

Parameters:
buffer_from_state : BufferState

The buffer to remove the job from.

buffer_to_state : BufferState

The buffer to put the job in.

job_state : JobState

The job to switch buffers.

instance : InstanceConfig

Returns:

The updated buffer states and job state.

Return type:

tuple[BufferState, BufferState, JobState]

remove_from_buffer(buffer_state, job_id)[source]

Remove a job from a buffer.

Parameters:
buffer_state : BufferState

The buffer to remove the job from.

job_id : str

The id of the job to remove from the buffer.

Returns:

The updated buffer state.

Return type:

BufferState

get_all_buffer_configs(instance)[source]

Get all buffer configurations from the instance configuration.

Parameters:
instance : InstanceConfig

The instance configuration.

Returns:

A list of all buffer configurations.

Return type:

list[BufferConfig]

get_all_buffer_states(state)[source]

Get all buffer states from the state.

Parameters:
state : State

The state.

Returns:

A list of all buffer states.

Return type:

list[BufferState]

get_buffer_state_by_id(buffers, buffer_id)[source]

Get a buffer state by its ID from a tuple of BufferState objects.

Parameters:
buffers : tuple[BufferState, ...]

A tuple of BufferState objects.

buffer_id : str

The ID of the desired buffer.

Returns:

The BufferState object with the specified ID.

Return type:

BufferState

Raises:

InvalidValue – If the desired buffer is not found in the given tuple of buffers.

jobshoplab.utils.state_machine_utils.component_type_utils module

get_obj_by_id(obj, id)[source]

Get an object by its ID from a tuple of objects.

Parameters:
obj : Tuple[T, ...]

A tuple of objects.

id : str

The ID of the desired object.

Returns:

The object with the specified ID.

Return type:

T

Raises:

InvalidValue – If the desired object is not found in the given tuple of objects.

get_comp_by_id(state, id)[source]
Parameters:
state : State

id : str

jobshoplab.utils.state_machine_utils.core_utils module

print_state(state)[source]
Parameters:
state : State

is_done(state)[source]

Check if the state machine is done. :param state: The current state of the state machine. :type state: State

Returns:

A boolean indicating if the state machine is done.

Return type:

bool

Parameters:
state : State

no_processing_operations(job)[source]

Checks if a job has any processing operations.

Parameters:
job : JobState

The job to check.

Returns:

True if the job has no processing operations, False otherwise.

Return type:

bool

is_machine_transition_from_idle_to_setup(machine, transition)[source]
Parameters:
machine : MachineState

is_machine_transition_from_setup_to_working(machine, transition)[source]
Parameters:
machine : MachineState

is_machine_transition_from_working_to_outage(machine, transition)[source]
Parameters:
machine : MachineState

is_machine_transition_from_outage_to_idle(machine, transition)[source]
Parameters:
machine : MachineState

is_transport_transition_from_idle_to_working(transport, transition)[source]
Parameters:
transport : TransportState

is_transport_transition_from_pickup_to_transit(transport, transition)[source]
Parameters:
transport : TransportState

is_transport_transition_from_pickup_to_waitingpickup(transport, transition)[source]
Parameters:
transport : TransportState

is_transport_transition_from_waitingpickup_to_transit(transport, transition)[source]
Parameters:
transport : TransportState

is_transport_transition_from_working_to_outage(transport, transition)[source]
Parameters:
transport : TransportState

is_transport_transition_from_transit_to_outage(transport, transition)[source]
Parameters:
transport : TransportState

is_transport_transition_from_outage_to_idle(transport, transition)[source]
Parameters:
transport : TransportState

is_transport_transition_from_waiting_pickup_waiting_pickup(transport, transition)[source]
Parameters:
transport : TransportState

sorted_by_transport(transitions)[source]
Parameters:
transitions : tuple[ComponentTransition, ...]

Return type:

tuple[ComponentTransition, …]

create_transport_location_from_job(current_dest, pickup_dest, dropoff_dest)[source]
Parameters:
current_dest : str

pickup_dest : str

dropoff_dest : str

Return type:

TransportLocation

sorted_done_operations(job_states)[source]
Parameters:
job_states : tuple[JobState, ...]

Return type:

tuple[OperationState, …]

jobshoplab.utils.state_machine_utils.dispatch_rules_uitls module

get_inbuffer_jobs_for_machine(instance, state, machine_id)[source]
Parameters:
instance : InstanceConfig

state : State

machine_id : str

get_prebuffer_operations_for_machine(instance, state, machine_id)[source]
Parameters:
instance : InstanceConfig

state : State

machine_id : str

find_job_state_from_operation(state, operation_id)[source]
Parameters:
state : State

operation_id : str

Return type:

JobState | None

find_job_config_from_operation(instance, operation_id)[source]
Parameters:
instance : InstanceConfig

operation_id : str

get_machine_prebuffer_jobs_by_processing_time(instance, state, mode='SPT')[source]

Gets jobs for machines based on the processing time of their next operation.

Parameters:
instance : InstanceConfig

state : State

get_machine_jobs_by_remaining_processing_time(instance, state, mode='srpt')[source]

Assigns jobs to machines based on Shortest/Longest Remaining Processing Time.

Parameters:
instance : InstanceConfig

state : State

get_all_outbuffer_jobs(instance, state)[source]

Retrieves all jobs in outbuffer and postbuffer across machines.

Parameters:
instance : InstanceConfig

state : State

get_job_with_most_remaining_processing_time(instance, job_states)[source]

Returns the job with the most remaining processing time.

Parameters:
instance : InstanceConfig

job_states : tuple[JobState, ...]

get_job_by_operation_count(job_states, find_max=True)[source]

Returns the job with the most or least remaining operations.

jobshoplab.utils.state_machine_utils.job_type_utils module

job_at_machine(job, machine)[source]

Check if a job is at a machine.

Parameters:
job : JobState

The job to check.

machine : MachineState

The machine to check.

Returns:

True if the job is at the machine, False otherwise.

Return type:

bool

get_job_state_by_id(jobs, job_id)[source]

Get a job by its ID from a tuple of JobState objects.

Parameters:
jobs : tuple[JobState, ...]

A tuple of JobState objects.

job_id : str

The ID of the desired job.

Returns:

The JobState object with the specified ID.

Return type:

JobState

Raises:

InvalidValue – If the desired job is not found in the given tuple of jobs.

get_job_config_by_id(jobs, job_id)[source]

Get a job config by its ID from a tuple of JobConfig objects.

Parameters:
jobs : tuple[JobConfig, ...]

A tuple of JobConfig objects.

job_id : str

The ID of the desired job.

Returns:

The JobConfig object with the specified ID.

Return type:

JobConfig

Raises:

InvalidValue – If the desired job is not found in the given tuple of jobs.

get_operation_state_by_id(jobs, operation_id)[source]

Get an operation by its ID from a tuple of JobState objects.

Parameters:
jobs : tuple[JobState, ...]

A tuple of JobState objects.

operation_id : str

The ID of the desired operation.

Returns:

The JobState object with the specified ID.

Return type:

JobState

Raises:

InvalidValue – If the desired operation is not found in the given tuple of jobs.

get_operation_config_by_id(jobs, operation_id)[source]

Get an operation config by its ID from a tuple of JobConfig objects.

Parameters:
jobs : tuple[JobConfig, ...]

A tuple of JobConfig objects.

operation_id : str

The ID of the desired operation.

Returns:

The JobConfig object with the specified ID.

Return type:

JobConfig

Raises:

InvalidValue – If the desired operation is not found in the given tuple of jobs.

is_last_operation_running(job)[source]

Check if the last operation of a job is running.

Parameters:
job : JobState

The job to check.

Returns:

True if the last operation of the job is running, False otherwise.

Return type:

bool

is_job_running(job)[source]

Check if a job is running.

Parameters:
job : JobState

The job to check.

Returns:

True if the job is running, False otherwise.

Return type:

bool

get_next_not_done_operation(job)[source]

Get the next operation from a job.

Parameters:
job : JobState

The job to get the next operation from.

Returns:

The next operation from the job.

Return type:

OperationState

Raises:

InvalidValue – If the job has no more operations.

get_next_idle_operation(job)[source]

Get the next operation from a job.

Parameters:
job : JobState

The job to get the next operation from.

Returns:

The next operation from the job.

Return type:

OperationState

Raises:

InvalidValue – If the job has no more operations.

get_next_operation_for_machine(machine_id, jobs)[source]
Parameters:
jobs : JobState

Return type:

OperationState

get_processing_operation(job)[source]

Get the active operation from a job.

Parameters:
job : JobState

The job to get the active operation from.

Returns:

The active operation from the job.

Return type:

OperationState

Raises:

InvalidValue – If the job has no active operations.

group_operations_by_state(job_states)[source]

Group all operations from job states by their operation state state.

Parameters:
job_states : Iterable[JobState]

An iterable of JobState objects.

Returns:

A dictionary with the operation state state as the key and a list of operations as the value.

Return type:

dict[OperationStateState, list[OperationState]]

is_done(job)[source]

Check if a job is done.

Parameters:
job : JobState

The job to check.

Returns:

True if the job is done, False otherwise.

Return type:

bool

jobshoplab.utils.state_machine_utils.logisitcs_type_uitls module

get_travel_time(logistics)[source]
Parameters:
logistics : LogisticsConfig

Return type:

int

jobshoplab.utils.state_machine_utils.machine_type_utils module

get_machine_state_by_id(machines, machine_id)[source]

Get a machine by its ID from a tuple of MachineState objects.

Parameters:
machines : tuple[MachineState, ...]

A tuple of MachineState objects.

machine_id : str

The ID of the desired machine.

Returns:

The MachineState object with the specified ID.

Return type:

MachineState

Raises:

InvalidValue – If the desired machine is not found in the given tuple of machines.

get_machine_config_by_id(machine_configs, machine_id)[source]

Get a machine config by its ID from a tuple of MachineConfig objects.

Parameters:
machine_configs : tuple[MachineConfig, ...]

A tuple of MachineConfig objects.

machine_id : str

The ID of the desired machine.

Returns:

The MachineConfig object with the specified ID.

Return type:

MachineConfig

Raises:

InvalidValue – If the desired machine config is not found in the given tuple of machine configs.

get_machine_id_from_buffer(machine_configs, buffer_id)[source]

Get the Machine where the buffer is located.

Checks if buffer is prebuffer, postbuffer or buffer and returns the corresponding machine id.

Parameters:
machine_configs : tuple[MachineConfig, ...]

buffer_id : str

Return type:

str | None

get_buffer_state_from_machine(machine_state, buffer_id)[source]

Get the buffer state from a machine state.

Parameters:
machine_state : MachineState

buffer_id : str

Return type:

BufferState

replace_buffer_state_in_machine(machine_state, buffer_state)[source]

Update the buffer state in a machine state.

Parameters:
machine_state : MachineState

buffer_state : BufferState

Return type:

MachineState

jobshoplab.utils.state_machine_utils.possible_transition_utils module

is_job_next_operation_free(job_state)[source]

Checks if a operation at a job is possible -> Job is not finished -> Job is not active

Parameters:
job_state : JobState

Return type:

bool

is_job_at_machine(job_state, machine_state)[source]

Check if a job is at a machine.

Parameters:
job_state : JobState

The job to check.

machine : MachineState

The machine to check.

machine_state : MachineState

Returns:

True if the job is at the machine, False otherwise.

Return type:

bool

is_action_possible(job_state, state, instance)[source]

Checks if a action at a job is possible -> Machine action -> Transport action

Returns: True if the operation is possible, False otherwise

Parameters:
job_state : JobState

state : State

instance : InstanceConfig

Return type:

bool

get_possible_transports(transport_states, transport_configs)[source]

Checks if the transport is possible

Returns: True if the transport is possible, False otherwise

Parameters:
transport_states : tuple[TransportState, ...]

transport_configs : tuple[TransportTypeConfig, ...]

Return type:

Generator[TransportState, None, None]

get_num_possible_events(state, instance)[source]

Get the number of possible events

Returns: The number of possible events

Return type:

int

sort_by_id(components)[source]
Parameters:
components : tuple[JobState | TransportState, ...]

Return type:

tuple[JobState | TransportState, …]

get_possible_transport_transition(state, instance)[source]

Get all available transports and mach each transport with each possible job Jobs are possible when:

  • Job is in state working -> when finised it need to be transported to next op

  • Job is in state idle and next op is not the current location

  • Jobs that are not getting are already assigned to an agv

Returns: The tuple of possible ComponentTransitions

Parameters:
state : State

Return type:

tuple[ComponentTransition, …]

get_possible_transitions(state, instance)[source]

Get all possible transitions for the state

Return type:

tuple[ComponentTransition, …]

replace_machine_state(state, machine_state)[source]
replace_job_state(state, job_state)[source]
Return type:

State

replace_transport_state(state, transport_state)[source]
Return type:

State

replace_job_operation_state(job, operation)[source]
Parameters:
job : JobState

operation : OperationState

Return type:

JobState

get_component_by_obj(state, obj)[source]
get_component_by_id(components, id)[source]
get_component_by_id_and_type(state, id, dtype)[source]
replace_component_by_id_and_type(state, id, dtype, new_obj)[source]
replace_component_by_obj(state, obj)[source]
replace_components(state, updated_components)[source]

jobshoplab.utils.state_machine_utils.transport_type_utils module

get_transport_state_by_id(transports, transport_id)[source]

Get a transport by its ID from a tuple of TransportState objects.

Parameters:
transports : tuple[TransportState, ...]

A tuple of TransportState objects.

transport_id : str

The ID of the desired transport.

Returns:

The TransportState object with the specified ID.

Return type:

TransportState

Raises:

InvalidValue – If the desired transport is not found in the given tuple of transports.

get_transport_config_by_id(transports, transport_id)[source]

Get a transport by its ID from a tuple of TransportConfig objects.

Parameters:
transports : tuple[TransportConfig, ...]

A tuple of TransportConfig objects.

transport_id : str

The ID of the desired transport.

Returns:

The TransportConfig object with the specified ID.

Return type:

TransportConfig

Raises:

InvalidValue – If the desired transport is not found in the given tuple of transports.

group_transports_by_state(transports)[source]

Group all transports by their state.

Parameters:
transports : tuple[TransportState, ...]

A tuple of TransportState objects.

Returns:

A dictionary with the transport state as the key and a tuple of transports as the value.

Return type:

dict[str, tuple[TransportState, …]]

Module contents