jobshoplab.utils package

Subpackages

Submodules

jobshoplab.utils.dipatching_benchmark module

jobshoplab.utils.exceptions module

exception JobShopException[source]

Bases: Exception

__init__(message)[source]
exception StopIteration[source]

Bases: JobShopException

__init__(message)[source]
exception FileNotFound[source]

Bases: JobShopException

__init__(file)[source]
exception NoJsspSpecified[source]

Bases: JobShopException

__init__()[source]
exception ValueNotSet[source]

Bases: JobShopException

__init__(key, value)[source]
exception InvalidValue[source]

Bases: JobShopException

__init__(key, value, message='')[source]
exception InvalidKey[source]

Bases: JobShopException

__init__(key)[source]
exception InvalidType[source]

Bases: JobShopException

__init__(key, value, expected_type)[source]
exception NotImplementedError[source]

Bases: JobShopException

__init__()[source]
exception InvalidObservationSpace[source]

Bases: JobShopException

__init__(message)[source]
exception InvalidActionSpace[source]

Bases: JobShopException

__init__(message)[source]
exception UnsuccessfulStateMachineResult[source]

Bases: JobShopException

__init__()[source]
exception ActionOutOfActionSpace[source]

Bases: JobShopException

__init__(action, action_space)[source]
exception EnvDone[source]

Bases: JobShopException

__init__()[source]
exception DslSyntaxError[source]

Bases: JobShopException

__init__(message, line)[source]
exception MissingSpecificationError[source]

Bases: JobShopException

__init__(specification_name)[source]
exception InvalidTimeSpecification[source]

Bases: JobShopException

__init__(message)[source]
exception UnknownLocationNameError[source]

Bases: JobShopException

__init__(name)[source]
exception InvalidDurationError[source]

Bases: JobShopException

__init__(value, expected_type='integer')[source]
exception InvalidDistributionError[source]

Bases: JobShopException

__init__(message)[source]
exception UnknownDistributionTypeError[source]

Bases: JobShopException

__init__(dist_type)[source]
exception InvalidTimeBehaviorError[source]

Bases: JobShopException

__init__(behavior)[source]
exception InvalidSetupTimesError[source]

Bases: JobShopException

__init__(machine_id)[source]
exception InvalidToolUsageError[source]

Bases: JobShopException

__init__(job_id)[source]
exception InvalidTransportConfig[source]

Bases: JobShopException

__init__(message)[source]
exception ComponentAssociationError[source]

Bases: JobShopException

__init__(component_id, component_type)[source]
exception MissingComponentError[source]

Bases: JobShopException

__init__(component_id, component_type)[source]
exception InvalidOutageTypeError[source]

Bases: JobShopException

__init__(outage_type)[source]
exception BufferFullError[source]

Bases: JobShopException

__init__(buffer_id)[source]
exception JobNotInBufferError[source]

Bases: JobShopException

__init__(job_id, buffer_id)[source]
exception InvalidDispatchRuleError[source]

Bases: JobShopException

__init__(mode, allowed_modes)[source]
exception OperationMachineMatchError[source]

Bases: JobShopException

__init__(operation_id, expected_machine, actual_machine)[source]
exception MissingJobIdError[source]

Bases: JobShopException

__init__(transition_type=None)[source]
exception TransportJobError[source]

Bases: JobShopException

__init__(transport_id, transport_job=None)[source]
exception MissingProcessingOperationError[source]

Bases: JobShopException

__init__(job_id=None)[source]
exception TransportConfigError[source]

Bases: JobShopException

__init__(config_field, value=None)[source]
exception TravelTimeError[source]

Bases: JobShopException

__init__(source, destination)[source]
exception InstanceSchemaError[source]

Bases: JobShopException

__init__(message, field=None)[source]
exception MissingRequiredFieldError[source]

Bases: InstanceSchemaError

__init__(field_name, parent_field=None)[source]
exception InvalidFieldValueError[source]

Bases: InstanceSchemaError

__init__(field_name, value, expected_format=None)[source]
exception JobSpecificationSyntaxError[source]

Bases: InstanceSchemaError

__init__(line_number, line_content, details=None)[source]
exception KeyError[source]

Bases: JobShopException

__init__(key)[source]
exception IndexError[source]

Bases: JobShopException

__init__(index, sequence_length=None)[source]
exception ValueError[source]

Bases: JobShopException

