simprocesd.utils package

Submodules

simprocesd.utils.enums module

class simprocesd.utils.enums.DataStorageType(value)

Bases: IntEnum

Options for how to store data.

FILE = 3
MEMORY = 2
NONE = 1

simprocesd.utils.math_utils module

simprocesd.utils.math_utils.geometric_distribution_sample(probability, target_successes=1)

How many Bernoulli trials will it take to reach a number of successes.

This function performs random trials based on provided probability. Because the trials are random calling the function will same parameters does not mean same results.

Randomness is generated with Python’s ‘random’ module.

Parameters
  • probability (float) – Chance of success of each trial (0 to 1).

  • target_successes (int, default=1) – Desired number of successes.

Returns

Number of iterations it took to get desired number of successes.

Return type

int

simprocesd.utils.simulation_info_utils module

simprocesd.utils.simulation_info_utils.plot_damage(system, machines)

Show a step function graph of damage over time for each machine.

Graph is shown using matplotlib library.

Note

Won’t work if System was initialized with simulation_data_storage_type = DataStorageType.NONE

Parameters
  • system (System) – System object used in the simulation.

  • machines (list) – List of Machines to plot.

simprocesd.utils.simulation_info_utils.plot_throughput(system, machines)

Show a graph of cumulative mean throughput over time.

Cumulative throughput means at time=100 the graph will show the mean throughput between time 0 and 100.

Graph is shown using matplotlib library.

Note

Won’t work if System was initialized with simulation_data_storage_type = DataStorageType.NONE

Parameters
  • system (System) – System object used in the simulation.

  • machines (list) – List of Machines to plot.

simprocesd.utils.simulation_info_utils.plot_value(assets)

Show a graph of value over time for assets.

Graph is shown using matplotlib library.

Parameters

assets (list) – List of Asset objects to plot.

simprocesd.utils.simulation_info_utils.print_finished_work_order_counts(system)

Print which machines had work orders completed on them and how many of those work orders there were.

Note

Won’t work if System was initialized with simulation_data_storage_type = DataStorageType.NONE

Parameters

system (System) – System object used in the simulation.

simprocesd.utils.simulation_info_utils.print_produced_parts_and_average_quality(system, machines)

Print the number of Parts produced by each machine in the list and the Part’s average quality.

Note

Won’t work if System was initialized with simulation_data_storage_type = DataStorageType.NONE

Parameters
  • system (System) – System object used in the simulation.

  • machines (list) – List of Machines to consider.

simprocesd.utils.simulation_info_utils.simple_plot(x, y, title='', xlabel='', ylabel='')

Show a graph with a single plot from the provided data.

Parameters
  • x (list) – List of x values.

  • y (list) – List of y values, must be same length as <x>.

  • title (str, optional) –

simprocesd.utils.utils module

simprocesd.utils.utils.assert_callable(obj, none_allowed=False, message=None)

Check if an object appears callable.

The check is done using the built-in ‘callable()’ function. In some cases it is possible the function not to raise an error even if <obj> cannot be called like a function.

Returns immediately if not in debug mode.

Parameters
  • obj (object) – Object that will be checked.

  • none_allowed (bool, default=False) – If the value of None is allowed.

  • message (str, optional) – Error message if object is not callable.

Raises

TypeError – If object is not callable.

simprocesd.utils.utils.assert_is_instance(obj, class_type, message=None)

Check if an object is an instance of a specific class type.

Returns immediately if not in debug mode.

Parameters
  • obj (object) – Object that will be checked.

  • class_type (type) – Class type that the object needs to be.

  • message (str, optional) – Error message if object is not an instance of <class_type>.

Raises

TypeError – If <obj> is not an instance of <class_type>

simprocesd.utils.utils.load_object(file_path)

Load an object from a file that was created using save_object().

See save_object() for information on how objects are stored.

Warning

Loaded object could execute arbitrary code when it is loaded. Recommended to only load object from files you created or ones from a source with a high degree of trust.

Parameters

file_path (str) – Relative or absolute path to the file to load.

simprocesd.utils.utils.save_list_to_csv(filename, data_list)

Save a list or table as a CSV file.

Each list entry will occupy one row and if the list entry is a list or a tuple then the entry’s elements will be split into columns.

Example:
in: data_list = [ [1,2], [3,4,5] ]
file out: Row 1 = 1,2
Row 2 = 3,4,5
Parameters
  • filename (str) – Relative or absolute path of where to store the CSV file.

  • data_list (list) – Data to be stored, can be a 1 or 2 dimensional list.

simprocesd.utils.utils.save_object(obj, file_path, override_file=False)

Serialize, compress, and save an object as a file.

Uses Dill module to serialize the object. https://pypi.org/project/dill/

Serialized data is compresses using lzma module.

Parameters
  • obj (object) – Object to be serialized and stored.

  • file_path (str) – Relative or absolute path of where to store the object.

  • override_file (bool, default=False) – If True then any existing file at <file_path> will be overwritten.

Raises

FileExistsError – If a file at <file_path> already exists and <override_file> is set to False.

Module contents