Skip to content

Adapter

Adapter module for prodsys.

This module provides aliases and utility functions for working with production system data. It serves as a compatibility layer and provides convenient access to production system functionality.

ProductionSystemData

Bases: BaseModel

A ProductionSystemAdapter serves as a n abstract base class of a data container to represent a production system. It is based on the prodsys.models module, but is also compatible with the prodsys.express API. It is used as the basis for all simulation and optimization algorithms in prodsys and comes with complete data validation. Thereby, it is assured that the expected data is used for simulation and optimization. If the data is not valid, an error is raised with information about the reasons for invalidity. The adapter targets easy integration of algorithms with each other in different environments. Therefore, the adapter can even be used for integration of new algorithms by serving as a defined data interface.

Attributes:

Name Type Description
ID str

ID of the production system. Defaults to "".

seed int

Seed for the random number generator used in simulation. Defaults to 0.

time_model_data List[TIME_MODEL_DATA]

List of time models used by the entities in the production system. Defaults to [].

state_data List[STATE_DATA_UNION]

List of states used by the resources in the production system. Defaults to [].

process_data List[PROCESS_DATA_UNION]

List of processes required by products and provided by resources in the production system. Defaults to [].

port_data List[QUEUE_DATA_UNION]

List of ports used by the resources, sources and sinks in the production system. Defaults to [].

node_data List[NodeData]

List of nodes in the production system. Defaults to [].

resource_data List[ResourceData]

List of resources in the production system. Defaults to [].

product_data List[ProductData]

List of products in the production system. Defaults to [].

sink_data List[SinkData]

List of sinks in the production system. Defaults to [].

source_data List[SOURCE_DATA_UNION]

List of sources in the production system. Defaults to [].

scenario_data Optional[ScenarioData]

Scenario data of the production system used for optimization. Defaults to None.

dependency_data Optional[List[DEPENDENCY_TYPES]]

List of dependencies in the production system. Defaults to [].

primitive_data Optional[List[StoredPrimitive]]

List of stored primitives in the production system. Defaults to [].

schedule Optional[List[Event]]

List of scheduled Events of the production system. Defaults to None.

order_data Optional[List[OrderData]]

List of orders in the production system. Defaults to None.

conwip_number Optional[int]

Number of allowed WIP (Work in Progress - number of released products) in the production system. Defaults to None.

reference_time Optional[datetime]

Reference time of the production system. Defaults to None.

time_unit Literal['s', 'min', 'h', 'd']

Time unit of the production system. Defaults to "min".

valid_configuration bool

Indicates if the configuration is valid. Defaults to True.

reconfiguration_cost float

Cost of reconfiguration in a optimization scenario. Defaults to 0.

check_no_duplicate_ids()

Validates that no duplicate IDs exist across all data types in the production system. This is critical for proper object resolution, especially for link transport processes.

This validator runs automatically: - On initialization of a new ProductionSystemData instance - When entire fields are reassigned (e.g., system.node_data = new_list)

For in-place mutations (e.g., system.node_data.append(item)), call revalidate() or model_validate() explicitly to trigger validation.

Raises:

Type Description
ValueError

If duplicate IDs are found with details about which IDs and where.

hash()

Generates a hash of the adapter based on the hash of all contained entities. Only information describing the physical structure and functionality of the production system is considered. Can be used to compare two production systems of adapters for functional equality.

Returns:

Name Type Description
str str

Hash of the adapter

read(filepath) classmethod

Reads a JSON file and returns a ProductionSystemData object.

Parameters:

Name Type Description Default
filepath str

Path to the JSON file

required

Returns:

Name Type Description
ProductionSystemData ProductionSystemData

ProductionSystemData object

revalidate()

Explicitly revalidates the entire ProductionSystemData model.

This is useful after making in-place modifications to lists (e.g., appending items) to ensure all validators run, including the duplicate ID check.

Example
system = ProductionSystemData(...)
system.node_data.append(new_node)  # In-place modification
system.revalidate()  # Trigger validation

Returns:

Name Type Description
ProductionSystemData 'ProductionSystemData'

Self, after validation

Raises:

Type Description
ValueError

If validation fails (e.g., duplicate IDs detected)

validate_configuration()

Checks if the configuration is physically valid, i.e. if all resources are positioned at different locations and if all required processes are available.

Raises:

Type Description
ValueError

If multiple objects are positioned at the same location.

ValueError

If not all required process are available.

ValueError

If not all links are available for LinkTransportProcesses.

ValueError

If ports are missing locations (needed for transport routing).