__init__(value, message='')[source]
exception AttributeError[source]

Bases: JobShopException

__init__(obj, attr)[source]
exception ImportError[source]

Bases: JobShopException

__init__(module)[source]
exception ConfigurationError[source]

Bases: JobShopException

__init__(config_name, value=None, details=None)[source]
exception InvalidTimeTypeError[source]

Bases: JobShopException

__init__(actual_type, expected_types=None)[source]
exception InvalidSetupTimeTypeError[source]

Bases: JobShopException

__init__(actual_type, expected_types=None)[source]

jobshoplab.utils.load_config module

load_config(frozen=True, stub_file_path=PosixPath('/home/runner/work/jobshoplab/jobshoplab/jobshoplab/utils/load_config.py'), config_path=PosixPath('data/config/config.yaml'))[source]

Load the configuration from the specified directory and return a Config object.

Parameters:
frozen : bool, optional

Whether the configuration should be frozen. Defaults to True.

stub_file_path : Path | None

config_path : Path

Returns:

The loaded configuration object.

Return type:

Config

Raises:
  • FileNotFoundError – If the configuration file does not exist.

  • yaml.YAMLError – If there is an error parsing the YAML configuration file.

Note

CONFIG_YAML_PATH is a global variable that sets the path of your YAML config file.

jobshoplab.utils.logger module

get_logger(name, loglevel, handler=<StreamHandler <stdout> (NOTSET)>)[source]

get a logger object with the given name and log level. matches various log levels and converts them to the corresponding logging level.

Parameters:
name : str

The name of the logger.

loglevel : int|str

The log level.

handler : Handler

Returns:

The logger object.

Return type:

logging.Logger

Raises:

ValueError – If the loglevel is invalid.

jobshoplab.utils.rich_cli module

load_history_from_pickle(file_path)[source]
Parameters:
file_path : str

Return type:

tuple[StateMachineResult, …]

render_action(state_result)[source]
Parameters:
state_result : StateMachineResult

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

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

render_job_table(job)[source]
Parameters:
job : JobState

render_possilbe_transitions(state_machine_result)[source]
Parameters:
state_machine_result : StateMachineResult

render_machine_with_buffers(machine_state)[source]

Render a machine with its pre-buffer and post-buffer in a single row.

render_standalone_buffers(state_machine_result)[source]

Render Buffer Overview.

Parameters:
state_machine_result : StateMachineResult

render_shopfloor_overview(state_machine_result)[source]

Render all machines compactly.

render_table(state_result)[source]
Parameters:
state_result : StateMachineResult

render_from_file(file_path)[source]
Parameters:
file_path : str

render(history, *args, **kwargs)[source]
Parameters:
history : tuple

jobshoplab.utils.solutions module

make_solution_action_sequence(dir)[source]

Create a solution action sequence. This function reads a file from the specified directory, processes its contents, and returns a tuple containing the machine, job, and start_time in each row. :param dir: The directory path to the file containing the solution data. :type dir: str

Returns:

A tuple containing the machine, job, and start_time sequences.

Return type:

tuple

group_by_time(tuples)[source]

Groups a list of tuples by their start time. :param tuples: A list where each tuple contains three elements:

  • machine: The machine identifier.

  • job: The job identifier.

  • start_time: The start time of the job on the machine.

Returns:

A dictionary where the keys are start times and the values are lists of tuples,

each containing a machine and a job that start at that time. start_time = [(machine, job), …]

Return type:

dict

get_machine_job_time_sequence(sol_arr)[source]

Generator function that yields the machine-job-time sequence from a given solution array. :param sol_arr: A 2D list where each sublist represents a job and each element in the sublist

represents the time required on a specific machine.

Yields:

tuple

A tuple containing the best machine index, best job index, and the lowest time found in the current iteration.

The best machine and job are the ones with the lowest processing time that hasn’t been processed yet.

get_make_span(sol_seq, instance)[source]

Calculate the makespan (total completion time) for a solution sequence.

The makespan is the maximum end time of all last operations across all jobs. For each job’s last operation, find its corresponding entry in the solution sequence, calculate its end time, and return the maximum end time.

Parameters:
sol_seq

Solution sequence with tuples of (machine, job, start_time)

instance : InstanceConfig

Instance configuration with job specifications

Returns:

The makespan (maximum completion time) of the solution

Return type:

int

