API Reference
Environment
The Environment class represents the central element of the library. All offered simulation functionalities are available to the user in the methods through an object of this class. In addition, the environment controls all program-internal method calls as well as access to the process data in the background.
- class environment.Environment
Execution Environment for the event-based production simulation.
- clear_env() None
Reinitialize the environment object between two different simulation runs.
After calling this method, a new process must be read in.
- data_to_csv(path_to_wd: str, remove_column: Optional[List[str]] = None, keep_original: bool = True) None
Exports the simulation data to csv files.
- Parameters
path_to_wd (str) – Path to the target directory
remove_column (List[str], optional) – List of labels whose columns are removed before saving
keep_original (bool, optional) – Keep an additional original file without removed columns
- Raises
MissingData –
simulate
was not called before
Note
If the passed folder does not exist, then the program creates it.
- data_to_hdf5(path_to_wd: str, file_name: str) None
Exports the simulation data to hdf5 files.
Creates a hdf5 file in which each simulation object is stored a group. The metadata (‘header’) of each simulation object is stored in an attribute and the simulation data in datasets of size max_memory.
- Parameters
path_to_wd (str) – Path to the target directory
file_name (str) – Name of the hdf5 file
- Raises
MissingData –
simulate
was not called before
Note
If the passed folder does not exist, then the program creates it.
- define_process() None
Launches an interactive web application to define a new production process. This method initiates a local development app on a flask server on localhoast:8050.
- inspect() None
Checks the passed input files for errors of logical and syntactic nature.
- Raises
MissingData –
read_files
was not called, or the data read in does not contain the arrays ‘order’ and ‘station’
Note
This method is only a support and does not guarantee an error-free simulation run.
- read_files(path_data_file: str, path_function_file: str) None
Reads in the process input files.
- Parameters
path_data_file (str) – Path to the JSON file with the process data
path_function_file (str) – Path to the py file with the function definitions
- Raises
FileNotFoundError – Files could not be found
MissingParameter – The ‘order’ or ‘station’ array is not defined in the process file or an order or station object has no name
UndefinedFunction – One of the referenced functions cannot be found in the function file
UndefinedObject – One of the referenced orders or stations cannot be found in the data file
InvalidType – The component list has an element that is not of type list, or the capacity of an order or station is not of type int
InvalidValue – The capacity of an order or station is not greater than zero
NotSupportedParameter – One of the values of the user-defined factory attributes has an undefined identifier
- simulate(sim_time: int, track_components: Optional[List[str]] = None, progress_bar: bool = False, max_memory: float = 2, bit_type: int = 32) None
Starts the simulation run.
- Parameters
sim_time (int) – Simulated time
track_components (List[str], optional) – List of strings representing components whose process data is to be stored
progress_bar (bool, optional) – Specifies whether a progress bar should be displayed
max_memory (float, optional) – Maximal size of a single a numpy data array [Mb]
bit_type (int, optional) – Bit type with which the values are stored
- Raises
MissingData –
read_files
was not called or the data read in does not contain ‘order’ or ‘station’
- visualize() None
Launches an interactive web application to display the input data. This method initiates a local development app on a flask server on localhoast:8050.
- Raises
MissingData –
read_files
was not called or the data read in does not contain the ‘order’ or ‘station’ array
Note
This method initiates a local development app on a flask server on localhoast:8050.
Estimator
The Estimator class offers some functionalities through which the runtime behavior of the simulation can be estimated. Alternatively, a reference simulation with a short simulation time can be performed, and the measured simulation time can be scaled proportionally. However, the function est_function is especially useful for developing suitable process functions.
- class estimator.Estimator
Estimator for estimating the expected simulation time.
- est_attribute(distribution: List[tuple], num_station: int, track: bool) float
Estimates the time caused by additional attributes.
- Parameters
distribution (List[tuple]) – List of attributes to be estimated
num_station (int) – Number of stations that workpieces of the order under consideration pass through
track (bool) – Indicates whether the order is being tracked
- Returns
Estimated additional simulation time for additional attributes
- Return type
float
- est_function(function: Callable, num_station: int, track: bool, imports: Optional[List[str]] = None, objects: Optional[Dict[str, object]] = None, item_attributes: Optional[Dict[str, list]] = None, machine_attributes: Optional[Dict[str, list]] = None, factory_attributes: Optional[Dict[str, list]] = None) float
Estimates the time caused by a specific function.
- Parameters
function (Callable) – List of attributes to be estimated
num_station (int) – Number of stations at which the process function is called
track (bool) – Indicates whether the order is being tracked
imports (List[str], optional) – List of all used import statements
objects (List[object], optional) – List of all used objects
item_attributes (Dict[str, list], optional) – List of all item attributes used in the function
machine_attributes (Dict[str, list], optional) – List of all machine attributes used in the function
factory_attributes (Dict[str, list], optional) – List of all factory attributes used in the function
- Raises
InvalidFunction – Function name is ‘function1’
- Returns
Estimated time for a single function call
- Return type
float
- est_item(track: bool) float
Estimates the time for creating a workpiece.
- Parameters
track (bool) – Indicates whether the order is being tracked
- Returns
Estimated simulation time for creating a workpiece without attributes
- Return type
float
- est_station(track: bool) float
Estimates the time caused by the recursive process logic.
- Parameters
track (bool) – Indicates whether the order is being tracked
- Returns
Estimated simulation time for simply passing through stations (without functions and item attributes)
- Return type
float