write(filepath)

Writes the ProductionSystemData object to a JSON file.

Parameters:

Name Type Description Default
filepath str

Path to the JSON file

required

check_for_clean_compound_processes(adapter_object)

Checks that the compound processes are clean, i.e. that they do not contain compund processes and normal processes at the same time.

Parameters:

Name Type Description Default
adapter_object ProductionSystemAdapter

Production system configuration

required

Returns:

Name Type Description
bool bool

True if the compound processes are clean, False otherwise

get_available_capability_processes(configuration)

Returns all available capability processes in the production system.

Parameters:

Name Type Description Default
configuration ProductionSystemData

Production system configuration

required

Returns:

Name Type Description
List List[PROCESS_DATA_UNION]

List of available capability processes

get_available_process_ids(configuration)

Returns all available process IDs that are used in the production system.

Parameters:

Name Type Description Default
configuration ProductionSystemData

Production system configuration

required

Returns:

Type Description
List[str]

List[str]: List of available process IDs

get_available_production_processes(configuration)

Returns all available production processes in the production system.

Parameters:

Name Type Description Default
configuration ProductionSystemData

Production system configuration

required

Returns:

Name Type Description
List List[PROCESS_DATA_UNION]

List of available production processes

get_available_transport_processes(configuration)

Returns all available transport processes in the production system.

Parameters:

Name Type Description Default
configuration ProductionSystemData

Production system configuration

required

Returns:

Name Type Description
List List[PROCESS_DATA_UNION]

List of available transport processes

get_conveyor_processes(configuration)

Returns all required transport processes in the production system.

Parameters:

Name Type Description Default
configuration ProductionSystemData

Production system configuration

required

Returns:

Name Type Description
List List[PROCESS_DATA_UNION]

List of required transport processes

get_missing_capability_processes(available, required)

Returns list of missing capability processes.

Parameters:

Name Type Description Default
available List[CapabilityProcessData]

capability processes that are available in the production system resources

required
required List[CapabilityProcessData]

capability processes that are required from the products

required

Returns:

Name Type Description
List List[CapabilityProcessData]

List of missing capability processes

get_missing_production_processes(available, required)

Returns list of missing production processes.

Parameters:

Name Type Description Default
available List[ProductionProcessData]

production processes that are available in the production system resources

required
required List[ProductionProcessData]

production processes that are required from the products

required

Returns:

Name Type Description
List List[Union[ProductionProcessData, ReworkProcessData]]

List of missing production processes

get_missing_transport_processes(available, required)

Returns list of missing transport processes.

Parameters:

Name Type Description Default
available List[TransportProcessData]

transport processes that are available in the production system resources

required
required List[TransportProcessData]

transport processes that are required from the products

required

Returns:

Name Type Description
List List[TransportProcessData]

List of missing transport processes

get_production_resources(adapter)

Returns a list of all machines in the adapter. Resources are considered production resources if they have production or capability processes.

Parameters:

Name Type Description Default
adapter ProductionSystemAdapter

ProductionSystemAdapter object

required

Returns:

Type Description
List[ResourceData]

List[resource_data_module.ResourceData]: List of all machines in the adapter

get_required_capability_processes(configuration)

Returns all required capability processes in the production system.

Parameters:

Name Type Description Default
configuration ProductionSystemData

Production system configuration

required

Returns:

Name Type Description
List List[PROCESS_DATA_UNION]

List of required capability processes

get_required_process_ids(configuration)

Returns all required process IDs that are used in the production system.

Parameters:

Name Type Description Default
configuration ProductionSystemData

Production system configuration

required

Returns:

Type Description
List[str]

List[str]: List of required process IDs

get_required_production_processes(configuration)

Returns all required production processes in the production system.

Parameters:

Name Type Description Default
configuration ProductionSystemData

Production system configuration

required

Returns:

Name Type Description
List List[PROCESS_DATA_UNION]

List of required production processes

get_required_transport_processes(configuration)

Returns all required transport processes in the production system.

Parameters:

Name Type Description Default
configuration ProductionSystemData

Production system configuration

required

Returns:

Name Type Description
List List[PROCESS_DATA_UNION]

List of required transport processes

get_transport_resources(adapter)

Returns a list of all transport resources in the adapter. Resources are considered transport resources if they have transport processes.

Parameters:

Name Type Description Default
adapter ProductionSystemAdapter

ProductionSystemAdapter object

required

Returns:

Type Description
List[ResourceData]

List[resource_data_module.ResourceData]: List of all transport resources in the adapter