jobshoplab.compiler package

Submodules

jobshoplab.compiler.compiler module

class Compiler[source]

Bases: object

__init__(config, loglevel='INFO', repo=None, *args, **kwargs)[source]

Initializes the Compiler object.

Parameters:
config : Config

The configuration object.

loglevel : int | str, optional

The log level. Defaults to “INFO”.

repo : None | Repository

compile()[source]

Compiles the provided input source to a instance and init_state dto.

Returns:

A tuple containing the compiled instance and initial state.

Return type:

Tuple[InstanceConfig, State]

jobshoplab.compiler.manipulators module

class Manipulator[source]

Bases: ABC

Abstract base class for manipulators.

abstractmethod __init__(loglevel, config, *args, **kwargs)[source]

Initialize the Manipulator.

Parameters:
loglevel : int

The log level.

config : Config

The configuration object.

abstractmethod manipulate(init_state, instance)[source]

Perform manipulation on the initial state and instance configuration.

Parameters:
init_state : State

The initial state.

instance : InstanceConfig

The instance configuration.

Returns:

The manipulated instance configuration and state.

Return type:

tuple[InstanceConfig, State]

class DummyManipulator[source]

Bases: Manipulator

A dummy manipulator implementation.

__init__(loglevel, config, *args, **kwargs)[source]

Initialize the DummyManipulator.

Parameters:
loglevel : int

The log level.

config : Config

The configuration object.

manipulate(instance_config, init_state)[source]

Perform manipulation on the instance configuration and initial state.

Parameters:
instance_config : InstanceConfig

The instance configuration.

init_state : State

The initial state.

Returns:

The manipulated instance configuration and state.

Return type:

tuple[InstanceConfig, State]

class InstanceRandomizer[source]

Bases: Manipulator

A manipulator that randomizes the instance configuration. but keeps the num jobs and machines the same.

__init__(loglevel, config, *args, **kwargs)[source]

Initialize the Manipulator.

Parameters:
loglevel : int

The log level.

config : Config

The configuration object.

manipulate(instance_config, init_state)[source]

Perform manipulation on the instance configuration and initial state.

Parameters:
instance_config : InstanceConfig

The instance configuration.

init_state : State

The initial state.

Returns:

The manipulated instance configuration and state.

Return type:

tuple[InstanceConfig, State]

jobshoplab.compiler.mapper module

class ID_Counter[source]

Bases: object

__init__()[source]
get_machine_id()[source]
get_buffer_id()[source]
get_transport_id()[source]
get_outage_id()[source]
class DefaultInstanceLookUpFactory[source]

Bases: object

__init__(loglevel, config, num_jobs, num_machines)[source]

Initialize the DefaultLookUpFactory.

Parameters:
loglevel : int | str

The log level.

config : Config

The configuration object.

num_jobs : int

The number of jobs.

num_machines : int

The number of machines.

get_default_tool()[source]
get_default_products()[source]

Get the default list of products.

Returns:

The default products.

Return type:

List[Product]

get_default_tools()[source]

Get the default list of tools.

Returns:

The default tools.

Return type:

List[ToolConfig]

get_default_machine(machine_id, prebuffer, postbuffer, machine_buffer_id)[source]

Get the default machine configuration with standard settings.

Parameters:
machine_id : str

The machine ID string (format: m-[number])

prebuffer : BufferConfig

The prebuffer configuration for the machine

postbuffer : BufferConfig

The postbuffer configuration for the machine

machine_buffer_id : str

The ID for the machine’s internal buffer

Returns:

The default machine configuration

Return type:

MachineConfig

get_default_buffer(buffer_id, parent, description=None)[source]

Get the default buffer configuration.

Parameters:
buffer_id : int

The buffer ID.

parent : str

description : str | None

Returns:

The default buffer configuration.

Return type:

BufferConfig

get_default_transport(transport_id, buffer_id)[source]

Get the default transport configuration.

Parameters:
transport_id : int

The transport ID.

buffer_id : str

Returns:

The default transport configuration.

Return type:

TransportConfig