jobshoplab.utils.textual_cli module

jobshoplab.utils.utils module

class ConfigProtocol[source]

Bases: Protocol

Protocol defining the interface expected for config objects

__init__(*args, **kwargs)
Config

alias of ConfigProtocol

get_args(logger, std_args, config, cfg_instance)[source]

Get the arguments by merging the standard arguments with the attributes of the config object.

Parameters:
std_args : dict

The standard arguments. can be empty. if no standard arguments are needed.

config : Config

The config object.

cfg_instance : list[str]

The list of attribute names to access the desired config instance.

logger : Logger

Returns:

The merged arguments. to be used in the constructor of the object.

Return type:

dict

Raises:

InvalidValue – If the config object is None or if it doesn’t have the required attribute.

hash(obj)[source]

Hash the given object.

Parameters:
obj : Hashable

The object to hash. preferably a string.

Returns:

The hash value.

Return type:

int

get_id_int(id)[source]

Extracts the integer part from an ID string.

Parameters:
id : str

The ID string in the format [a-z]-[0-999]+.

Returns:

The extracted integer part of the ID.

Return type:

str

Raises:

InvalidValue – If the ID format is invalid.

Example

>>> get_id_int('a-123')
'123'

# TODO: How to handle Operation -> o-1-2

get_component_type_int(id)[source]

Get the integer representation of a component type from its ID.

Parameters:
id : str

The component ID string (format: [a-z]-[number])

Returns:

Integer code for the component type (0 for machine, 1 for transport, 2 for buffer)

Return type:

int

Raises:

InvalidValue – If the component type is invalid

get_component_id_int(all_components, id)[source]

Get the integer index of a component in a list of components.

Parameters:
all_components : list[Any]

List of component objects with ‘id’ attribute

id : str

The component ID to find

Returns:

The index of the component in the list

Return type:

int

Raises:

InvalidValue – If the component ID is not found

calculate_bi(schedule)[source]

Calculate the bi values for Taillard’s lower bound calculation.

Parameters:
schedule : ndarray

A 3D numpy array representing the job schedule [job_index][operation_index][machine, duration]

Returns:

Array of bi values for each machine

Return type:

np.ndarray

calculate_ai(schedule)[source]

Calculate the ai values for Taillard’s lower bound calculation.

Parameters:
schedule : ndarray

A 3D numpy array representing the job schedule [job_index][operation_index][machine, duration]

Returns:

Array of ai values for each machine

Return type:

np.ndarray

total_processing_time(schedule)[source]

Calculate the total processing time for each machine.

Parameters:
schedule : ndarray

A 3D numpy array representing the job schedule [job_index][operation_index][machine, duration]

Returns:

Array of total processing times for each machine

Return type:

np.ndarray

max_job_duration(schedule)[source]

Calculate the maximum total duration of any job.

Parameters:
schedule : ndarray

A 3D numpy array representing the job schedule [job_index][operation_index][machine, duration]

Returns:

Maximum duration of any job

Return type:

int

max_machine_duration(schedule)[source]

Calculate the maximum total duration of operations on any machine.

Parameters:
schedule : ndarray

A 3D numpy array representing the job schedule [job_index][operation_index][machine, duration]

Returns:

Maximum duration of any machine

Return type:

int

calculate_lower_bound2(schedule)[source]

Calculate a simple lower bound for the makespan as the maximum of: 1. The maximum total duration of any job 2. The maximum total duration of operations on any machine

Parameters:
schedule : ndarray

A 3D numpy array representing the job schedule [job_index][operation_index][machine, duration]

Returns:

A lower bound for the makespan

Return type:

int

calculate_lower_bound(instance)[source]

lowerbound calculation implementation after taillard 1989 Benchmarks for basic scheduling problems. gives a rought estimate of the lower bound of the makespan of the instance. the estimate is allways less than the actual makespan. :param instance: The instance object. :type instance: object

Returns:

The lower bound of the makespan of the instance

Return type:

int

get_max_allowed_time(instance_config)[source]

Calculate the maximum allowed time for a given instance configuration.

This function computes the sum of the durations of all operations in the instance configuration. This sum represents the worst-case scenario for scheduling without any obvious mistakes.

Parameters:
instance_config : object

The configuration of the instance, which

operations. : includes job specifications and their respective

Returns:

The total duration of all operations, representing the maximum allowed time.

Return type:

int

Module contents