get_default_logistics(machines, buffers)[source]

Get the default logistics configuration.

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

The machines.

buffers : tuple[BufferConfig, ...]

The buffers.

Returns:

The default logistics configuration.

Return type:

LogisticsConfig

classmethod partial(loglevel, config)[source]
Parameters:
loglevel : int | str

config : __SPHINX_IMMATERIAL_TYPE_VAR__V_Config

class DefaultStateLookUpFactory[source]

Bases: object

__init__(loglevel, config, instance)[source]

Initialize the DefaultLookUpFactory.

Parameters:
loglevel : int | str

The log level.

config : Config

The configuration object.

num_jobs : int

The number of jobs.

num_machines : int

The number of machines.

instance : InstanceConfig

get_operations(job)[source]

Get the open operations for the given job.

Parameters:
job : JobConfig

The job to get the open operations for.

Yields:

OperationState – The open operations.

Return type:

Generator[OperationState, None, None]

get_default_machine(machine)[source]
Parameters:
machine : MachineConfig

Return type:

MachineState

get_default_tool()[source]
get_default_transport(transport, machines)[source]
Parameters:
transport : TransportConfig

machines : tuple[MachineState, ...]

Return type:

TransportState

classmethod partial(loglevel, config)[source]
Parameters:
loglevel : int | str

config : __SPHINX_IMMATERIAL_TYPE_VAR__V_Config

class AbstractDictMapper[source]

Bases: ABC

Abstract base class for dictionary mappers.

abstractmethod __init__(loglevel, config, default_factory, *args, **kwargs)[source]

Initialize the AbstractDictMapper.

Parameters:
loglevel : int

The log level.

config : Config

The configuration object.

default_factory : DefaultInstanceLookUpFactory | DefaultStateLookUpFactory

abstractmethod map(spec_dict)[source]

Map the given dictionary to an InstanceConfig or State object.

Parameters:
spec_dict : Dict

The dictionary to be mapped.

Returns:

The mapped object.

Return type:

Union[InstanceConfig, State]

has_key(keys, spec_dict)[source]

Check if the given key is in the dictionary.

Parameters:
key : List[str]

The key to check.

spec_dict : Dict

The dictionary to check.

keys : tuple[str, ...]

Returns:

True if the key is in the dictionary, False otherwise.

Return type:

bool

class DictToInstanceMapper[source]

Bases: AbstractDictMapper

Dictionary to InstanceConfig mapper.

This class is responsible for mapping a dictionary representation of an instance configuration to an InstanceConfig object. It provides methods for parsing and mapping the specification, components, and logistics of the instance.

Parameters:
loglevel : int | str

The log level.

config : Config

The configuration object.

__init__(loglevel, config, *args, **kwargs)[source]

Initialize the DictToInstanceMapper.

Parameters:
loglevel : int

The log level.

config : Config

The configuration object.

make_defaults(spec_dict)[source]

Perform a lookup based on the given key.

Parameters:
key : List[str]

The lookup key.

spec_dict : Dict

Returns:

The lookup result.

Return type:

Dict

map(spec_dict)[source]

Map a specification dictionary to an InstanceConfig object.

Takes a dictionary representation of the instance specification and converts it into a structured InstanceConfig object with typed components, including machines, transports, buffers, and logistics.

Parameters:
spec_dict : Dict

The specification dictionary containing the configuration

Returns:

The complete instance configuration object

Return type:

InstanceConfig

Raises:

ValueError – If required configuration elements are missing or invalid

class DictToInitStateMapper[source]

Bases: AbstractDictMapper

Dictionary to State mapper

__init__(loglevel, config)[source]

Initialize the DictToInitStateMapper.

Parameters:
loglevel : int

The log level.

config : Config

The configuration object.

map(spec_dict, instance)[source]

Map the given dictionary to a State object.

Parameters:
spec_dict : Dict

The dictionary to be mapped.

instance : InstanceConfig

Returns:

The mapped State object.

Return type:

State

jobshoplab.compiler.repos module

class Repository[source]

Bases: ABC

Abstract base class for repositories.

abstractmethod __init__(loglevel, config, *args, **kwargs)[source]

Initialize the Repository.

Parameters:
loglevel : int

The log level.

config : Config

The configuration object.

check_dir(dir)[source]

Check if the given directory exists.

Parameters:
dir : Path

The directory to check.

Return type:

Path

abstractmethod load_as_dict()[source]

Load the repository data as a dictionary.

Returns:

The repository data as a dictionary.

Return type:

Dict[str, Any]

class DslRepository[source]

Bases: Repository

Repository for YAML files.

__init__(dir, loglevel, config, *args, **kwargs)[source]

Initialize the DslRepository.

Parameters:
dir : Path

The directory of the repository.

loglevel : int

The log level.

config : Config

The configuration object.

load_as_dict()[source]

Load the repository data as a dictionary.

Returns:

The repository data as a dictionary.

Return type:

Dict[str, Any]

class DslStrRepository[source]

Bases: Repository

__init__(dsl_str, loglevel, config, *args, **kwargs)[source]

Initialize the DslStrRepository.

Parameters:
dir : Path

The directory of the repository.

loglevel : int

The log level.

config : Config

The configuration object.

dsl_str : str

load_as_dict()[source]

Load the repository data as a dictionary.

Returns:

The repository data as a dictionary.

Return type:

Dict[str, Any]

class SpecRepository[source]

Bases: Repository

Repository for specification files.

__init__(dir, loglevel, config, *args, **kwargs)[source]

Initialize the SpecRepository.

Parameters:
dir : Path

The directory of the repository.

loglevel : int

The log level.

config : Config

The configuration object.

map_to_instance_dsl_format(raw_str)[source]

Map the raw string to the instance DSL format.

Parameters:
raw_str : str

The raw string to map.

Returns:

The mapped string in instance DSL format.

Return type:

str

load_as_dict()[source]

Load the repository data as a dictionary.

Returns:

The repository data as a dictionary.

Return type:

Dict[str, Any]

class ApiRepo[source]

Bases: Repository

Repository for API data.

__init__(_, loglevel, config, *args, **kwargs)[source]

Initialize the ApiRepo.

Parameters:
_ : Any

Placeholder argument.

loglevel : int

The log level.

config : Config

The configuration object.

load_as_dict()[source]

Load the repository data as a dictionary.

Returns:

The repository data as a dictionary.

Return type:

Dict[str, Any]

jobshoplab.compiler.validators module

class AbstractValidator[source]

Bases: ABC

Abstract base class for validators.

abstractmethod __init__(loglevel, config, *args, **kwargs)[source]

Initializes the AbstractValidator.

Parameters:
loglevel : int

The log level for the logger.

config : Config

The configuration object.

Raises:

NotImplementedError – This method must be implemented by subclasses.

abstractmethod validate(spec_dict)[source]

Validates the given spec_dict.

Parameters:
spec_dict : dict

The dictionary to be validated.

Raises:

NotImplementedError – This method must be implemented by subclasses.

Return type:

None

class DummyValidator[source]

Bases: AbstractValidator

A dummy validator for testing purposes.

__init__(loglevel, config, *args, **kwargs)[source]

Initializes the DummyValidator.

Parameters:
loglevel : int

The log level for the logger.

config : Config

The configuration object.

validate(spec_dict)[source]

Validates the given spec_dict.

Parameters:
spec_dict : dict

The dictionary to be validated.

Returns:

None

Return type:

None

class SimpleDSLValidator[source]

Bases: AbstractValidator

Validator for Instance DSL syntax in YAML configurations.

This validator checks the structure and syntax of instance configuration files, ensuring they adhere to the expected format before they are processed by the mapper.

__init__(loglevel, config, *args, **kwargs)[source]

Initializes the InstanceDSLValidator.

Parameters:
loglevel : int | str

The log level for the logger.

config : Config

The configuration object.

validate(spec_dict)[source]

Validates the given instance specification dictionary.

Parameters:
spec_dict : dict

The dictionary representation of an instance configuration.

Raises:
Return type:

None

Module contents